39 #include "AMDGPUGenMCPseudoLowering.inc"
44 Ctx(ctx),
ST(st), AP(ap) { }
63 const MCExpr *AMDGPUMCInstLower::getLongBranchBlockExpr(
132 if (MCOpcode == -1) {
134 C.
emitError(
"AMDGPUMCInstLower::lower - Pseudo instruction doesn't have "
151 return MCInstLowering.lowerOperand(MO, MCOp);
164 C.
emitError(
"Illegal instruction detected: " + Err);
171 while (I != MBB->
instr_end() && I->isInsideBundle()) {
178 if (MI->
getOpcode() == AMDGPU::SI_MASK_BRANCH) {
187 OutStreamer->emitRawComment(
" mask branch " + BBStr);
193 if (MI->
getOpcode() == AMDGPU::SI_RETURN) {
199 if (MI->
getOpcode() == AMDGPU::WAVE_BARRIER) {
206 MCInstLowering.lower(MI, TmpInst);
226 MCCodeEmitter &InstEmitter = ObjStreamer.getAssembler().getEmitter();
230 std::string &HexLine =
HexLines.back();
233 for (
size_t i = 0;
i < CodeBytes.
size();
i += 4) {
234 unsigned int CodeDWord = *(
unsigned int *)&CodeBytes[
i];
235 HexStream <<
format(
"%s%08X", (
i > 0 ?
" " :
""), CodeDWord);
238 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
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. ...
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 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...
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 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.
#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)
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)
void dump(const TargetInstrInfo *TII=nullptr) const
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
std::vector< std::string > DisasmLines
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.
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)
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp) const