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