17#define DEBUG_TYPE "build-dep-graph"
22void SPIRVGeneralDuplicatesTracker::prebuildReg2Entry(
25 for (
auto &TPair : DT.getAllUses()) {
26 for (
auto &RegPair : TPair.second) {
30 if (!
MI || (TPair.second.getIsConst() && !
TII->isConstantInstr(*
MI)))
32 Reg2Entry[&
MI->getOperand(0)] = &TPair.second;
41 prebuildReg2Entry(TT, Reg2Entry,
TII);
42 prebuildReg2Entry(CT, Reg2Entry,
TII);
43 prebuildReg2Entry(GT, Reg2Entry,
TII);
44 prebuildReg2Entry(FT, Reg2Entry,
TII);
45 prebuildReg2Entry(AT, Reg2Entry,
TII);
46 prebuildReg2Entry(MT, Reg2Entry,
TII);
47 prebuildReg2Entry(ST, Reg2Entry,
TII);
49 for (
auto &Op2E : Reg2Entry) {
57 assert(
MI &&
MI->getParent() &&
"No MachineInstr created yet");
58 for (
auto i =
MI->getNumDefs(); i < MI->getNumOperands(); i++) {
67 if (
MI->getOpcode() == SPIRV::OpConstantFunctionPointerINTEL && i == 2)
70 if (Reg2Entry.
count(RegOp) == 0 &&
71 (
MI->getOpcode() != SPIRV::OpVariable || i != 3)) {
74 if (VRegDef->
getOpcode() == TargetOpcode::G_CONSTANT &&
78 auto Iter = CT.Storage.find(
C);
79 if (Iter != CT.Storage.end()) {
81 Reg2Entry[RegOp] = &MissedEntry;
88 OS <<
"Unexpected pattern while building a dependency "
89 "graph.\nInstruction: ";
93 OS <<
"\nOperand definition: ";
98 if (Reg2Entry.
count(RegOp))
99 E->
addDep(Reg2Entry[RegOp]);
104 if (Next && (Next->
getOpcode() == SPIRV::OpFunction ||
105 Next->
getOpcode() == SPIRV::OpFunctionParameter)) {
112#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
114 const Module *M = MMI->getModule();
115 for (
auto F = M->begin(), E = M->end();
F != E; ++
F) {
123 if (
MI.getNumExplicitDefs() > 0 &&
124 Reg2Entry.
count(&
MI.getOperand(0))) {
127 Reg2Entry.
lookup(&
MI.getOperand(0))->getDeps())
unsigned const MachineRegisterInfo * MRI
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
const HexagonInstrInfo * TII
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This is an important base class in LLVM.
This class represents an Operation in the Expression.
bool print(raw_ostream &OS, DIDumpOptions DumpOpts, const DWARFExpression *Expr, DWARFUnit *U) const
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
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.
const MachineOperand & getOperand(unsigned i) const
This class contains meta information specific to a module.
MachineOperand class - Representation of each machine instruction operand.
const ConstantInt * getCImm() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
This class implements a map that also provides access to all stored values in a deterministic order.
size_type count(const KeyT &Key) const
ValueT lookup(const KeyT &Key) const
A Module instance is used to store all the information related to an LLVM module.
virtual void print(raw_ostream &OS, const Module *M) const
print - Print out the internal state of the pass.
Wrapper class representing virtual and physical registers.
static unsigned virtReg2Index(Register Reg)
Convert a virtual register number to a 0-based index.
void add(const Type *Ty, const MachineFunction *MF, Register R)
void buildDepsGraph(std::vector< SPIRV::DTSortableEntry * > &Graph, const SPIRVInstrInfo *TII, MachineModuleInfo *MMI)
void addDep(DTSortableEntry *E)
A raw_ostream that writes to an std::string.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.