@@ -679,26 +679,37 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertPointerLikeType(
679
679
/* optional<address space>=*/ std::nullopt , /* extra data=*/ nullptr );
680
680
}
681
681
682
+ static mlir::StringAttr getBasicTypeName (mlir::MLIRContext *context,
683
+ llvm::StringRef baseName,
684
+ unsigned bitSize) {
685
+ std::string name (baseName.str ());
686
+ if (bitSize != 32 )
687
+ name += " *" + std::to_string (bitSize / 8 );
688
+ return mlir::StringAttr::get (context, name);
689
+ }
690
+
682
691
mlir::LLVM::DITypeAttr
683
692
DebugTypeGenerator::convertType (mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
684
693
mlir::LLVM::DIScopeAttr scope,
685
694
fir::cg::XDeclareOp declOp) {
686
695
mlir::MLIRContext *context = module .getContext ();
687
696
if (Ty.isInteger ()) {
688
- return genBasicType (context, mlir::StringAttr::get (context, " integer" ),
689
- Ty.getIntOrFloatBitWidth (), llvm::dwarf::DW_ATE_signed);
697
+ unsigned bitWidth = Ty.getIntOrFloatBitWidth ();
698
+ return genBasicType (context, getBasicTypeName (context, " integer" , bitWidth),
699
+ bitWidth, llvm::dwarf::DW_ATE_signed);
690
700
} else if (mlir::isa<mlir::FloatType>(Ty)) {
691
- return genBasicType (context, mlir::StringAttr::get (context, " real" ),
692
- Ty.getIntOrFloatBitWidth (), llvm::dwarf::DW_ATE_float);
701
+ unsigned bitWidth = Ty.getIntOrFloatBitWidth ();
702
+ return genBasicType (context, getBasicTypeName (context, " real" , bitWidth),
703
+ bitWidth, llvm::dwarf::DW_ATE_float);
693
704
} else if (auto logTy = mlir::dyn_cast_if_present<fir::LogicalType>(Ty)) {
694
- return genBasicType (context,
695
- mlir::StringAttr::get (context, logTy. getMnemonic ()),
696
- kindMapping. getLogicalBitsize ( logTy.getFKind () ),
697
- llvm::dwarf::DW_ATE_boolean);
705
+ unsigned bitWidth = kindMapping. getLogicalBitsize (logTy. getFKind ());
706
+ return genBasicType (
707
+ context, getBasicTypeName (context, logTy.getMnemonic (), bitWidth ),
708
+ bitWidth, llvm::dwarf::DW_ATE_boolean);
698
709
} else if (auto cplxTy = mlir::dyn_cast_if_present<mlir::ComplexType>(Ty)) {
699
710
auto floatTy = mlir::cast<mlir::FloatType>(cplxTy.getElementType ());
700
711
unsigned bitWidth = floatTy.getWidth ();
701
- return genBasicType (context, mlir::StringAttr::get (context, " complex" ),
712
+ return genBasicType (context, getBasicTypeName (context, " complex" , bitWidth ),
702
713
bitWidth * 2 , llvm::dwarf::DW_ATE_complex_float);
703
714
} else if (auto seqTy = mlir::dyn_cast_if_present<fir::SequenceType>(Ty)) {
704
715
return convertSequenceType (seqTy, fileAttr, scope, declOp);
0 commit comments