34 #define DEBUG_TYPE "mccodeemitter" 36 STATISTIC(MCNumEmitted,
"Number of MC instructions emitted");
37 STATISTIC(MCNumFixups,
"Number of MC fixups created");
41 RISCVMCCodeEmitter(
const RISCVMCCodeEmitter &) =
delete;
42 void operator=(
const RISCVMCCodeEmitter &) =
delete;
48 : Ctx(ctx), MCII(MCII) {}
50 ~RISCVMCCodeEmitter()
override {}
62 uint64_t getBinaryCodeForInstr(
const MCInst &
MI,
72 unsigned getImmOpValueAsr1(
const MCInst &
MI,
unsigned OpNo,
76 unsigned getImmOpValue(
const MCInst &
MI,
unsigned OpNo,
85 return new RISCVMCCodeEmitter(Ctx, MCII);
100 unsigned Ra = (MI.
getOpcode() == RISCV::PseudoTAIL) ? RISCV::X6 : RISCV::X1;
115 Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI);
124 Binary = getBinaryCodeForInstr(TmpInst, Fixups, STI);
135 if (MI.
getOpcode() == RISCV::PseudoCALL ||
137 expandFunctionCall(MI, OS, Fixups, STI);
146 uint16_t
Bits = getBinaryCodeForInstr(MI, Fixups, STI);
161 RISCVMCCodeEmitter::getMachineOpValue(
const MCInst &MI,
const MCOperand &MO,
166 return Ctx.getRegisterInfo()->getEncodingValue(MO.
getReg());
169 return static_cast<unsigned>(MO.
getImm());
176 RISCVMCCodeEmitter::getImmOpValueAsr1(
const MCInst &MI,
unsigned OpNo,
182 unsigned Res = MO.
getImm();
183 assert((Res & 1) == 0 &&
"LSB is non-zero");
187 return getImmOpValue(MI, OpNo, Fixups, STI);
190 unsigned RISCVMCCodeEmitter::getImmOpValue(
const MCInst &MI,
unsigned OpNo,
204 "getImmOpValue expects only expressions or immediates");
209 const RISCVMCExpr *RVExpr = cast<RISCVMCExpr>(Expr);
233 "VK_RISCV_PCREL_LO used with unexpected instruction format");
273 #include "RISCVGenMCCodeEmitter.inc"
This class represents lattice values for constants.
static MCOperand createExpr(const MCExpr *Val)
void push_back(const T &Elt)
Describe properties that are true of each instruction in the target description file.
VariantKind getKind() const
STATISTIC(NumFunctions, "Total number of functions")
static Lanai::Fixups FixupKind(const MCExpr *Expr)
const FeatureBitset & getFeatureBits() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Base class for the full range of assembler expressions which are needed for parsing.
MCCodeEmitter * createRISCVMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
unsigned getReg() const
Returns the register number.
Context object for machine code objects.
const MCExpr * getExpr() const
MCInstBuilder & addOperand(const MCOperand &Op)
Add an operand.
Instances of this class represent a single low-level machine instruction.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
MCInstBuilder & addReg(unsigned Reg)
Add a new register operand.
unsigned const MachineRegisterInfo * MRI
MCCodeEmitter - Generic instruction encoding interface.
Interface to description of machine instruction set.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
const MCOperand & getOperand(unsigned i) const
Generic base class for all target subtargets.
References to labels and assigned expressions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getOpcode() const
Return the opcode number for this descriptor.
This class implements an extremely fast bulk output stream that can only output to a stream...
Target specific expression.
unsigned getOpcode() const
Instances of this class represent operands of the MCInst class.
static const RISCVMCExpr * create(const MCExpr *Expr, VariantKind Kind, MCContext &Ctx)
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...