llvm.org GIT mirror llvm / 95d7135
AsmWriter: MDBasicType: Recognize DW_ATE in 'encoding' git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229006 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
6 changed file(s) with 43 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
737737 INSTKEYWORD(landingpad, LandingPad);
738738 #undef INSTKEYWORD
739739
740 if (Len >= strlen("DW_TAG_") &&
741 !memcmp(StartChar, "DW_TAG_", strlen("DW_TAG_"))) {
742 StrVal.assign(StartChar, CurPtr);
743 return lltok::DwarfTag;
744 }
740 #define DWKEYWORD(TYPE, TOKEN) \
741 if (Len >= strlen("DW_" #TYPE "_") && \
742 !memcmp(StartChar, "DW_" #TYPE "_", strlen("DW_" #TYPE "_"))) { \
743 StrVal.assign(StartChar, CurPtr); \
744 return lltok::TOKEN; \
745 }
746 DWKEYWORD(TAG, DwarfTag);
747 DWKEYWORD(ATE, DwarfAttEncoding);
748 #undef DWKEYWORD
745749
746750 // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
747751 // the CFE to avoid forcing it to deal with 64-bit numbers.
29452945 struct DwarfTagField : public MDUnsignedField {
29462946 DwarfTagField() : MDUnsignedField(0, dwarf::DW_TAG_hi_user) {}
29472947 };
2948 struct DwarfAttEncodingField : public MDUnsignedField {
2949 DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {}
2950 };
29482951
29492952 struct MDSignedField : public MDFieldImpl {
29502953 int64_t Min;
30093012 assert(Tag <= Result.Max && "Expected valid DWARF tag");
30103013
30113014 Result.assign(Tag);
3015 Lex.Lex();
3016 return false;
3017 }
3018
3019 template <>
3020 bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
3021 DwarfAttEncodingField &Result) {
3022 if (Lex.getKind() == lltok::APSInt)
3023 return ParseMDField(Loc, Name, static_cast(Result));
3024
3025 if (Lex.getKind() != lltok::DwarfAttEncoding)
3026 return TokError("expected DWARF type attribute encoding");
3027
3028 unsigned Encoding = dwarf::getAttributeEncoding(Lex.getStrVal());
3029 if (!Encoding)
3030 return TokError("invalid DWARF type attribute encoding" + Twine(" '") +
3031 Lex.getStrVal() + "'");
3032 assert(Encoding <= Result.Max && "Expected valid DWARF language");
3033 Result.assign(Encoding);
30123034 Lex.Lex();
30133035 return false;
30143036 }
32013223 OPTIONAL(name, MDStringField, ); \
32023224 OPTIONAL(size, MDUnsignedField, (0, UINT32_MAX)); \
32033225 OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
3204 OPTIONAL(encoding, MDUnsignedField, (0, UINT32_MAX));
3226 OPTIONAL(encoding, DwarfAttEncodingField, );
32053227 PARSE_MD_FIELDS();
32063228 #undef VISIT_MD_FIELDS
32073229
198198 MetadataVar, // !foo
199199 StringConstant, // "foo"
200200 DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
201 DwarfAttEncoding, // DW_ATE_foo (includes "DW_ATE_")
201202
202203 // Type valued tokens (TyVal).
203204 Type,
13761376 Out << FS << "size: " << N->getSizeInBits();
13771377 if (N->getAlignInBits())
13781378 Out << FS << "align: " << N->getAlignInBits();
1379 if (N->getEncoding())
1380 Out << FS << "encoding: " << N->getEncoding();
1379 if (unsigned Encoding = N->getEncoding()) {
1380 Out << FS << "encoding: ";
1381 if (const char *S = dwarf::AttributeEncodingString(Encoding))
1382 Out << S;
1383 else
1384 Out << Encoding;
1385 }
13811386 Out << ")";
13821387 }
13831388
1919 !5 = !MDEnumerator(value: -8, name: "negeight")
2020 !6 = !MDEnumerator(value: 0, name: "")
2121
22 ; CHECK-NEXT: !6 = !MDBasicType(tag: DW_TAG_base_type, name: "name", size: 1, align: 2, encoding: 3)
22 ; CHECK-NEXT: !6 = !MDBasicType(tag: DW_TAG_base_type, name: "name", size: 1, align: 2, encoding: DW_ATE_unsigned_char)
2323 ; CHECK-NEXT: !7 = !MDBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
2424 ; CHECK-NEXT: !8 = !MDBasicType(tag: DW_TAG_base_type)
25 !7 = !MDBasicType(tag: DW_TAG_base_type, name: "name", size: 1, align: 2, encoding: 3)
25 !7 = !MDBasicType(tag: DW_TAG_base_type, name: "name", size: 1, align: 2, encoding: DW_ATE_unsigned_char)
2626 !8 = !MDBasicType(tag: DW_TAG_unspecified_type, name: "decltype(nullptr)")
2727 !9 = !MDBasicType(tag: DW_TAG_base_type)
2828 !10 = !MDBasicType(tag: DW_TAG_base_type, name: "", size: 0, align: 0, encoding: 0)
7777 syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*[=!]/
7878 syn match llvmType /!\zs\a\+\ze\s*(/
7979 syn match llvmConstant /\/
80 syn match llvmConstant /\/
8081
8182 " Syntax-highlight dejagnu test commands.
8283 syn match llvmSpecialComment /;\s*RUN:.*$/