41 class AMDGPUMCInstLower {
60 class R600MCInstLower :
public AMDGPUMCInstLower {
72 #include "AMDGPUGenMCPseudoLowering.inc" 74 AMDGPUMCInstLower::AMDGPUMCInstLower(
MCContext &ctx,
77 Ctx(ctx),
ST(st), AP(ap) { }
100 const MCExpr *AMDGPUMCInstLower::getLongBranchBlockExpr(
112 AMDGPU::S_GETPC_B64 &&
113 ST.getInstrInfo()->get(AMDGPU::S_GETPC_B64).Size == 4);
151 AP.getNameWithPrefix(SymbolName, GV);
152 MCSymbol *Sym = Ctx.getOrCreateSymbol(SymbolName);
183 if (Opcode == AMDGPU::S_SETPC_B64_return)
184 Opcode = AMDGPU::S_SETPC_B64;
185 else if (Opcode == AMDGPU::SI_CALL) {
188 OutMI.
setOpcode(
TII->pseudoToMCOpcode(AMDGPU::S_SWAPPC_B64));
195 }
else if (Opcode == AMDGPU::SI_TCRETURN) {
197 Opcode = AMDGPU::S_SETPC_B64;
200 int MCOpcode =
TII->pseudoToMCOpcode(Opcode);
201 if (MCOpcode == -1) {
203 C.
emitError(
"AMDGPUMCInstLower::lower - Pseudo instruction doesn't have " 211 lowerOperand(MO, MCOp);
223 AMDGPUMCInstLower MCInstLowering(
OutContext, STI, *
this);
224 return MCInstLowering.lowerOperand(MO, MCOp);
239 if (CE && CE->getOpcode() == Instruction::AddrSpaceCast) {
240 auto Op = CE->getOperand(0);
241 auto SrcAddr =
Op->getType()->getPointerAddressSpace();
242 if (
Op->isNullValue() && AT.getNullPointerValue(SrcAddr) == 0) {
243 auto DstAddr = CE->getType()->getPointerAddressSpace();
262 AMDGPUMCInstLower MCInstLowering(
OutContext, STI, *
this);
267 C.
emitError(
"Illegal instruction detected: " + Err);
274 while (I != MBB->
instr_end() && I->isInsideBundle()) {
282 if (MI->
getOpcode() == AMDGPU::SI_MASK_BRANCH) {
297 if (MI->
getOpcode() == AMDGPU::SI_RETURN_TO_EPILOG) {
299 OutStreamer->emitRawComment(
" return to shader part epilog");
303 if (MI->
getOpcode() == AMDGPU::WAVE_BARRIER) {
309 if (MI->
getOpcode() == AMDGPU::SI_MASKED_UNREACHABLE) {
311 OutStreamer->emitRawComment(
" divergent unreachable");
316 MCInstLowering.lower(MI, TmpInst);
319 #ifdef EXPENSIVE_CHECKS 326 if (!MI->
isPseudo() && STI.isCPUStringValid(STI.getCPU())) {
333 InstEmitter->encodeInstruction(TmpInst, CodeStream, Fixups, STI);
339 if (DumpCodeInstEmitter) {
357 std::string &HexLine =
HexLines.back();
360 for (
size_t i = 0; i < CodeBytes.
size(); i += 4) {
361 unsigned int CodeDWord = *(
unsigned int *)&CodeBytes[i];
362 HexStream <<
format(
"%s%08X", (i > 0 ?
" " :
""), CodeDWord);
365 DisasmStream.
flush();
373 AMDGPUMCInstLower(Ctx, ST, AP) { }
386 R600MCInstLower MCInstLowering(
OutContext, STI, *
this);
391 C.
emitError(
"Illegal instruction detected: " + Err);
398 while (I != MBB->
instr_end() && I->isInsideBundle()) {
404 MCInstLowering.lower(MI, TmpInst);
unsigned getTargetFlags() const
void EmitInstruction(const MachineInstr *MI) override
Implemented in AMDGPUMCInstLower.cpp.
const MCExpr * lowerConstant(const Constant *CV) override
Lower the specified LLVM Constant to an MCExpr.
MCCodeEmitter * createSIMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
AMDGPU specific subclass of TargetSubtarget.
instr_iterator instr_end()
MachineBasicBlock * getMBB() const
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
This class represents lattice values for constants.
const MCExpr * lowerConstant(const Constant *CV) override
Lower the specified LLVM Constant to an MCExpr.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
iterator_range< mop_iterator > explicit_operands()
MCContext & OutContext
This is the context for the output file that we are streaming.
static MCOperand createExpr(const MCExpr *Val)
bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, const MachineInstr *MI)
tblgen'erated driver function for lowering simple MI->MC pseudo instructions.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, const MCSubtargetInfo &STI, raw_ostream &O) override
Print the specified MCInst to the specified raw_ostream.
const SIInstrInfo * getInstrInfo() const override
A raw_ostream that writes to an SmallVector or SmallString.
MachineBasicBlock reference.
MachineFunction * MF
The current machine function.
Mask of preserved registers.
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
bool verifyInstruction(const MachineInstr &MI, StringRef &ErrInfo) const override
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
void setExternal(bool Value) const
static MCOperand createReg(unsigned Reg)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
const HexagonInstrInfo * TII
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
Base class for the full range of assembler expressions which are needed for parsing.
Name of external global symbol.
Represent a reference to a symbol from inside an expression.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const char * getSymbolName() const
Context object for machine code objects.
void emitError(unsigned LocCookie, const Twine &ErrorStr)
emitError - Emit an error message to the currently installed error handler with optional location inf...
A constant value that is initialized with an expression using other constant values.
void EmitInstruction(const MachineInstr *MI) override
Implemented in AMDGPUMCInstLower.cpp.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isVerbose() const
Return true if assembly output should contain comments.
Instances of this class represent a single low-level machine instruction.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
Address of a global value.
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
const MCAsmInfo * MAI
Target Asm Printer information.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This is an important class for using LLVM in a threaded context.
bool isPseudo(QueryType Type=IgnoreBundle) const
Return true if this is a pseudo instruction that doesn't correspond to a real machine instruction...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const GlobalValue * getGlobal() const
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
const R600InstrInfo * getInstrInfo() const override
self_iterator getIterator()
unsigned getNumOperands() const
void print(raw_ostream &OS, bool IsStandalone=true, bool SkipOpers=false, bool SkipDebugLoc=false, bool AddNewLine=true, const TargetInstrInfo *TII=nullptr) const
Print this MI to OS.
The AMDGPU TargetMachine interface definition for hw codgen targets.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static MCSymbolRefExpr::VariantKind getVariantKind(unsigned MOFlags)
Iterator for intrusive lists based on ilist_node.
std::vector< std::string > HexLines
void setOpcode(unsigned Op)
Align max(MaybeAlign Lhs, Align Rhs)
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
R600 Assembly printer class.
MachineOperand class - Representation of each machine instruction operand.
static const MCExpr * lowerAddrSpaceCast(const TargetMachine &TM, const Constant *CV, MCContext &OutContext)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
const Function & getFunction() const
Return the LLVM function that this machine code represents.
std::vector< std::string > DisasmLines
IterT skipDebugInstructionsForward(IterT It, IterT End)
Increment It until it points to a non-debug instruction or to End and return the resulting iterator...
const MachineBasicBlock * getParent() const
TargetSubtargetInfo - Generic base class for all target subtargets.
Provides AMDGPU specific target descriptions.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Interface definition for SIInstrInfo.
int64_t getOffset() const
Return the offset from the symbol in this operand.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
AMDGPU Assembly printer class.
Generic base class for all target subtargets.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
const MCRegisterInfo * getRegisterInfo() const
unsigned getMCReg(unsigned Reg, const MCSubtargetInfo &STI)
If Reg is a pseudo reg, return the correct hardware register given STI otherwise return Reg...
Primary interface to the complete machine description for the target machine.
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
Register getReg() const
getReg - Returns the register number.
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const
Wrapper for MCInstLowering.lowerOperand() for the tblgen'erated pseudo lowering.
const MachineOperand & getOperand(unsigned i) const
Instances of this class represent operands of the MCInst class.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static MCOperand createImm(int64_t Val)
const SIRegisterInfo * getRegisterInfo() const override