LLVM 22.0.0git
PPCMCCodeEmitter.cpp
Go to the documentation of this file.
1//===-- PPCMCCodeEmitter.cpp - Convert PPC 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 PPCMCCodeEmitter class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "PPCMCCodeEmitter.h"
15#include "PPCMCAsmInfo.h"
16#include "PPCMCTargetDesc.h"
18#include "llvm/ADT/Statistic.h"
19#include "llvm/MC/MCExpr.h"
20#include "llvm/MC/MCFixup.h"
21#include "llvm/MC/MCInstrDesc.h"
27#include <cassert>
28#include <cstdint>
29
30using namespace llvm;
31
32#define DEBUG_TYPE "mccodeemitter"
33
34STATISTIC(MCNumEmitted, "Number of MC instructions emitted");
35
37 MCContext &Ctx) {
38 return new PPCMCCodeEmitter(MCII, Ctx);
39}
40
42 const MCExpr *Value, uint16_t Kind) {
43 bool PCRel = false;
44 switch (Kind) {
49 PCRel = true;
50 }
51 Fixups.push_back(MCFixup::create(Offset, Value, Kind, PCRel));
52}
53
55getDirectBrEncoding(const MCInst &MI, unsigned OpNo,
57 const MCSubtargetInfo &STI) const {
58 const MCOperand &MO = MI.getOperand(OpNo);
59
60 if (MO.isReg() || MO.isImm())
61 return getMachineOpValue(MI, MO, Fixups, STI);
62
63 // Add a fixup for the branch target.
65 Fixups, 0, MO.getExpr(),
67 return 0;
68}
69
70/// Check if Opcode corresponds to a call instruction that should be marked
71/// with the NOTOC relocation.
73 unsigned Opcode = MI.getOpcode();
74 if (!MCII.get(Opcode).isCall())
75 return false;
76
77 switch (Opcode) {
78 default:
79#ifndef NDEBUG
80 llvm_unreachable("Unknown call opcode");
81#endif
82 return false;
83 case PPC::BL8_NOTOC:
84 case PPC::BL8_NOTOC_TLS:
85 case PPC::BL8_NOTOC_RM:
86 return true;
87#ifndef NDEBUG
88 case PPC::BL8:
89 case PPC::BL:
90 case PPC::BL8_TLS:
91 case PPC::BL_TLS:
92 case PPC::BLA8:
93 case PPC::BLA:
94 case PPC::BCCL:
95 case PPC::BCCLA:
96 case PPC::BCL:
97 case PPC::BCLn:
98 case PPC::BL8_NOP:
99 case PPC::BL_NOP:
100 case PPC::BL8_NOP_TLS:
101 case PPC::BLA8_NOP:
102 case PPC::BCTRL8:
103 case PPC::BCTRL:
104 case PPC::BCCCTRL8:
105 case PPC::BCCCTRL:
106 case PPC::BCCTRL8:
107 case PPC::BCCTRL:
108 case PPC::BCCTRL8n:
109 case PPC::BCCTRLn:
110 case PPC::BL8_RM:
111 case PPC::BLA8_RM:
112 case PPC::BL8_NOP_RM:
113 case PPC::BLA8_NOP_RM:
114 case PPC::BCTRL8_RM:
115 case PPC::BCTRL8_LDinto_toc:
116 case PPC::BCTRL8_LDinto_toc_RM:
117 case PPC::BL8_TLS_:
118 case PPC::TCRETURNdi8:
119 case PPC::TCRETURNai8:
120 case PPC::TCRETURNri8:
121 case PPC::TAILBCTR8:
122 case PPC::TAILB8:
123 case PPC::TAILBA8:
124 case PPC::BCLalways:
125 case PPC::BLRL:
126 case PPC::BCCLRL:
127 case PPC::BCLRL:
128 case PPC::BCLRLn:
129 case PPC::BDZL:
130 case PPC::BDNZL:
131 case PPC::BDZLA:
132 case PPC::BDNZLA:
133 case PPC::BDZLp:
134 case PPC::BDNZLp:
135 case PPC::BDZLAp:
136 case PPC::BDNZLAp:
137 case PPC::BDZLm:
138 case PPC::BDNZLm:
139 case PPC::BDZLAm:
140 case PPC::BDNZLAm:
141 case PPC::BDZLRL:
142 case PPC::BDNZLRL:
143 case PPC::BDZLRLp:
144 case PPC::BDNZLRLp:
145 case PPC::BDZLRLm:
146 case PPC::BDNZLRLm:
147 case PPC::BL_RM:
148 case PPC::BLA_RM:
149 case PPC::BL_NOP_RM:
150 case PPC::BCTRL_RM:
151 case PPC::TCRETURNdi:
152 case PPC::TCRETURNai:
153 case PPC::TCRETURNri:
154 case PPC::BCTRL_LWZinto_toc:
155 case PPC::BCTRL_LWZinto_toc_RM:
156 case PPC::TAILBCTR:
157 case PPC::TAILB:
158 case PPC::TAILBA:
159 return false;
160#endif
161 }
162}
163
164unsigned PPCMCCodeEmitter::getCondBrEncoding(const MCInst &MI, unsigned OpNo,
166 const MCSubtargetInfo &STI) const {
167 const MCOperand &MO = MI.getOperand(OpNo);
168 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
169
170 // Add a fixup for the branch target.
171 addFixup(Fixups, 0, MO.getExpr(), PPC::fixup_ppc_brcond14);
172 return 0;
173}
174
176getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo,
178 const MCSubtargetInfo &STI) const {
179 const MCOperand &MO = MI.getOperand(OpNo);
180 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
181
182 // Add a fixup for the branch target.
183 addFixup(Fixups, 0, MO.getExpr(), PPC::fixup_ppc_br24abs);
184 return 0;
185}
186
188getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo,
190 const MCSubtargetInfo &STI) const {
191 const MCOperand &MO = MI.getOperand(OpNo);
192 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
193
194 // Add a fixup for the branch target.
196 return 0;
197}
198
199unsigned
202 const MCSubtargetInfo &STI) const {
203 assert(MI.getOperand(OpNo).isReg() && "Operand should be a register");
204 unsigned RegBits = getMachineOpValue(MI, MI.getOperand(OpNo), Fixups, STI)
205 << 1;
206 return RegBits;
207}
208
209template <MCFixupKind Fixup>
212 const MCSubtargetInfo &STI) const {
213 const MCOperand &MO = MI.getOperand(OpNo);
214 assert(!MO.isReg() && "Not expecting a register for this operand.");
215 if (MO.isImm())
216 return getMachineOpValue(MI, MO, Fixups, STI);
217
218 uint32_t Offset = 0;
220 Offset = IsLittleEndian ? 0 : 2;
221
222 // Add a fixup for the immediate field.
223 addFixup(Fixups, Offset, MO.getExpr(), Fixup);
224 return 0;
225}
226
227unsigned PPCMCCodeEmitter::getDispRIEncoding(const MCInst &MI, unsigned OpNo,
229 const MCSubtargetInfo &STI) const {
230 const MCOperand &MO = MI.getOperand(OpNo);
231 if (MO.isImm())
232 return getMachineOpValue(MI, MO, Fixups, STI) & 0xFFFF;
233
234 // Add a fixup for the displacement field.
235 addFixup(Fixups, IsLittleEndian ? 0 : 2, MO.getExpr(), PPC::fixup_ppc_half16);
236 return 0;
237}
238
239unsigned
242 const MCSubtargetInfo &STI) const {
243 const MCOperand &MO = MI.getOperand(OpNo);
244 if (MO.isImm())
245 return ((getMachineOpValue(MI, MO, Fixups, STI) >> 2) & 0x3FFF);
246
247 // Add a fixup for the displacement field.
248 addFixup(Fixups, IsLittleEndian ? 0 : 2, MO.getExpr(),
250 return 0;
251}
252
253unsigned
256 const MCSubtargetInfo &STI) const {
257 const MCOperand &MO = MI.getOperand(OpNo);
258 if (MO.isImm()) {
259 assert(!(MO.getImm() % 16) &&
260 "Expecting an immediate that is a multiple of 16");
261 return ((getMachineOpValue(MI, MO, Fixups, STI) >> 4) & 0xFFF);
262 }
263
264 // Otherwise add a fixup for the displacement field.
265 addFixup(Fixups, IsLittleEndian ? 0 : 2, MO.getExpr(),
267 return 0;
268}
269
270unsigned
273 const MCSubtargetInfo &STI) const {
274 // Encode imm for the hash load/store to stack for the ROP Protection
275 // instructions.
276 const MCOperand &MO = MI.getOperand(OpNo);
277
278 assert(MO.isImm() && "Expecting an immediate operand.");
279 assert(!(MO.getImm() % 8) && "Expecting offset to be 8 byte aligned.");
280
281 unsigned DX = (MO.getImm() >> 3) & 0x3F;
282 return DX;
283}
284
288 const MCSubtargetInfo &STI) const {
289 // Encode the displacement part of pc-relative memri34, which is an imm34.
290 // The 34 bit immediate can fall into one of three cases:
291 // 1) It is a relocation to be filled in by the linker represented as:
292 // (MCExpr::SymbolRef)
293 // 2) It is a relocation + SignedOffset represented as:
294 // (MCExpr::Binary(MCExpr::SymbolRef + MCExpr::Constant))
295 // 3) It is a known value at compile time.
296
297 // If this is not a MCExpr then we are in case 3) and we are dealing with
298 // a value known at compile time, not a relocation.
299 const MCOperand &MO = MI.getOperand(OpNo);
300 if (!MO.isExpr())
301 return (getMachineOpValue(MI, MO, Fixups, STI)) & 0x3FFFFFFFFUL;
302
303 // At this point in the function it is known that MO is of type MCExpr.
304 // Therefore we are dealing with either case 1) a symbol ref or
305 // case 2) a symbol ref plus a constant.
306 const MCExpr *Expr = MO.getExpr();
307 switch (Expr->getKind()) {
308 default:
309 llvm_unreachable("Unsupported MCExpr for getMemRI34PCRelEncoding.");
310 case MCExpr::SymbolRef: {
311 // Relocation alone.
312 const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(Expr);
313 (void)SRE;
314 // Currently these are the only valid PCRelative Relocations.
317 SRE->getSpecifier()) &&
318 "specifier must be S_PCREL, S_GOT_PCREL, S_GOT_TLSGD_PCREL, "
319 "S_GOT_TLSLD_PCREL, or S_GOT_TPREL_PCREL");
320 // Generate the fixup for the relocation.
321 addFixup(Fixups, 0, Expr, PPC::fixup_ppc_pcrel34);
322 // Put zero in the location of the immediate. The linker will fill in the
323 // correct value based on the relocation.
324 return 0;
325 }
326 case MCExpr::Binary: {
327 // Relocation plus some offset.
328 const MCBinaryExpr *BE = cast<MCBinaryExpr>(Expr);
330 "Binary expression opcode must be an add.");
331
332 const MCExpr *LHS = BE->getLHS();
333 const MCExpr *RHS = BE->getRHS();
334
335 // Need to check in both directions. Reloc+Offset and Offset+Reloc.
336 if (LHS->getKind() != MCExpr::SymbolRef)
337 std::swap(LHS, RHS);
338
339 if (LHS->getKind() != MCExpr::SymbolRef ||
340 RHS->getKind() != MCExpr::Constant)
341 llvm_unreachable("Expecting to have one constant and one relocation.");
342
343 const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(LHS);
344 (void)SRE;
345 assert(isInt<34>(cast<MCConstantExpr>(RHS)->getValue()) &&
346 "Value must fit in 34 bits.");
347
348 // Currently these are the only valid PCRelative Relocations.
351 "VariantKind must be VK_PCREL or VK_GOT_PCREL");
352 // Generate the fixup for the relocation.
353 addFixup(Fixups, 0, Expr, PPC::fixup_ppc_pcrel34);
354 // Put zero in the location of the immediate. The linker will fill in the
355 // correct value based on the relocation.
356 return 0;
357 }
358 }
359}
360
364 const MCSubtargetInfo &STI) const {
365 // Encode the displacement part of a memri34.
366 const MCOperand &MO = MI.getOperand(OpNo);
367 return (getMachineOpValue(MI, MO, Fixups, STI)) & 0x3FFFFFFFFUL;
368}
369
370unsigned
373 const MCSubtargetInfo &STI) const {
374 // Encode imm as a dispSPE8, which has the low 5-bits of (imm / 8).
375 const MCOperand &MO = MI.getOperand(OpNo);
376 assert(MO.isImm());
377 return getMachineOpValue(MI, MO, Fixups, STI) >> 3;
378}
379
380unsigned
383 const MCSubtargetInfo &STI) const {
384 // Encode imm as a dispSPE8, which has the low 5-bits of (imm / 4).
385 const MCOperand &MO = MI.getOperand(OpNo);
386 assert(MO.isImm());
387 return getMachineOpValue(MI, MO, Fixups, STI) >> 2;
388}
389
390unsigned
393 const MCSubtargetInfo &STI) const {
394 // Encode imm as a dispSPE8, which has the low 5-bits of (imm / 2).
395 const MCOperand &MO = MI.getOperand(OpNo);
396 assert(MO.isImm());
397 return getMachineOpValue(MI, MO, Fixups, STI) >> 1;
398}
399
400unsigned PPCMCCodeEmitter::getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
402 const MCSubtargetInfo &STI) const {
403 const MCOperand &MO = MI.getOperand(OpNo);
404 if (MO.isReg()) return getMachineOpValue(MI, MO, Fixups, STI);
405
406 // Add a fixup for the TLS register, which simply provides a relocation
407 // hint to the linker that this statement is part of a relocation sequence.
408 // Return the thread-pointer register's encoding. Add a one byte displacement
409 // if using PC relative memops.
410 const MCExpr *Expr = MO.getExpr();
411 const MCSymbolRefExpr *SRE = cast<MCSymbolRefExpr>(Expr);
412 bool IsPCRel = getSpecifier(SRE) == PPC::S_TLS_PCREL;
413 addFixup(Fixups, IsPCRel ? 1 : 0, Expr, PPC::fixup_ppc_nofixup);
414 const Triple &TT = STI.getTargetTriple();
415 bool isPPC64 = TT.isPPC64();
416 return CTX.getRegisterInfo()->getEncodingValue(isPPC64 ? PPC::X13 : PPC::R2);
417}
418
419unsigned PPCMCCodeEmitter::getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
421 const MCSubtargetInfo &STI) const {
422 // For special TLS calls, we need two fixups; one for the branch target
423 // (__tls_get_addr), which we create via getDirectBrEncoding as usual,
424 // and one for the TLSGD or TLSLD symbol, which is emitted here.
425 const MCOperand &MO = MI.getOperand(OpNo+1);
426 addFixup(Fixups, 0, MO.getExpr(), PPC::fixup_ppc_nofixup);
427 return getDirectBrEncoding(MI, OpNo, Fixups, STI);
428}
429
431get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
433 const MCSubtargetInfo &STI) const {
434 const MCOperand &MO = MI.getOperand(OpNo);
435 assert((MI.getOpcode() == PPC::MTOCRF || MI.getOpcode() == PPC::MTOCRF8 ||
436 MI.getOpcode() == PPC::MFOCRF || MI.getOpcode() == PPC::MFOCRF8) &&
437 (MO.getReg() >= PPC::CR0 && MO.getReg() <= PPC::CR7));
438 return 0x80 >> CTX.getRegisterInfo()->getEncodingValue(MO.getReg());
439}
440
441// Get the index for this operand in this instruction. This is needed for
442// computing the register number in PPC::getRegNumForOperand() for
443// any instructions that use a different numbering scheme for registers in
444// different operands.
445static unsigned getOpIdxForMO(const MCInst &MI, const MCOperand &MO) {
446 for (unsigned i = 0; i < MI.getNumOperands(); i++) {
447 const MCOperand &Op = MI.getOperand(i);
448 if (&Op == &MO)
449 return i;
450 }
451 llvm_unreachable("This operand is not part of this instruction");
452 return ~0U; // Silence any warnings about no return.
453}
454
456getMachineOpValue(const MCInst &MI, const MCOperand &MO,
458 const MCSubtargetInfo &STI) const {
459 if (MO.isReg()) {
460 // MTOCRF/MFOCRF should go through get_crbitm_encoding for the CR operand.
461 // The GPR operand should come through here though.
462 assert((MI.getOpcode() != PPC::MTOCRF && MI.getOpcode() != PPC::MTOCRF8 &&
463 MI.getOpcode() != PPC::MFOCRF && MI.getOpcode() != PPC::MFOCRF8) ||
464 MO.getReg() < PPC::CR0 || MO.getReg() > PPC::CR7);
465 unsigned OpNo = getOpIdxForMO(MI, MO);
466 MCRegister Reg =
467 PPC::getRegNumForOperand(MCII.get(MI.getOpcode()), MO.getReg(), OpNo);
468 return CTX.getRegisterInfo()->getEncodingValue(Reg);
469 }
470
471 assert(MO.isImm() &&
472 "Relocation required in an instruction that we cannot encode!");
473 return MO.getImm();
474}
475
479 const MCSubtargetInfo &STI) const {
480 uint64_t Bits = getBinaryCodeForInstr(MI, Fixups, STI);
481
482 // Output the constant in big/little endian byte order.
483 unsigned Size = getInstSizeInBytes(MI);
486 switch (Size) {
487 case 0:
488 break;
489 case 4:
491 break;
492 case 8:
493 // If we emit a pair of instructions, the first one is
494 // always in the top 32 bits, even on little-endian.
495 support::endian::write<uint32_t>(CB, Bits >> 32, E);
497 break;
498 default:
499 llvm_unreachable("Invalid instruction size");
500 }
501
502 ++MCNumEmitted; // Keep track of the # of mi's emitted.
503}
504
505// Get the number of bytes used to encode the given MCInst.
507 unsigned Opcode = MI.getOpcode();
508 const MCInstrDesc &Desc = MCII.get(Opcode);
509 return Desc.getSize();
510}
511
513 return MCII.get(MI.getOpcode()).TSFlags & PPCII::Prefixed;
514}
515
516#include "PPCGenMCCodeEmitter.inc"
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
IRTranslator LLVM IR MI
static unsigned getOpIdxForMO(const MCInst &MI, const MCOperand &MO)
PowerPC TLS Dynamic Call Fixup
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:171
Binary assembler expressions.
Definition MCExpr.h:299
const MCExpr * getLHS() const
Get the left-hand side expression of the binary operator.
Definition MCExpr.h:446
const MCExpr * getRHS() const
Get the right-hand side expression of the binary operator.
Definition MCExpr.h:449
Opcode getOpcode() const
Get the kind of this binary expression.
Definition MCExpr.h:443
@ Add
Addition.
Definition MCExpr.h:302
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Definition MCContext.h:83
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
@ Constant
Constant expressions.
Definition MCExpr.h:42
@ SymbolRef
References to labels and assigned expressions.
Definition MCExpr.h:43
@ Binary
Binary expressions.
Definition MCExpr.h:41
ExprKind getKind() const
Definition MCExpr.h:85
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:86
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
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
int64_t getImm() const
Definition MCInst.h:84
bool isImm() const
Definition MCInst.h:66
bool isReg() const
Definition MCInst.h:65
MCRegister getReg() const
Returns the register number.
Definition MCInst.h:73
const MCExpr * getExpr() const
Definition MCInst.h:118
bool isExpr() const
Definition MCInst.h:69
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:33
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
Represent a reference to a symbol from inside an expression.
Definition MCExpr.h:190
uint16_t getSpecifier() const
Definition MCExpr.h:233
unsigned getDispSPE2Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDispRIHashEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getDispRI34Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDirectBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDispRIXEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDispSPE8Encoding(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
Encode the given Inst to bytes and append to CB.
unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
bool isNoTOCCallInstr(const MCInst &MI) const
Check if Opcode corresponds to a call instruction that should be marked with the NOTOC relocation.
unsigned getDispRIX16Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getDispRI34PCRelEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
bool isPrefixedInstruction(const MCInst &MI) const
unsigned getDispSPE4Encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getDispRIEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getMachineOpValue(const MCInst &MI, const MCOperand &MO, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
getMachineOpValue - Return binary encoding of operand.
unsigned getVSRpEvenEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getBinaryCodeForInstr(const MCInst &MI, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
uint64_t getImmEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getInstSizeInBytes(const MCInst &MI) const
unsigned getCondBrEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
LLVM Value Representation.
Definition Value.h:75
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Prefixed
This instruction is prefixed.
MCRegister getRegNumForOperand(const MCInstrDesc &Desc, MCRegister Reg, unsigned OpNo)
getRegNumForOperand - some operands use different numbering schemes for the same registers.
@ fixup_ppc_brcond14abs
14-bit absolute relocation for conditional branches.
@ fixup_ppc_half16
A 16-bit fixup corresponding to lo16(_foo) or ha16(_foo) for instrs like 'li' or 'addis'.
@ fixup_ppc_br24_notoc
@ fixup_ppc_brcond14
14-bit PC relative relocation for conditional branches.
@ fixup_ppc_half16dq
A 16-bit fixup corresponding to lo16(_foo) with implied 3 zero bits for instrs like 'lxv'.
@ fixup_ppc_half16ds
A 14-bit fixup corresponding to lo16(_foo) with implied 2 zero bits for instrs like 'std'.
@ fixup_ppc_nofixup
Not a true fixup, but ties a symbol to a call to __tls_get_addr for the TLS general and local dynamic...
@ fixup_ppc_br24abs
24-bit absolute relocation for direct branches like 'ba' and 'bla'.
@ S_GOT_TLSGD_PCREL
@ S_GOT_TPREL_PCREL
@ S_GOT_TLSLD_PCREL
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
Definition Endian.h:96
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:477
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
Definition MathExtras.h:174
Op::Description Desc
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind)
DWARFExpression::Operation Op
MCCodeEmitter * createPPCMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:560
static uint16_t getSpecifier(const MCSymbolRefExpr *SRE)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1877
endianness
Definition bit.h:71
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Definition BitVector.h:869