39 void operator=(const SIMCCodeEmitter &) LLVM_DELETED_FUNCTION;
44 bool isSrcOperand(const
MCInstrDesc &Desc,
unsigned OpNo) const;
47 uint32_t getLitEncoding(const
MCOperand &MO) const;
52 : MCII(mcii), MRI(mri) { }
54 ~SIMCCodeEmitter() { }
71 return new SIMCCodeEmitter(MCII, MRI, STI, Ctx);
74 bool SIMCCodeEmitter::isSrcOperand(
const MCInstrDesc &Desc,
75 unsigned OpNo)
const {
78 return (AMDGPU::SSrc_32RegClassID == RegClass) ||
79 (AMDGPU::SSrc_64RegClassID == RegClass) ||
80 (AMDGPU::VSrc_32RegClassID == RegClass) ||
81 (AMDGPU::VSrc_64RegClassID == RegClass);
84 uint32_t SIMCCodeEmitter::getLitEncoding(
const MCOperand &MO)
const {
94 if (Imm.I >= 0 && Imm.I <= 64)
97 if (Imm.I >= -16 && Imm.I <= -1)
98 return 192 +
abs(Imm.I);
130 uint64_t Encoding = getBinaryCodeForInstr(MI, Fixups);
132 unsigned bytes = Desc.
getSize();
134 for (
unsigned i = 0; i < bytes; i++) {
135 OS.
write((uint8_t) ((Encoding >> (8 * i)) & 0xff));
145 if (!isSrcOperand(Desc, i))
150 if (getLitEncoding(Op) != 255)
160 for (
unsigned j = 0; j < 4; j++) {
161 OS.
write((uint8_t) ((Imm.I >> (8 * j)) & 0xff));
169 uint64_t SIMCCodeEmitter::getMachineOpValue(
const MCInst &MI,
190 if (isSrcOperand(Desc, OpNo)) {
191 uint32_t Enc = getLitEncoding(MO);
192 if (Enc != ~0U && (Enc != 255 || Desc.
getSize() == 4))
195 }
else if (MO.
isImm())
void push_back(const T &Elt)
#define llvm_unreachable(msg)
unsigned getReg() const
getReg - Returns the register number.
const MCExpr * getExpr() const
MCCodeEmitter - Generic instruction encoding interface.
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
MCFixupKind
MCFixupKind - Extensible enumeration to represent the type of a fixup.
raw_ostream & write(unsigned char C)
A four-byte pc relative fixup.
#define LLVM_DELETED_FUNCTION
unsigned getOpcode() const
Provides AMDGPU specific target descriptions.
MCCodeEmitter * createSIMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, const MCSubtargetInfo &STI, MCContext &Ctx)
unsigned getNumOperands() const
CodeEmitter interface for R600 and SI codegen.
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
static MCFixup Create(uint32_t Offset, const MCExpr *Value, MCFixupKind Kind, SMLoc Loc=SMLoc())
const MCOperandInfo * OpInfo
const MCRegisterInfo & MRI
const MCOperand & getOperand(unsigned i) const