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);
67 return MCDesc.
operands()[0].RegClass >= 0 &&
68 MCDesc.
operands()[1].RegClass >= 0 &&
69 MCDesc.
operands()[0].RegClass != SPIRV::TYPERegClassID &&
70 MCDesc.
operands()[1].RegClass == SPIRV::TYPERegClassID;
81 }
else if (
Op.isImm()) {
93 unsigned NumOps =
MI.getNumOperands();
96 for (
unsigned i = 2; i <
NumOps; ++i)
103 for (
const auto &
Op :
MI)
107void SPIRVMCCodeEmitter::encodeUnknownType(
const MCInst &
MI,
112 const uint64_t
OpCode =
MI.getOperand(1).getImm();
113 const uint32_t NumWords =
MI.getNumOperands();
114 const uint32_t FirstWord = (0xFFFF & NumWords) << 16 | (0xFFFF & OpCode);
120 for (
unsigned i = 2; i < NumWords; ++i)
124void SPIRVMCCodeEmitter::encodeInstruction(
const MCInst &
MI,
125 SmallVectorImpl<char> &CB,
126 SmallVectorImpl<MCFixup> &Fixups,
127 const MCSubtargetInfo &STI)
const {
128 if (
MI.getOpcode() == SPIRV::UNKNOWN_type) {
129 encodeUnknownType(
MI, CB, Fixups, STI);
134 const uint64_t
OpCode = getBinaryCodeForInstr(
MI, Fixups, STI);
135 const uint32_t NumWords =
MI.getNumOperands() + 1;
136 const uint32_t FirstWord = (NumWords << 16) | OpCode;
146#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)
support::endian::Writer EndianWriter
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
Adapter to write values to a stream in a particular byte order.