54 SIMCCodeEmitter(
const SIMCCodeEmitter &) =
delete;
55 SIMCCodeEmitter &operator=(
const SIMCCodeEmitter &) =
delete;
69 unsigned getSOPPBrEncoding(
const MCInst &
MI,
unsigned OpNo,
73 unsigned getSDWASrcEncoding(
const MCInst &
MI,
unsigned OpNo,
77 unsigned getSDWAVopcDstEncoding(
const MCInst &
MI,
unsigned OpNo,
87 return new SIMCCodeEmitter(MCII, MRI, Ctx);
92 template <
typename IntTy>
94 if (Imm >= 0 && Imm <= 64)
97 if (Imm >= -16 && Imm <= -1)
168 if (Val == 0x3e22f983 &&
204 if (Val == 0x3fc45f306dc9c882 &&
254 uint16_t Lo16 =
static_cast<uint16_t
>(Imm);
266 verifyInstructionPredicates(MI,
269 uint64_t Encoding = getBinaryCodeForInstr(MI, Fixups, STI);
271 unsigned bytes = Desc.
getSize();
273 for (
unsigned i = 0; i < bytes; i++) {
274 OS.
write((uint8_t) ((Encoding >> (8 * i)) & 0xff));
289 if (getLitEncoding(Op, Desc.
OpInfo[i], STI) != 255)
298 if (
const auto *
C = dyn_cast<MCConstantExpr>(Op.
getExpr()))
304 for (
unsigned j = 0; j < 4; j++) {
305 OS.
write((uint8_t) ((Imm >> (8 * j)) & 0xff));
313 unsigned SIMCCodeEmitter::getSOPPBrEncoding(
const MCInst &MI,
unsigned OpNo,
325 return getMachineOpValue(MI, MO, Fixups, STI);
329 SIMCCodeEmitter::getSDWASrcEncoding(
const MCInst &MI,
unsigned OpNo,
340 RegEnc |=
MRI.getEncodingValue(Reg);
349 if (Enc != ~0U && Enc != 255) {
359 SIMCCodeEmitter::getSDWAVopcDstEncoding(
const MCInst &MI,
unsigned OpNo,
369 if (Reg != AMDGPU::VCC) {
370 RegEnc |=
MRI.getEncodingValue(Reg);
382 auto *BE = cast<MCBinaryExpr>(Expr);
388 return needsPCRel(cast<MCUnaryExpr>(Expr)->getSubExpr());
396 uint64_t SIMCCodeEmitter::getMachineOpValue(
const MCInst &MI,
401 return MRI.getEncodingValue(MO.
getReg());
432 if (Enc != ~0U && (Enc != 255 || Desc.
getSize() == 4))
435 }
else if (MO.
isImm())
442 #define ENABLE_INSTR_PREDICATE_VERIFIER 443 #include "AMDGPUGenMCCodeEmitter.inc"
unsigned mc2PseudoReg(unsigned Reg)
Convert hardware register Reg to a pseudo register.
MCCodeEmitter * createSIMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
This class represents lattice values for constants.
void push_back(const T &Elt)
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.
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.
unsigned getReg() const
Returns the register number.
Context object for machine code objects.
uint8_t OperandType
Information about the type of the operand.
static uint32_t getLit64Encoding(uint64_t Val, const MCSubtargetInfo &STI)
const MCExpr * getExpr() const
Instances of this class represent a single low-level machine instruction.
uint32_t FloatToBits(float Float)
This function takes a float and returns the bit equivalent 32-bit integer.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
unsigned const MachineRegisterInfo * MRI
static uint32_t getLit32Encoding(uint32_t Val, const MCSubtargetInfo &STI)
MCCodeEmitter - Generic instruction encoding interface.
Interface to description of machine instruction set.
MCFixupKind
Extensible enumeration to represent the type of a fixup.
static uint32_t getIntInlineImmEncoding(IntTy Imm)
static bool needsPCRel(const MCExpr *Expr)
unsigned getNumOperands() const
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.
Operands with register or inline constant.
raw_ostream & write(unsigned char C)
static uint32_t getLit16Encoding(uint16_t Val, const MCSubtargetInfo &STI)
A four-byte pc relative fixup.
const MCOperand & getOperand(unsigned i) const
uint64_t DoubleToBits(double Double)
This function takes a double and returns the bit equivalent 64-bit integer.
Provides AMDGPU specific target descriptions.
16-bit PC relative fixup for SOPP branch instructions.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
Generic base class for all target subtargets.
CodeEmitter interface for R600 and SI codegen.
References to labels and assigned expressions.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Operands with register or 32-bit immediate.
bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo)
Can this operand also contain immediate values?
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const MCOperandInfo * OpInfo
This class implements an extremely fast bulk output stream that can only output to a stream...
Target specific expression.
bool isSGPR(unsigned Reg, const MCRegisterInfo *TRI)
Is Reg - scalar register.
This holds information about one operand of a machine instruction, indicating the register class for ...
unsigned getOpcode() const
Instances of this class represent operands of the MCInst class.
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...