24 #include "llvm/Config/config.h" 31 #define DEBUG_TYPE "instruction-select" 35 #ifdef LLVM_GISEL_COV_PREFIX 38 cl::desc(
"Record GlobalISel rule coverage files of this " 39 "prefix if instrumentation was generated"));
46 "Select target instructions out of generic instructions",
74 assert(ISel &&
"Cannot work without InstructionSelector");
90 "instruction is not legal", *
MI);
96 const size_t NumBlocks = MF.
size();
104 bool ReachedBegin =
false;
105 for (
auto MII = std::prev(MBB->end()), Begin = MBB->begin();
109 const auto AfterIt = std::next(MII);
130 if (!ISel->select(MI, CoverageInfo)) {
139 auto InsertedBegin = ReachedBegin ? MBB->begin() : std::next(MII);
141 for (
auto &InsertedMI :
make_range(InsertedBegin, AfterIt))
142 dbgs() <<
" " << InsertedMI;
155 bool ReachedBegin =
false;
156 for (
auto MII = std::prev(MBB.end()), Begin = MBB.begin(); !ReachedBegin;) {
165 if (MI.
getOpcode() != TargetOpcode::COPY)
173 if (SrcRC == DstRC) {
198 "VReg has no regclass after selection", *MI);
205 MF, TPC, MORE,
"gisel-select",
206 "VReg's low-level type and register class have different sizes", *MI);
211 if (MF.size() != NumBlocks) {
213 MF.getFunction().getSubprogram(),
215 R <<
"inserting blocks is not supported yet";
220 auto &TLI = *MF.getSubtarget().getTargetLowering();
221 TLI.finalizeLowering(MF);
224 dbgs() <<
"Rules covered by selecting function: " << MF.getName() <<
":";
225 for (
auto RuleID : CoverageInfo.
covered())
226 dbgs() <<
" id" << RuleID;
229 CoverageInfo.
emit(CoveragePrefix,
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
void clearVirtRegTypes()
Remove all types associated to virtual registers (after instruction selection and constraining of all...
This class represents lattice values for constants.
void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
void initializeInstructionSelectPass(PassRegistry &)
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
const MachineFunctionProperties & getProperties() const
Get the function properties.
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
unsigned const TargetRegisterInfo * TRI
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
bool emit(StringRef FilePrefix, StringRef BackendName) const
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
Target-Independent Code Generator Pass Configuration Options.
INITIALIZE_PASS_BEGIN(InstructionSelect, DEBUG_TYPE, "Select target instructions out of generic instructions", false, false) INITIALIZE_PASS_END(InstructionSelect
void eraseFromParentAndMarkDBGValuesForRemoval()
Unlink 'this' from the containing basic block and delete it.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
initializer< Ty > init(const Ty &Val)
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Represent the analysis usage information of a pass.
use_instr_iterator use_instr_begin(unsigned RegNo) const
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool def_empty(unsigned RegNo) const
def_empty - Return true if there are no instructions defining the specified register (it may be live-...
iterator_range< po_iterator< T > > post_order(const T &G)
unsigned getNumVirtRegs() const
getNumVirtRegs - Return the number of virtual registers created.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static const std::string CoveragePrefix
cl::opt< bool > DisableGISelLegalityCheck
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
const MachineInstr * machineFunctionIsIllegal(const MachineFunction &MF)
Checks that MIR is fully legal, returns an illegal instruction if it's not, nullptr otherwise...
unsigned getSizeInBits() const
Returns the total size of the type. Must only be called on sized types.
This pass is responsible for selecting generic machine instructions to target-specific instructions...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool use_empty(unsigned RegNo) const
use_empty - Return true if there are no instructions using the specified register.
def_instr_iterator def_instr_begin(unsigned RegNo) const
void replaceRegWith(unsigned FromReg, unsigned ToReg)
replaceRegWith - Replace all instances of FromReg with ToReg in the machine function.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Provides the logic to select generic machine instructions.
bool isTriviallyDead(const MachineInstr &MI, const MachineRegisterInfo &MRI)
Check whether an instruction MI is dead: it only defines dead virtual registers, and doesn't have oth...
Representation of each machine instruction.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
virtual const InstructionSelector * getInstructionSelector() const
iterator_range< const_covered_iterator > covered() const
const TargetRegisterClass * getRegClassOrNull(unsigned Reg) const
Return the register class of Reg, or null if Reg has not been assigned a register class yet...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
inst_range instructions(Function *F)
const MachineOperand & getOperand(unsigned i) const
void reportGISelFailure(MachineFunction &MF, const TargetPassConfig &TPC, MachineOptimizationRemarkEmitter &MORE, MachineOptimizationRemarkMissed &R)
Report an ISel error as a missed optimization remark to the LLVMContext's diagnostic stream...
This file describes how to lower LLVM code to machine code.