Remove misplaced ';'. Make buildbots happy, hopefully.
[oota-llvm.git] / lib / Target / ARM / ARMAsmBackend.cpp
1 //===-- ARMAsmBackend.cpp - ARM Assembler Backend -------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "llvm/Target/TargetAsmBackend.h"
11 #include "ARM.h"
12 //FIXME: add #include "ARMFixupKinds.h"
13 #include "llvm/ADT/Twine.h"
14 #include "llvm/MC/ELFObjectWriter.h"
15 #include "llvm/MC/MCAssembler.h"
16 #include "llvm/MC/MCExpr.h"
17 #include "llvm/MC/MCObjectWriter.h"
18 #include "llvm/MC/MCSectionCOFF.h"
19 #include "llvm/MC/MCSectionELF.h"
20 #include "llvm/MC/MCSectionMachO.h"
21 #include "llvm/MC/MachObjectWriter.h"
22 #include "llvm/Support/ErrorHandling.h"
23 #include "llvm/Support/raw_ostream.h"
24 #include "llvm/Target/TargetRegistry.h"
25 #include "llvm/Target/TargetAsmBackend.h"
26 using namespace llvm;
27
28 namespace {
29 class ARMAsmBackend : public TargetAsmBackend {
30 public:
31   ARMAsmBackend(const Target &T)
32     : TargetAsmBackend(T) {    
33   }
34
35   bool MayNeedRelaxation(const MCInst &Inst) const;
36
37   void RelaxInstruction(const MCInst &Inst, MCInst &Res) const;
38
39   bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const;
40 };
41
42 bool ARMAsmBackend::MayNeedRelaxation(const MCInst &Inst) const {
43   // FIXME: Thumb targets, different move constant targets..
44   return false;
45 }
46
47 void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
48   assert(0 && "ARMAsmBackend::RelaxInstruction() unimplemented");
49   return;
50 }
51
52 bool ARMAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
53   assert(0 && "ARMAsmBackend::WriteNopData() unimplemented");
54   if ((Count % 4) != 0) {    
55     // Fixme: % 2 for Thumb?
56     return false;
57   }
58   return false;
59 }
60 } // end anonymous namespace
61
62 namespace {
63 // FIXME: This should be in a separate file.
64 // ELF is an ELF of course...
65 class ELFARMAsmBackend : public ARMAsmBackend {
66 public:
67   Triple::OSType OSType;
68   ELFARMAsmBackend(const Target &T, Triple::OSType _OSType)
69     : ARMAsmBackend(T), OSType(_OSType) {
70     HasAbsolutizedSet = true;
71     HasScatteredSymbols = true;
72   }
73
74   void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF,
75                   uint64_t Value) const;
76
77   bool isVirtualSection(const MCSection &Section) const {
78     const MCSectionELF &SE = static_cast<const MCSectionELF&>(Section);
79     return SE.getType() == MCSectionELF::SHT_NOBITS;
80   }
81
82   MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
83     return new ELFObjectWriter(OS, /*Is64Bit=*/false,
84                                OSType,
85                                /*IsLittleEndian=*/true,
86                                /*HasRelocationAddend=*/false);
87   }
88 };
89
90 // Fixme: can we raise this to share code bet. Darwin and ELF?
91 void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF,
92                                   uint64_t Value) const {
93   assert(0 && "ELFARMAsmBackend::ApplyFixup() unimplemented");
94 }
95
96 // FIXME: This should be in a separate file.
97 class DarwinARMAsmBackend : public ARMAsmBackend {
98 public:
99   DarwinARMAsmBackend(const Target &T)
100     : ARMAsmBackend(T) {
101     HasAbsolutizedSet = true;
102     HasScatteredSymbols = true;
103     assert(0 && "DarwinARMAsmBackend::DarwinARMAsmBackend() unimplemented");
104   }
105
106   void ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF,
107                   uint64_t Value) const;
108
109   bool isVirtualSection(const MCSection &Section) const {
110     const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
111     return (SMO.getType() == MCSectionMachO::S_ZEROFILL ||
112             SMO.getType() == MCSectionMachO::S_GB_ZEROFILL ||
113             SMO.getType() == MCSectionMachO::S_THREAD_LOCAL_ZEROFILL);
114   }
115
116   MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
117     return new MachObjectWriter(OS, /*Is64Bit=*/false);
118   }
119
120   virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
121     return false;
122   }
123 };
124
125 void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, MCDataFragment &DF,
126                                   uint64_t Value) const {
127   assert(0 && "DarwinARMAsmBackend::ApplyFixup() unimplemented");
128 }
129 } // end anonymous namespace 
130
131 TargetAsmBackend *llvm::createARMAsmBackend(const Target &T,
132                                             const std::string &TT) {
133   switch (Triple(TT).getOS()) {
134   case Triple::Darwin:
135     return new DarwinARMAsmBackend(T);
136   case Triple::MinGW32:
137   case Triple::Cygwin:
138   case Triple::Win32:
139     assert(0 && "Windows not supported on ARM");
140   default:
141     return new ELFARMAsmBackend(T, Triple(TT).getOS());
142   }
143 }