22#define DEBUG_TYPE "spirv-nonsemantic-debug-info"
34 bool IsGlobalDIEmitted =
false;
42 "SPIRV NonSemantic.Shader.DebugInfo.100 emitter",
false,
false)
64 IsGlobalDIEmitted =
false;
72 int64_t DwarfVersion = 0;
73 int64_t DebugInfoVersion = 0;
79 getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
81 Context = &M->getContext();
82 const NamedMDNode *DbgCu = M->getNamedMetadata(
"llvm.dbg.cu");
93 const NamedMDNode *ModuleFlags =
M->getNamedMetadata(
"llvm.module.flags");
94 for (
const auto *
Op : ModuleFlags->
operands()) {
96 if (MaybeStrOp.
equalsStr(
"Dwarf Version"))
99 cast<ConstantAsMetadata>(
Op->getOperand(2))->getValue())
101 else if (MaybeStrOp.
equalsStr(
"Debug Info Version"))
104 cast<ConstantAsMetadata>(
Op->getOperand(2))->getValue())
124 const Register StrReg =
MRI.createVirtualRegister(&SPIRV::IDRegClass);
134 const Register DebugSourceResIdReg =
135 MRI.createVirtualRegister(&SPIRV::IDRegClass);
137 MIB = MIRBuilder.buildInstr(SPIRV::OpExtInst)
138 .
addDef(DebugSourceResIdReg)
140 .
addImm(
static_cast<int64_t
>(
141 SPIRV::InstructionSet::NonSemantic_Shader_DebugInfo_100))
142 .
addImm(SPIRV::NonSemanticExtInst::DebugSource)
154 const Register DebugInfoVersionReg =
160 const Register DebugCompUnitResIdReg =
161 MRI.createVirtualRegister(&SPIRV::IDRegClass);
163 MIB = MIRBuilder.buildInstr(SPIRV::OpExtInst)
164 .
addDef(DebugCompUnitResIdReg)
166 .
addImm(
static_cast<int64_t
>(
167 SPIRV::InstructionSet::NonSemantic_Shader_DebugInfo_100))
168 .
addImm(SPIRV::NonSemanticExtInst::DebugCompilationUnit)
169 .
addUse(DebugInfoVersionReg)
171 .
addUse(DebugSourceResIdReg)
172 .
addUse(SourceLanguageReg);
183 if (!IsGlobalDIEmitted) {
184 IsGlobalDIEmitted =
true;
185 Res = emitGlobalDI(MF);
unsigned const MachineRegisterInfo * MRI
const HexagonInstrInfo * TII
This file declares the MachineIRBuilder class.
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file defines the SmallString class.
This class represents an Operation in the Expression.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
This is an important class for using LLVM in a threaded context.
Tracking metadata reference owned by Metadata.
bool equalsStr(StringRef Str) const
iterator getFirstTerminator()
Returns an iterator to the first terminator instruction of this basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Helper class to build MachineInstr.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
bool constrainAllUses(const TargetInstrInfo &TII, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI) const
const MachineInstrBuilder & addUse(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register use operand.
const MachineInstrBuilder & addDef(Register RegNo, unsigned Flags=0, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
This class contains meta information specific to a module.
const Module * getModule() const
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
A Module instance is used to store all the information related to an LLVM module.
iterator_range< op_iterator > operands()
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Holds all the information related to register banks.
Wrapper class representing virtual and physical registers.
Register getSPIRVTypeID(const SPIRVType *SpirvType) const
SPIRVType * getOrCreateSPIRVType(const Type *Type, MachineIRBuilder &MIRBuilder, SPIRV::AccessQualifier::AccessQualifier AQ=SPIRV::AccessQualifier::ReadWrite, bool EmitIR=true)
void assignSPIRVTypeToVReg(SPIRVType *Type, Register VReg, MachineFunction &MF)
Register buildConstantInt(uint64_t Val, MachineIRBuilder &MIRBuilder, SPIRVType *SpvType, bool EmitIR=true)
const SPIRVInstrInfo * getInstrInfo() const override
SPIRVGlobalRegistry * getSPIRVGlobalRegistry() const
const SPIRVRegisterInfo * getRegisterInfo() const override
const RegisterBankInfo * getRegBankInfo() const override
const SPIRVSubtarget * getSubtargetImpl() const
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
static Type * getVoidTy(LLVMContext &C)
static IntegerType * getInt32Ty(LLVMContext &C)
Stores all information relating to a compile unit, be it in its original instance in the object file ...
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
This is an optimization pass for GlobalISel generic memory operations.
MachineFunctionPass * createSPIRVEmitNonSemanticDIPass(SPIRVTargetMachine *TM)
void initializeSPIRVEmitNonSemanticDIPass(PassRegistry &)
void addStringImm(const StringRef &Str, MCInst &Inst)
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...