Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 1 | //===-- PPCAsmBackend.cpp - PPC 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 | |
Evan Cheng | 61d4a20 | 2011-07-25 19:53:23 +0000 | [diff] [blame] | 10 | #include "MCTargetDesc/PPCMCTargetDesc.h" |
| 11 | #include "MCTargetDesc/PPCFixupKinds.h" |
Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 12 | #include "llvm/MC/MCAsmBackend.h" |
Chandler Carruth | d990388 | 2015-01-14 11:23:27 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCAssembler.h" |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCELFObjectWriter.h" |
Craig Topper | 6e80c28 | 2012-03-26 06:58:25 +0000 | [diff] [blame] | 15 | #include "llvm/MC/MCFixupKindInfo.h" |
Daniel Dunbar | 73b8713 | 2010-12-16 16:08:33 +0000 | [diff] [blame] | 16 | #include "llvm/MC/MCMachObjectWriter.h" |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 17 | #include "llvm/MC/MCObjectWriter.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCSectionMachO.h" |
Rafael Espindola | 95fb9b9 | 2015-06-02 20:38:46 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCSymbolELF.h" |
Jim Grosbach | 28fcafb | 2011-06-24 23:44:37 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCValue.h" |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 21 | #include "llvm/Support/ELF.h" |
| 22 | #include "llvm/Support/ErrorHandling.h" |
Charles Davis | 8bdfafd | 2013-09-01 04:28:48 +0000 | [diff] [blame] | 23 | #include "llvm/Support/MachO.h" |
Evan Cheng | 2bb4035 | 2011-08-24 18:08:43 +0000 | [diff] [blame] | 24 | #include "llvm/Support/TargetRegistry.h" |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 25 | using namespace llvm; |
| 26 | |
Ulrich Weigand | 56f5b28 | 2013-05-15 15:01:46 +0000 | [diff] [blame] | 27 | static uint64_t adjustFixupValue(unsigned Kind, uint64_t Value) { |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 28 | switch (Kind) { |
| 29 | default: |
| 30 | llvm_unreachable("Unknown fixup kind!"); |
| 31 | case FK_Data_1: |
| 32 | case FK_Data_2: |
| 33 | case FK_Data_4: |
Adhemerval Zanella | f2aceda | 2012-10-25 12:27:42 +0000 | [diff] [blame] | 34 | case FK_Data_8: |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 35 | case PPC::fixup_ppc_nofixup: |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 36 | return Value; |
| 37 | case PPC::fixup_ppc_brcond14: |
Ulrich Weigand | b6a30d1 | 2013-06-24 11:03:33 +0000 | [diff] [blame] | 38 | case PPC::fixup_ppc_brcond14abs: |
Adhemerval Zanella | f2aceda | 2012-10-25 12:27:42 +0000 | [diff] [blame] | 39 | return Value & 0xfffc; |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 40 | case PPC::fixup_ppc_br24: |
Ulrich Weigand | b6a30d1 | 2013-06-24 11:03:33 +0000 | [diff] [blame] | 41 | case PPC::fixup_ppc_br24abs: |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 42 | return Value & 0x3fffffc; |
Ulrich Weigand | 6e23ac6 | 2013-05-17 12:37:21 +0000 | [diff] [blame] | 43 | case PPC::fixup_ppc_half16: |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 44 | return Value & 0xffff; |
Ulrich Weigand | 6e23ac6 | 2013-05-17 12:37:21 +0000 | [diff] [blame] | 45 | case PPC::fixup_ppc_half16ds: |
Ulrich Weigand | 3e18601 | 2013-03-26 10:56:47 +0000 | [diff] [blame] | 46 | return Value & 0xfffc; |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
Ulrich Weigand | 56f5b28 | 2013-05-15 15:01:46 +0000 | [diff] [blame] | 50 | static unsigned getFixupKindNumBytes(unsigned Kind) { |
| 51 | switch (Kind) { |
| 52 | default: |
| 53 | llvm_unreachable("Unknown fixup kind!"); |
| 54 | case FK_Data_1: |
| 55 | return 1; |
| 56 | case FK_Data_2: |
Ulrich Weigand | 6e23ac6 | 2013-05-17 12:37:21 +0000 | [diff] [blame] | 57 | case PPC::fixup_ppc_half16: |
| 58 | case PPC::fixup_ppc_half16ds: |
Ulrich Weigand | 56f5b28 | 2013-05-15 15:01:46 +0000 | [diff] [blame] | 59 | return 2; |
| 60 | case FK_Data_4: |
| 61 | case PPC::fixup_ppc_brcond14: |
Ulrich Weigand | b6a30d1 | 2013-06-24 11:03:33 +0000 | [diff] [blame] | 62 | case PPC::fixup_ppc_brcond14abs: |
Ulrich Weigand | 56f5b28 | 2013-05-15 15:01:46 +0000 | [diff] [blame] | 63 | case PPC::fixup_ppc_br24: |
Ulrich Weigand | b6a30d1 | 2013-06-24 11:03:33 +0000 | [diff] [blame] | 64 | case PPC::fixup_ppc_br24abs: |
Ulrich Weigand | 56f5b28 | 2013-05-15 15:01:46 +0000 | [diff] [blame] | 65 | return 4; |
| 66 | case FK_Data_8: |
| 67 | return 8; |
Ulrich Weigand | 56f5b28 | 2013-05-15 15:01:46 +0000 | [diff] [blame] | 68 | case PPC::fixup_ppc_nofixup: |
| 69 | return 0; |
| 70 | } |
| 71 | } |
| 72 | |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 73 | namespace { |
Daniel Dunbar | 8888a96 | 2010-12-16 16:09:19 +0000 | [diff] [blame] | 74 | |
Evan Cheng | 5928e69 | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 75 | class PPCAsmBackend : public MCAsmBackend { |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 76 | const Target &TheTarget; |
| 77 | bool IsLittleEndian; |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 78 | public: |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 79 | PPCAsmBackend(const Target &T, bool isLittle) : MCAsmBackend(), TheTarget(T), |
| 80 | IsLittleEndian(isLittle) {} |
Daniel Dunbar | 0c9d9fd | 2010-12-16 03:20:06 +0000 | [diff] [blame] | 81 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 82 | unsigned getNumFixupKinds() const override { |
| 83 | return PPC::NumTargetFixupKinds; |
| 84 | } |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 85 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 86 | const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const override { |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 87 | const static MCFixupKindInfo InfosBE[PPC::NumTargetFixupKinds] = { |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 88 | // name offset bits flags |
| 89 | { "fixup_ppc_br24", 6, 24, MCFixupKindInfo::FKF_IsPCRel }, |
| 90 | { "fixup_ppc_brcond14", 16, 14, MCFixupKindInfo::FKF_IsPCRel }, |
Ulrich Weigand | b6a30d1 | 2013-06-24 11:03:33 +0000 | [diff] [blame] | 91 | { "fixup_ppc_br24abs", 6, 24, 0 }, |
| 92 | { "fixup_ppc_brcond14abs", 16, 14, 0 }, |
Ulrich Weigand | 6e23ac6 | 2013-05-17 12:37:21 +0000 | [diff] [blame] | 93 | { "fixup_ppc_half16", 0, 16, 0 }, |
| 94 | { "fixup_ppc_half16ds", 0, 14, 0 }, |
Bill Schmidt | 24b8dd6 | 2012-12-12 19:29:35 +0000 | [diff] [blame] | 95 | { "fixup_ppc_nofixup", 0, 0, 0 } |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 96 | }; |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 97 | const static MCFixupKindInfo InfosLE[PPC::NumTargetFixupKinds] = { |
| 98 | // name offset bits flags |
| 99 | { "fixup_ppc_br24", 2, 24, MCFixupKindInfo::FKF_IsPCRel }, |
| 100 | { "fixup_ppc_brcond14", 2, 14, MCFixupKindInfo::FKF_IsPCRel }, |
| 101 | { "fixup_ppc_br24abs", 2, 24, 0 }, |
| 102 | { "fixup_ppc_brcond14abs", 2, 14, 0 }, |
| 103 | { "fixup_ppc_half16", 0, 16, 0 }, |
| 104 | { "fixup_ppc_half16ds", 2, 14, 0 }, |
| 105 | { "fixup_ppc_nofixup", 0, 0, 0 } |
| 106 | }; |
Jim Grosbach | e2d2981 | 2012-01-18 18:52:20 +0000 | [diff] [blame] | 107 | |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 108 | if (Kind < FirstTargetFixupKind) |
Evan Cheng | 5928e69 | 2011-07-25 23:24:55 +0000 | [diff] [blame] | 109 | return MCAsmBackend::getFixupKindInfo(Kind); |
Jim Grosbach | e2d2981 | 2012-01-18 18:52:20 +0000 | [diff] [blame] | 110 | |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 111 | assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && |
| 112 | "Invalid kind!"); |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 113 | return (IsLittleEndian? InfosLE : InfosBE)[Kind - FirstTargetFixupKind]; |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 114 | } |
Jim Grosbach | e2d2981 | 2012-01-18 18:52:20 +0000 | [diff] [blame] | 115 | |
Benjamin Kramer | 8abfec3 | 2012-11-24 13:18:17 +0000 | [diff] [blame] | 116 | void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 117 | uint64_t Value, bool IsPCRel) const override { |
Benjamin Kramer | 8abfec3 | 2012-11-24 13:18:17 +0000 | [diff] [blame] | 118 | Value = adjustFixupValue(Fixup.getKind(), Value); |
| 119 | if (!Value) return; // Doesn't change encoding. |
| 120 | |
| 121 | unsigned Offset = Fixup.getOffset(); |
Ulrich Weigand | 56f5b28 | 2013-05-15 15:01:46 +0000 | [diff] [blame] | 122 | unsigned NumBytes = getFixupKindNumBytes(Fixup.getKind()); |
Benjamin Kramer | 8abfec3 | 2012-11-24 13:18:17 +0000 | [diff] [blame] | 123 | |
| 124 | // For each byte of the fragment that the fixup touches, mask in the bits |
| 125 | // from the fixup value. The Value has been "split up" into the appropriate |
| 126 | // bitfields above. |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 127 | for (unsigned i = 0; i != NumBytes; ++i) { |
| 128 | unsigned Idx = IsLittleEndian ? i : (NumBytes - 1 - i); |
| 129 | Data[Offset + i] |= uint8_t((Value >> (Idx * 8)) & 0xff); |
| 130 | } |
Benjamin Kramer | 8abfec3 | 2012-11-24 13:18:17 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Ulrich Weigand | bb68610 | 2014-07-20 23:06:03 +0000 | [diff] [blame] | 133 | void processFixupValue(const MCAssembler &Asm, const MCAsmLayout &Layout, |
| 134 | const MCFixup &Fixup, const MCFragment *DF, |
| 135 | const MCValue &Target, uint64_t &Value, |
| 136 | bool &IsResolved) override { |
| 137 | switch ((PPC::Fixups)Fixup.getKind()) { |
| 138 | default: break; |
| 139 | case PPC::fixup_ppc_br24: |
| 140 | case PPC::fixup_ppc_br24abs: |
| 141 | // If the target symbol has a local entry point we must not attempt |
| 142 | // to resolve the fixup directly. Emit a relocation and leave |
| 143 | // resolution of the final target address to the linker. |
| 144 | if (const MCSymbolRefExpr *A = Target.getSymA()) { |
Rafael Espindola | 95fb9b9 | 2015-06-02 20:38:46 +0000 | [diff] [blame] | 145 | if (const auto *S = dyn_cast<MCSymbolELF>(&A->getSymbol())) { |
| 146 | // The "other" values are stored in the last 6 bits of the second |
| 147 | // byte. The traditional defines for STO values assume the full byte |
| 148 | // and thus the shift to pack it. |
| 149 | unsigned Other = S->getOther() << 2; |
| 150 | if ((Other & ELF::STO_PPC64_LOCAL_MASK) != 0) |
| 151 | IsResolved = false; |
| 152 | } |
Ulrich Weigand | bb68610 | 2014-07-20 23:06:03 +0000 | [diff] [blame] | 153 | } |
| 154 | break; |
| 155 | } |
| 156 | } |
| 157 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 158 | bool mayNeedRelaxation(const MCInst &Inst) const override { |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 159 | // FIXME. |
| 160 | return false; |
| 161 | } |
Jim Grosbach | 25b63fa | 2011-12-06 00:47:03 +0000 | [diff] [blame] | 162 | |
| 163 | bool fixupNeedsRelaxation(const MCFixup &Fixup, |
| 164 | uint64_t Value, |
Eli Bendersky | 4d9ada0 | 2013-01-08 00:22:56 +0000 | [diff] [blame] | 165 | const MCRelaxableFragment *DF, |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 166 | const MCAsmLayout &Layout) const override { |
Jim Grosbach | 25b63fa | 2011-12-06 00:47:03 +0000 | [diff] [blame] | 167 | // FIXME. |
Craig Topper | e55c556 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 168 | llvm_unreachable("relaxInstruction() unimplemented"); |
Jim Grosbach | 25b63fa | 2011-12-06 00:47:03 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Nirav Dave | 8603062 | 2016-07-11 14:23:53 +0000 | [diff] [blame] | 171 | void relaxInstruction(const MCInst &Inst, const MCSubtargetInfo &STI, |
| 172 | MCInst &Res) const override { |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 173 | // FIXME. |
Craig Topper | e55c556 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 174 | llvm_unreachable("relaxInstruction() unimplemented"); |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 175 | } |
Jim Grosbach | e2d2981 | 2012-01-18 18:52:20 +0000 | [diff] [blame] | 176 | |
Craig Topper | 0d3fa92 | 2014-04-29 07:57:37 +0000 | [diff] [blame] | 177 | bool writeNopData(uint64_t Count, MCObjectWriter *OW) const override { |
Ulrich Weigand | d3ac7c0 | 2013-07-04 18:28:46 +0000 | [diff] [blame] | 178 | uint64_t NumNops = Count / 4; |
| 179 | for (uint64_t i = 0; i != NumNops; ++i) |
Jim Grosbach | 36e60e9 | 2015-06-04 22:24:41 +0000 | [diff] [blame] | 180 | OW->write32(0x60000000); |
Ulrich Weigand | d3ac7c0 | 2013-07-04 18:28:46 +0000 | [diff] [blame] | 181 | |
Benjamin Kramer | 97fbdd5 | 2015-04-17 11:12:43 +0000 | [diff] [blame] | 182 | OW->WriteZeros(Count % 4); |
David Majnemer | 7137420 | 2013-09-26 09:18:48 +0000 | [diff] [blame] | 183 | |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 184 | return true; |
Jim Grosbach | e2d2981 | 2012-01-18 18:52:20 +0000 | [diff] [blame] | 185 | } |
| 186 | |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 187 | unsigned getPointerSize() const { |
| 188 | StringRef Name = TheTarget.getName(); |
Bill Schmidt | 0a9170d | 2013-07-26 01:35:43 +0000 | [diff] [blame] | 189 | if (Name == "ppc64" || Name == "ppc64le") return 8; |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 190 | assert(Name == "ppc32" && "Unknown target name!"); |
| 191 | return 4; |
| 192 | } |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 193 | |
| 194 | bool isLittleEndian() const { |
| 195 | return IsLittleEndian; |
| 196 | } |
Daniel Dunbar | 7ee2181 | 2010-12-16 16:08:43 +0000 | [diff] [blame] | 197 | }; |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 198 | } // end anonymous namespace |
| 199 | |
| 200 | |
| 201 | // FIXME: This should be in a separate file. |
| 202 | namespace { |
| 203 | class DarwinPPCAsmBackend : public PPCAsmBackend { |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 204 | public: |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 205 | DarwinPPCAsmBackend(const Target &T) : PPCAsmBackend(T, false) { } |
Jim Grosbach | e2d2981 | 2012-01-18 18:52:20 +0000 | [diff] [blame] | 206 | |
Rafael Espindola | 5560a4c | 2015-04-14 22:14:34 +0000 | [diff] [blame] | 207 | MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override { |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 208 | bool is64 = getPointerSize() == 8; |
David Fang | b88cdf6 | 2013-08-08 20:14:40 +0000 | [diff] [blame] | 209 | return createPPCMachObjectWriter( |
| 210 | OS, |
| 211 | /*Is64Bit=*/is64, |
Charles Davis | 8bdfafd | 2013-09-01 04:28:48 +0000 | [diff] [blame] | 212 | (is64 ? MachO::CPU_TYPE_POWERPC64 : MachO::CPU_TYPE_POWERPC), |
| 213 | MachO::CPU_SUBTYPE_POWERPC_ALL); |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 214 | } |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 215 | }; |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 216 | |
| 217 | class ELFPPCAsmBackend : public PPCAsmBackend { |
Rafael Espindola | 1ad4095 | 2011-12-21 17:00:36 +0000 | [diff] [blame] | 218 | uint8_t OSABI; |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 219 | public: |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 220 | ELFPPCAsmBackend(const Target &T, bool IsLittleEndian, uint8_t OSABI) : |
| 221 | PPCAsmBackend(T, IsLittleEndian), OSABI(OSABI) { } |
Jim Grosbach | e2d2981 | 2012-01-18 18:52:20 +0000 | [diff] [blame] | 222 | |
Rafael Espindola | 5560a4c | 2015-04-14 22:14:34 +0000 | [diff] [blame] | 223 | MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override { |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 224 | bool is64 = getPointerSize() == 8; |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 225 | return createPPCELFObjectWriter(OS, is64, isLittleEndian(), OSABI); |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 226 | } |
Roman Divacky | 038c1a1 | 2011-08-02 15:51:38 +0000 | [diff] [blame] | 227 | }; |
| 228 | |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 229 | } // end anonymous namespace |
| 230 | |
Bill Wendling | 58e2d3d | 2013-09-09 02:37:14 +0000 | [diff] [blame] | 231 | MCAsmBackend *llvm::createPPCAsmBackend(const Target &T, |
| 232 | const MCRegisterInfo &MRI, |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame] | 233 | const Triple &TT, StringRef CPU) { |
Daniel Sanders | 418caf5 | 2015-06-10 10:35:34 +0000 | [diff] [blame] | 234 | if (TT.isOSDarwin()) |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 235 | return new DarwinPPCAsmBackend(T); |
Daniel Dunbar | 2b9b0e3 | 2011-04-19 21:14:45 +0000 | [diff] [blame] | 236 | |
Daniel Sanders | 418caf5 | 2015-06-10 10:35:34 +0000 | [diff] [blame] | 237 | uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS()); |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame] | 238 | bool IsLittleEndian = TT.getArch() == Triple::ppc64le; |
Ulrich Weigand | cae3a17 | 2014-03-24 18:16:09 +0000 | [diff] [blame] | 239 | return new ELFPPCAsmBackend(T, IsLittleEndian, OSABI); |
Chris Lattner | aac9fa7 | 2010-11-15 08:49:58 +0000 | [diff] [blame] | 240 | } |