Tomar, Sourabh Singh via llvm-dev
2021-May-18 12:50 UTC
[llvm-dev] [DebugInfo] FP Constants representation
[AMD Public Use] Hello Everyone, I’ve started investigating representation of named FP constants in `DIExpression`. A similar approach has been tried and deployed in https://reviews.llvm.org/D99273 for named **integer** constants. I'm trying to represent named FP constants as: ``` !4 = !DIGlobalVariableExpression(var: !5, expr: (DW_OP_consts, **2.888000e+03**, DW_OP_stack_value)) !5 = distinct !DIGlobalVariable(name: "real_constant", scope: !2, file: !3, line: 3, type: !9, isLocal: false, isDefinition: true) Which should materialize in dwarf as: DW_TAG_variable DW_AT_name "real_constant") DW_AT_type "const real(kind=4)") DW_AT_const_value [DW_FORM_block1] (<0x04> 00 80 34 45 ) ``` While trying this I got stumbled upon `DIExpression` limitation(Or it could be a design choice also ?). It seems that `DIExpression` only accepts `uint64_t` as its potential elements thereby leaving no room for things like FP constants to be inside. Digging in further, I realized that extending `DIExpression` for FP constants is non-trivial/maybe breaking also ? I need to have your/community thoughts on this approach or some other potential approach 😊 **NOTE**: Named constants are extensively used in FORTRAN, but having this support should benefit other potential languages/FE also. Thanks a lot! Sourabh.