[llvm] [SPIR-V] Emit DebugTypeBasic for NonSemantic DI (PR #106980)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 05:46:14 PDT 2024
================
@@ -156,22 +205,56 @@ bool SPIRVEmitNonSemanticDI::emitGlobalDI(MachineFunction &MF) {
const Register SourceLanguageReg =
GR->buildConstantInt(SourceLanguage, MIRBuilder, I32Ty, false);
- // Emit DebugCompilationUnit
+ [[maybe_unused]]
const Register DebugCompUnitResIdReg =
- MRI.createVirtualRegister(&SPIRV::IDRegClass);
- MRI.setType(DebugCompUnitResIdReg, LLT::scalar(32));
- MIB = MIRBuilder.buildInstr(SPIRV::OpExtInst)
- .addDef(DebugCompUnitResIdReg)
- .addUse(GR->getSPIRVTypeID(VoidTy))
- .addImm(static_cast<int64_t>(
- SPIRV::InstructionSet::NonSemantic_Shader_DebugInfo_100))
- .addImm(SPIRV::NonSemanticExtInst::DebugCompilationUnit)
- .addUse(DebugInfoVersionReg)
- .addUse(DwarfVersionReg)
- .addUse(DebugSourceResIdReg)
- .addUse(SourceLanguageReg);
- MIB.constrainAllUses(*TII, *TRI, *RBI);
- GR->assignSPIRVTypeToVReg(VoidTy, DebugCompUnitResIdReg, MF);
+ EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugCompilationUnit,
+ {DebugInfoVersionReg, DwarfVersionReg,
+ DebugSourceResIdReg, SourceLanguageReg});
+
+ // Emit DebugInfoNone. This instruction is a wildcard accepted
+ // by standard to put into instruction arguments as Not Available/Null
+ const Register DebugInfoNoneReg =
+ EmitDIInstruction(SPIRV::NonSemanticExtInst::DebugInfoNone, {});
+
+ for (auto *BasicType : BasicTypes) {
+ const Register BasicTypeStrReg = EmitOpString(BasicType->getName());
+
+ const Register ConstIntBitwidthReg = GR->buildConstantInt(
+ BasicType->getSizeInBits(), MIRBuilder, I32Ty, false);
+
+ uint64_t AttributeEncoding = BaseTypeAttributeEncoding::Unspecified;
+ switch (BasicType->getEncoding()) {
+ case dwarf::DW_ATE_signed:
+ AttributeEncoding = BaseTypeAttributeEncoding::Signed;
+ break;
+ case dwarf::DW_ATE_unsigned:
+ AttributeEncoding = BaseTypeAttributeEncoding::Unsigned;
+ break;
+ case dwarf::DW_ATE_unsigned_char:
+ AttributeEncoding = BaseTypeAttributeEncoding::UnsignedChar;
+ break;
+ case dwarf::DW_ATE_signed_char:
+ AttributeEncoding = BaseTypeAttributeEncoding::SignedChar;
+ break;
+ case dwarf::DW_ATE_float:
+ AttributeEncoding = BaseTypeAttributeEncoding::Float;
+ break;
+ case dwarf::DW_ATE_boolean:
+ AttributeEncoding = BaseTypeAttributeEncoding::Boolean;
+ break;
+ case dwarf::DW_ATE_address:
+ AttributeEncoding = BaseTypeAttributeEncoding::Address;
+ }
+
+ const Register AttributeEncodingReg =
+ GR->buildConstantInt(AttributeEncoding, MIRBuilder, I32Ty, false);
+
+ [[maybe_unused]]
+ const Register BasicTypeReg =
----------------
bwlodarcz wrote:
Yes. It's used later by many other instructions, among others, in follow up `DebugPointerType`.
https://github.com/llvm/llvm-project/pull/106980
More information about the llvm-commits
mailing list