supports to mark DW_TAG_base_type with DW_AT_picture_string, DW_AT_digit_count, DW_AT_decimal_scale and DW_AT_decimal_sign.
Diff Detail
Event Timeline
Thanks!, Comments are inline. Please also update the metadata unit test, to test the stuff in LLVMContext.
include/llvm/BinaryFormat/Dwarf.def | ||
---|---|---|
707 | Thanks! Looks like none of these were introduced recently so we can get away with not encoding the version number this was introduced in. | |
include/llvm/IR/DIBuilder.h | ||
211 | I think I would prefer a struct DecimalInfo { unsigned DigitCount; unsigned DecimalSign; int DecimalScale; }; DIBasicType *createBasicType(..., Optional<DecimalInfo>() = {}, ... Since this is more of an all-or-nothing affair. | |
include/llvm/IR/DebugInfoMetadata.h | ||
742 | Perhaps you could reuse this struct for the optional arg I mentioned above? | |
743 | Doxygen comments? | |
751 | I don't think this is needed? | |
854 | I think these assertions are redundant and can be removed, because the Optional deref operation would also assert. | |
lib/IR/DIBuilder.cpp | ||
268 | Same here, I think having an Optional<> for all the decimal info would be preferable. (Do all of these values even have a N/A-sentinel value otherwise?) |
I will also include the metadata unit test with listed changes, thanks.
include/llvm/IR/DebugInfoMetadata.h | ||
---|---|---|
854 | i will remove them, thanks. | |
lib/IR/DIBuilder.cpp | ||
268 | All those are optional and one or more may be absent for some encoding type, i will re-factor the code instead of all-or-nothing to all-optional. After having one more look, currently scale is one which does not have invalid value to mark with, yes it would be better to use optional so all of them will have same N/A-sentinal values instead of different for each of them. Thanks! , i will make the changes. |
- Updated metatdata unittest
- Fixed optional issues with decimal attributes.
- Added doxygen comments.
- Updated asm roundtrip tests.
include/llvm/IR/DIBuilder.h | ||
---|---|---|
211 | Ok according to you comment later, these are all optional by themselves. | |
213 | You will also need to provide a clang patch to use the new interface. | |
include/llvm/IR/DebugInfoMetadata.h | ||
744 | . | |
746 | We don't typically combine Optional<> with pointer types but use the nullptr value as a sentinel instead. | |
747 | Do you need the full 32 bits here, or could you pack this tighter? | |
758 | What's the point of having this Optional and all fields inside Optional, too? | |
lib/AsmParser/LLParser.cpp | ||
4356 | clang-format please | |
lib/Bitcode/Reader/MetadataLoader.cpp | ||
1226 | clang-format please | |
unittests/IR/MetadataTest.cpp | ||
1149 | It might be better to use a fully populated DecimalInfo here? | |
1160 | The idea of these tests is that you change exactly one argument each time, here' you're changing the picture string, too, so all the other differences don't matter any more. |
include/llvm/IR/DIBuilder.h | ||
---|---|---|
213 | correct me if i am wrong, clang do not support the languages which uses the related data type encoding, which uses this optional dwarf generation for base type. | |
include/llvm/IR/DebugInfoMetadata.h | ||
746 | i will use nullptr for N/A-sentinal value instead of None. | |
747 | not really, i will try to decrease the memory footprint for this struct. |
include/llvm/IR/DIBuilder.h | ||
---|---|---|
213 | I was blindly assuming that clang was setting the DIFlags argument. If it leaves it blank, then you don't need to do anything. |
+llvm-commits
clang-format-diff is your friend.
Remind me of your use case? Clang does not support any decimal types, although there is work in progress to support scaled binary.
include/llvm/BinaryFormat/Dwarf.def | ||
---|---|---|
702 | Need a space after the // | |
707 | Right the decimal stuff was all added in DWARF 3 and I'm pretty sure has not changed since. As these are enums used in an attribute that is correctly identified as v3, I don't think these need a version. | |
include/llvm/IR/DIBuilder.h | ||
203 | I don't know that DW_ATE_float is an appropriate example here. | |
204 | Does it have to be "packed" decimal type? That may be your use case but as you are passing the encoding as a parameter, I think this would work for all the decimal types. | |
206 | DecimalScale | |
lib/AsmParser/LLParser.cpp | ||
4335 | I'd prefer the example to be self-consistent (digits/scale matching the pic string). | |
lib/Bitcode/Writer/BitcodeWriter.cpp | ||
1500 | LLVM style uses full sentences in comments (with proper capitalization and punctuation). | |
lib/CodeGen/AsmPrinter/DwarfUnit.cpp | ||
753 | Space before the =. |
@aprantl yes, at the moment clang is not generating bi-endian code, hence not using DIFlags.
@probinson, thanks i will fix format/typos related changes.
about the use cases, this patch will provide containers to convey and generate optional DWARF attributes for base type tag with below listed encodings,
DW_ATE_packed_decimal
DW_ATE_numeric_string
DW_ATE_edited
DW_ATE_signed_fixed
DW_ATE_unsigned_fixed
What I meant by "use case" is, do you have a front end that will make use of these new features?
Are you supporting binary scale as well as decimal scale, for [un]signed_fixed encodings? It looks like you are supporting only decimal scale.
Apologies for late reply.
Yes, with this patch, only decimal scale is supported and i will add binary scale as well. (will modify this patch), and related changes too.
and about the front-end, we have a pl1/cobol llvm based front-end (in development) which generates this info.
Awesome; is this the OpenVMS port or something else? I had thought there were maybe two people in the world with both COBOL and LLVM experience.
COBOL doesn't need binary scale but I believe PL/I does (not that I've used PL/I in the past 25 years). You'll want to think about whether it's simpler to use a single API for any scaled type, or split out decimal from binary. Binary scaled obviously doesn't need most of the new parameters.
- Added DW_AT_binary_scale attribute.
- Fixed llvm type code formatting
- Fixed minor typos.
@probinson - no, it is not openvms port, instead we have our own PLI/Cobol compiler for which we are adding debugging support.
@aprantl - apartt from saving memory, here optional in optional is used to mark if basictype is extended or not, so instead of checking all underlying optional attributes only one check is needed.
include/llvm/IR/DebugInfoFlags.def | ||
---|---|---|
54 | The space in DIFLags is precious. Can you explain why we need this as a generic DIFlag and not just a bit in DIBasicType? |
include/llvm/IR/DebugInfoFlags.def | ||
---|---|---|
54 | Thanks for reply. i am thinking this is a bad design as data seems scattered and basicType is getting bloated also you are right about DIFlags' bit being reserved and used only in rare cases is not good. |
Need a space after the //