ARM Fixup valus for movt/movw are for the whole value.
[oota-llvm.git] / lib / Target / ARM / MCTargetDesc / 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 "MCTargetDesc/ARMMCTargetDesc.h"
11 #include "MCTargetDesc/ARMBaseInfo.h"
12 #include "MCTargetDesc/ARMFixupKinds.h"
13 #include "MCTargetDesc/ARMAddressingModes.h"
14 #include "llvm/ADT/Twine.h"
15 #include "llvm/MC/MCAssembler.h"
16 #include "llvm/MC/MCDirectives.h"
17 #include "llvm/MC/MCELFObjectWriter.h"
18 #include "llvm/MC/MCExpr.h"
19 #include "llvm/MC/MCMachObjectWriter.h"
20 #include "llvm/MC/MCObjectWriter.h"
21 #include "llvm/MC/MCSectionELF.h"
22 #include "llvm/MC/MCSectionMachO.h"
23 #include "llvm/MC/MCAsmBackend.h"
24 #include "llvm/MC/MCSubtargetInfo.h"
25 #include "llvm/Object/MachOFormat.h"
26 #include "llvm/Support/ELF.h"
27 #include "llvm/Support/ErrorHandling.h"
28 #include "llvm/Support/raw_ostream.h"
29 using namespace llvm;
30
31 namespace {
32 class ARMELFObjectWriter : public MCELFObjectTargetWriter {
33 public:
34   ARMELFObjectWriter(Triple::OSType OSType)
35     : MCELFObjectTargetWriter(/*Is64Bit*/ false, OSType, ELF::EM_ARM,
36                               /*HasRelocationAddend*/ false) {}
37 };
38
39 class ARMAsmBackend : public MCAsmBackend {
40   const MCSubtargetInfo* STI;
41   bool isThumbMode;  // Currently emitting Thumb code.
42 public:
43   ARMAsmBackend(const Target &T, const StringRef TT)
44     : MCAsmBackend(), STI(ARM_MC::createARMMCSubtargetInfo(TT, "", "")),
45       isThumbMode(TT.startswith("thumb")) {}
46
47   ~ARMAsmBackend() {
48     delete STI;
49   }
50
51   unsigned getNumFixupKinds() const { return ARM::NumTargetFixupKinds; }
52
53   bool hasNOP() const {
54     return (STI->getFeatureBits() & ARM::HasV6T2Ops) != 0;
55   }
56
57   const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const {
58     const static MCFixupKindInfo Infos[ARM::NumTargetFixupKinds] = {
59 // This table *must* be in the order that the fixup_* kinds are defined in
60 // ARMFixupKinds.h.
61 //
62 // Name                      Offset (bits) Size (bits)     Flags
63 { "fixup_arm_ldst_pcrel_12", 1,            24,  MCFixupKindInfo::FKF_IsPCRel },
64 { "fixup_t2_ldst_pcrel_12",  0,            32,  MCFixupKindInfo::FKF_IsPCRel |
65                                    MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
66 { "fixup_arm_pcrel_10",      1,            24,  MCFixupKindInfo::FKF_IsPCRel },
67 { "fixup_t2_pcrel_10",       0,            32,  MCFixupKindInfo::FKF_IsPCRel |
68                                    MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
69 { "fixup_thumb_adr_pcrel_10",0,            8,   MCFixupKindInfo::FKF_IsPCRel |
70                                    MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
71 { "fixup_arm_adr_pcrel_12",  1,            24,  MCFixupKindInfo::FKF_IsPCRel },
72 { "fixup_t2_adr_pcrel_12",   0,            32,  MCFixupKindInfo::FKF_IsPCRel |
73                                    MCFixupKindInfo::FKF_IsAlignedDownTo32Bits},
74 { "fixup_arm_condbranch",    0,            24,  MCFixupKindInfo::FKF_IsPCRel },
75 { "fixup_arm_uncondbranch",  0,            24,  MCFixupKindInfo::FKF_IsPCRel },
76 { "fixup_t2_condbranch",     0,            32,  MCFixupKindInfo::FKF_IsPCRel },
77 { "fixup_t2_uncondbranch",   0,            32,  MCFixupKindInfo::FKF_IsPCRel },
78 { "fixup_arm_thumb_br",      0,            16,  MCFixupKindInfo::FKF_IsPCRel },
79 { "fixup_arm_thumb_bl",      0,            32,  MCFixupKindInfo::FKF_IsPCRel },
80 { "fixup_arm_thumb_blx",     0,            32,  MCFixupKindInfo::FKF_IsPCRel },
81 { "fixup_arm_thumb_cb",      0,            16,  MCFixupKindInfo::FKF_IsPCRel },
82 { "fixup_arm_thumb_cp",      0,             8,  MCFixupKindInfo::FKF_IsPCRel },
83 { "fixup_arm_thumb_bcc",     0,             8,  MCFixupKindInfo::FKF_IsPCRel },
84 // movw / movt: 16-bits immediate but scattered into two chunks 0 - 12, 16 - 19.
85 { "fixup_arm_movt_hi16",     0,            20,  0 },
86 { "fixup_arm_movw_lo16",     0,            20,  0 },
87 { "fixup_t2_movt_hi16",      0,            20,  0 },
88 { "fixup_t2_movw_lo16",      0,            20,  0 },
89 { "fixup_arm_movt_hi16_pcrel", 0,          20,  MCFixupKindInfo::FKF_IsPCRel },
90 { "fixup_arm_movw_lo16_pcrel", 0,          20,  MCFixupKindInfo::FKF_IsPCRel },
91 { "fixup_t2_movt_hi16_pcrel", 0,           20,  MCFixupKindInfo::FKF_IsPCRel },
92 { "fixup_t2_movw_lo16_pcrel", 0,           20,  MCFixupKindInfo::FKF_IsPCRel },
93     };
94
95     if (Kind < FirstTargetFixupKind)
96       return MCAsmBackend::getFixupKindInfo(Kind);
97
98     assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
99            "Invalid kind!");
100     return Infos[Kind - FirstTargetFixupKind];
101   }
102
103   bool MayNeedRelaxation(const MCInst &Inst) const;
104
105   void RelaxInstruction(const MCInst &Inst, MCInst &Res) const;
106
107   bool WriteNopData(uint64_t Count, MCObjectWriter *OW) const;
108
109   void HandleAssemblerFlag(MCAssemblerFlag Flag) {
110     switch (Flag) {
111     default: break;
112     case MCAF_Code16:
113       setIsThumb(true);
114       break;
115     case MCAF_Code32:
116       setIsThumb(false);
117       break;
118     }
119   }
120
121   unsigned getPointerSize() const { return 4; }
122   bool isThumb() const { return isThumbMode; }
123   void setIsThumb(bool it) { isThumbMode = it; }
124 };
125 } // end anonymous namespace
126
127 bool ARMAsmBackend::MayNeedRelaxation(const MCInst &Inst) const {
128   // FIXME: Thumb targets, different move constant targets..
129   return false;
130 }
131
132 void ARMAsmBackend::RelaxInstruction(const MCInst &Inst, MCInst &Res) const {
133   assert(0 && "ARMAsmBackend::RelaxInstruction() unimplemented");
134   return;
135 }
136
137 bool ARMAsmBackend::WriteNopData(uint64_t Count, MCObjectWriter *OW) const {
138   const uint16_t Thumb1_16bitNopEncoding = 0x46c0; // using MOV r8,r8
139   const uint16_t Thumb2_16bitNopEncoding = 0xbf00; // NOP
140   const uint32_t ARMv4_NopEncoding = 0xe1a0000; // using MOV r0,r0
141   const uint32_t ARMv6T2_NopEncoding = 0xe3207800; // NOP
142   if (isThumb()) {
143     const uint16_t nopEncoding = hasNOP() ? Thumb2_16bitNopEncoding
144                                           : Thumb1_16bitNopEncoding;
145     uint64_t NumNops = Count / 2;
146     for (uint64_t i = 0; i != NumNops; ++i)
147       OW->Write16(nopEncoding);
148     if (Count & 1)
149       OW->Write8(0);
150     return true;
151   }
152   // ARM mode
153   const uint32_t nopEncoding = hasNOP() ? ARMv6T2_NopEncoding
154                                         : ARMv4_NopEncoding;
155   uint64_t NumNops = Count / 4;
156   for (uint64_t i = 0; i != NumNops; ++i)
157     OW->Write32(nopEncoding);
158   // FIXME: should this function return false when unable to write exactly
159   // 'Count' bytes with NOP encodings?
160   switch (Count % 4) {
161   default: break; // No leftover bytes to write
162   case 1: OW->Write8(0); break;
163   case 2: OW->Write16(0); break;
164   case 3: OW->Write16(0); OW->Write8(0xa0); break;
165   }
166
167   return true;
168 }
169
170 static unsigned adjustFixupValue(unsigned Kind, uint64_t Value) {
171   switch (Kind) {
172   default:
173     llvm_unreachable("Unknown fixup kind!");
174   case FK_Data_1:
175   case FK_Data_2:
176   case FK_Data_4:
177     return Value;
178   case ARM::fixup_arm_movt_hi16:
179     Value >>= 16;
180     // Fallthrough
181   case ARM::fixup_arm_movw_lo16:
182   case ARM::fixup_arm_movt_hi16_pcrel:
183   case ARM::fixup_arm_movw_lo16_pcrel: {
184     unsigned Hi4 = (Value & 0xF000) >> 12;
185     unsigned Lo12 = Value & 0x0FFF;
186     // inst{19-16} = Hi4;
187     // inst{11-0} = Lo12;
188     Value = (Hi4 << 16) | (Lo12);
189     return Value;
190   }
191   case ARM::fixup_t2_movt_hi16:
192     Value >>= 16;
193     // Fallthrough
194   case ARM::fixup_t2_movw_lo16:
195   case ARM::fixup_t2_movt_hi16_pcrel:  //FIXME: Shouldn't this be shifted like
196                                        // the other hi16 fixup?
197   case ARM::fixup_t2_movw_lo16_pcrel: {
198     unsigned Hi4 = (Value & 0xF000) >> 12;
199     unsigned i = (Value & 0x800) >> 11;
200     unsigned Mid3 = (Value & 0x700) >> 8;
201     unsigned Lo8 = Value & 0x0FF;
202     // inst{19-16} = Hi4;
203     // inst{26} = i;
204     // inst{14-12} = Mid3;
205     // inst{7-0} = Lo8;
206     uint64_t swapped = (Value & 0xFFFF0000) >> 16;
207     swapped |= (Value & 0x0000FFFF) << 16;
208     return swapped;
209   }
210   case ARM::fixup_arm_ldst_pcrel_12:
211     // ARM PC-relative values are offset by 8.
212     Value -= 4;
213     // FALLTHROUGH
214   case ARM::fixup_t2_ldst_pcrel_12: {
215     // Offset by 4, adjusted by two due to the half-word ordering of thumb.
216     Value -= 4;
217     bool isAdd = true;
218     if ((int64_t)Value < 0) {
219       Value = -Value;
220       isAdd = false;
221     }
222     assert ((Value < 4096) && "Out of range pc-relative fixup value!");
223     Value |= isAdd << 23;
224
225     // Same addressing mode as fixup_arm_pcrel_10,
226     // but with 16-bit halfwords swapped.
227     if (Kind == ARM::fixup_t2_ldst_pcrel_12) {
228       uint64_t swapped = (Value & 0xFFFF0000) >> 16;
229       swapped |= (Value & 0x0000FFFF) << 16;
230       return swapped;
231     }
232
233     return Value;
234   }
235   case ARM::fixup_thumb_adr_pcrel_10:
236     return ((Value - 4) >> 2) & 0xff;
237   case ARM::fixup_arm_adr_pcrel_12: {
238     // ARM PC-relative values are offset by 8.
239     Value -= 8;
240     unsigned opc = 4; // bits {24-21}. Default to add: 0b0100
241     if ((int64_t)Value < 0) {
242       Value = -Value;
243       opc = 2; // 0b0010
244     }
245     assert(ARM_AM::getSOImmVal(Value) != -1 &&
246            "Out of range pc-relative fixup value!");
247     // Encode the immediate and shift the opcode into place.
248     return ARM_AM::getSOImmVal(Value) | (opc << 21);
249   }
250
251   case ARM::fixup_t2_adr_pcrel_12: {
252     Value -= 4;
253     unsigned opc = 0;
254     if ((int64_t)Value < 0) {
255       Value = -Value;
256       opc = 5;
257     }
258
259     uint32_t out = (opc << 21);
260     out |= (Value & 0x800) << 15;
261     out |= (Value & 0x700) << 4;
262     out |= (Value & 0x0FF);
263
264     uint64_t swapped = (out & 0xFFFF0000) >> 16;
265     swapped |= (out & 0x0000FFFF) << 16;
266     return swapped;
267   }
268
269   case ARM::fixup_arm_condbranch:
270   case ARM::fixup_arm_uncondbranch:
271     // These values don't encode the low two bits since they're always zero.
272     // Offset by 8 just as above.
273     return 0xffffff & ((Value - 8) >> 2);
274   case ARM::fixup_t2_uncondbranch: {
275     Value = Value - 4;
276     Value >>= 1; // Low bit is not encoded.
277
278     uint32_t out = 0;
279     bool I =  Value & 0x800000;
280     bool J1 = Value & 0x400000;
281     bool J2 = Value & 0x200000;
282     J1 ^= I;
283     J2 ^= I;
284
285     out |= I  << 26; // S bit
286     out |= !J1 << 13; // J1 bit
287     out |= !J2 << 11; // J2 bit
288     out |= (Value & 0x1FF800)  << 5; // imm6 field
289     out |= (Value & 0x0007FF);        // imm11 field
290
291     uint64_t swapped = (out & 0xFFFF0000) >> 16;
292     swapped |= (out & 0x0000FFFF) << 16;
293     return swapped;
294   }
295   case ARM::fixup_t2_condbranch: {
296     Value = Value - 4;
297     Value >>= 1; // Low bit is not encoded.
298
299     uint64_t out = 0;
300     out |= (Value & 0x80000) << 7; // S bit
301     out |= (Value & 0x40000) >> 7; // J2 bit
302     out |= (Value & 0x20000) >> 4; // J1 bit
303     out |= (Value & 0x1F800) << 5; // imm6 field
304     out |= (Value & 0x007FF);      // imm11 field
305
306     uint32_t swapped = (out & 0xFFFF0000) >> 16;
307     swapped |= (out & 0x0000FFFF) << 16;
308     return swapped;
309   }
310   case ARM::fixup_arm_thumb_bl: {
311     // The value doesn't encode the low bit (always zero) and is offset by
312     // four. The value is encoded into disjoint bit positions in the destination
313     // opcode. x = unchanged, I = immediate value bit, S = sign extension bit
314     //
315     //   BL:  xxxxxSIIIIIIIIII xxxxxIIIIIIIIIII
316     //
317     // Note that the halfwords are stored high first, low second; so we need
318     // to transpose the fixup value here to map properly.
319     unsigned isNeg = (int64_t(Value - 4) < 0) ? 1 : 0;
320     uint32_t Binary = 0;
321     Value = 0x3fffff & ((Value - 4) >> 1);
322     Binary  = (Value & 0x7ff) << 16;    // Low imm11 value.
323     Binary |= (Value & 0x1ffc00) >> 11; // High imm10 value.
324     Binary |= isNeg << 10;              // Sign bit.
325     return Binary;
326   }
327   case ARM::fixup_arm_thumb_blx: {
328     // The value doesn't encode the low two bits (always zero) and is offset by
329     // four (see fixup_arm_thumb_cp). The value is encoded into disjoint bit
330     // positions in the destination opcode. x = unchanged, I = immediate value
331     // bit, S = sign extension bit, 0 = zero.
332     //
333     //   BLX: xxxxxSIIIIIIIIII xxxxxIIIIIIIIII0
334     //
335     // Note that the halfwords are stored high first, low second; so we need
336     // to transpose the fixup value here to map properly.
337     unsigned isNeg = (int64_t(Value-4) < 0) ? 1 : 0;
338     uint32_t Binary = 0;
339     Value = 0xfffff & ((Value - 2) >> 2);
340     Binary  = (Value & 0x3ff) << 17;    // Low imm10L value.
341     Binary |= (Value & 0xffc00) >> 10;  // High imm10H value.
342     Binary |= isNeg << 10;              // Sign bit.
343     return Binary;
344   }
345   case ARM::fixup_arm_thumb_cp:
346     // Offset by 4, and don't encode the low two bits. Two bytes of that
347     // 'off by 4' is implicitly handled by the half-word ordering of the
348     // Thumb encoding, so we only need to adjust by 2 here.
349     return ((Value - 2) >> 2) & 0xff;
350   case ARM::fixup_arm_thumb_cb: {
351     // Offset by 4 and don't encode the lower bit, which is always 0.
352     uint32_t Binary = (Value - 4) >> 1;
353     return ((Binary & 0x20) << 4) | ((Binary & 0x1f) << 3);
354   }
355   case ARM::fixup_arm_thumb_br:
356     // Offset by 4 and don't encode the lower bit, which is always 0.
357     return ((Value - 4) >> 1) & 0x7ff;
358   case ARM::fixup_arm_thumb_bcc:
359     // Offset by 4 and don't encode the lower bit, which is always 0.
360     return ((Value - 4) >> 1) & 0xff;
361   case ARM::fixup_arm_pcrel_10:
362     Value = Value - 4; // ARM fixups offset by an additional word and don't
363                        // need to adjust for the half-word ordering.
364     // Fall through.
365   case ARM::fixup_t2_pcrel_10: {
366     // Offset by 4, adjusted by two due to the half-word ordering of thumb.
367     Value = Value - 4;
368     bool isAdd = true;
369     if ((int64_t)Value < 0) {
370       Value = -Value;
371       isAdd = false;
372     }
373     // These values don't encode the low two bits since they're always zero.
374     Value >>= 2;
375     assert ((Value < 256) && "Out of range pc-relative fixup value!");
376     Value |= isAdd << 23;
377
378     // Same addressing mode as fixup_arm_pcrel_10,
379     // but with 16-bit halfwords swapped.
380     if (Kind == ARM::fixup_t2_pcrel_10) {
381       uint32_t swapped = (Value & 0xFFFF0000) >> 16;
382       swapped |= (Value & 0x0000FFFF) << 16;
383       return swapped;
384     }
385
386     return Value;
387   }
388   }
389 }
390
391 namespace {
392
393 // FIXME: This should be in a separate file.
394 // ELF is an ELF of course...
395 class ELFARMAsmBackend : public ARMAsmBackend {
396 public:
397   Triple::OSType OSType;
398   ELFARMAsmBackend(const Target &T, const StringRef TT,
399                    Triple::OSType _OSType)
400     : ARMAsmBackend(T, TT), OSType(_OSType) { }
401
402   void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
403                   uint64_t Value) const;
404
405   MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
406     return createELFObjectWriter(new ARMELFObjectWriter(OSType), OS,
407                               /*IsLittleEndian*/ true);
408   }
409 };
410
411 // FIXME: Raise this to share code between Darwin and ELF.
412 void ELFARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
413                                   unsigned DataSize, uint64_t Value) const {
414   unsigned NumBytes = 4;        // FIXME: 2 for Thumb
415   Value = adjustFixupValue(Fixup.getKind(), Value);
416   if (!Value) return;           // Doesn't change encoding.
417
418   unsigned Offset = Fixup.getOffset();
419
420   // For each byte of the fragment that the fixup touches, mask in the bits from
421   // the fixup value. The Value has been "split up" into the appropriate
422   // bitfields above.
423   for (unsigned i = 0; i != NumBytes; ++i)
424     Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
425 }
426
427 // FIXME: This should be in a separate file.
428 class DarwinARMAsmBackend : public ARMAsmBackend {
429 public:
430   const object::mach::CPUSubtypeARM Subtype;
431   DarwinARMAsmBackend(const Target &T, const StringRef TT,
432                       object::mach::CPUSubtypeARM st)
433     : ARMAsmBackend(T, TT), Subtype(st) { }
434
435   MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
436     return createARMMachObjectWriter(OS, /*Is64Bit=*/false,
437                                      object::mach::CTM_ARM,
438                                      Subtype);
439   }
440
441   void ApplyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
442                   uint64_t Value) const;
443
444   virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
445     return false;
446   }
447 };
448
449 /// getFixupKindNumBytes - The number of bytes the fixup may change.
450 static unsigned getFixupKindNumBytes(unsigned Kind) {
451   switch (Kind) {
452   default:
453     llvm_unreachable("Unknown fixup kind!");
454
455   case FK_Data_1:
456   case ARM::fixup_arm_thumb_bcc:
457   case ARM::fixup_arm_thumb_cp:
458   case ARM::fixup_thumb_adr_pcrel_10:
459     return 1;
460
461   case FK_Data_2:
462   case ARM::fixup_arm_thumb_br:
463   case ARM::fixup_arm_thumb_cb:
464     return 2;
465
466   case ARM::fixup_arm_ldst_pcrel_12:
467   case ARM::fixup_arm_pcrel_10:
468   case ARM::fixup_arm_adr_pcrel_12:
469   case ARM::fixup_arm_condbranch:
470   case ARM::fixup_arm_uncondbranch:
471     return 3;
472
473   case FK_Data_4:
474   case ARM::fixup_t2_ldst_pcrel_12:
475   case ARM::fixup_t2_condbranch:
476   case ARM::fixup_t2_uncondbranch:
477   case ARM::fixup_t2_pcrel_10:
478   case ARM::fixup_t2_adr_pcrel_12:
479   case ARM::fixup_arm_thumb_bl:
480   case ARM::fixup_arm_thumb_blx:
481   case ARM::fixup_arm_movt_hi16:
482   case ARM::fixup_arm_movw_lo16:
483   case ARM::fixup_arm_movt_hi16_pcrel:
484   case ARM::fixup_arm_movw_lo16_pcrel:
485   case ARM::fixup_t2_movt_hi16:
486   case ARM::fixup_t2_movw_lo16:
487   case ARM::fixup_t2_movt_hi16_pcrel:
488   case ARM::fixup_t2_movw_lo16_pcrel:
489     return 4;
490   }
491 }
492
493 void DarwinARMAsmBackend::ApplyFixup(const MCFixup &Fixup, char *Data,
494                                      unsigned DataSize, uint64_t Value) const {
495   unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind());
496   Value = adjustFixupValue(Fixup.getKind(), Value);
497   if (!Value) return;           // Doesn't change encoding.
498
499   unsigned Offset = Fixup.getOffset();
500   assert(Offset + NumBytes <= DataSize && "Invalid fixup offset!");
501
502   // For each byte of the fragment that the fixup touches, mask in the
503   // bits from the fixup value.
504   for (unsigned i = 0; i != NumBytes; ++i)
505     Data[Offset + i] |= uint8_t((Value >> (i * 8)) & 0xff);
506 }
507
508 } // end anonymous namespace
509
510 MCAsmBackend *llvm::createARMAsmBackend(const Target &T, StringRef TT) {
511   Triple TheTriple(TT);
512
513   if (TheTriple.isOSDarwin()) {
514     if (TheTriple.getArchName() == "armv4t" ||
515         TheTriple.getArchName() == "thumbv4t")
516       return new DarwinARMAsmBackend(T, TT, object::mach::CSARM_V4T);
517     else if (TheTriple.getArchName() == "armv5e" ||
518         TheTriple.getArchName() == "thumbv5e")
519       return new DarwinARMAsmBackend(T, TT, object::mach::CSARM_V5TEJ);
520     else if (TheTriple.getArchName() == "armv6" ||
521         TheTriple.getArchName() == "thumbv6")
522       return new DarwinARMAsmBackend(T, TT, object::mach::CSARM_V6);
523     return new DarwinARMAsmBackend(T, TT, object::mach::CSARM_V7);
524   }
525
526   if (TheTriple.isOSWindows())
527     assert(0 && "Windows not supported on ARM");
528
529   return new ELFARMAsmBackend(T, TT, Triple(TT).getOS());
530 }