39 #include "AMDGPUGenMCPseudoLowering.inc"
43 Ctx(ctx),
ST(st), AP(ap) { }
62 const MCExpr *AMDGPUMCInstLower::getLongBranchBlockExpr(
133 if (Opcode == AMDGPU::S_SETPC_B64_return)
134 Opcode = AMDGPU::S_SETPC_B64;
137 if (MCOpcode == -1) {
139 C.
emitError(
"AMDGPUMCInstLower::lower - Pseudo instruction doesn't have "
156 return MCInstLowering.lowerOperand(MO, MCOp);
169 if (CE && CE->getOpcode() == Instruction::AddrSpaceCast) {
170 auto Op = CE->getOperand(0);
171 auto SrcAddr =
Op->getType()->getPointerAddressSpace();
172 if (
Op->isNullValue() && AT->getNullPointerValue(SrcAddr) == 0) {
173 auto DstAddr = CE->getType()->getPointerAddressSpace();
191 C.
emitError(
"Illegal instruction detected: " + Err);
198 while (I != MBB->
instr_end() && I->isInsideBundle()) {
206 if (MI->
getOpcode() == AMDGPU::SI_MASK_BRANCH) {
215 OutStreamer->emitRawComment(
" mask branch " + BBStr);
221 if (MI->
getOpcode() == AMDGPU::SI_RETURN_TO_EPILOG) {
223 OutStreamer->emitRawComment(
" return to shader part epilog");
227 if (MI->
getOpcode() == AMDGPU::WAVE_BARRIER) {
233 if (MI->
getOpcode() == AMDGPU::SI_MASKED_UNREACHABLE) {
235 OutStreamer->emitRawComment(
" divergent unreachable");
240 MCInstLowering.lower(MI, TmpInst);
260 MCCodeEmitter &InstEmitter = ObjStreamer.getAssembler().getEmitter();
264 std::string &HexLine =
HexLines.back();
267 for (
size_t i = 0; i < CodeBytes.
size(); i += 4) {
268 unsigned int CodeDWord = *(
unsigned int *)&CodeBytes[i];
269 HexStream <<
format(
"%s%08X", (i > 0 ?
" " :
""), CodeDWord);
272 DisasmStream.
flush();
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const
Wrapper for MCInstLowering.lowerOperand() for the tblgen'erated pseudo lowering.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const AMDGPURegisterInfo * getRegisterInfo() const override=0
const MCExpr * lowerConstant(const Constant *CV) override
Lower the specified LLVM Constant to an MCExpr.
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.
const GlobalValue * getGlobal() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
AMDGPU specific subclass of TargetSubtarget.
instr_iterator instr_end()
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)
MachineBasicBlock * getMBB() const
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.
const MachineFunction * MF
The current machine function.
A raw_ostream that writes to an SmallVector or SmallString.
MachineBasicBlock reference.
const char * getSymbolName() const
const Function * getFunction() const
getFunction - Return the LLVM function that this machine code represents
void print(raw_ostream &OS, bool SkipOpers=false, bool SkipDebugLoc=false, const TargetInstrInfo *TII=nullptr) const
Debugging supportPrint this MI to OS.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV) const
int pseudoToMCOpcode(int Opcode) const
Return a target-specific opcode if Opcode is a pseudo instruction.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static MCOperand createReg(unsigned Reg)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
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.
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)
Streaming object file generation interface.
void setExternal(bool Value) const
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
format_object< Ts...> format(const char *Fmt, const Ts &...Vals)
These are helper functions used to produce formatted output.
Address of a global value.
unsigned getTargetFlags() const
const MCAsmInfo * MAI
Target Asm Printer information.
This is an important class for using LLVM in a threaded context.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MachineOperand & getOperand(unsigned i) const
MCCodeEmitter - Generic instruction encoding interface.
TargetMachine & TM
Target machine description.
This class is intended to be used as a driving class for all asm writers.
int64_t getOffset() const
Return the offset from the symbol in this operand.
self_iterator getIterator()
The AMDGPU TargetMachine interface definition for hw codgen targets.
const AMDGPUInstrInfo * getInstrInfo() const override=0
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
static MCSymbolRefExpr::VariantKind getVariantKind(unsigned MOFlags)
std::vector< std::string > HexLines
void setOpcode(unsigned Op)
virtual const MCExpr * lowerConstant(const Constant *CV)
Lower the specified LLVM Constant to an MCExpr.
MachineOperand class - Representation of each machine instruction operand.
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)
std::vector< std::string > DisasmLines
llvm_unreachable("Unknown RegBank!")
Representation of each machine instruction.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
void lower(const MachineInstr *MI, MCInst &OutMI) const
Lower a MachineInstr to an MCInst.
Interface definition for SIInstrInfo.
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot, const MCSubtargetInfo &STI) override
Print the specified MCInst to the specified raw_ostream.
AMDGPU Assembly printer class.
MCSubtargetInfo - 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)
void print(raw_ostream &OS, const MCAsmInfo *MAI, bool InParens=false) const
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A raw_ostream that writes to an std::string.
unsigned getMCReg(unsigned Reg, const MCSubtargetInfo &STI)
If Reg is a pseudo reg, return the correct hardware register given STI otherwise return Reg...
void addOperand(const MCOperand &Op)
StringRef - Represent a constant reference to a string, i.e.
bool isVerbose() const
Return true if assembly output should contain comments.
Instances of this class represent operands of the MCInst class.
AMDGPUMCInstLower(MCContext &ctx, const AMDGPUSubtarget &ST, const AsmPrinter &AP)
static MCOperand createImm(int64_t Val)
Instructions::const_iterator const_instr_iterator
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const