42 class AMDGPUMCInstLower {
61 class R600MCInstLower :
public AMDGPUMCInstLower {
73 #include "AMDGPUGenMCPseudoLowering.inc" 75 AMDGPUMCInstLower::AMDGPUMCInstLower(
MCContext &ctx,
78 Ctx(ctx),
ST(st), AP(ap) { }
97 const MCExpr *AMDGPUMCInstLower::getLongBranchBlockExpr(
105 ST.getInstrInfo()->get(AMDGPU::S_GETPC_B64).Size == 4);
143 AP.getNameWithPrefix(SymbolName, GV);
144 MCSymbol *Sym = Ctx.getOrCreateSymbol(SymbolName);
172 if (Opcode == AMDGPU::S_SETPC_B64_return)
173 Opcode = AMDGPU::S_SETPC_B64;
174 else if (Opcode == AMDGPU::SI_CALL) {
177 OutMI.
setOpcode(
TII->pseudoToMCOpcode(AMDGPU::S_SWAPPC_B64));
184 }
else if (Opcode == AMDGPU::SI_TCRETURN) {
186 Opcode = AMDGPU::S_SETPC_B64;
189 int MCOpcode =
TII->pseudoToMCOpcode(Opcode);
190 if (MCOpcode == -1) {
192 C.
emitError(
"AMDGPUMCInstLower::lower - Pseudo instruction doesn't have " 200 lowerOperand(MO, MCOp);
208 AMDGPUMCInstLower MCInstLowering(
OutContext, STI, *
this);
209 return MCInstLowering.lowerOperand(MO, MCOp);
224 if (CE && CE->getOpcode() == Instruction::AddrSpaceCast) {
225 auto Op = CE->getOperand(0);
226 auto SrcAddr =
Op->getType()->getPointerAddressSpace();
227 if (
Op->isNullValue() && AT.getNullPointerValue(SrcAddr) == 0) {
228 auto DstAddr = CE->getType()->getPointerAddressSpace();
247 AMDGPUMCInstLower MCInstLowering(
OutContext, STI, *
this);
252 C.
emitError(
"Illegal instruction detected: " + Err);
259 while (I != MBB->
instr_end() && I->isInsideBundle()) {
267 if (MI->
getOpcode() == AMDGPU::SI_MASK_BRANCH) {
282 if (MI->
getOpcode() == AMDGPU::SI_RETURN_TO_EPILOG) {
284 OutStreamer->emitRawComment(
" return to shader part epilog");
288 if (MI->
getOpcode() == AMDGPU::WAVE_BARRIER) {
294 if (MI->
getOpcode() == AMDGPU::SI_MASKED_UNREACHABLE) {
296 OutStreamer->emitRawComment(
" divergent unreachable");
301 MCInstLowering.lower(MI, TmpInst);
304 #ifdef EXPENSIVE_CHECKS 311 if (!MI->
isPseudo() && STI.isCPUStringValid(STI.getCPU())) {
318 InstEmitter->encodeInstruction(TmpInst, CodeStream, Fixups, STI);
341 MCCodeEmitter &InstEmitter = ObjStreamer.getAssembler().getEmitter();
345 std::string &HexLine =
HexLines.back();
348 for (
size_t i = 0; i < CodeBytes.
size(); i += 4) {
349 unsigned int CodeDWord = *(
unsigned int *)&CodeBytes[i];
350 HexStream <<
format(
"%s%08X", (i > 0 ?
" " :
""), CodeDWord);
353 DisasmStream.
flush();
361 AMDGPUMCInstLower(Ctx, ST, AP) { }
374 R600MCInstLower MCInstLowering(
OutContext, STI, *
this);
379 C.
emitError(
"Illegal instruction detected: " + Err);
386 while (I != MBB->
instr_end() && I->isInsideBundle()) {
392 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.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
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.
unsigned getReg() const
getReg - Returns the register number.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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.
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
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)
Streaming object file generation interface.
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.
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
MCCodeEmitter - Generic instruction encoding interface.
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()
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)
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
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.
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.
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.
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)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
const SIRegisterInfo * getRegisterInfo() const override