55 SIMCCodeEmitter(
const SIMCCodeEmitter &) =
delete;
56 SIMCCodeEmitter &operator=(
const SIMCCodeEmitter &) =
delete;
70 unsigned getSOPPBrEncoding(
const MCInst &
MI,
unsigned OpNo,
74 unsigned getSDWASrcEncoding(
const MCInst &
MI,
unsigned OpNo,
78 unsigned getSDWAVopcDstEncoding(
const MCInst &
MI,
unsigned OpNo,
82 unsigned getAVOperandEncoding(
const MCInst &
MI,
unsigned OpNo,
92 return new SIMCCodeEmitter(MCII, MRI, Ctx);
97 template <
typename IntTy>
99 if (Imm >= 0 && Imm <= 64)
102 if (Imm >= -16 && Imm <= -1)
173 if (Val == 0x3e22f983 &&
209 if (Val == 0x3fc45f306dc9c882 &&
282 verifyInstructionPredicates(MI,
285 uint64_t Encoding = getBinaryCodeForInstr(MI, Fixups, STI);
287 unsigned bytes = Desc.
getSize();
289 for (
unsigned i = 0; i < bytes; i++) {
290 OS.
write((uint8_t) ((Encoding >> (8 * i)) & 0xff));
296 AMDGPU::OpName::vaddr0);
298 AMDGPU::OpName::srsrc);
299 assert(vaddr0 >= 0 && srsrc > vaddr0);
300 unsigned NumExtraAddrs = srsrc - vaddr0 - 1;
301 unsigned NumPadding = (-NumExtraAddrs) & 3;
303 for (
unsigned i = 0; i < NumExtraAddrs; ++i)
306 for (
unsigned i = 0; i < NumPadding; ++i)
310 if ((bytes > 8 && STI.
getFeatureBits()[AMDGPU::FeatureVOP3Literal]) ||
323 if (getLitEncoding(Op, Desc.
OpInfo[i], STI) != 255)
332 if (
const auto *
C = dyn_cast<MCConstantExpr>(Op.
getExpr()))
338 for (
unsigned j = 0; j < 4; j++) {
339 OS.
write((uint8_t) ((Imm >> (8 * j)) & 0xff));
347 unsigned SIMCCodeEmitter::getSOPPBrEncoding(
const MCInst &MI,
unsigned OpNo,
359 return getMachineOpValue(MI, MO, Fixups, STI);
363 SIMCCodeEmitter::getSDWASrcEncoding(
const MCInst &MI,
unsigned OpNo,
374 RegEnc |=
MRI.getEncodingValue(Reg);
383 if (Enc != ~0U && Enc != 255) {
393 SIMCCodeEmitter::getSDWAVopcDstEncoding(
const MCInst &MI,
unsigned OpNo,
403 if (Reg != AMDGPU::VCC && Reg != AMDGPU::VCC_LO) {
404 RegEnc |=
MRI.getEncodingValue(Reg);
412 SIMCCodeEmitter::getAVOperandEncoding(
const MCInst &MI,
unsigned OpNo,
416 uint64_t Enc =
MRI.getEncodingValue(Reg);
421 if (
MRI.getRegClass(AMDGPU::AGPR_32RegClassID).contains(Reg) ||
422 MRI.getRegClass(AMDGPU::AReg_64RegClassID).contains(Reg))
431 auto *SE = cast<MCSymbolRefExpr>(Expr);
437 auto *BE = cast<MCBinaryExpr>(Expr);
443 return needsPCRel(cast<MCUnaryExpr>(Expr)->getSubExpr());
451 uint64_t SIMCCodeEmitter::getMachineOpValue(
const MCInst &MI,
456 return MRI.getEncodingValue(MO.
getReg());
477 assert(Offset == 4 || Offset == 8);
497 }
else if (MO.
isImm())
504 #define ENABLE_INSTR_PREDICATE_VERIFIER 505 #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.
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
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.
TargetRegisterInfo interface that is implemented by all hw codegen targets.
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
bool isGFX10(const MCSubtargetInfo &STI)
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.
raw_ostream & write(unsigned char C)
static uint32_t getLit16Encoding(uint16_t Val, const MCSubtargetInfo &STI)
A four-byte pc relative fixup.
Operands with register or 32-bit immediate.
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 inline constant.
constexpr bool isUInt< 16 >(uint64_t x)
bool isSISrcOperand(const MCInstrDesc &Desc, unsigned OpNo)
Can this operand also contain immediate values?
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
Operands with an AccVGPR register or inline constant.
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...