23#define DEBUG_TYPE "spirv-mccodeemitter"
31 SPIRVMCCodeEmitter(
const MCInstrInfo &mcii) : MCII(mcii) {}
32 SPIRVMCCodeEmitter(
const SPIRVMCCodeEmitter &) =
delete;
33 void operator=(
const SPIRVMCCodeEmitter &) =
delete;
34 ~SPIRVMCCodeEmitter()
override =
default;
54 return new SPIRVMCCodeEmitter(MCII);
65 return MCDesc.
operands()[0].RegClass >= 0 &&
66 MCDesc.
operands()[1].RegClass >= 0 &&
67 MCDesc.
operands()[0].RegClass != SPIRV::TYPERegClassID &&
68 MCDesc.
operands()[1].RegClass == SPIRV::TYPERegClassID;
79 }
else if (
Op.isImm()) {
91 unsigned NumOps =
MI.getNumOperands();
94 for (
unsigned i = 2; i <
NumOps; ++i)
101 for (
const auto &
Op :
MI)
105void SPIRVMCCodeEmitter::encodeUnknownType(
const MCInst &
MI,
111 const uint32_t NumWords =
MI.getNumOperands();
112 const uint32_t FirstWord = (0xFFFF & NumWords) << 16 | (0xFFFF & OpCode);
118 for (
unsigned i = 2; i < NumWords; ++i)
122void SPIRVMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
123 SmallVectorImpl<char> &CB,
124 SmallVectorImpl<MCFixup> &Fixups,
125 const MCSubtargetInfo &STI)
const {
126 if (
MI.getOpcode() == SPIRV::UNKNOWN_type) {
127 encodeUnknownType(
MI, CB, Fixups, STI);
133 const uint32_t NumWords =
MI.getNumOperands() + 1;
134 const uint32_t FirstWord = (NumWords << 16) | OpCode;
144#include "SPIRVGenMCCodeEmitter.inc"
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
static void emitUntypedInstrOperands(const MCInst &MI, SmallVectorImpl< char > &CB)
static void emitOperand(const MCOperand &Op, SmallVectorImpl< char > &CB)
static void emitTypedInstrOperands(const MCInst &MI, SmallVectorImpl< char > &CB)
static bool hasType(const MCInst &MI, const MCInstrInfo &MII)
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
Instances of this class represent a single low-level machine instruction.
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
Interface to description of machine instruction set.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Instances of this class represent operands of the MCInst class.
Generic base class for all target subtargets.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getIDFromRegister(unsigned Reg)
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.
MCCodeEmitter * createSPIRVMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
DWARFExpression::Operation Op