LLVM 24.0.0git
MipsMCCodeEmitter.cpp
Go to the documentation of this file.
1//===-- MipsMCCodeEmitter.cpp - Convert Mips Code to Machine Code ---------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the MipsMCCodeEmitter class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "MipsMCCodeEmitter.h"
18#include "llvm/ADT/APFloat.h"
19#include "llvm/ADT/APInt.h"
21#include "llvm/MC/MCContext.h"
22#include "llvm/MC/MCExpr.h"
23#include "llvm/MC/MCFixup.h"
24#include "llvm/MC/MCInst.h"
26#include "llvm/MC/MCInstrDesc.h"
27#include "llvm/MC/MCInstrInfo.h"
30#include "llvm/MC/MCValue.h"
34#include <cassert>
35#include <cstdint>
36
37using namespace llvm;
38
39#define DEBUG_TYPE "mccodeemitter"
40
41#define GET_INSTRMAP_INFO
42#include "MipsGenInstrInfo.inc"
43#undef GET_INSTRMAP_INFO
44
45namespace llvm {
46
48 MCContext &Ctx) {
49 return new MipsMCCodeEmitter(MCII, Ctx, false);
50}
51
53 MCContext &Ctx) {
54 return new MipsMCCodeEmitter(MCII, Ctx, true);
55}
56
57} // end namespace llvm
58
82
83// If the D<shift> instruction has a shift amount that is greater
84// than 31 (checked in calling routine), lower it to a D<shift>32 instruction
85static void LowerLargeShift(MCInst& Inst) {
86 assert(Inst.getNumOperands() == 3 && "Invalid no. of operands for shift!");
87 assert(Inst.getOperand(2).isImm());
88
89 int64_t Shift = Inst.getOperand(2).getImm();
90 if (Shift <= 31)
91 return; // Do nothing
92 Shift -= 32;
93
94 // saminus32
95 Inst.getOperand(2).setImm(Shift);
96
97 switch (Inst.getOpcode()) {
98 default:
99 // Calling function is not synchronized
100 llvm_unreachable("Unexpected shift instruction");
101 case Mips::DSLL:
102 Inst.setOpcode(Mips::DSLL32);
103 return;
104 case Mips::DSRL:
105 Inst.setOpcode(Mips::DSRL32);
106 return;
107 case Mips::DSRA:
108 Inst.setOpcode(Mips::DSRA32);
109 return;
110 case Mips::DROTR:
111 Inst.setOpcode(Mips::DROTR32);
112 return;
113 }
114}
115
116// Fix a bad compact branch encoding for beqc/bnec.
117void MipsMCCodeEmitter::LowerCompactBranch(MCInst& Inst) const {
118 // Encoding may be illegal !(rs < rt), but this situation is
119 // easily fixed.
120 MCRegister RegOp0 = Inst.getOperand(0).getReg();
121 MCRegister RegOp1 = Inst.getOperand(1).getReg();
122
123 unsigned Reg0 = Ctx.getRegisterInfo()->getEncodingValue(RegOp0);
124 unsigned Reg1 = Ctx.getRegisterInfo()->getEncodingValue(RegOp1);
125
126 if (Inst.getOpcode() == Mips::BNEC || Inst.getOpcode() == Mips::BEQC ||
127 Inst.getOpcode() == Mips::BNEC64 || Inst.getOpcode() == Mips::BEQC64) {
128 assert(Reg0 != Reg1 && "Instruction has bad operands ($rs == $rt)!");
129 if (Reg0 < Reg1)
130 return;
131 } else if (Inst.getOpcode() == Mips::BNVC || Inst.getOpcode() == Mips::BOVC) {
132 if (Reg0 >= Reg1)
133 return;
134 } else if (Inst.getOpcode() == Mips::BNVC_MMR6 ||
135 Inst.getOpcode() == Mips::BOVC_MMR6) {
136 if (Reg1 >= Reg0)
137 return;
138 } else
139 llvm_unreachable("Cannot rewrite unknown branch!");
140
141 Inst.getOperand(0).setReg(RegOp1);
142 Inst.getOperand(1).setReg(RegOp0);
143}
144
145bool MipsMCCodeEmitter::isMicroMips(const MCSubtargetInfo &STI) const {
146 return STI.hasFeature(Mips::FeatureMicroMips);
147}
148
149bool MipsMCCodeEmitter::isMips32r6(const MCSubtargetInfo &STI) const {
150 return STI.hasFeature(Mips::FeatureMips32r6);
151}
152
153bool MipsMCCodeEmitter::isNanoMips(const MCSubtargetInfo &STI) const {
154 return STI.hasFeature(Mips::FeatureNanoMips);
155}
156
157void MipsMCCodeEmitter::EmitByte(unsigned char C, raw_ostream &OS) const {
158 OS << (char)C;
159}
160
161/// encodeInstruction - Emit the instruction.
162/// Size the instruction with Desc.getSize().
166 const MCSubtargetInfo &STI) const {
167 if (MI.getOpcode() == Mips::PseudoGOTLoadGlobal ||
168 MI.getOpcode() == Mips::PseudoGOTLoadLocal) {
169 expandGOTLoad(MI, CB, Fixups, STI);
170 return;
171 }
172
173 // Non-pseudo instructions that get changed for direct object
174 // only based on operand values.
175 // If this list of instructions get much longer we will move
176 // the check to a function call. Until then, this is more efficient.
177 MCInst TmpInst = MI;
178 switch (MI.getOpcode()) {
179 // If shift amount is >= 32 it the inst needs to be lowered further
180 case Mips::DSLL:
181 case Mips::DSRL:
182 case Mips::DSRA:
183 case Mips::DROTR:
184 LowerLargeShift(TmpInst);
185 break;
186 // Compact branches, enforce encoding restrictions.
187 case Mips::BEQC:
188 case Mips::BNEC:
189 case Mips::BEQC64:
190 case Mips::BNEC64:
191 case Mips::BOVC:
192 case Mips::BOVC_MMR6:
193 case Mips::BNVC:
194 case Mips::BNVC_MMR6:
195 LowerCompactBranch(TmpInst);
196 }
197
198 size_t N = Fixups.size();
199 uint64_t Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI);
200
201 // Check for unimplemented opcodes.
202 // Unfortunately in MIPS both NOP and SLL will come in with Binary == 0
203 // so we have to special check for them.
204 const unsigned Opcode = TmpInst.getOpcode();
205 if ((Opcode != Mips::NOP) && (Opcode != Mips::SLL) &&
206 (Opcode != Mips::SLL_MM) && (Opcode != Mips::SLL_MMR6) && !Binary)
207 llvm_unreachable("unimplemented opcode in encodeInstruction()");
208
209 int NewOpcode = -1;
210 if (isMicroMips(STI)) {
211 if (isMips32r6(STI)) {
212 NewOpcode = Mips::MipsR62MicroMipsR6(Opcode, Mips::Arch_micromipsr6);
213 if (NewOpcode == -1)
214 NewOpcode = Mips::Std2MicroMipsR6(Opcode, Mips::Arch_micromipsr6);
215 }
216 else
217 NewOpcode = Mips::Std2MicroMips(Opcode, Mips::Arch_micromips);
218
219 // Check whether it is Dsp instruction.
220 if (NewOpcode == -1)
221 NewOpcode = Mips::Dsp2MicroMips(Opcode, Mips::Arch_mmdsp);
222
223 if (NewOpcode != -1) {
224 if (Fixups.size() > N)
225 Fixups.pop_back();
226
227 TmpInst.setOpcode (NewOpcode);
228 Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI);
229 }
230
231 if (((MI.getOpcode() == Mips::MOVEP_MM) ||
232 (MI.getOpcode() == Mips::MOVEP_MMR6))) {
233 unsigned RegPair = getMovePRegPairOpValue(MI, 0, Fixups, STI);
234 Binary = (Binary & 0xFFFFFC7F) | (RegPair << 7);
235 }
236 }
237
238 const MCInstrDesc &Desc = MCII.get(TmpInst.getOpcode());
239
240 // Get byte count of instruction
241 unsigned Size = Desc.getSize();
242 if (!Size)
243 llvm_unreachable("Desc.getSize() returns 0");
244
245 auto Endian =
247 if (Size == 2) {
249 } else if (IsLittleEndian && Size == 4 &&
250 (isMicroMips(STI) || isNanoMips(STI))) {
251 support::endian::write<uint16_t>(CB, Binary >> 16, Endian);
252 support::endian::write<uint16_t>(CB, Binary & 0xffff, Endian);
253 } else if (IsLittleEndian && Size == 6 && isNanoMips(STI)) {
254 support::endian::write<uint16_t>(CB, Binary >> 32, Endian);
255 support::endian::write<uint16_t>(CB, Binary >> 16, Endian);
256 support::endian::write<uint16_t>(CB, Binary & 0xffff, Endian);
257 } else {
259 }
260}
261
262/// Expand PseudoGOTLoadGlobal and PseudoGOTLoadLocal into the sequence that
263/// MipsAsmParser::loadAndAddSymbolAddress emits when the binding of the
264/// symbol is already known:
265///
266/// Global: lw $rd, %got(sym)($gp)
267/// >addiu $rd, $rd, offset
268/// Global call: lw $25, %call16(sym)($gp)
269/// Local (O32): lw $rd, %got(sym+offset)($gp)
270/// addiu $rd, $rd, %lo(sym+offset)
271/// Local (N32/N64): ld $rd, %got_disp(sym)($gp)
272/// >daddiu $rd, $rd, offset
273void MipsMCCodeEmitter::expandGOTLoad(const MCInst &MI,
276 const MCSubtargetInfo &STI) const {
277 MCRegister DstReg = MI.getOperand(0).getReg();
278 MCRegister GPReg = MI.getOperand(1).getReg();
279 const MCExpr *SymExpr = MI.getOperand(2).getExpr();
280 unsigned Flags = MI.getOperand(3).getImm();
281 bool IsLocal = MI.getOpcode() == Mips::PseudoGOTLoadLocal;
282 bool IsPtr64 = Flags & MipsII::GOTLoad_Ptr64;
283 unsigned LoadOpc = IsPtr64 ? Mips::LD : Mips::LW;
284 unsigned AddiuOpc = IsPtr64 ? Mips::DADDiu : Mips::ADDiu;
285
286 MCValue Res;
287 [[maybe_unused]] bool Ok = SymExpr->evaluateAsRelocatable(Res, nullptr);
288 assert(Ok && Res.getAddSym() && !Res.getSubSym() &&
289 "expected a symbol plus an optional constant");
290 const MCExpr *Sym = MCSymbolRefExpr::create(Res.getAddSym(), Ctx);
291 int64_t Offset = Res.getConstant();
292
294 auto AddInst = [&](unsigned Opc, MCRegister Rd, MCRegister Rs,
295 const MCExpr *Expr) {
296 Insts.push_back(MCInstBuilder(Opc).addReg(Rd).addReg(Rs).addExpr(Expr));
297 };
298 auto AddOffset = [&]() {
299 if (Offset != 0)
300 AddInst(AddiuOpc, DstReg, DstReg, MCConstantExpr::create(Offset, Ctx));
301 };
302
303 if (!IsLocal && (Flags & MipsII::GOTLoad_Call)) {
304 assert(Offset == 0 && "unexpected offset for a call");
305 AddInst(LoadOpc, DstReg, GPReg,
307 } else if (!IsLocal) {
308 AddInst(LoadOpc, DstReg, GPReg,
310 AddOffset();
311 } else if (Flags & MipsII::GOTLoad_NewABI) {
312 AddInst(LoadOpc, DstReg, GPReg,
314 AddOffset();
315 } else {
316 AddInst(LoadOpc, DstReg, GPReg,
317 MCSpecifierExpr::create(SymExpr, Mips::S_GOT, Ctx));
318 AddInst(AddiuOpc, DstReg, DstReg,
319 MCSpecifierExpr::create(SymExpr, Mips::S_LO, Ctx));
320 }
321
322 // Fixup offsets are relative to the start of the instruction being encoded,
323 // so rebase the fixups of each expanded instruction onto the pseudo.
324 size_t Start = CB.size();
325 for (const MCInst &Inst : Insts) {
326 size_t InstOffset = CB.size() - Start;
327 size_t N = Fixups.size();
328 encodeInstruction(Inst, CB, Fixups, STI);
329 for (size_t I = N, E = Fixups.size(); I != E; ++I)
330 Fixups[I].setOffset(Fixups[I].getOffset() + InstOffset);
331 }
332}
333
334/// getBranchTargetOpValue - Return binary encoding of the branch
335/// target operand. If the machine operand requires relocation,
336/// record the relocation and return zero.
338getBranchTargetOpValue(const MCInst &MI, unsigned OpNo,
340 const MCSubtargetInfo &STI) const {
341 const MCOperand &MO = MI.getOperand(OpNo);
342
343 // If the destination is an immediate, divide by 4.
344 if (MO.isImm()) return MO.getImm() >> 2;
345
346 assert(MO.isExpr() &&
347 "getBranchTargetOpValue expects only expressions or immediates");
348
349 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
350 MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
351 addFixup(Fixups, 0, FixupExpression, Mips::fixup_Mips_PC16);
352 return 0;
353}
354
355/// getBranchTargetOpValue1SImm16 - Return binary encoding of the branch
356/// target operand. If the machine operand requires relocation,
357/// record the relocation and return zero.
359getBranchTargetOpValue1SImm16(const MCInst &MI, unsigned OpNo,
361 const MCSubtargetInfo &STI) const {
362 const MCOperand &MO = MI.getOperand(OpNo);
363
364 // If the destination is an immediate, divide by 2.
365 if (MO.isImm()) return MO.getImm() >> 1;
366
367 assert(MO.isExpr() &&
368 "getBranchTargetOpValue expects only expressions or immediates");
369
370 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
371 MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
372 addFixup(Fixups, 0, FixupExpression, Mips::fixup_Mips_PC16);
373 return 0;
374}
375
376/// getBranchTargetOpValueMMR6 - Return binary encoding of the branch
377/// target operand. If the machine operand requires relocation,
378/// record the relocation and return zero.
380getBranchTargetOpValueMMR6(const MCInst &MI, unsigned OpNo,
382 const MCSubtargetInfo &STI) const {
383 const MCOperand &MO = MI.getOperand(OpNo);
384
385 // If the destination is an immediate, divide by 2.
386 if (MO.isImm())
387 return MO.getImm() >> 1;
388
389 assert(MO.isExpr() &&
390 "getBranchTargetOpValueMMR6 expects only expressions or immediates");
391
392 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
393 MO.getExpr(), MCConstantExpr::create(-2, Ctx), Ctx);
394 addFixup(Fixups, 0, FixupExpression, Mips::fixup_Mips_PC16);
395 return 0;
396}
397
398/// getBranchTargetOpValueLsl2MMR6 - Return binary encoding of the branch
399/// target operand. If the machine operand requires relocation,
400/// record the relocation and return zero.
402getBranchTargetOpValueLsl2MMR6(const MCInst &MI, unsigned OpNo,
404 const MCSubtargetInfo &STI) const {
405 const MCOperand &MO = MI.getOperand(OpNo);
406
407 // If the destination is an immediate, divide by 4.
408 if (MO.isImm())
409 return MO.getImm() >> 2;
410
411 assert(MO.isExpr() &&
412 "getBranchTargetOpValueLsl2MMR6 expects only expressions or immediates");
413
414 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
415 MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
416 addFixup(Fixups, 0, FixupExpression, Mips::fixup_Mips_PC16);
417 return 0;
418}
419
420/// getBranchTarget7OpValueMM - Return binary encoding of the microMIPS branch
421/// target operand. If the machine operand requires relocation,
422/// record the relocation and return zero.
424getBranchTarget7OpValueMM(const MCInst &MI, unsigned OpNo,
426 const MCSubtargetInfo &STI) const {
427 const MCOperand &MO = MI.getOperand(OpNo);
428
429 // If the destination is an immediate, divide by 2.
430 if (MO.isImm()) return MO.getImm() >> 1;
431
432 assert(MO.isExpr() &&
433 "getBranchTargetOpValueMM expects only expressions or immediates");
434
435 const MCExpr *Expr = MO.getExpr();
436 addFixup(Fixups, 0, Expr, Mips::fixup_MICROMIPS_PC7_S1);
437 return 0;
438}
439
440/// getBranchTargetOpValueMMPC10 - Return binary encoding of the microMIPS
441/// 10-bit branch target operand. If the machine operand requires relocation,
442/// record the relocation and return zero.
444getBranchTargetOpValueMMPC10(const MCInst &MI, unsigned OpNo,
446 const MCSubtargetInfo &STI) const {
447 const MCOperand &MO = MI.getOperand(OpNo);
448
449 // If the destination is an immediate, divide by 2.
450 if (MO.isImm()) return MO.getImm() >> 1;
451
452 assert(MO.isExpr() &&
453 "getBranchTargetOpValuePC10 expects only expressions or immediates");
454
455 const MCExpr *Expr = MO.getExpr();
456 addFixup(Fixups, 0, Expr, Mips::fixup_MICROMIPS_PC10_S1);
457 return 0;
458}
459
460/// getBranchTargetOpValue - Return binary encoding of the microMIPS branch
461/// target operand. If the machine operand requires relocation,
462/// record the relocation and return zero.
464getBranchTargetOpValueMM(const MCInst &MI, unsigned OpNo,
466 const MCSubtargetInfo &STI) const {
467 const MCOperand &MO = MI.getOperand(OpNo);
468
469 // If the destination is an immediate, divide by 2.
470 if (MO.isImm()) return MO.getImm() >> 1;
471
472 assert(MO.isExpr() &&
473 "getBranchTargetOpValueMM expects only expressions or immediates");
474
475 const MCExpr *Expr = MO.getExpr();
476 addFixup(Fixups, 0, Expr, Mips::fixup_MICROMIPS_PC16_S1);
477 return 0;
478}
479
480/// getBranchTarget21OpValue - Return binary encoding of the branch
481/// target operand. If the machine operand requires relocation,
482/// record the relocation and return zero.
484getBranchTarget21OpValue(const MCInst &MI, unsigned OpNo,
486 const MCSubtargetInfo &STI) const {
487 const MCOperand &MO = MI.getOperand(OpNo);
488
489 // If the destination is an immediate, divide by 4.
490 if (MO.isImm()) return MO.getImm() >> 2;
491
492 assert(MO.isExpr() &&
493 "getBranchTarget21OpValue expects only expressions or immediates");
494
495 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
496 MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
497 addFixup(Fixups, 0, FixupExpression, Mips::fixup_MIPS_PC21_S2);
498 return 0;
499}
500
501/// getBranchTarget21OpValueMM - Return binary encoding of the branch
502/// target operand for microMIPS. If the machine operand requires
503/// relocation, record the relocation and return zero.
505getBranchTarget21OpValueMM(const MCInst &MI, unsigned OpNo,
507 const MCSubtargetInfo &STI) const {
508 const MCOperand &MO = MI.getOperand(OpNo);
509
510 // If the destination is an immediate, divide by 4.
511 if (MO.isImm()) return MO.getImm() >> 2;
512
513 assert(MO.isExpr() &&
514 "getBranchTarget21OpValueMM expects only expressions or immediates");
515
516 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
517 MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
518 addFixup(Fixups, 0, FixupExpression, Mips::fixup_MICROMIPS_PC21_S1);
519 return 0;
520}
521
522/// getBranchTarget26OpValue - Return binary encoding of the branch
523/// target operand. If the machine operand requires relocation,
524/// record the relocation and return zero.
526getBranchTarget26OpValue(const MCInst &MI, unsigned OpNo,
528 const MCSubtargetInfo &STI) const {
529 const MCOperand &MO = MI.getOperand(OpNo);
530
531 // If the destination is an immediate, divide by 4.
532 if (MO.isImm()) return MO.getImm() >> 2;
533
534 assert(MO.isExpr() &&
535 "getBranchTarget26OpValue expects only expressions or immediates");
536
537 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
538 MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
539 addFixup(Fixups, 0, FixupExpression, Mips::fixup_MIPS_PC26_S2);
540 return 0;
541}
542
543/// getBranchTarget26OpValueMM - Return binary encoding of the branch
544/// target operand. If the machine operand requires relocation,
545/// record the relocation and return zero.
547 const MCInst &MI, unsigned OpNo, SmallVectorImpl<MCFixup> &Fixups,
548 const MCSubtargetInfo &STI) const {
549 const MCOperand &MO = MI.getOperand(OpNo);
550
551 // If the destination is an immediate, divide by 2.
552 if (MO.isImm())
553 return MO.getImm() >> 1;
554
555 assert(MO.isExpr() &&
556 "getBranchTarget26OpValueMM expects only expressions or immediates");
557
558 const MCExpr *FixupExpression = MCBinaryExpr::createAdd(
559 MO.getExpr(), MCConstantExpr::create(-4, Ctx), Ctx);
560 addFixup(Fixups, 0, FixupExpression, Mips::fixup_MICROMIPS_PC26_S1);
561 return 0;
562}
563
564/// getJumpOffset16OpValue - Return binary encoding of the jump
565/// target operand. If the machine operand requires relocation,
566/// record the relocation and return zero.
568getJumpOffset16OpValue(const MCInst &MI, unsigned OpNo,
570 const MCSubtargetInfo &STI) const {
571 const MCOperand &MO = MI.getOperand(OpNo);
572
573 if (MO.isImm()) return MO.getImm();
574
575 assert(MO.isExpr() &&
576 "getJumpOffset16OpValue expects only expressions or an immediate");
577
578 const MCExpr *Expr = MO.getExpr();
581 addFixup(Fixups, 0, Expr, MCFixupKind(FixupKind));
582 return 0;
583}
584
585/// getJumpTargetOpValue - Return binary encoding of the jump
586/// target operand. If the machine operand requires relocation,
587/// record the relocation and return zero.
589getJumpTargetOpValue(const MCInst &MI, unsigned OpNo,
591 const MCSubtargetInfo &STI) const {
592 const MCOperand &MO = MI.getOperand(OpNo);
593 // If the destination is an immediate, divide by 4.
594 if (MO.isImm()) return MO.getImm()>>2;
595
596 assert(MO.isExpr() &&
597 "getJumpTargetOpValue expects only expressions or an immediate");
598
599 const MCExpr *Expr = MO.getExpr();
600 addFixup(Fixups, 0, Expr, Mips::fixup_Mips_26);
601 return 0;
602}
603
605getJumpTargetOpValueMM(const MCInst &MI, unsigned OpNo,
607 const MCSubtargetInfo &STI) const {
608 const MCOperand &MO = MI.getOperand(OpNo);
609 // If the destination is an immediate, divide by 2.
610 if (MO.isImm()) return MO.getImm() >> 1;
611
612 assert(MO.isExpr() &&
613 "getJumpTargetOpValueMM expects only expressions or an immediate");
614
615 const MCExpr *Expr = MO.getExpr();
616 addFixup(Fixups, 0, Expr, Mips::fixup_MICROMIPS_26_S1);
617 return 0;
618}
619
621getUImm5Lsl2Encoding(const MCInst &MI, unsigned OpNo,
623 const MCSubtargetInfo &STI) const {
624 const MCOperand &MO = MI.getOperand(OpNo);
625 if (MO.isImm()) {
626 // The immediate is encoded as 'immediate << 2'.
627 unsigned Res = getMachineOpValue(MI, MO, Fixups, STI);
628 assert((Res & 3) == 0);
629 return Res >> 2;
630 }
631
632 assert(MO.isExpr() &&
633 "getUImm5Lsl2Encoding expects only expressions or an immediate");
634
635 return 0;
636}
637
639getSImm3Lsa2Value(const MCInst &MI, unsigned OpNo,
641 const MCSubtargetInfo &STI) const {
642 const MCOperand &MO = MI.getOperand(OpNo);
643 if (MO.isImm()) {
644 int Value = MO.getImm();
645 return Value >> 2;
646 }
647
648 return 0;
649}
650
652getUImm6Lsl2Encoding(const MCInst &MI, unsigned OpNo,
654 const MCSubtargetInfo &STI) const {
655 const MCOperand &MO = MI.getOperand(OpNo);
656 if (MO.isImm()) {
657 unsigned Value = MO.getImm();
658 return Value >> 2;
659 }
660
661 return 0;
662}
663
665getSImm9AddiuspValue(const MCInst &MI, unsigned OpNo,
667 const MCSubtargetInfo &STI) const {
668 const MCOperand &MO = MI.getOperand(OpNo);
669 if (MO.isImm()) {
670 unsigned Binary = (MO.getImm() >> 2) & 0x0000ffff;
671 return (((Binary & 0x8000) >> 7) | (Binary & 0x00ff));
672 }
673
674 return 0;
675}
676
679 const MCSubtargetInfo &STI) const {
680 MCExpr::ExprKind Kind = Expr->getKind();
681 if (Kind == MCExpr::Specifier) {
682 const auto *MipsExpr = cast<MCSpecifierExpr>(Expr);
683
685 switch (MipsExpr->getSpecifier()) {
686 case Mips::S_None:
687 case Mips::S_Special:
688 llvm_unreachable("Unhandled fixup kind!");
689 break;
690 case Mips::S_DTPREL:
691 // MEK_DTPREL is used for marking TLS DIEExpr only
692 // and contains a regular sub-expression.
693 return getExprOpValue(MipsExpr->getSubExpr(), Fixups, STI);
696 break;
699 break;
703 break;
707 break;
708 case Mips::S_GOTTPREL:
709 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOTTPREL
711 break;
712 case Mips::S_GOT:
713 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT16
715 break;
716 case Mips::S_GOT_CALL:
717 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_CALL16
719 break;
720 case Mips::S_GOT_DISP:
721 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_DISP
723 break;
724 case Mips::S_GOT_HI16:
726 break;
727 case Mips::S_GOT_LO16:
729 break;
730 case Mips::S_GOT_PAGE:
731 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_PAGE
733 break;
734 case Mips::S_GOT_OFST:
735 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GOT_OFST
737 break;
738 case Mips::S_GPREL:
740 break;
741 case Mips::S_LO:
742 // Check for %lo(%neg(%gp_rel(X)))
743 if (Mips::isGpOff(*MipsExpr))
744 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GPOFF_LO
746 else
747 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_LO16
749 break;
750 case Mips::S_HIGHEST:
751 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HIGHEST
753 break;
754 case Mips::S_HIGHER:
755 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HIGHER
757 break;
758 case Mips::S_HI:
759 // Check for %hi(%neg(%gp_rel(X)))
760 if (Mips::isGpOff(*MipsExpr))
761 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_GPOFF_HI
763 else
764 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_HI16
766 break;
769 break;
772 break;
773 case Mips::S_TLSGD:
774 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_GD
776 break;
777 case Mips::S_TLSLDM:
778 FixupKind = isMicroMips(STI) ? Mips::fixup_MICROMIPS_TLS_LDM
780 break;
781 case Mips::S_TPREL_HI:
784 break;
785 case Mips::S_TPREL_LO:
788 break;
789 case Mips::S_NEG:
790 FixupKind =
792 break;
793 }
794 addFixup(Fixups, 0, MipsExpr, MCFixupKind(FixupKind));
795 return 0;
796 }
797
798 Ctx.reportError(Expr->getLoc(), "expected an immediate");
799 return 0;
800}
801
802/// getMachineOpValue - Return binary encoding of operand. If the machine
803/// operand requires relocation, record the relocation and return zero.
805getMachineOpValue(const MCInst &MI, const MCOperand &MO,
807 const MCSubtargetInfo &STI) const {
808 if (MO.isReg()) {
809 MCRegister Reg = MO.getReg();
810 unsigned RegNo = Ctx.getRegisterInfo()->getEncodingValue(Reg);
811 return RegNo;
812 } else if (MO.isImm()) {
813 return static_cast<unsigned>(MO.getImm());
814 } else if (MO.isDFPImm()) {
815 return static_cast<unsigned>(bit_cast<double>(MO.getDFPImm()));
816 }
817 // TODO: Set EncoderMethod to "getImmOpValue" for imm Operand so that
818 // getMachineOpValue will not be called for isExpr code paths.
819 assert(MO.isExpr());
820 return getImmOpValue(MI, MO, Fixups, STI);
821}
822
825 const MCSubtargetInfo &STI) const {
826 if (MO.isImm())
827 return MO.getImm();
828 assert(MO.isExpr() && "getImmOpValue expects only expressions or immediates");
829 const MCExpr *Expr = MO.getExpr();
830 int64_t Res;
831 if (Expr->evaluateAsAbsolute(Res))
832 return Res;
833 unsigned MIFrm = MipsII::getFormat(MCII.get(MI.getOpcode()).TSFlags);
834 if (!isa<MCSpecifierExpr>(Expr) && MIFrm == MipsII::FrmI) {
835 addFixup(Fixups, 0, Expr, Mips::fixup_Mips_AnyImm16);
836 return 0;
837 }
838 return getExprOpValue(Expr, Fixups, STI);
839}
840
841template <unsigned Shift>
842unsigned
845 const MCSubtargetInfo &STI) const {
846 return getMachineOpValue(MI, MI.getOperand(OpNo), Fixups, STI) >> Shift;
847}
848
849template <unsigned FromEnd, unsigned Shift>
850unsigned
853 const MCSubtargetInfo &STI) const {
854 return getScaledImmOpValue<Shift>(MI, MI.getNumOperands() - FromEnd, Fixups,
855 STI);
856}
857
858// FIXME: should be called getMSBEncoding
859//
860unsigned
863 const MCSubtargetInfo &STI) const {
864 assert(MI.getOperand(OpNo-1).isImm());
865 assert(MI.getOperand(OpNo).isImm());
866 unsigned Position = getMachineOpValue(MI, MI.getOperand(OpNo-1), Fixups, STI);
867 unsigned Size = getMachineOpValue(MI, MI.getOperand(OpNo), Fixups, STI);
868
869 return Position + Size - 1;
870}
871
872template <unsigned Bits, int Offset>
873unsigned
876 const MCSubtargetInfo &STI) const {
877 assert(MI.getOperand(OpNo).isImm());
878 unsigned Value = getMachineOpValue(MI, MI.getOperand(OpNo), Fixups, STI);
879 Value -= Offset;
880 return Value;
881}
882
883unsigned
886 const MCSubtargetInfo &STI) const {
887 const MCOperand &MO = MI.getOperand(OpNo);
888 if (MO.isImm()) {
889 // The immediate is encoded as 'immediate << 2'.
890 unsigned Res = getMachineOpValue(MI, MO, Fixups, STI);
891 assert((Res & 3) == 0);
892 return Res >> 2;
893 }
894
895 assert(MO.isExpr() &&
896 "getSimm19Lsl2Encoding expects only expressions or an immediate");
897
898 const MCExpr *Expr = MO.getExpr();
901 addFixup(Fixups, 0, Expr, MCFixupKind(FixupKind));
902 return 0;
903}
904
905unsigned
908 const MCSubtargetInfo &STI) const {
909 const MCOperand &MO = MI.getOperand(OpNo);
910 if (MO.isImm()) {
911 // The immediate is encoded as 'immediate << 3'.
912 unsigned Res = getMachineOpValue(MI, MI.getOperand(OpNo), Fixups, STI);
913 assert((Res & 7) == 0);
914 return Res >> 3;
915 }
916
917 assert(MO.isExpr() &&
918 "getSimm18Lsl2Encoding expects only expressions or an immediate");
919
920 const MCExpr *Expr = MO.getExpr();
923 addFixup(Fixups, 0, Expr, MCFixupKind(FixupKind));
924 return 0;
925}
926
927unsigned
930 const MCSubtargetInfo &STI) const {
931 assert(MI.getOperand(OpNo).isImm());
932 const MCOperand &MO = MI.getOperand(OpNo);
933 return MO.getImm() % 8;
934}
935
936unsigned
939 const MCSubtargetInfo &STI) const {
940 assert(MI.getOperand(OpNo).isImm());
941 const MCOperand &MO = MI.getOperand(OpNo);
942 unsigned Value = MO.getImm();
943 switch (Value) {
944 case 128: return 0x0;
945 case 1: return 0x1;
946 case 2: return 0x2;
947 case 3: return 0x3;
948 case 4: return 0x4;
949 case 7: return 0x5;
950 case 8: return 0x6;
951 case 15: return 0x7;
952 case 16: return 0x8;
953 case 31: return 0x9;
954 case 32: return 0xa;
955 case 63: return 0xb;
956 case 64: return 0xc;
957 case 255: return 0xd;
958 case 32768: return 0xe;
959 case 65535: return 0xf;
960 }
961 llvm_unreachable("Unexpected value");
962}
963
964unsigned
967 const MCSubtargetInfo &STI) const {
968 unsigned res = 0;
969
970 // Register list operand is always first operand of instruction and it is
971 // placed before memory operand (register + imm).
972
973 for (unsigned I = OpNo, E = MI.getNumOperands() - 2; I < E; ++I) {
974 MCRegister Reg = MI.getOperand(I).getReg();
975 unsigned RegNo = Ctx.getRegisterInfo()->getEncodingValue(Reg);
976 if (RegNo != 31)
977 res++;
978 else
979 res |= 0x10;
980 }
981 return res;
982}
983
984unsigned
987 const MCSubtargetInfo &STI) const {
988 return (MI.getNumOperands() - 4);
989}
990
991unsigned
994 const MCSubtargetInfo &STI) const {
995 unsigned res = 0;
996
997 if (MI.getOperand(0).getReg() == Mips::R5 &&
998 MI.getOperand(1).getReg() == Mips::R6)
999 res = 0;
1000 else if (MI.getOperand(0).getReg() == Mips::R5 &&
1001 MI.getOperand(1).getReg() == Mips::R7)
1002 res = 1;
1003 else if (MI.getOperand(0).getReg() == Mips::R6 &&
1004 MI.getOperand(1).getReg() == Mips::R7)
1005 res = 2;
1006 else if (MI.getOperand(0).getReg() == Mips::R4 &&
1007 MI.getOperand(1).getReg() == Mips::R21)
1008 res = 3;
1009 else if (MI.getOperand(0).getReg() == Mips::R4 &&
1010 MI.getOperand(1).getReg() == Mips::R22)
1011 res = 4;
1012 else if (MI.getOperand(0).getReg() == Mips::R4 &&
1013 MI.getOperand(1).getReg() == Mips::R5)
1014 res = 5;
1015 else if (MI.getOperand(0).getReg() == Mips::R4 &&
1016 MI.getOperand(1).getReg() == Mips::R6)
1017 res = 6;
1018 else if (MI.getOperand(0).getReg() == Mips::R4 &&
1019 MI.getOperand(1).getReg() == Mips::R7)
1020 res = 7;
1021
1022 return res;
1023}
1024
1025unsigned
1028 const MCSubtargetInfo &STI) const {
1029 assert(((OpNo == 2) || (OpNo == 3)) &&
1030 "Unexpected OpNo for movep operand encoding!");
1031
1032 MCOperand Op = MI.getOperand(OpNo);
1033 assert(Op.isReg() && "Operand of movep is not a register!");
1034 switch (Op.getReg().id()) {
1035 default:
1036 llvm_unreachable("Unknown register for movep!");
1037 case Mips::R0:
1038 return 0;
1039 case Mips::R17:
1040 return 1;
1041 case Mips::R2:
1042 return 2;
1043 case Mips::R3:
1044 return 3;
1045 case Mips::R16:
1046 return 4;
1047 case Mips::R18:
1048 return 5;
1049 case Mips::R19:
1050 return 6;
1051 case Mips::R20:
1052 return 7;
1053 }
1054}
1055
1056unsigned
1059 const MCSubtargetInfo &STI) const {
1060 const MCOperand &MO = MI.getOperand(OpNo);
1061 assert(MO.isImm() && "getSimm23Lsl2Encoding expects only an immediate");
1062 // The immediate is encoded as 'immediate >> 2'.
1063 unsigned Res = static_cast<unsigned>(MO.getImm());
1064 assert((Res & 3) == 0);
1065 return Res >> 2;
1066}
1067
1068#include "MipsGenMCCodeEmitter.inc"
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
static void LowerLargeShift(MCInst &Inst)
This file defines the SmallVector class.
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:342
MCCodeEmitter - Generic instruction encoding interface.
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition MCExpr.cpp:212
Context object for machine code objects.
Definition MCContext.h:84
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
LLVM_ABI bool evaluateAsRelocatable(MCValue &Res, const MCAssembler *Asm) const
Try to evaluate the expression to a relocatable value, i.e.
Definition MCExpr.cpp:450
@ Specifier
Expression with a relocation specifier.
Definition MCExpr.h:45
ExprKind getKind() const
Definition MCExpr.h:85
SMLoc getLoc() const
Definition MCExpr.h:86
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
Definition MCFixup.h:90
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
unsigned getNumOperands() const
Definition MCInst.h:212
unsigned getOpcode() const
Definition MCInst.h:202
void setOpcode(unsigned Op)
Definition MCInst.h:201
const MCOperand & getOperand(unsigned i) const
Definition MCInst.h:210
Describe properties that are true of each instruction in the target description file.
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
void setImm(int64_t Val)
Definition MCInst.h:89
int64_t getImm() const
Definition MCInst.h:84
bool isImm() const
Definition MCInst.h:66
void setReg(MCRegister Reg)
Set the register number.
Definition MCInst.h:79
bool isReg() const
Definition MCInst.h:65
MCRegister getReg() const
Returns the register number.
Definition MCInst.h:73
bool isDFPImm() const
Definition MCInst.h:68
const MCExpr * getExpr() const
Definition MCInst.h:118
uint64_t getDFPImm() const
Definition MCInst.h:104
bool isExpr() const
Definition MCInst.h:69
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.cpp:743
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
const MCSymbol * getAddSym() const
Definition MCValue.h:49
int64_t getConstant() const
Definition MCValue.h:44
const MCSymbol * getSubSym() const
Definition MCValue.h:51
unsigned getBranchTargetOpValueLsl2MMR6(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTargetOpValueLsl2MMR6 - Return binary encoding of the branch target operand.
unsigned getSimm23Lsl2Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getBranchTarget21OpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTarget21OpValue - Return binary encoding of the branch target operand.
uint64_t getBinaryCodeForInstr(const MCInst &MI, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getSimm19Lsl2Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getJumpTargetOpValueMM(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getMachineOpValue(const MCInst &MI, const MCOperand &MO, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getMachineOpValue - Return binary encoding of operand.
unsigned getUImmWithOffsetEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
Subtract Offset then encode as a N-bit unsigned integer.
unsigned getOperandFromEndValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getSizeInsEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getScaledImmOpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getMovePRegPairOpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getBranchTargetOpValueMMR6(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTargetOpValueMMR6 - Return binary encoding of the branch target operand.
unsigned getBranchTargetOpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTargetOpValue - Return binary encoding of the branch target operand.
unsigned getRegisterListOpValue16(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getBranchTarget26OpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTarget26OpValue - Return binary encoding of the branch target operand.
unsigned getBranchTarget26OpValueMM(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTarget26OpValueMM - Return binary encoding of the branch target operand.
unsigned getImmOpValue(const MCInst &MI, const MCOperand &MO, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getBranchTargetOpValue1SImm16(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTargetOpValue1SImm16 - Return binary encoding of the branch target operand.
unsigned getSimm18Lsl3Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getSImm3Lsa2Value(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getJumpOffset16OpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getJumpOffset16OpValue - Return binary encoding of the jump target operand.
unsigned getBranchTargetOpValueMMPC10(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTargetOpValueMMPC10 - Return binary encoding of the microMIPS 10-bit branch target operand.
unsigned getJumpTargetOpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getJumpTargetOpValue - Return binary encoding of the jump target operand.
unsigned getUImm4AndValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getRegisterListOpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getUImm5Lsl2Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getExprOpValue(const MCExpr *Expr, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getBranchTargetOpValueMM(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTargetOpValue - Return binary encoding of the microMIPS branch target operand.
unsigned getMovePRegSingleOpValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getSImm9AddiuspValue(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
void encodeInstruction(const MCInst &MI, SmallVectorImpl< char > &CB, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const override
encodeInstruction - Emit the instruction.
unsigned getUImm3Mod8Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getBranchTarget21OpValueMM(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTarget21OpValueMM - Return binary encoding of the branch target operand for microMIPS.
unsigned getBranchTarget7OpValueMM(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getBranchTarget7OpValueMM - Return binary encoding of the microMIPS branch target operand.
unsigned getUImm6Lsl2Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
void EmitByte(unsigned char C, raw_ostream &OS) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static unsigned getFormat(uint64_t TSFlags)
@ fixup_MICROMIPS_TLS_TPREL_LO16
@ fixup_MICROMIPS_TLS_TPREL_HI16
@ fixup_MICROMIPS_TLS_DTPREL_HI16
@ fixup_MICROMIPS_TLS_DTPREL_LO16
@ fixup_Mips_Branch_PCRel
bool isGpOff(const MCSpecifierExpr &E)
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
Definition Endian.h:82
This is an optimization pass for GlobalISel generic memory operations.
MCCodeEmitter * createMipsMCCodeEmitterEL(const MCInstrInfo &MCII, MCContext &Ctx)
MCCodeEmitter * createMipsMCCodeEmitterEB(const MCInstrInfo &MCII, MCContext &Ctx)
@ Offset
Definition DWP.cpp:577
Op::Description Desc
static Error getOffset(const SymbolRef &Sym, SectionRef Sec, uint64_t &Result)
uint16_t MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition MCFixup.h:22
static Lanai::Fixups FixupKind(const MCExpr *Expr)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind)
To bit_cast(const From &from) noexcept
Definition bit.h:90
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
#define N