18#ifndef LLVM_LIB_TARGET_SPIRV_SPIRVNONSEMANTICDEBUGHANDLER_H
19#define LLVM_LIB_TARGET_SPIRV_SPIRVNONSEMANTICDEBUGHANDLER_H
66 bool UseLexicalBlockDiscriminatorScope =
false;
67 bool UseDebugScopeForwardRefs =
false;
68 bool AllowDebugDeclareUntypedVariable =
false;
70 static constexpr unsigned NSSet =
static_cast<unsigned>(
71 SPIRV::InstructionSet::NonSemantic_Shader_DebugInfo_100);
73 struct CompileUnitInfo {
76 unsigned SpirvSourceLanguage = 0;
80 int64_t DwarfVersion = 0;
91 enum class EmitStatus {
99 struct PreparedScope {
100 SPIRV::NonSemanticExtInst::NonSemanticExtInst Opcode{};
103 PreparedScope() =
default;
104 PreparedScope(SPIRV::NonSemanticExtInst::NonSemanticExtInst
Op,
113 template <
typename T>
struct EmitResult {
114 EmitStatus
Status = EmitStatus::Unsupported;
115 std::optional<T>
Value;
117 static EmitResult emitted(
T V) {
119 R.Status = EmitStatus::Emitted;
120 R.Value = std::move(
V);
124 static EmitResult inProgress() {
126 R.Status = EmitStatus::InProgress;
130 template <
typename U>
132 assert(!
Other &&
"failure() requires a non-emitted result");
134 R.Status =
Other.Status;
138 explicit operator bool()
const {
140 "payload is set exactly when the result is emitted");
141 if constexpr (std::is_same_v<T, MCRegister>)
143 return Status == EmitStatus::Emitted;
150 struct InProgressScope {
152 bool ForwardReferenced =
false;
160 bool CanUseForwardRefs =
false;
163 bool UsedForwardRefs =
false;
179 struct GlobalVariableDebugInfo {
184 GlobalVariableDebugInfoMap;
226 bool DebugStringsGenerated =
false;
267 bool GlobalDIEmitted =
false;
271 bool GlobalNSDIEnabled =
false;
279 bool DebugFunctionDefinitionEmitted =
false;
295 SPIRV::NonSemanticExtInst::NonSemanticExtInst Opcode;
363 void emitDebugFunctionDefinition(
MCRegister DebugFunctionReg,
367 void resetPerFunctionDebugState();
375 std::optional<const MachineInstr *>
397 void emitMCInst(
MCInst &Inst);
423 getCachedScopePathOpStringReg(
const DIScope *Scope,
424 bool UseEmptyPathIfNullScope =
false);
432 MCRegister emitExtInst(SPIRV::NonSemanticExtInst::NonSemanticExtInst Opcode,
436 std::optional<MCRegister> ResultReg = std::nullopt);
461 EmitResult<MCRegister> getOrCreateDebugScope(
const DIScope *S);
465 EmitResult<MCRegister> getOrCreateDebugTypeOrNone(
const DIType *Ty);
469 EmitResult<PreparedScope> emitDebugScope(
const DIScope *S);
472 EmitResult<PreparedScope> emitDebugTypeForCompositeType(
477 EmitResult<PreparedScope>
484 EmitResult<PreparedScope> emitDebugTypeBasic(
const DIBasicType *
BT,
490 EmitResult<PreparedScope>
498 EmitResult<PreparedScope>
505 EmitResult<PreparedScope>
510 EmitResult<PreparedScope>
516 EmitResult<PreparedScope> emitDebugFunction(
const DISubprogram *SP,
534 std::optional<MCRegister>
556 std::optional<MCRegister> emitDebugGlobalVariable(
585 std::optional<MCRegister>
604 std::optional<MCRegister> emitDebugExpression(
const DIExpression *Expr,
629 void placeRecord(SPIRV::NonSemanticExtInst::NonSemanticExtInst Opcode,
637 std::optional<MCRegister> getConstantValueReg(
const MachineInstr &
MI)
const;
668 void emitDebugBinding(SPIRV::NonSemanticExtInst::NonSemanticExtInst Opcode,
677 EmitResult<PreparedScope> emitDebugTypeVector(
const DICompositeType *VT,
690 EmitResult<PreparedScope> emitDebugTypeArray(
const DICompositeType *AT,
700 EmitResult<PreparedScope> emitDebugTypeMember(
const DIDerivedType *M,
715 EmitResult<PreparedScope>
742 EmitResult<PreparedScope> emitDebugTypedef(
const DIDerivedType *TD,
750 EmitResult<MCRegister> mapDISignatureTypeToReg(
const DIType *Ty,
756 static unsigned toNSDISrcLang(
unsigned DwarfSrcLang);
784 EmitResult<MCRegister>
794 EmitResult<PreparedScope>
801 EmitResult<PreparedScope> emitDebugLexicalBlockDiscriminator(
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static NVPTX::Scope resolveScope(NVPTX::Scope S, const NVPTXSubtarget *T)
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallString class.
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This class is intended to be used as a driving class for all asm writers.
Basic type, like 'int' or 'float'.
A lightweight wrapper around an expression operand.
Base class for scope-like contexts.
Subprogram description. Uses SubclassData1.
Type array for a subprogram.
DebugHandlerBase(AsmPrinter *A)
Implements a dense probed hash-table based set.
Instances of this class represent a single low-level machine instruction.
Wrapper class representing physical registers and target specific virtual registers.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
Representation of each machine instruction.
This class implements a map that also provides access to all stored values in a deterministic order.
A Module instance is used to store all the information related to an LLVM module.
void beginInstruction(const MachineInstr *MI) override
Process beginning of an instruction.
void endModule() override
Emit all sections that should come after the content.
void beginModule(Module *M) override
Collect compile-unit metadata from the module.
void emitNonSemanticGlobalDebugInfo(SPIRV::ModuleAnalysisInfo &)
Output the module-scope NSDI built by generateModuleDebugInfo().
void emitNonSemanticDebugStrings(SPIRV::ModuleAnalysisInfo &)
Output the NSDI OpStrings built by generateModuleDebugInfo() into the debug section (section 7 of the...
void endFunctionImpl(const MachineFunction *MF) override
void beginFunctionImpl(const MachineFunction *MF) override
void prepareModuleOutput(const SPIRVSubtarget &ST, SPIRV::ModuleAnalysisInfo &MAI)
Add SPV_KHR_non_semantic_info extension and NonSemantic.Shader.DebugInfo.100 ext inst set entry to MA...
SPIRVNonSemanticDebugHandler(AsmPrinter &AP)
void generateModuleDebugInfo(SPIRV::ModuleAnalysisInfo &MAI)
Buffer the module-scope NSDI and add SPV_KHR_relaxed_extended_instruction to MAI if a forward referen...
void endInstruction() override
Process end of an instruction.
void notifyEntryLabelEmitted(const MachineFunction &MF)
Called after the synthesized entry OpLabel has been emitted.
A vector that has set insertion semantics.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Represent a constant reference to a string, i.e.
LLVM Value Representation.
This is an optimization pass for GlobalISel generic memory operations.
LogicalResult failure(bool IsFailure=true)
Utility function to generate a LogicalResult.
DWARFExpression::Operation Op