Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 1 | //===-- MipsAsmBackend.cpp - Mips Asm Backend ----------------------------===// |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 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 | // |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 10 | // This file implements the MipsAsmBackend class. |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | // |
| 14 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 15 | #include "MCTargetDesc/MipsFixupKinds.h" |
| 16 | #include "MCTargetDesc/MipsAsmBackend.h" |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 17 | #include "MCTargetDesc/MipsMCExpr.h" |
Akira Hatanaka | 587fe6c | 2011-09-30 21:04:02 +0000 | [diff] [blame] | 18 | #include "MCTargetDesc/MipsMCTargetDesc.h" |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCAsmBackend.h" |
Akira Hatanaka | 587fe6c | 2011-09-30 21:04:02 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCAssembler.h" |
Matheus Almeida | e0d75aa | 2013-12-13 11:11:02 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCContext.h" |
Akira Hatanaka | 587fe6c | 2011-09-30 21:04:02 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCDirectives.h" |
| 23 | #include "llvm/MC/MCELFObjectWriter.h" |
Craig Topper | 6e80c28 | 2012-03-26 06:58:25 +0000 | [diff] [blame] | 24 | #include "llvm/MC/MCFixupKindInfo.h" |
Akira Hatanaka | 587fe6c | 2011-09-30 21:04:02 +0000 | [diff] [blame] | 25 | #include "llvm/MC/MCObjectWriter.h" |
Akira Hatanaka | 587fe6c | 2011-09-30 21:04:02 +0000 | [diff] [blame] | 26 | #include "llvm/MC/MCSubtargetInfo.h" |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 27 | #include "llvm/MC/MCValue.h" |
Akira Hatanaka | 587fe6c | 2011-09-30 21:04:02 +0000 | [diff] [blame] | 28 | #include "llvm/Support/ErrorHandling.h" |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 29 | #include "llvm/Support/Format.h" |
Matheus Almeida | e0d75aa | 2013-12-13 11:11:02 +0000 | [diff] [blame] | 30 | #include "llvm/Support/MathExtras.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 31 | #include "llvm/Support/raw_ostream.h" |
Bruno Cardoso Lopes | 61e6d98 | 2011-12-07 00:28:57 +0000 | [diff] [blame] | 32 | |
Akira Hatanaka | 587fe6c | 2011-09-30 21:04:02 +0000 | [diff] [blame] | 33 | using namespace llvm; |
| 34 | |
Bruno Cardoso Lopes | 61e6d98 | 2011-12-07 00:28:57 +0000 | [diff] [blame] | 35 | // Prepare value for the target space for it |
Matheus Almeida | e0d75aa | 2013-12-13 11:11:02 +0000 | [diff] [blame] | 36 | static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value, |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 37 | MCContext *Ctx = nullptr) { |
Matheus Almeida | e0d75aa | 2013-12-13 11:11:02 +0000 | [diff] [blame] | 38 | |
| 39 | unsigned Kind = Fixup.getKind(); |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 40 | |
| 41 | // Add/subtract and shift |
| 42 | switch (Kind) { |
| 43 | default: |
Bruno Cardoso Lopes | 61e6d98 | 2011-12-07 00:28:57 +0000 | [diff] [blame] | 44 | return 0; |
Ed Maste | 2a710d0 | 2014-03-03 14:27:49 +0000 | [diff] [blame] | 45 | case FK_Data_2: |
Bruno Cardoso Lopes | 61e6d98 | 2011-12-07 00:28:57 +0000 | [diff] [blame] | 46 | case Mips::fixup_Mips_LO16: |
Jack Carter | c3dd91c | 2013-01-08 19:01:28 +0000 | [diff] [blame] | 47 | case Mips::fixup_Mips_GPREL16: |
Jack Carter | b9f9de9 | 2012-06-27 22:48:25 +0000 | [diff] [blame] | 48 | case Mips::fixup_Mips_GPOFF_HI: |
| 49 | case Mips::fixup_Mips_GPOFF_LO: |
| 50 | case Mips::fixup_Mips_GOT_PAGE: |
| 51 | case Mips::fixup_Mips_GOT_OFST: |
Jack Carter | 5ddcfda | 2012-07-13 19:15:47 +0000 | [diff] [blame] | 52 | case Mips::fixup_Mips_GOT_DISP: |
Jack Carter | b05cb67 | 2012-11-21 23:38:59 +0000 | [diff] [blame] | 53 | case Mips::fixup_Mips_GOT_LO16: |
| 54 | case Mips::fixup_Mips_CALL_LO16: |
Zoran Jovanovic | e7ae8af | 2013-10-23 16:14:44 +0000 | [diff] [blame] | 55 | case Mips::fixup_MICROMIPS_LO16: |
| 56 | case Mips::fixup_MICROMIPS_GOT_PAGE: |
| 57 | case Mips::fixup_MICROMIPS_GOT_OFST: |
| 58 | case Mips::fixup_MICROMIPS_GOT_DISP: |
Zoran Jovanovic | b355e8f | 2014-05-27 14:58:51 +0000 | [diff] [blame] | 59 | case Mips::fixup_MIPS_PCLO16: |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 60 | Value &= 0xffff; |
| 61 | break; |
| 62 | case FK_GPRel_4: |
| 63 | case FK_Data_4: |
| 64 | case FK_Data_8: |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 65 | break; |
| 66 | case Mips::fixup_Mips_PC16: |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 67 | // The displacement is then divided by 4 to give us an 18 bit |
Matheus Almeida | e0d75aa | 2013-12-13 11:11:02 +0000 | [diff] [blame] | 68 | // address range. Forcing a signed division because Value can be negative. |
| 69 | Value = (int64_t)Value / 4; |
| 70 | // We now check if Value can be encoded as a 16-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 71 | if (!isInt<16>(Value) && Ctx) { |
| 72 | Ctx->reportError(Fixup.getLoc(), "out of range PC16 fixup"); |
| 73 | return 0; |
| 74 | } |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 75 | break; |
Zoran Jovanovic | b9c07f3 | 2014-06-12 12:40:00 +0000 | [diff] [blame] | 76 | case Mips::fixup_MIPS_PC19_S2: |
Zoran Jovanovic | 6764fa7 | 2016-04-21 14:09:35 +0000 | [diff] [blame] | 77 | case Mips::fixup_MICROMIPS_PC19_S2: |
Zoran Jovanovic | b9c07f3 | 2014-06-12 12:40:00 +0000 | [diff] [blame] | 78 | // Forcing a signed division because Value can be negative. |
| 79 | Value = (int64_t)Value / 4; |
| 80 | // We now check if Value can be encoded as a 19-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 81 | if (!isInt<19>(Value) && Ctx) { |
| 82 | Ctx->reportError(Fixup.getLoc(), "out of range PC19 fixup"); |
| 83 | return 0; |
| 84 | } |
Zoran Jovanovic | b9c07f3 | 2014-06-12 12:40:00 +0000 | [diff] [blame] | 85 | break; |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 86 | case Mips::fixup_Mips_26: |
| 87 | // So far we are only using this type for jumps. |
| 88 | // The displacement is then divided by 4 to give us an 28 bit |
| 89 | // address range. |
| 90 | Value >>= 2; |
| 91 | break; |
Akira Hatanaka | f5ddf13 | 2011-11-23 22:18:04 +0000 | [diff] [blame] | 92 | case Mips::fixup_Mips_HI16: |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 93 | case Mips::fixup_Mips_GOT: |
Daniel Sanders | a2bde88 | 2016-05-16 09:33:59 +0000 | [diff] [blame] | 94 | case Mips::fixup_MICROMIPS_GOT16: |
Jack Carter | b05cb67 | 2012-11-21 23:38:59 +0000 | [diff] [blame] | 95 | case Mips::fixup_Mips_GOT_HI16: |
| 96 | case Mips::fixup_Mips_CALL_HI16: |
Zoran Jovanovic | e7ae8af | 2013-10-23 16:14:44 +0000 | [diff] [blame] | 97 | case Mips::fixup_MICROMIPS_HI16: |
Zoran Jovanovic | b355e8f | 2014-05-27 14:58:51 +0000 | [diff] [blame] | 98 | case Mips::fixup_MIPS_PCHI16: |
Jack Carter | 84491ab | 2012-08-06 21:26:03 +0000 | [diff] [blame] | 99 | // Get the 2nd 16-bits. Also add 1 if bit 15 is 1. |
Akira Hatanaka | da72819 | 2012-03-27 01:50:08 +0000 | [diff] [blame] | 100 | Value = ((Value + 0x8000) >> 16) & 0xffff; |
Akira Hatanaka | f5ddf13 | 2011-11-23 22:18:04 +0000 | [diff] [blame] | 101 | break; |
Jack Carter | 84491ab | 2012-08-06 21:26:03 +0000 | [diff] [blame] | 102 | case Mips::fixup_Mips_HIGHER: |
| 103 | // Get the 3rd 16-bits. |
| 104 | Value = ((Value + 0x80008000LL) >> 32) & 0xffff; |
| 105 | break; |
| 106 | case Mips::fixup_Mips_HIGHEST: |
| 107 | // Get the 4th 16-bits. |
| 108 | Value = ((Value + 0x800080008000LL) >> 48) & 0xffff; |
| 109 | break; |
Zoran Jovanovic | 507e084 | 2013-10-29 16:38:59 +0000 | [diff] [blame] | 110 | case Mips::fixup_MICROMIPS_26_S1: |
| 111 | Value >>= 1; |
| 112 | break; |
Jozef Kolek | 9761e96 | 2015-01-12 12:03:34 +0000 | [diff] [blame] | 113 | case Mips::fixup_MICROMIPS_PC7_S1: |
| 114 | Value -= 4; |
| 115 | // Forcing a signed division because Value can be negative. |
| 116 | Value = (int64_t) Value / 2; |
| 117 | // We now check if Value can be encoded as a 7-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 118 | if (!isInt<7>(Value) && Ctx) { |
| 119 | Ctx->reportError(Fixup.getLoc(), "out of range PC7 fixup"); |
| 120 | return 0; |
| 121 | } |
Jozef Kolek | 9761e96 | 2015-01-12 12:03:34 +0000 | [diff] [blame] | 122 | break; |
Jozef Kolek | 5cfebdd | 2015-01-21 12:39:30 +0000 | [diff] [blame] | 123 | case Mips::fixup_MICROMIPS_PC10_S1: |
| 124 | Value -= 2; |
| 125 | // Forcing a signed division because Value can be negative. |
| 126 | Value = (int64_t) Value / 2; |
| 127 | // We now check if Value can be encoded as a 10-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 128 | if (!isInt<10>(Value) && Ctx) { |
| 129 | Ctx->reportError(Fixup.getLoc(), "out of range PC10 fixup"); |
| 130 | return 0; |
| 131 | } |
Jozef Kolek | 5cfebdd | 2015-01-21 12:39:30 +0000 | [diff] [blame] | 132 | break; |
Zoran Jovanovic | 8a80aa7 | 2013-11-04 14:53:22 +0000 | [diff] [blame] | 133 | case Mips::fixup_MICROMIPS_PC16_S1: |
| 134 | Value -= 4; |
Matheus Almeida | e0d75aa | 2013-12-13 11:11:02 +0000 | [diff] [blame] | 135 | // Forcing a signed division because Value can be negative. |
| 136 | Value = (int64_t)Value / 2; |
| 137 | // We now check if Value can be encoded as a 16-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 138 | if (!isInt<16>(Value) && Ctx) { |
| 139 | Ctx->reportError(Fixup.getLoc(), "out of range PC16 fixup"); |
| 140 | return 0; |
| 141 | } |
Zoran Jovanovic | 8a80aa7 | 2013-11-04 14:53:22 +0000 | [diff] [blame] | 142 | break; |
Zoran Jovanovic | a5acdcf | 2014-06-13 14:26:47 +0000 | [diff] [blame] | 143 | case Mips::fixup_MIPS_PC18_S3: |
| 144 | // Forcing a signed division because Value can be negative. |
| 145 | Value = (int64_t)Value / 8; |
| 146 | // We now check if Value can be encoded as a 18-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 147 | if (!isInt<18>(Value) && Ctx) { |
| 148 | Ctx->reportError(Fixup.getLoc(), "out of range PC18 fixup"); |
| 149 | return 0; |
| 150 | } |
Zoran Jovanovic | a5acdcf | 2014-06-13 14:26:47 +0000 | [diff] [blame] | 151 | break; |
Zoran Jovanovic | 8e36682 | 2016-04-22 10:15:12 +0000 | [diff] [blame] | 152 | case Mips::fixup_MICROMIPS_PC18_S3: |
| 153 | // Check alignment. |
| 154 | if ((Value & 7) && Ctx) { |
| 155 | Ctx->reportError(Fixup.getLoc(), "out of range PC18 fixup"); |
| 156 | } |
| 157 | // Forcing a signed division because Value can be negative. |
| 158 | Value = (int64_t)Value / 8; |
| 159 | // We now check if Value can be encoded as a 18-bit signed immediate. |
| 160 | if (!isInt<18>(Value) && Ctx) { |
| 161 | Ctx->reportError(Fixup.getLoc(), "out of range PC18 fixup"); |
| 162 | return 0; |
| 163 | } |
| 164 | break; |
Zoran Jovanovic | 10e06da | 2014-05-27 12:55:40 +0000 | [diff] [blame] | 165 | case Mips::fixup_MIPS_PC21_S2: |
Zoran Jovanovic | 10e06da | 2014-05-27 12:55:40 +0000 | [diff] [blame] | 166 | // Forcing a signed division because Value can be negative. |
| 167 | Value = (int64_t) Value / 4; |
| 168 | // We now check if Value can be encoded as a 21-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 169 | if (!isInt<21>(Value) && Ctx) { |
| 170 | Ctx->reportError(Fixup.getLoc(), "out of range PC21 fixup"); |
| 171 | return 0; |
| 172 | } |
Zoran Jovanovic | 10e06da | 2014-05-27 12:55:40 +0000 | [diff] [blame] | 173 | break; |
| 174 | case Mips::fixup_MIPS_PC26_S2: |
Zoran Jovanovic | 10e06da | 2014-05-27 12:55:40 +0000 | [diff] [blame] | 175 | // Forcing a signed division because Value can be negative. |
| 176 | Value = (int64_t) Value / 4; |
| 177 | // We now check if Value can be encoded as a 26-bit signed immediate. |
Oliver Stannard | 9be59af | 2015-11-17 10:00:43 +0000 | [diff] [blame] | 178 | if (!isInt<26>(Value) && Ctx) { |
| 179 | Ctx->reportError(Fixup.getLoc(), "out of range PC26 fixup"); |
| 180 | return 0; |
| 181 | } |
Zoran Jovanovic | 10e06da | 2014-05-27 12:55:40 +0000 | [diff] [blame] | 182 | break; |
Zoran Jovanovic | 02b7003 | 2016-04-21 13:43:26 +0000 | [diff] [blame] | 183 | case Mips::fixup_MICROMIPS_PC26_S1: |
| 184 | // Forcing a signed division because Value can be negative. |
| 185 | Value = (int64_t)Value / 2; |
| 186 | // We now check if Value can be encoded as a 26-bit signed immediate. |
| 187 | if (!isInt<26>(Value) && Ctx) { |
| 188 | Ctx->reportFatalError(Fixup.getLoc(), "out of range PC26 fixup"); |
| 189 | return 0; |
| 190 | } |
| 191 | break; |
Zoran Jovanovic | 5f94ced | 2016-05-19 12:20:40 +0000 | [diff] [blame] | 192 | case Mips::fixup_MICROMIPS_PC21_S1: |
| 193 | // Forcing a signed division because Value can be negative. |
| 194 | Value = (int64_t)Value / 2; |
| 195 | // We now check if Value can be encoded as a 21-bit signed immediate. |
| 196 | if (!isInt<21>(Value) && Ctx) { |
| 197 | Ctx->reportError(Fixup.getLoc(), "out of range PC21 fixup"); |
| 198 | return 0; |
| 199 | } |
| 200 | break; |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | return Value; |
| 204 | } |
| 205 | |
Rafael Espindola | 5560a4c | 2015-04-14 22:14:34 +0000 | [diff] [blame] | 206 | MCObjectWriter * |
| 207 | MipsAsmBackend::createObjectWriter(raw_pwrite_stream &OS) const { |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 208 | return createMipsELFObjectWriter(OS, |
| 209 | MCELFObjectTargetWriter::getOSABI(OSType), IsLittle, Is64Bit); |
| 210 | } |
Akira Hatanaka | 1ee768d | 2012-03-01 01:53:15 +0000 | [diff] [blame] | 211 | |
Zoran Jovanovic | 842f20e | 2014-04-03 12:01:01 +0000 | [diff] [blame] | 212 | // Little-endian fixup data byte ordering: |
| 213 | // mips32r2: a | b | x | x |
| 214 | // microMIPS: x | x | a | b |
| 215 | |
| 216 | static bool needsMMLEByteOrder(unsigned Kind) { |
Jozef Kolek | 5cfebdd | 2015-01-21 12:39:30 +0000 | [diff] [blame] | 217 | return Kind != Mips::fixup_MICROMIPS_PC10_S1 && |
| 218 | Kind >= Mips::fixup_MICROMIPS_26_S1 && |
Zoran Jovanovic | 842f20e | 2014-04-03 12:01:01 +0000 | [diff] [blame] | 219 | Kind < Mips::LastTargetFixupKind; |
| 220 | } |
| 221 | |
| 222 | // Calculate index for microMIPS specific little endian byte order |
| 223 | static unsigned calculateMMLEIndex(unsigned i) { |
| 224 | assert(i <= 3 && "Index out of range!"); |
| 225 | |
| 226 | return (1 - i / 2) * 2 + i % 2; |
| 227 | } |
| 228 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 229 | /// ApplyFixup - Apply the \p Value for given \p Fixup into the provided |
| 230 | /// data fragment, at the offset specified by the fixup and following the |
| 231 | /// fixup kind as appropriate. |
| 232 | void MipsAsmBackend::applyFixup(const MCFixup &Fixup, char *Data, |
Rafael Espindola | 5904e12 | 2014-03-29 06:26:49 +0000 | [diff] [blame] | 233 | unsigned DataSize, uint64_t Value, |
| 234 | bool IsPCRel) const { |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 235 | MCFixupKind Kind = Fixup.getKind(); |
| 236 | Value = adjustFixupValue(Fixup, Value); |
Akira Hatanaka | 1ee768d | 2012-03-01 01:53:15 +0000 | [diff] [blame] | 237 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 238 | if (!Value) |
| 239 | return; // Doesn't change encoding. |
| 240 | |
| 241 | // Where do we start in the object |
| 242 | unsigned Offset = Fixup.getOffset(); |
| 243 | // Number of bytes we need to fixup |
| 244 | unsigned NumBytes = (getFixupKindInfo(Kind).TargetSize + 7) / 8; |
| 245 | // Used to point to big endian bytes |
| 246 | unsigned FullSize; |
| 247 | |
| 248 | switch ((unsigned)Kind) { |
| 249 | case FK_Data_2: |
| 250 | case Mips::fixup_Mips_16: |
Jozef Kolek | 5cfebdd | 2015-01-21 12:39:30 +0000 | [diff] [blame] | 251 | case Mips::fixup_MICROMIPS_PC10_S1: |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 252 | FullSize = 2; |
| 253 | break; |
| 254 | case FK_Data_8: |
| 255 | case Mips::fixup_Mips_64: |
| 256 | FullSize = 8; |
| 257 | break; |
| 258 | case FK_Data_4: |
| 259 | default: |
| 260 | FullSize = 4; |
| 261 | break; |
Akira Hatanaka | 1ee768d | 2012-03-01 01:53:15 +0000 | [diff] [blame] | 262 | } |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 263 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 264 | // Grab current value, if any, from bits. |
| 265 | uint64_t CurVal = 0; |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 266 | |
Zoran Jovanovic | 842f20e | 2014-04-03 12:01:01 +0000 | [diff] [blame] | 267 | bool microMipsLEByteOrder = needsMMLEByteOrder((unsigned) Kind); |
| 268 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 269 | for (unsigned i = 0; i != NumBytes; ++i) { |
Zoran Jovanovic | 842f20e | 2014-04-03 12:01:01 +0000 | [diff] [blame] | 270 | unsigned Idx = IsLittle ? (microMipsLEByteOrder ? calculateMMLEIndex(i) |
| 271 | : i) |
| 272 | : (FullSize - 1 - i); |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 273 | CurVal |= (uint64_t)((uint8_t)Data[Offset + Idx]) << (i*8); |
Akira Hatanaka | 0137dfe | 2012-03-21 00:52:01 +0000 | [diff] [blame] | 274 | } |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 275 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 276 | uint64_t Mask = ((uint64_t)(-1) >> |
| 277 | (64 - getFixupKindInfo(Kind).TargetSize)); |
| 278 | CurVal |= Value & Mask; |
Bruno Cardoso Lopes | c85e3ff | 2011-11-11 22:58:42 +0000 | [diff] [blame] | 279 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 280 | // Write out the fixed up bytes back to the code/data bits. |
| 281 | for (unsigned i = 0; i != NumBytes; ++i) { |
Zoran Jovanovic | 842f20e | 2014-04-03 12:01:01 +0000 | [diff] [blame] | 282 | unsigned Idx = IsLittle ? (microMipsLEByteOrder ? calculateMMLEIndex(i) |
| 283 | : i) |
| 284 | : (FullSize - 1 - i); |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 285 | Data[Offset + Idx] = (uint8_t)((CurVal >> (i*8)) & 0xff); |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 286 | } |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 287 | } |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 288 | |
David Majnemer | ce10842 | 2016-01-19 23:05:27 +0000 | [diff] [blame] | 289 | Optional<MCFixupKind> MipsAsmBackend::getFixupKind(StringRef Name) const { |
| 290 | return StringSwitch<Optional<MCFixupKind>>(Name) |
| 291 | .Case("R_MIPS_NONE", (MCFixupKind)Mips::fixup_Mips_NONE) |
| 292 | .Case("R_MIPS_32", FK_Data_4) |
| 293 | .Default(MCAsmBackend::getFixupKind(Name)); |
Daniel Sanders | 9f6ad49 | 2015-11-12 13:33:00 +0000 | [diff] [blame] | 294 | } |
| 295 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 296 | const MCFixupKindInfo &MipsAsmBackend:: |
| 297 | getFixupKindInfo(MCFixupKind Kind) const { |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 298 | const static MCFixupKindInfo LittleEndianInfos[Mips::NumTargetFixupKinds] = { |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 299 | // This table *must* be in same the order of fixup_* kinds in |
| 300 | // MipsFixupKinds.h. |
| 301 | // |
| 302 | // name offset bits flags |
Daniel Sanders | 9f6ad49 | 2015-11-12 13:33:00 +0000 | [diff] [blame] | 303 | { "fixup_Mips_NONE", 0, 0, 0 }, |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 304 | { "fixup_Mips_16", 0, 16, 0 }, |
| 305 | { "fixup_Mips_32", 0, 32, 0 }, |
| 306 | { "fixup_Mips_REL32", 0, 32, 0 }, |
| 307 | { "fixup_Mips_26", 0, 26, 0 }, |
| 308 | { "fixup_Mips_HI16", 0, 16, 0 }, |
| 309 | { "fixup_Mips_LO16", 0, 16, 0 }, |
| 310 | { "fixup_Mips_GPREL16", 0, 16, 0 }, |
| 311 | { "fixup_Mips_LITERAL", 0, 16, 0 }, |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 312 | { "fixup_Mips_GOT", 0, 16, 0 }, |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 313 | { "fixup_Mips_PC16", 0, 16, MCFixupKindInfo::FKF_IsPCRel }, |
| 314 | { "fixup_Mips_CALL16", 0, 16, 0 }, |
| 315 | { "fixup_Mips_GPREL32", 0, 32, 0 }, |
| 316 | { "fixup_Mips_SHIFT5", 6, 5, 0 }, |
| 317 | { "fixup_Mips_SHIFT6", 6, 5, 0 }, |
| 318 | { "fixup_Mips_64", 0, 64, 0 }, |
| 319 | { "fixup_Mips_TLSGD", 0, 16, 0 }, |
| 320 | { "fixup_Mips_GOTTPREL", 0, 16, 0 }, |
| 321 | { "fixup_Mips_TPREL_HI", 0, 16, 0 }, |
| 322 | { "fixup_Mips_TPREL_LO", 0, 16, 0 }, |
| 323 | { "fixup_Mips_TLSLDM", 0, 16, 0 }, |
| 324 | { "fixup_Mips_DTPREL_HI", 0, 16, 0 }, |
| 325 | { "fixup_Mips_DTPREL_LO", 0, 16, 0 }, |
| 326 | { "fixup_Mips_Branch_PCRel", 0, 16, MCFixupKindInfo::FKF_IsPCRel }, |
| 327 | { "fixup_Mips_GPOFF_HI", 0, 16, 0 }, |
| 328 | { "fixup_Mips_GPOFF_LO", 0, 16, 0 }, |
| 329 | { "fixup_Mips_GOT_PAGE", 0, 16, 0 }, |
| 330 | { "fixup_Mips_GOT_OFST", 0, 16, 0 }, |
| 331 | { "fixup_Mips_GOT_DISP", 0, 16, 0 }, |
| 332 | { "fixup_Mips_HIGHER", 0, 16, 0 }, |
| 333 | { "fixup_Mips_HIGHEST", 0, 16, 0 }, |
| 334 | { "fixup_Mips_GOT_HI16", 0, 16, 0 }, |
| 335 | { "fixup_Mips_GOT_LO16", 0, 16, 0 }, |
| 336 | { "fixup_Mips_CALL_HI16", 0, 16, 0 }, |
| 337 | { "fixup_Mips_CALL_LO16", 0, 16, 0 }, |
Zoran Jovanovic | a5acdcf | 2014-06-13 14:26:47 +0000 | [diff] [blame] | 338 | { "fixup_Mips_PC18_S3", 0, 18, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | b9c07f3 | 2014-06-12 12:40:00 +0000 | [diff] [blame] | 339 | { "fixup_MIPS_PC19_S2", 0, 19, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 10e06da | 2014-05-27 12:55:40 +0000 | [diff] [blame] | 340 | { "fixup_MIPS_PC21_S2", 0, 21, MCFixupKindInfo::FKF_IsPCRel }, |
| 341 | { "fixup_MIPS_PC26_S2", 0, 26, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | b355e8f | 2014-05-27 14:58:51 +0000 | [diff] [blame] | 342 | { "fixup_MIPS_PCHI16", 0, 16, MCFixupKindInfo::FKF_IsPCRel }, |
| 343 | { "fixup_MIPS_PCLO16", 0, 16, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 344 | { "fixup_MICROMIPS_26_S1", 0, 26, 0 }, |
| 345 | { "fixup_MICROMIPS_HI16", 0, 16, 0 }, |
| 346 | { "fixup_MICROMIPS_LO16", 0, 16, 0 }, |
| 347 | { "fixup_MICROMIPS_GOT16", 0, 16, 0 }, |
Jozef Kolek | 9761e96 | 2015-01-12 12:03:34 +0000 | [diff] [blame] | 348 | { "fixup_MICROMIPS_PC7_S1", 0, 7, MCFixupKindInfo::FKF_IsPCRel }, |
Jozef Kolek | 5cfebdd | 2015-01-21 12:39:30 +0000 | [diff] [blame] | 349 | { "fixup_MICROMIPS_PC10_S1", 0, 10, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 350 | { "fixup_MICROMIPS_PC16_S1", 0, 16, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 02b7003 | 2016-04-21 13:43:26 +0000 | [diff] [blame] | 351 | { "fixup_MICROMIPS_PC26_S1", 0, 26, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 6764fa7 | 2016-04-21 14:09:35 +0000 | [diff] [blame] | 352 | { "fixup_MICROMIPS_PC19_S2", 0, 19, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 8e36682 | 2016-04-22 10:15:12 +0000 | [diff] [blame] | 353 | { "fixup_MICROMIPS_PC18_S3", 0, 18, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 5f94ced | 2016-05-19 12:20:40 +0000 | [diff] [blame] | 354 | { "fixup_MICROMIPS_PC21_S1", 0, 21, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 355 | { "fixup_MICROMIPS_CALL16", 0, 16, 0 }, |
| 356 | { "fixup_MICROMIPS_GOT_DISP", 0, 16, 0 }, |
| 357 | { "fixup_MICROMIPS_GOT_PAGE", 0, 16, 0 }, |
| 358 | { "fixup_MICROMIPS_GOT_OFST", 0, 16, 0 }, |
| 359 | { "fixup_MICROMIPS_TLS_GD", 0, 16, 0 }, |
| 360 | { "fixup_MICROMIPS_TLS_LDM", 0, 16, 0 }, |
| 361 | { "fixup_MICROMIPS_TLS_DTPREL_HI16", 0, 16, 0 }, |
| 362 | { "fixup_MICROMIPS_TLS_DTPREL_LO16", 0, 16, 0 }, |
| 363 | { "fixup_MICROMIPS_TLS_TPREL_HI16", 0, 16, 0 }, |
Daniel Sanders | cae9aee | 2016-08-08 09:33:14 +0000 | [diff] [blame] | 364 | { "fixup_MICROMIPS_TLS_TPREL_LO16", 0, 16, 0 } |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 365 | }; |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 366 | |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 367 | const static MCFixupKindInfo BigEndianInfos[Mips::NumTargetFixupKinds] = { |
| 368 | // This table *must* be in same the order of fixup_* kinds in |
| 369 | // MipsFixupKinds.h. |
| 370 | // |
| 371 | // name offset bits flags |
Daniel Sanders | 9f6ad49 | 2015-11-12 13:33:00 +0000 | [diff] [blame] | 372 | { "fixup_Mips_NONE", 0, 0, 0 }, |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 373 | { "fixup_Mips_16", 16, 16, 0 }, |
| 374 | { "fixup_Mips_32", 0, 32, 0 }, |
| 375 | { "fixup_Mips_REL32", 0, 32, 0 }, |
| 376 | { "fixup_Mips_26", 6, 26, 0 }, |
| 377 | { "fixup_Mips_HI16", 16, 16, 0 }, |
| 378 | { "fixup_Mips_LO16", 16, 16, 0 }, |
| 379 | { "fixup_Mips_GPREL16", 16, 16, 0 }, |
| 380 | { "fixup_Mips_LITERAL", 16, 16, 0 }, |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 381 | { "fixup_Mips_GOT", 16, 16, 0 }, |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 382 | { "fixup_Mips_PC16", 16, 16, MCFixupKindInfo::FKF_IsPCRel }, |
| 383 | { "fixup_Mips_CALL16", 16, 16, 0 }, |
| 384 | { "fixup_Mips_GPREL32", 0, 32, 0 }, |
| 385 | { "fixup_Mips_SHIFT5", 21, 5, 0 }, |
| 386 | { "fixup_Mips_SHIFT6", 21, 5, 0 }, |
| 387 | { "fixup_Mips_64", 0, 64, 0 }, |
| 388 | { "fixup_Mips_TLSGD", 16, 16, 0 }, |
| 389 | { "fixup_Mips_GOTTPREL", 16, 16, 0 }, |
| 390 | { "fixup_Mips_TPREL_HI", 16, 16, 0 }, |
| 391 | { "fixup_Mips_TPREL_LO", 16, 16, 0 }, |
| 392 | { "fixup_Mips_TLSLDM", 16, 16, 0 }, |
| 393 | { "fixup_Mips_DTPREL_HI", 16, 16, 0 }, |
| 394 | { "fixup_Mips_DTPREL_LO", 16, 16, 0 }, |
| 395 | { "fixup_Mips_Branch_PCRel",16, 16, MCFixupKindInfo::FKF_IsPCRel }, |
| 396 | { "fixup_Mips_GPOFF_HI", 16, 16, 0 }, |
| 397 | { "fixup_Mips_GPOFF_LO", 16, 16, 0 }, |
| 398 | { "fixup_Mips_GOT_PAGE", 16, 16, 0 }, |
| 399 | { "fixup_Mips_GOT_OFST", 16, 16, 0 }, |
| 400 | { "fixup_Mips_GOT_DISP", 16, 16, 0 }, |
| 401 | { "fixup_Mips_HIGHER", 16, 16, 0 }, |
| 402 | { "fixup_Mips_HIGHEST", 16, 16, 0 }, |
| 403 | { "fixup_Mips_GOT_HI16", 16, 16, 0 }, |
| 404 | { "fixup_Mips_GOT_LO16", 16, 16, 0 }, |
| 405 | { "fixup_Mips_CALL_HI16", 16, 16, 0 }, |
| 406 | { "fixup_Mips_CALL_LO16", 16, 16, 0 }, |
Zoran Jovanovic | a5acdcf | 2014-06-13 14:26:47 +0000 | [diff] [blame] | 407 | { "fixup_Mips_PC18_S3", 14, 18, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | b9c07f3 | 2014-06-12 12:40:00 +0000 | [diff] [blame] | 408 | { "fixup_MIPS_PC19_S2", 13, 19, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 10e06da | 2014-05-27 12:55:40 +0000 | [diff] [blame] | 409 | { "fixup_MIPS_PC21_S2", 11, 21, MCFixupKindInfo::FKF_IsPCRel }, |
| 410 | { "fixup_MIPS_PC26_S2", 6, 26, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | b355e8f | 2014-05-27 14:58:51 +0000 | [diff] [blame] | 411 | { "fixup_MIPS_PCHI16", 16, 16, MCFixupKindInfo::FKF_IsPCRel }, |
| 412 | { "fixup_MIPS_PCLO16", 16, 16, MCFixupKindInfo::FKF_IsPCRel }, |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 413 | { "fixup_MICROMIPS_26_S1", 6, 26, 0 }, |
| 414 | { "fixup_MICROMIPS_HI16", 16, 16, 0 }, |
| 415 | { "fixup_MICROMIPS_LO16", 16, 16, 0 }, |
| 416 | { "fixup_MICROMIPS_GOT16", 16, 16, 0 }, |
Jozef Kolek | 9761e96 | 2015-01-12 12:03:34 +0000 | [diff] [blame] | 417 | { "fixup_MICROMIPS_PC7_S1", 9, 7, MCFixupKindInfo::FKF_IsPCRel }, |
Jozef Kolek | 5cfebdd | 2015-01-21 12:39:30 +0000 | [diff] [blame] | 418 | { "fixup_MICROMIPS_PC10_S1", 6, 10, MCFixupKindInfo::FKF_IsPCRel }, |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 419 | { "fixup_MICROMIPS_PC16_S1",16, 16, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 02b7003 | 2016-04-21 13:43:26 +0000 | [diff] [blame] | 420 | { "fixup_MICROMIPS_PC26_S1", 6, 26, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 6764fa7 | 2016-04-21 14:09:35 +0000 | [diff] [blame] | 421 | { "fixup_MICROMIPS_PC19_S2",13, 19, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 8e36682 | 2016-04-22 10:15:12 +0000 | [diff] [blame] | 422 | { "fixup_MICROMIPS_PC18_S3",14, 18, MCFixupKindInfo::FKF_IsPCRel }, |
Zoran Jovanovic | 5f94ced | 2016-05-19 12:20:40 +0000 | [diff] [blame] | 423 | { "fixup_MICROMIPS_PC21_S1",11, 21, MCFixupKindInfo::FKF_IsPCRel }, |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 424 | { "fixup_MICROMIPS_CALL16", 16, 16, 0 }, |
| 425 | { "fixup_MICROMIPS_GOT_DISP", 16, 16, 0 }, |
| 426 | { "fixup_MICROMIPS_GOT_PAGE", 16, 16, 0 }, |
| 427 | { "fixup_MICROMIPS_GOT_OFST", 16, 16, 0 }, |
| 428 | { "fixup_MICROMIPS_TLS_GD", 16, 16, 0 }, |
| 429 | { "fixup_MICROMIPS_TLS_LDM", 16, 16, 0 }, |
| 430 | { "fixup_MICROMIPS_TLS_DTPREL_HI16", 16, 16, 0 }, |
| 431 | { "fixup_MICROMIPS_TLS_DTPREL_LO16", 16, 16, 0 }, |
| 432 | { "fixup_MICROMIPS_TLS_TPREL_HI16", 16, 16, 0 }, |
Daniel Sanders | cae9aee | 2016-08-08 09:33:14 +0000 | [diff] [blame] | 433 | { "fixup_MICROMIPS_TLS_TPREL_LO16", 16, 16, 0 } |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 434 | }; |
| 435 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 436 | if (Kind < FirstTargetFixupKind) |
| 437 | return MCAsmBackend::getFixupKindInfo(Kind); |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 438 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 439 | assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() && |
| 440 | "Invalid kind!"); |
Daniel Sanders | 683ed96 | 2014-05-23 13:35:24 +0000 | [diff] [blame] | 441 | |
| 442 | if (IsLittle) |
| 443 | return LittleEndianInfos[Kind - FirstTargetFixupKind]; |
| 444 | return BigEndianInfos[Kind - FirstTargetFixupKind]; |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 445 | } |
Jim Grosbach | 25b63fa | 2011-12-06 00:47:03 +0000 | [diff] [blame] | 446 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 447 | /// WriteNopData - Write an (optimal) nop sequence of Count bytes |
| 448 | /// to the given output. If the target cannot generate such a sequence, |
| 449 | /// it should return an error. |
| 450 | /// |
| 451 | /// \return - True on success. |
| 452 | bool MipsAsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const { |
| 453 | // Check for a less than instruction size number of bytes |
| 454 | // FIXME: 16 bit instructions are not handled yet here. |
| 455 | // We shouldn't be using a hard coded number for instruction size. |
Joerg Sonnenberger | f148a6d | 2014-10-02 13:41:42 +0000 | [diff] [blame] | 456 | |
| 457 | // If the count is not 4-byte aligned, we must be writing data into the text |
| 458 | // section (otherwise we have unaligned instructions, and thus have far |
| 459 | // bigger problems), so just write zeros instead. |
Benjamin Kramer | 97fbdd5 | 2015-04-17 11:12:43 +0000 | [diff] [blame] | 460 | OW->WriteZeros(Count); |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 461 | return true; |
| 462 | } |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 463 | |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 464 | /// processFixupValue - Target hook to process the literal value of a fixup |
| 465 | /// if necessary. |
| 466 | void MipsAsmBackend::processFixupValue(const MCAssembler &Asm, |
| 467 | const MCAsmLayout &Layout, |
| 468 | const MCFixup &Fixup, |
| 469 | const MCFragment *DF, |
Rafael Espindola | 3e3de5e | 2014-03-28 16:06:09 +0000 | [diff] [blame] | 470 | const MCValue &Target, |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 471 | uint64_t &Value, |
| 472 | bool &IsResolved) { |
| 473 | // At this point we'll ignore the value returned by adjustFixupValue as |
| 474 | // we are only checking if the fixup can be applied correctly. We have |
| 475 | // access to MCContext from here which allows us to report a fatal error |
| 476 | // with *possibly* a source code location. |
Daniel Sanders | fe98b2f | 2016-05-03 13:35:44 +0000 | [diff] [blame] | 477 | // The caller will also ignore any changes we make to Value |
| 478 | // (recordRelocation() overwrites it with it's own calculation). |
Zoran Jovanovic | ada38ef | 2014-03-27 12:38:40 +0000 | [diff] [blame] | 479 | (void)adjustFixupValue(Fixup, Value, &Asm.getContext()); |
| 480 | } |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 481 | |
Akira Hatanaka | 1ee768d | 2012-03-01 01:53:15 +0000 | [diff] [blame] | 482 | // MCAsmBackend |
Bill Wendling | 58e2d3d | 2013-09-09 02:37:14 +0000 | [diff] [blame] | 483 | MCAsmBackend *llvm::createMipsAsmBackendEL32(const Target &T, |
| 484 | const MCRegisterInfo &MRI, |
Joel Jones | 373d7d3 | 2016-07-25 17:18:28 +0000 | [diff] [blame] | 485 | const Triple &TT, StringRef CPU, |
| 486 | const MCTargetOptions &Options) { |
Daniel Sanders | 418caf5 | 2015-06-10 10:35:34 +0000 | [diff] [blame] | 487 | return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ true, |
| 488 | /*Is64Bit*/ false); |
Rafael Espindola | 647841b | 2012-01-11 04:04:14 +0000 | [diff] [blame] | 489 | } |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 490 | |
Bill Wendling | 58e2d3d | 2013-09-09 02:37:14 +0000 | [diff] [blame] | 491 | MCAsmBackend *llvm::createMipsAsmBackendEB32(const Target &T, |
| 492 | const MCRegisterInfo &MRI, |
Joel Jones | 373d7d3 | 2016-07-25 17:18:28 +0000 | [diff] [blame] | 493 | const Triple &TT, StringRef CPU, |
| 494 | const MCTargetOptions &Options) { |
Daniel Sanders | 418caf5 | 2015-06-10 10:35:34 +0000 | [diff] [blame] | 495 | return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ false, |
| 496 | /*Is64Bit*/ false); |
Akira Hatanaka | 44220ca | 2011-09-30 21:23:45 +0000 | [diff] [blame] | 497 | } |
Akira Hatanaka | b1f68f9 | 2012-04-02 19:25:22 +0000 | [diff] [blame] | 498 | |
Bill Wendling | 58e2d3d | 2013-09-09 02:37:14 +0000 | [diff] [blame] | 499 | MCAsmBackend *llvm::createMipsAsmBackendEL64(const Target &T, |
| 500 | const MCRegisterInfo &MRI, |
Joel Jones | 373d7d3 | 2016-07-25 17:18:28 +0000 | [diff] [blame] | 501 | const Triple &TT, StringRef CPU, |
| 502 | const MCTargetOptions &Options) { |
Daniel Sanders | 418caf5 | 2015-06-10 10:35:34 +0000 | [diff] [blame] | 503 | return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ true, /*Is64Bit*/ true); |
Akira Hatanaka | b1f68f9 | 2012-04-02 19:25:22 +0000 | [diff] [blame] | 504 | } |
| 505 | |
Bill Wendling | 58e2d3d | 2013-09-09 02:37:14 +0000 | [diff] [blame] | 506 | MCAsmBackend *llvm::createMipsAsmBackendEB64(const Target &T, |
| 507 | const MCRegisterInfo &MRI, |
Joel Jones | 373d7d3 | 2016-07-25 17:18:28 +0000 | [diff] [blame] | 508 | const Triple &TT, StringRef CPU, |
| 509 | const MCTargetOptions &Options) { |
Daniel Sanders | 418caf5 | 2015-06-10 10:35:34 +0000 | [diff] [blame] | 510 | return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ false, |
| 511 | /*Is64Bit*/ true); |
Akira Hatanaka | b1f68f9 | 2012-04-02 19:25:22 +0000 | [diff] [blame] | 512 | } |