blob: 4397c971d0802baca85c3ebe312dda9804203850 [file] [log] [blame]
Zoran Jovanovicada38ef2014-03-27 12:38:40 +00001//===-- MipsAsmBackend.cpp - Mips Asm Backend ----------------------------===//
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +00002//
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 Jovanovicada38ef2014-03-27 12:38:40 +000010// This file implements the MipsAsmBackend class.
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000011//
12//===----------------------------------------------------------------------===//
13//
14
Zoran Jovanovicada38ef2014-03-27 12:38:40 +000015#include "MCTargetDesc/MipsAsmBackend.h"
Chandler Carruth6bda14b2017-06-06 11:49:48 +000016#include "MCTargetDesc/MipsFixupKinds.h"
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000017#include "MCTargetDesc/MipsMCExpr.h"
Akira Hatanaka587fe6c2011-09-30 21:04:02 +000018#include "MCTargetDesc/MipsMCTargetDesc.h"
Alexander Richardsone8059b12018-03-27 10:08:12 +000019#include "llvm/ADT/STLExtras.h"
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000020#include "llvm/MC/MCAsmBackend.h"
Akira Hatanaka587fe6c2011-09-30 21:04:02 +000021#include "llvm/MC/MCAssembler.h"
Matheus Almeidae0d75aa2013-12-13 11:11:02 +000022#include "llvm/MC/MCContext.h"
Akira Hatanaka587fe6c2011-09-30 21:04:02 +000023#include "llvm/MC/MCDirectives.h"
24#include "llvm/MC/MCELFObjectWriter.h"
Craig Topper6e80c282012-03-26 06:58:25 +000025#include "llvm/MC/MCFixupKindInfo.h"
Akira Hatanaka587fe6c2011-09-30 21:04:02 +000026#include "llvm/MC/MCObjectWriter.h"
Akira Hatanaka587fe6c2011-09-30 21:04:02 +000027#include "llvm/MC/MCSubtargetInfo.h"
Simon Atanasyan117665582017-09-21 10:44:26 +000028#include "llvm/MC/MCTargetOptions.h"
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000029#include "llvm/MC/MCValue.h"
Akira Hatanaka587fe6c2011-09-30 21:04:02 +000030#include "llvm/Support/ErrorHandling.h"
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000031#include "llvm/Support/Format.h"
Matheus Almeidae0d75aa2013-12-13 11:11:02 +000032#include "llvm/Support/MathExtras.h"
Chandler Carruth8a8cd2b2014-01-07 11:48:04 +000033#include "llvm/Support/raw_ostream.h"
Bruno Cardoso Lopes61e6d982011-12-07 00:28:57 +000034
Akira Hatanaka587fe6c2011-09-30 21:04:02 +000035using namespace llvm;
36
Bruno Cardoso Lopes61e6d982011-12-07 00:28:57 +000037// Prepare value for the target space for it
Matheus Almeidae0d75aa2013-12-13 11:11:02 +000038static unsigned adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
Alex Bradbury866113c2017-04-05 10:16:14 +000039 MCContext &Ctx) {
Matheus Almeidae0d75aa2013-12-13 11:11:02 +000040
41 unsigned Kind = Fixup.getKind();
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000042
43 // Add/subtract and shift
44 switch (Kind) {
45 default:
Bruno Cardoso Lopes61e6d982011-12-07 00:28:57 +000046 return 0;
Ed Maste2a710d02014-03-03 14:27:49 +000047 case FK_Data_2:
Bruno Cardoso Lopes61e6d982011-12-07 00:28:57 +000048 case Mips::fixup_Mips_LO16:
Jack Carterc3dd91c2013-01-08 19:01:28 +000049 case Mips::fixup_Mips_GPREL16:
Jack Carterb9f9de92012-06-27 22:48:25 +000050 case Mips::fixup_Mips_GPOFF_HI:
51 case Mips::fixup_Mips_GPOFF_LO:
52 case Mips::fixup_Mips_GOT_PAGE:
53 case Mips::fixup_Mips_GOT_OFST:
Jack Carter5ddcfda2012-07-13 19:15:47 +000054 case Mips::fixup_Mips_GOT_DISP:
Jack Carterb05cb672012-11-21 23:38:59 +000055 case Mips::fixup_Mips_GOT_LO16:
56 case Mips::fixup_Mips_CALL_LO16:
Simon Atanasyana1d69f92018-05-29 11:33:54 +000057 case Mips::fixup_MICROMIPS_GPOFF_HI:
58 case Mips::fixup_MICROMIPS_GPOFF_LO:
Zoran Jovanovice7ae8af2013-10-23 16:14:44 +000059 case Mips::fixup_MICROMIPS_LO16:
60 case Mips::fixup_MICROMIPS_GOT_PAGE:
61 case Mips::fixup_MICROMIPS_GOT_OFST:
62 case Mips::fixup_MICROMIPS_GOT_DISP:
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +000063 case Mips::fixup_MIPS_PCLO16:
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000064 Value &= 0xffff;
65 break;
Simon Atanasyaneb9ed612016-08-22 16:18:42 +000066 case FK_DTPRel_4:
67 case FK_DTPRel_8:
68 case FK_TPRel_4:
69 case FK_TPRel_8:
Daniel Sandersfe98b2f2016-05-03 13:35:44 +000070 case FK_GPRel_4:
71 case FK_Data_4:
72 case FK_Data_8:
Daniel Sanders3feeb9c2016-08-08 11:50:25 +000073 case Mips::fixup_Mips_SUB:
74 case Mips::fixup_MICROMIPS_SUB:
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000075 break;
76 case Mips::fixup_Mips_PC16:
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000077 // The displacement is then divided by 4 to give us an 18 bit
Matheus Almeidae0d75aa2013-12-13 11:11:02 +000078 // address range. 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 16-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +000081 if (!isInt<16>(Value)) {
82 Ctx.reportError(Fixup.getLoc(), "out of range PC16 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +000083 return 0;
84 }
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000085 break;
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +000086 case Mips::fixup_MIPS_PC19_S2:
Zoran Jovanovic6764fa72016-04-21 14:09:35 +000087 case Mips::fixup_MICROMIPS_PC19_S2:
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +000088 // Forcing a signed division because Value can be negative.
89 Value = (int64_t)Value / 4;
90 // We now check if Value can be encoded as a 19-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +000091 if (!isInt<19>(Value)) {
92 Ctx.reportError(Fixup.getLoc(), "out of range PC19 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +000093 return 0;
94 }
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +000095 break;
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +000096 case Mips::fixup_Mips_26:
97 // So far we are only using this type for jumps.
98 // The displacement is then divided by 4 to give us an 28 bit
99 // address range.
100 Value >>= 2;
101 break;
Akira Hatanakaf5ddf132011-11-23 22:18:04 +0000102 case Mips::fixup_Mips_HI16:
Daniel Sandersfe98b2f2016-05-03 13:35:44 +0000103 case Mips::fixup_Mips_GOT:
Daniel Sandersa2bde882016-05-16 09:33:59 +0000104 case Mips::fixup_MICROMIPS_GOT16:
Jack Carterb05cb672012-11-21 23:38:59 +0000105 case Mips::fixup_Mips_GOT_HI16:
106 case Mips::fixup_Mips_CALL_HI16:
Zoran Jovanovice7ae8af2013-10-23 16:14:44 +0000107 case Mips::fixup_MICROMIPS_HI16:
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +0000108 case Mips::fixup_MIPS_PCHI16:
Jack Carter84491ab2012-08-06 21:26:03 +0000109 // Get the 2nd 16-bits. Also add 1 if bit 15 is 1.
Akira Hatanakada728192012-03-27 01:50:08 +0000110 Value = ((Value + 0x8000) >> 16) & 0xffff;
Akira Hatanakaf5ddf132011-11-23 22:18:04 +0000111 break;
Jack Carter84491ab2012-08-06 21:26:03 +0000112 case Mips::fixup_Mips_HIGHER:
Simon Atanasyan6be87bc2018-05-29 10:27:44 +0000113 case Mips::fixup_MICROMIPS_HIGHER:
Jack Carter84491ab2012-08-06 21:26:03 +0000114 // Get the 3rd 16-bits.
115 Value = ((Value + 0x80008000LL) >> 32) & 0xffff;
116 break;
117 case Mips::fixup_Mips_HIGHEST:
Simon Atanasyan6be87bc2018-05-29 10:27:44 +0000118 case Mips::fixup_MICROMIPS_HIGHEST:
Jack Carter84491ab2012-08-06 21:26:03 +0000119 // Get the 4th 16-bits.
120 Value = ((Value + 0x800080008000LL) >> 48) & 0xffff;
121 break;
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000122 case Mips::fixup_MICROMIPS_26_S1:
123 Value >>= 1;
124 break;
Jozef Kolek9761e962015-01-12 12:03:34 +0000125 case Mips::fixup_MICROMIPS_PC7_S1:
126 Value -= 4;
127 // Forcing a signed division because Value can be negative.
128 Value = (int64_t) Value / 2;
129 // We now check if Value can be encoded as a 7-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000130 if (!isInt<7>(Value)) {
131 Ctx.reportError(Fixup.getLoc(), "out of range PC7 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +0000132 return 0;
133 }
Jozef Kolek9761e962015-01-12 12:03:34 +0000134 break;
Jozef Kolek5cfebdd2015-01-21 12:39:30 +0000135 case Mips::fixup_MICROMIPS_PC10_S1:
136 Value -= 2;
137 // Forcing a signed division because Value can be negative.
138 Value = (int64_t) Value / 2;
139 // We now check if Value can be encoded as a 10-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000140 if (!isInt<10>(Value)) {
141 Ctx.reportError(Fixup.getLoc(), "out of range PC10 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +0000142 return 0;
143 }
Jozef Kolek5cfebdd2015-01-21 12:39:30 +0000144 break;
Zoran Jovanovic8a80aa72013-11-04 14:53:22 +0000145 case Mips::fixup_MICROMIPS_PC16_S1:
146 Value -= 4;
Matheus Almeidae0d75aa2013-12-13 11:11:02 +0000147 // Forcing a signed division because Value can be negative.
148 Value = (int64_t)Value / 2;
149 // We now check if Value can be encoded as a 16-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000150 if (!isInt<16>(Value)) {
151 Ctx.reportError(Fixup.getLoc(), "out of range PC16 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +0000152 return 0;
153 }
Zoran Jovanovic8a80aa72013-11-04 14:53:22 +0000154 break;
Zoran Jovanovica5acdcf2014-06-13 14:26:47 +0000155 case Mips::fixup_MIPS_PC18_S3:
156 // Forcing a signed division because Value can be negative.
157 Value = (int64_t)Value / 8;
158 // We now check if Value can be encoded as a 18-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000159 if (!isInt<18>(Value)) {
160 Ctx.reportError(Fixup.getLoc(), "out of range PC18 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +0000161 return 0;
162 }
Zoran Jovanovica5acdcf2014-06-13 14:26:47 +0000163 break;
Zoran Jovanovic8e366822016-04-22 10:15:12 +0000164 case Mips::fixup_MICROMIPS_PC18_S3:
165 // Check alignment.
Alex Bradbury866113c2017-04-05 10:16:14 +0000166 if ((Value & 7)) {
167 Ctx.reportError(Fixup.getLoc(), "out of range PC18 fixup");
Zoran Jovanovic8e366822016-04-22 10:15:12 +0000168 }
169 // Forcing a signed division because Value can be negative.
170 Value = (int64_t)Value / 8;
171 // We now check if Value can be encoded as a 18-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000172 if (!isInt<18>(Value)) {
173 Ctx.reportError(Fixup.getLoc(), "out of range PC18 fixup");
Zoran Jovanovic8e366822016-04-22 10:15:12 +0000174 return 0;
175 }
176 break;
Zoran Jovanovic10e06da2014-05-27 12:55:40 +0000177 case Mips::fixup_MIPS_PC21_S2:
Zoran Jovanovic10e06da2014-05-27 12:55:40 +0000178 // Forcing a signed division because Value can be negative.
179 Value = (int64_t) Value / 4;
180 // We now check if Value can be encoded as a 21-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000181 if (!isInt<21>(Value)) {
182 Ctx.reportError(Fixup.getLoc(), "out of range PC21 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +0000183 return 0;
184 }
Zoran Jovanovic10e06da2014-05-27 12:55:40 +0000185 break;
186 case Mips::fixup_MIPS_PC26_S2:
Zoran Jovanovic10e06da2014-05-27 12:55:40 +0000187 // Forcing a signed division because Value can be negative.
188 Value = (int64_t) Value / 4;
189 // We now check if Value can be encoded as a 26-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000190 if (!isInt<26>(Value)) {
191 Ctx.reportError(Fixup.getLoc(), "out of range PC26 fixup");
Oliver Stannard9be59af2015-11-17 10:00:43 +0000192 return 0;
193 }
Zoran Jovanovic10e06da2014-05-27 12:55:40 +0000194 break;
Zoran Jovanovic02b70032016-04-21 13:43:26 +0000195 case Mips::fixup_MICROMIPS_PC26_S1:
196 // Forcing a signed division because Value can be negative.
197 Value = (int64_t)Value / 2;
198 // We now check if Value can be encoded as a 26-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000199 if (!isInt<26>(Value)) {
200 Ctx.reportFatalError(Fixup.getLoc(), "out of range PC26 fixup");
Zoran Jovanovic02b70032016-04-21 13:43:26 +0000201 return 0;
202 }
203 break;
Zoran Jovanovic5f94ced2016-05-19 12:20:40 +0000204 case Mips::fixup_MICROMIPS_PC21_S1:
205 // Forcing a signed division because Value can be negative.
206 Value = (int64_t)Value / 2;
207 // We now check if Value can be encoded as a 21-bit signed immediate.
Alex Bradbury866113c2017-04-05 10:16:14 +0000208 if (!isInt<21>(Value)) {
209 Ctx.reportError(Fixup.getLoc(), "out of range PC21 fixup");
Zoran Jovanovic5f94ced2016-05-19 12:20:40 +0000210 return 0;
211 }
212 break;
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +0000213 }
214
215 return Value;
216}
217
Peter Collingbournedcd7d6c2018-05-21 19:20:29 +0000218std::unique_ptr<MCObjectTargetWriter>
219MipsAsmBackend::createObjectTargetWriter() const {
220 return createMipsELFObjectWriter(TheTriple, IsN32);
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000221}
Akira Hatanaka1ee768d2012-03-01 01:53:15 +0000222
Zoran Jovanovic842f20e2014-04-03 12:01:01 +0000223// Little-endian fixup data byte ordering:
224// mips32r2: a | b | x | x
225// microMIPS: x | x | a | b
226
227static bool needsMMLEByteOrder(unsigned Kind) {
Jozef Kolek5cfebdd2015-01-21 12:39:30 +0000228 return Kind != Mips::fixup_MICROMIPS_PC10_S1 &&
229 Kind >= Mips::fixup_MICROMIPS_26_S1 &&
Zoran Jovanovic842f20e2014-04-03 12:01:01 +0000230 Kind < Mips::LastTargetFixupKind;
231}
232
233// Calculate index for microMIPS specific little endian byte order
234static unsigned calculateMMLEIndex(unsigned i) {
235 assert(i <= 3 && "Index out of range!");
236
237 return (1 - i / 2) * 2 + i % 2;
238}
239
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000240/// ApplyFixup - Apply the \p Value for given \p Fixup into the provided
241/// data fragment, at the offset specified by the fixup and following the
242/// fixup kind as appropriate.
Rafael Espindola801b42d2017-06-23 22:52:36 +0000243void MipsAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
244 const MCValue &Target,
Rafael Espindola88d9e372017-06-21 23:06:53 +0000245 MutableArrayRef<char> Data, uint64_t Value,
Peter Smith57f661b2018-06-06 09:40:06 +0000246 bool IsResolved,
247 const MCSubtargetInfo *STI) const {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000248 MCFixupKind Kind = Fixup.getKind();
Rafael Espindolaf3512922017-06-24 00:26:57 +0000249 MCContext &Ctx = Asm.getContext();
Alex Bradbury866113c2017-04-05 10:16:14 +0000250 Value = adjustFixupValue(Fixup, Value, Ctx);
Akira Hatanaka1ee768d2012-03-01 01:53:15 +0000251
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000252 if (!Value)
253 return; // Doesn't change encoding.
254
255 // Where do we start in the object
256 unsigned Offset = Fixup.getOffset();
257 // Number of bytes we need to fixup
258 unsigned NumBytes = (getFixupKindInfo(Kind).TargetSize + 7) / 8;
259 // Used to point to big endian bytes
260 unsigned FullSize;
261
262 switch ((unsigned)Kind) {
263 case FK_Data_2:
264 case Mips::fixup_Mips_16:
Jozef Kolek5cfebdd2015-01-21 12:39:30 +0000265 case Mips::fixup_MICROMIPS_PC10_S1:
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000266 FullSize = 2;
267 break;
268 case FK_Data_8:
269 case Mips::fixup_Mips_64:
270 FullSize = 8;
271 break;
272 case FK_Data_4:
273 default:
274 FullSize = 4;
275 break;
Akira Hatanaka1ee768d2012-03-01 01:53:15 +0000276 }
Akira Hatanaka44220ca2011-09-30 21:23:45 +0000277
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000278 // Grab current value, if any, from bits.
279 uint64_t CurVal = 0;
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +0000280
Zoran Jovanovic842f20e2014-04-03 12:01:01 +0000281 bool microMipsLEByteOrder = needsMMLEByteOrder((unsigned) Kind);
282
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000283 for (unsigned i = 0; i != NumBytes; ++i) {
Peter Collingbourne571a3302018-05-21 17:57:19 +0000284 unsigned Idx = Endian == support::little
285 ? (microMipsLEByteOrder ? calculateMMLEIndex(i) : i)
286 : (FullSize - 1 - i);
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000287 CurVal |= (uint64_t)((uint8_t)Data[Offset + Idx]) << (i*8);
Akira Hatanaka0137dfe2012-03-21 00:52:01 +0000288 }
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +0000289
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000290 uint64_t Mask = ((uint64_t)(-1) >>
291 (64 - getFixupKindInfo(Kind).TargetSize));
292 CurVal |= Value & Mask;
Bruno Cardoso Lopesc85e3ff2011-11-11 22:58:42 +0000293
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000294 // Write out the fixed up bytes back to the code/data bits.
295 for (unsigned i = 0; i != NumBytes; ++i) {
Peter Collingbourne571a3302018-05-21 17:57:19 +0000296 unsigned Idx = Endian == support::little
297 ? (microMipsLEByteOrder ? calculateMMLEIndex(i) : i)
298 : (FullSize - 1 - i);
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000299 Data[Offset + Idx] = (uint8_t)((CurVal >> (i*8)) & 0xff);
Akira Hatanaka44220ca2011-09-30 21:23:45 +0000300 }
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000301}
Akira Hatanaka44220ca2011-09-30 21:23:45 +0000302
David Majnemerce108422016-01-19 23:05:27 +0000303Optional<MCFixupKind> MipsAsmBackend::getFixupKind(StringRef Name) const {
304 return StringSwitch<Optional<MCFixupKind>>(Name)
305 .Case("R_MIPS_NONE", (MCFixupKind)Mips::fixup_Mips_NONE)
306 .Case("R_MIPS_32", FK_Data_4)
Simon Atanasyan3a44bcf2018-06-01 16:37:42 +0000307 .Case("R_MIPS_GOT_PAGE", (MCFixupKind)Mips::fixup_Mips_GOT_PAGE)
308 .Case("R_MIPS_CALL_HI16", (MCFixupKind)Mips::fixup_Mips_CALL_HI16)
309 .Case("R_MIPS_CALL_LO16", (MCFixupKind)Mips::fixup_Mips_CALL_LO16)
310 .Case("R_MIPS_CALL16", (MCFixupKind)Mips::fixup_Mips_CALL16)
311 .Case("R_MIPS_GOT16", (MCFixupKind)Mips::fixup_Mips_GOT)
312 .Case("R_MIPS_GOT_PAGE", (MCFixupKind)Mips::fixup_Mips_GOT_PAGE)
313 .Case("R_MIPS_GOT_OFST", (MCFixupKind)Mips::fixup_Mips_GOT_OFST)
314 .Case("R_MIPS_GOT_DISP", (MCFixupKind)Mips::fixup_Mips_GOT_DISP)
315 .Case("R_MIPS_GOT_HI16", (MCFixupKind)Mips::fixup_Mips_GOT_HI16)
316 .Case("R_MIPS_GOT_LO16", (MCFixupKind)Mips::fixup_Mips_GOT_LO16)
317 .Case("R_MIPS_TLS_GOTTPREL", (MCFixupKind)Mips::fixup_Mips_GOTTPREL)
318 .Case("R_MIPS_TLS_DTPREL_HI16", (MCFixupKind)Mips::fixup_Mips_DTPREL_HI)
319 .Case("R_MIPS_TLS_DTPREL_LO16", (MCFixupKind)Mips::fixup_Mips_DTPREL_LO)
320 .Case("R_MIPS_TLS_GD", (MCFixupKind)Mips::fixup_Mips_TLSGD)
321 .Case("R_MIPS_TLS_LDM", (MCFixupKind)Mips::fixup_Mips_TLSLDM)
322 .Case("R_MIPS_TLS_TPREL_HI16", (MCFixupKind)Mips::fixup_Mips_TPREL_HI)
323 .Case("R_MIPS_TLS_TPREL_LO16", (MCFixupKind)Mips::fixup_Mips_TPREL_LO)
324 .Case("R_MICROMIPS_CALL16", (MCFixupKind)Mips::fixup_MICROMIPS_CALL16)
325 .Case("R_MICROMIPS_GOT_DISP", (MCFixupKind)Mips::fixup_MICROMIPS_GOT_DISP)
326 .Case("R_MICROMIPS_GOT_PAGE", (MCFixupKind)Mips::fixup_MICROMIPS_GOT_PAGE)
327 .Case("R_MICROMIPS_GOT_OFST", (MCFixupKind)Mips::fixup_MICROMIPS_GOT_OFST)
328 .Case("R_MICROMIPS_GOT16", (MCFixupKind)Mips::fixup_MICROMIPS_GOT16)
329 .Case("R_MICROMIPS_TLS_GOTTPREL",
330 (MCFixupKind)Mips::fixup_MICROMIPS_GOTTPREL)
331 .Case("R_MICROMIPS_TLS_DTPREL_HI16",
332 (MCFixupKind)Mips::fixup_MICROMIPS_TLS_DTPREL_HI16)
333 .Case("R_MICROMIPS_TLS_DTPREL_LO16",
334 (MCFixupKind)Mips::fixup_MICROMIPS_TLS_DTPREL_LO16)
335 .Case("R_MICROMIPS_TLS_GD", (MCFixupKind)Mips::fixup_MICROMIPS_TLS_GD)
336 .Case("R_MICROMIPS_TLS_LDM", (MCFixupKind)Mips::fixup_MICROMIPS_TLS_LDM)
337 .Case("R_MICROMIPS_TLS_TPREL_HI16",
338 (MCFixupKind)Mips::fixup_MICROMIPS_TLS_TPREL_HI16)
339 .Case("R_MICROMIPS_TLS_TPREL_LO16",
340 (MCFixupKind)Mips::fixup_MICROMIPS_TLS_TPREL_LO16)
David Majnemerce108422016-01-19 23:05:27 +0000341 .Default(MCAsmBackend::getFixupKind(Name));
Daniel Sanders9f6ad492015-11-12 13:33:00 +0000342}
343
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000344const MCFixupKindInfo &MipsAsmBackend::
345getFixupKindInfo(MCFixupKind Kind) const {
Alexander Richardsone8059b12018-03-27 10:08:12 +0000346 const static MCFixupKindInfo LittleEndianInfos[] = {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000347 // This table *must* be in same the order of fixup_* kinds in
348 // MipsFixupKinds.h.
349 //
350 // name offset bits flags
Daniel Sanders9f6ad492015-11-12 13:33:00 +0000351 { "fixup_Mips_NONE", 0, 0, 0 },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000352 { "fixup_Mips_16", 0, 16, 0 },
353 { "fixup_Mips_32", 0, 32, 0 },
354 { "fixup_Mips_REL32", 0, 32, 0 },
355 { "fixup_Mips_26", 0, 26, 0 },
356 { "fixup_Mips_HI16", 0, 16, 0 },
357 { "fixup_Mips_LO16", 0, 16, 0 },
358 { "fixup_Mips_GPREL16", 0, 16, 0 },
359 { "fixup_Mips_LITERAL", 0, 16, 0 },
Daniel Sandersfe98b2f2016-05-03 13:35:44 +0000360 { "fixup_Mips_GOT", 0, 16, 0 },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000361 { "fixup_Mips_PC16", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
362 { "fixup_Mips_CALL16", 0, 16, 0 },
363 { "fixup_Mips_GPREL32", 0, 32, 0 },
364 { "fixup_Mips_SHIFT5", 6, 5, 0 },
365 { "fixup_Mips_SHIFT6", 6, 5, 0 },
366 { "fixup_Mips_64", 0, 64, 0 },
367 { "fixup_Mips_TLSGD", 0, 16, 0 },
368 { "fixup_Mips_GOTTPREL", 0, 16, 0 },
369 { "fixup_Mips_TPREL_HI", 0, 16, 0 },
370 { "fixup_Mips_TPREL_LO", 0, 16, 0 },
371 { "fixup_Mips_TLSLDM", 0, 16, 0 },
372 { "fixup_Mips_DTPREL_HI", 0, 16, 0 },
373 { "fixup_Mips_DTPREL_LO", 0, 16, 0 },
374 { "fixup_Mips_Branch_PCRel", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
375 { "fixup_Mips_GPOFF_HI", 0, 16, 0 },
Simon Atanasyana1d69f92018-05-29 11:33:54 +0000376 { "fixup_MICROMIPS_GPOFF_HI",0, 16, 0 },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000377 { "fixup_Mips_GPOFF_LO", 0, 16, 0 },
Simon Atanasyana1d69f92018-05-29 11:33:54 +0000378 { "fixup_MICROMIPS_GPOFF_LO",0, 16, 0 },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000379 { "fixup_Mips_GOT_PAGE", 0, 16, 0 },
380 { "fixup_Mips_GOT_OFST", 0, 16, 0 },
381 { "fixup_Mips_GOT_DISP", 0, 16, 0 },
382 { "fixup_Mips_HIGHER", 0, 16, 0 },
Simon Atanasyan6be87bc2018-05-29 10:27:44 +0000383 { "fixup_MICROMIPS_HIGHER", 0, 16, 0 },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000384 { "fixup_Mips_HIGHEST", 0, 16, 0 },
Simon Atanasyan6be87bc2018-05-29 10:27:44 +0000385 { "fixup_MICROMIPS_HIGHEST", 0, 16, 0 },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000386 { "fixup_Mips_GOT_HI16", 0, 16, 0 },
387 { "fixup_Mips_GOT_LO16", 0, 16, 0 },
388 { "fixup_Mips_CALL_HI16", 0, 16, 0 },
389 { "fixup_Mips_CALL_LO16", 0, 16, 0 },
Zoran Jovanovica5acdcf2014-06-13 14:26:47 +0000390 { "fixup_Mips_PC18_S3", 0, 18, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +0000391 { "fixup_MIPS_PC19_S2", 0, 19, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic10e06da2014-05-27 12:55:40 +0000392 { "fixup_MIPS_PC21_S2", 0, 21, MCFixupKindInfo::FKF_IsPCRel },
393 { "fixup_MIPS_PC26_S2", 0, 26, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +0000394 { "fixup_MIPS_PCHI16", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
395 { "fixup_MIPS_PCLO16", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000396 { "fixup_MICROMIPS_26_S1", 0, 26, 0 },
397 { "fixup_MICROMIPS_HI16", 0, 16, 0 },
398 { "fixup_MICROMIPS_LO16", 0, 16, 0 },
399 { "fixup_MICROMIPS_GOT16", 0, 16, 0 },
Jozef Kolek9761e962015-01-12 12:03:34 +0000400 { "fixup_MICROMIPS_PC7_S1", 0, 7, MCFixupKindInfo::FKF_IsPCRel },
Jozef Kolek5cfebdd2015-01-21 12:39:30 +0000401 { "fixup_MICROMIPS_PC10_S1", 0, 10, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000402 { "fixup_MICROMIPS_PC16_S1", 0, 16, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic02b70032016-04-21 13:43:26 +0000403 { "fixup_MICROMIPS_PC26_S1", 0, 26, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic6764fa72016-04-21 14:09:35 +0000404 { "fixup_MICROMIPS_PC19_S2", 0, 19, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic8e366822016-04-22 10:15:12 +0000405 { "fixup_MICROMIPS_PC18_S3", 0, 18, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic5f94ced2016-05-19 12:20:40 +0000406 { "fixup_MICROMIPS_PC21_S1", 0, 21, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000407 { "fixup_MICROMIPS_CALL16", 0, 16, 0 },
408 { "fixup_MICROMIPS_GOT_DISP", 0, 16, 0 },
409 { "fixup_MICROMIPS_GOT_PAGE", 0, 16, 0 },
410 { "fixup_MICROMIPS_GOT_OFST", 0, 16, 0 },
411 { "fixup_MICROMIPS_TLS_GD", 0, 16, 0 },
412 { "fixup_MICROMIPS_TLS_LDM", 0, 16, 0 },
413 { "fixup_MICROMIPS_TLS_DTPREL_HI16", 0, 16, 0 },
414 { "fixup_MICROMIPS_TLS_DTPREL_LO16", 0, 16, 0 },
Simon Atanasyan3979f432017-04-30 04:27:23 +0000415 { "fixup_MICROMIPS_GOTTPREL", 0, 16, 0 },
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000416 { "fixup_MICROMIPS_TLS_TPREL_HI16", 0, 16, 0 },
Daniel Sanders3feeb9c2016-08-08 11:50:25 +0000417 { "fixup_MICROMIPS_TLS_TPREL_LO16", 0, 16, 0 },
418 { "fixup_Mips_SUB", 0, 64, 0 },
419 { "fixup_MICROMIPS_SUB", 0, 64, 0 }
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000420 };
Alexander Richardsone8059b12018-03-27 10:08:12 +0000421 static_assert(array_lengthof(LittleEndianInfos) == Mips::NumTargetFixupKinds,
422 "Not all MIPS little endian fixup kinds added!");
Akira Hatanaka44220ca2011-09-30 21:23:45 +0000423
Alexander Richardsone8059b12018-03-27 10:08:12 +0000424 const static MCFixupKindInfo BigEndianInfos[] = {
Daniel Sanders683ed962014-05-23 13:35:24 +0000425 // This table *must* be in same the order of fixup_* kinds in
426 // MipsFixupKinds.h.
427 //
428 // name offset bits flags
Daniel Sanders9f6ad492015-11-12 13:33:00 +0000429 { "fixup_Mips_NONE", 0, 0, 0 },
Daniel Sanders683ed962014-05-23 13:35:24 +0000430 { "fixup_Mips_16", 16, 16, 0 },
431 { "fixup_Mips_32", 0, 32, 0 },
432 { "fixup_Mips_REL32", 0, 32, 0 },
433 { "fixup_Mips_26", 6, 26, 0 },
434 { "fixup_Mips_HI16", 16, 16, 0 },
435 { "fixup_Mips_LO16", 16, 16, 0 },
436 { "fixup_Mips_GPREL16", 16, 16, 0 },
437 { "fixup_Mips_LITERAL", 16, 16, 0 },
Daniel Sandersfe98b2f2016-05-03 13:35:44 +0000438 { "fixup_Mips_GOT", 16, 16, 0 },
Daniel Sanders683ed962014-05-23 13:35:24 +0000439 { "fixup_Mips_PC16", 16, 16, MCFixupKindInfo::FKF_IsPCRel },
440 { "fixup_Mips_CALL16", 16, 16, 0 },
441 { "fixup_Mips_GPREL32", 0, 32, 0 },
442 { "fixup_Mips_SHIFT5", 21, 5, 0 },
443 { "fixup_Mips_SHIFT6", 21, 5, 0 },
444 { "fixup_Mips_64", 0, 64, 0 },
445 { "fixup_Mips_TLSGD", 16, 16, 0 },
446 { "fixup_Mips_GOTTPREL", 16, 16, 0 },
447 { "fixup_Mips_TPREL_HI", 16, 16, 0 },
448 { "fixup_Mips_TPREL_LO", 16, 16, 0 },
449 { "fixup_Mips_TLSLDM", 16, 16, 0 },
450 { "fixup_Mips_DTPREL_HI", 16, 16, 0 },
451 { "fixup_Mips_DTPREL_LO", 16, 16, 0 },
452 { "fixup_Mips_Branch_PCRel",16, 16, MCFixupKindInfo::FKF_IsPCRel },
453 { "fixup_Mips_GPOFF_HI", 16, 16, 0 },
Simon Atanasyana1d69f92018-05-29 11:33:54 +0000454 { "fixup_MICROMIPS_GPOFF_HI", 16, 16, 0 },
Daniel Sanders683ed962014-05-23 13:35:24 +0000455 { "fixup_Mips_GPOFF_LO", 16, 16, 0 },
Simon Atanasyana1d69f92018-05-29 11:33:54 +0000456 { "fixup_MICROMIPS_GPOFF_LO", 16, 16, 0 },
Daniel Sanders683ed962014-05-23 13:35:24 +0000457 { "fixup_Mips_GOT_PAGE", 16, 16, 0 },
458 { "fixup_Mips_GOT_OFST", 16, 16, 0 },
459 { "fixup_Mips_GOT_DISP", 16, 16, 0 },
460 { "fixup_Mips_HIGHER", 16, 16, 0 },
Simon Atanasyan6be87bc2018-05-29 10:27:44 +0000461 { "fixup_MICROMIPS_HIGHER", 16, 16, 0 },
Daniel Sanders683ed962014-05-23 13:35:24 +0000462 { "fixup_Mips_HIGHEST", 16, 16, 0 },
Simon Atanasyan6be87bc2018-05-29 10:27:44 +0000463 { "fixup_MICROMIPS_HIGHEST",16, 16, 0 },
Daniel Sanders683ed962014-05-23 13:35:24 +0000464 { "fixup_Mips_GOT_HI16", 16, 16, 0 },
465 { "fixup_Mips_GOT_LO16", 16, 16, 0 },
466 { "fixup_Mips_CALL_HI16", 16, 16, 0 },
467 { "fixup_Mips_CALL_LO16", 16, 16, 0 },
Zoran Jovanovica5acdcf2014-06-13 14:26:47 +0000468 { "fixup_Mips_PC18_S3", 14, 18, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovicb9c07f32014-06-12 12:40:00 +0000469 { "fixup_MIPS_PC19_S2", 13, 19, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic10e06da2014-05-27 12:55:40 +0000470 { "fixup_MIPS_PC21_S2", 11, 21, MCFixupKindInfo::FKF_IsPCRel },
471 { "fixup_MIPS_PC26_S2", 6, 26, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovicb355e8f2014-05-27 14:58:51 +0000472 { "fixup_MIPS_PCHI16", 16, 16, MCFixupKindInfo::FKF_IsPCRel },
473 { "fixup_MIPS_PCLO16", 16, 16, MCFixupKindInfo::FKF_IsPCRel },
Daniel Sanders683ed962014-05-23 13:35:24 +0000474 { "fixup_MICROMIPS_26_S1", 6, 26, 0 },
475 { "fixup_MICROMIPS_HI16", 16, 16, 0 },
476 { "fixup_MICROMIPS_LO16", 16, 16, 0 },
477 { "fixup_MICROMIPS_GOT16", 16, 16, 0 },
Jozef Kolek9761e962015-01-12 12:03:34 +0000478 { "fixup_MICROMIPS_PC7_S1", 9, 7, MCFixupKindInfo::FKF_IsPCRel },
Jozef Kolek5cfebdd2015-01-21 12:39:30 +0000479 { "fixup_MICROMIPS_PC10_S1", 6, 10, MCFixupKindInfo::FKF_IsPCRel },
Daniel Sanders683ed962014-05-23 13:35:24 +0000480 { "fixup_MICROMIPS_PC16_S1",16, 16, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic02b70032016-04-21 13:43:26 +0000481 { "fixup_MICROMIPS_PC26_S1", 6, 26, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic6764fa72016-04-21 14:09:35 +0000482 { "fixup_MICROMIPS_PC19_S2",13, 19, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic8e366822016-04-22 10:15:12 +0000483 { "fixup_MICROMIPS_PC18_S3",14, 18, MCFixupKindInfo::FKF_IsPCRel },
Zoran Jovanovic5f94ced2016-05-19 12:20:40 +0000484 { "fixup_MICROMIPS_PC21_S1",11, 21, MCFixupKindInfo::FKF_IsPCRel },
Daniel Sanders683ed962014-05-23 13:35:24 +0000485 { "fixup_MICROMIPS_CALL16", 16, 16, 0 },
486 { "fixup_MICROMIPS_GOT_DISP", 16, 16, 0 },
487 { "fixup_MICROMIPS_GOT_PAGE", 16, 16, 0 },
488 { "fixup_MICROMIPS_GOT_OFST", 16, 16, 0 },
489 { "fixup_MICROMIPS_TLS_GD", 16, 16, 0 },
490 { "fixup_MICROMIPS_TLS_LDM", 16, 16, 0 },
491 { "fixup_MICROMIPS_TLS_DTPREL_HI16", 16, 16, 0 },
492 { "fixup_MICROMIPS_TLS_DTPREL_LO16", 16, 16, 0 },
Simon Atanasyan3979f432017-04-30 04:27:23 +0000493 { "fixup_MICROMIPS_GOTTPREL", 16, 16, 0 },
Daniel Sanders683ed962014-05-23 13:35:24 +0000494 { "fixup_MICROMIPS_TLS_TPREL_HI16", 16, 16, 0 },
Daniel Sanders3feeb9c2016-08-08 11:50:25 +0000495 { "fixup_MICROMIPS_TLS_TPREL_LO16", 16, 16, 0 },
496 { "fixup_Mips_SUB", 0, 64, 0 },
497 { "fixup_MICROMIPS_SUB", 0, 64, 0 }
Daniel Sanders683ed962014-05-23 13:35:24 +0000498 };
Alexander Richardsone8059b12018-03-27 10:08:12 +0000499 static_assert(array_lengthof(BigEndianInfos) == Mips::NumTargetFixupKinds,
500 "Not all MIPS big endian fixup kinds added!");
Daniel Sanders683ed962014-05-23 13:35:24 +0000501
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000502 if (Kind < FirstTargetFixupKind)
503 return MCAsmBackend::getFixupKindInfo(Kind);
Akira Hatanaka44220ca2011-09-30 21:23:45 +0000504
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000505 assert(unsigned(Kind - FirstTargetFixupKind) < getNumFixupKinds() &&
506 "Invalid kind!");
Daniel Sanders683ed962014-05-23 13:35:24 +0000507
Peter Collingbourne571a3302018-05-21 17:57:19 +0000508 if (Endian == support::little)
Daniel Sanders683ed962014-05-23 13:35:24 +0000509 return LittleEndianInfos[Kind - FirstTargetFixupKind];
510 return BigEndianInfos[Kind - FirstTargetFixupKind];
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000511}
Jim Grosbach25b63fa2011-12-06 00:47:03 +0000512
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000513/// WriteNopData - Write an (optimal) nop sequence of Count bytes
514/// to the given output. If the target cannot generate such a sequence,
515/// it should return an error.
516///
517/// \return - True on success.
Peter Collingbourne571a3302018-05-21 17:57:19 +0000518bool MipsAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count) const {
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000519 // Check for a less than instruction size number of bytes
520 // FIXME: 16 bit instructions are not handled yet here.
521 // We shouldn't be using a hard coded number for instruction size.
Joerg Sonnenbergerf148a6d2014-10-02 13:41:42 +0000522
523 // If the count is not 4-byte aligned, we must be writing data into the text
524 // section (otherwise we have unaligned instructions, and thus have far
525 // bigger problems), so just write zeros instead.
Peter Collingbourne571a3302018-05-21 17:57:19 +0000526 OS.write_zeros(Count);
Zoran Jovanovicada38ef2014-03-27 12:38:40 +0000527 return true;
528}
Simon Atanasyan117665582017-09-21 10:44:26 +0000529
Simon Atanasyan3a44bcf2018-06-01 16:37:42 +0000530bool MipsAsmBackend::shouldForceRelocation(const MCAssembler &Asm,
531 const MCFixup &Fixup,
532 const MCValue &Target) {
533 const unsigned FixupKind = Fixup.getKind();
534 switch (FixupKind) {
535 default:
536 return false;
537 // All these relocations require special processing
538 // at linking time. Delegate this work to a linker.
539 case Mips::fixup_Mips_CALL_HI16:
540 case Mips::fixup_Mips_CALL_LO16:
541 case Mips::fixup_Mips_CALL16:
542 case Mips::fixup_Mips_GOT:
543 case Mips::fixup_Mips_GOT_PAGE:
544 case Mips::fixup_Mips_GOT_OFST:
545 case Mips::fixup_Mips_GOT_DISP:
546 case Mips::fixup_Mips_GOT_HI16:
547 case Mips::fixup_Mips_GOT_LO16:
548 case Mips::fixup_Mips_GOTTPREL:
549 case Mips::fixup_Mips_DTPREL_HI:
550 case Mips::fixup_Mips_DTPREL_LO:
551 case Mips::fixup_Mips_TLSGD:
552 case Mips::fixup_Mips_TLSLDM:
553 case Mips::fixup_Mips_TPREL_HI:
554 case Mips::fixup_Mips_TPREL_LO:
555 case Mips::fixup_MICROMIPS_CALL16:
556 case Mips::fixup_MICROMIPS_GOT_DISP:
557 case Mips::fixup_MICROMIPS_GOT_PAGE:
558 case Mips::fixup_MICROMIPS_GOT_OFST:
559 case Mips::fixup_MICROMIPS_GOT16:
560 case Mips::fixup_MICROMIPS_GOTTPREL:
561 case Mips::fixup_MICROMIPS_TLS_DTPREL_HI16:
562 case Mips::fixup_MICROMIPS_TLS_DTPREL_LO16:
563 case Mips::fixup_MICROMIPS_TLS_GD:
564 case Mips::fixup_MICROMIPS_TLS_LDM:
565 case Mips::fixup_MICROMIPS_TLS_TPREL_HI16:
566 case Mips::fixup_MICROMIPS_TLS_TPREL_LO16:
567 return true;
568 }
569}
570
Simon Atanasyan117665582017-09-21 10:44:26 +0000571MCAsmBackend *llvm::createMipsAsmBackend(const Target &T,
Alex Bradburyb22f7512018-01-03 08:53:05 +0000572 const MCSubtargetInfo &STI,
Simon Atanasyan117665582017-09-21 10:44:26 +0000573 const MCRegisterInfo &MRI,
Simon Atanasyan117665582017-09-21 10:44:26 +0000574 const MCTargetOptions &Options) {
Alex Bradburyb22f7512018-01-03 08:53:05 +0000575 return new MipsAsmBackend(T, MRI, STI.getTargetTriple(), STI.getCPU(),
576 Options.ABIName == "n32");
Simon Atanasyan117665582017-09-21 10:44:26 +0000577}