34#define DEBUG_TYPE "mccodeemitter"
36STATISTIC(MCNumEmitted,
"Number of MC instructions emitted");
46 VEMCCodeEmitter(
const VEMCCodeEmitter &) =
delete;
47 VEMCCodeEmitter &operator=(
const VEMCCodeEmitter &) =
delete;
48 ~VEMCCodeEmitter()
override =
default;
50 void encodeInstruction(
const MCInst &
MI, SmallVectorImpl<char> &CB,
51 SmallVectorImpl<MCFixup> &Fixups,
52 const MCSubtargetInfo &STI)
const override;
56 uint64_t getBinaryCodeForInstr(
const MCInst &
MI,
57 SmallVectorImpl<MCFixup> &Fixups,
58 const MCSubtargetInfo &STI)
const;
62 unsigned getMachineOpValue(
const MCInst &
MI,
const MCOperand &MO,
63 SmallVectorImpl<MCFixup> &Fixups,
64 const MCSubtargetInfo &STI)
const;
67 SmallVectorImpl<MCFixup> &Fixups,
68 const MCSubtargetInfo &STI)
const;
69 uint64_t getCCOpValue(
const MCInst &
MI,
unsigned OpNo,
70 SmallVectorImpl<MCFixup> &Fixups,
71 const MCSubtargetInfo &STI)
const;
72 uint64_t getRDOpValue(
const MCInst &
MI,
unsigned OpNo,
73 SmallVectorImpl<MCFixup> &Fixups,
74 const MCSubtargetInfo &STI)
const;
91void VEMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
95 uint64_t
Bits = getBinaryCodeForInstr(
MI, Fixups, STI);
101unsigned VEMCCodeEmitter::getMachineOpValue(
const MCInst &
MI,
103 SmallVectorImpl<MCFixup> &Fixups,
104 const MCSubtargetInfo &STI)
const {
108 return static_cast<unsigned>(MO.
getImm());
112 const MCExpr *Expr = MO.
getExpr();
120 if (Expr->evaluateAsAbsolute(Res))
128VEMCCodeEmitter::getBranchTargetOpValue(
const MCInst &
MI,
unsigned OpNo,
129 SmallVectorImpl<MCFixup> &Fixups,
130 const MCSubtargetInfo &STI)
const {
131 const MCOperand &MO =
MI.getOperand(OpNo);
133 return getMachineOpValue(
MI, MO, Fixups, STI);
139uint64_t VEMCCodeEmitter::getCCOpValue(
const MCInst &
MI,
unsigned OpNo,
140 SmallVectorImpl<MCFixup> &Fixups,
141 const MCSubtargetInfo &STI)
const {
142 const MCOperand &MO =
MI.getOperand(OpNo);
149uint64_t VEMCCodeEmitter::getRDOpValue(
const MCInst &
MI,
unsigned OpNo,
150 SmallVectorImpl<MCFixup> &Fixups,
151 const MCSubtargetInfo &STI)
const {
152 const MCOperand &MO =
MI.getOperand(OpNo);
155 getMachineOpValue(
MI, MO, Fixups, STI)));
159#include "VEGenMCCodeEmitter.inc"
163 return new VEMCCodeEmitter(MCII, Ctx);
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind, bool PCRel=false)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static uint32_t getBranchTargetOpValue(const MCInst &MI, unsigned OpIdx, unsigned FixupKind, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI)
getBranchTargetOpValue - Helper function to get the branch target operand, which is either an immedia...
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)
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
const MCRegisterInfo * getRegisterInfo() const
Base class for the full range of assembler expressions which are needed for parsing.
static MCFixup create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, bool PCRel=false)
Consider bit fields if we need more flags.
Instances of this class represent a single low-level machine instruction.
Interface to description of machine instruction set.
MCRegister getReg() const
Returns the register number.
const MCExpr * getExpr() const
uint16_t getEncodingValue(MCRegister Reg) const
Returns the encoding for Reg.
Generic base class for all target subtargets.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ fixup_ve_srel32
fixup_ve_srel32 - 32-bit fixup corresponding to foo for relative branch
@ fixup_ve_pc_hi32
fixup_ve_pc_hi32 - 32-bit fixup corresponding to foo@pc_hi
@ fixup_ve_pc_lo32
fixup_ve_pc_lo32 - 32-bit fixup corresponding to foo@pc_lo
VE::Fixups getFixupKind(uint8_t S)
void write(void *memory, value_type value, endianness endian)
Write a value to memory with a particular endianness.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
static unsigned VECondCodeToVal(VECC::CondCode CC)
static unsigned VERDToVal(VERD::RoundingMode R)
static void addFixup(SmallVectorImpl< MCFixup > &Fixups, uint32_t Offset, const MCExpr *Value, uint16_t Kind)
MCCodeEmitter * createVEMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)