llvm.org GIT mirror llvm / 1602e58
AsmParser: Recognize DW_TAG_* constants Recognize `DW_TAG_` constants in assembly, and output it by default for `GenericDebugNode`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228042 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
9 changed file(s) with 57 addition(s) and 8 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 }
745
740746 // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
741747 // the CFE to avoid forcing it to deal with 64-bit numbers.
742748 if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
2323 #include "llvm/IR/Module.h"
2424 #include "llvm/IR/Operator.h"
2525 #include "llvm/IR/ValueSymbolTable.h"
26 #include "llvm/Support/Dwarf.h"
2627 #include "llvm/Support/ErrorHandling.h"
2728 #include "llvm/Support/SaveAndRestore.h"
2829 #include "llvm/Support/raw_ostream.h"
29352936 return false;
29362937 }
29372938
2939 bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
2940 if (Lex.getKind() == lltok::APSInt)
2941 return ParseMDField(Loc, Name,
2942 static_cast &>(Result));
2943
2944 if (Result.Seen)
2945 return Error(Loc,
2946 "field '" + Name + "' cannot be specified more than once");
2947
2948 if (Lex.getKind() != lltok::DwarfTag)
2949 return TokError("expected DWARF tag");
2950
2951 unsigned Tag = dwarf::getTag(Lex.getStrVal());
2952 if (Tag == dwarf::DW_TAG_invalid)
2953 return TokError("invalid DWARF tag" + Twine(" '") + Lex.getStrVal() + "'");
2954 assert(Tag < 1u << 16 && "Expected valid DWARF tag");
2955
2956 Result.assign(Tag);
2957 Lex.Lex();
2958 return false;
2959 }
2960
29382961 bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDField &Result) {
29392962 Metadata *MD;
29402963 if (ParseMetadata(MD, nullptr))
30553078 /// ::= !GenericDebugNode(tag: 15, header: "...", operands: {...})
30563079 bool LLParser::ParseGenericDebugNode(MDNode *&Result, bool IsDistinct) {
30573080 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
3058 REQUIRED(tag, MDUnsignedField, (0, ~0u >> 16)); \
3081 REQUIRED(tag, DwarfTagField, ); \
30593082 OPTIONAL(header, MDStringField, ); \
30603083 OPTIONAL(operands, MDFieldList, );
30613084 PARSE_MD_FIELDS();
100100 MDUnsignedField(NumTy Default = 0,
101101 NumTy Max = std::numeric_limits::max())
102102 : ImplTy(Default), Max(Max) {}
103 };
104 struct DwarfTagField : public MDUnsignedField {
105 DwarfTagField() : MDUnsignedField(0, ~0u >> 16) {}
103106 };
104107 struct MDField : public MDFieldImpl {
105108 MDField() : ImplTy(nullptr) {}
426429
427430 bool ParseMDField(LocTy Loc, StringRef Name,
428431 MDUnsignedField &Result);
432 bool ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result);
429433 bool ParseMDField(LocTy Loc, StringRef Name, MDField &Result);
430434 bool ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result);
431435 bool ParseMDField(LocTy Loc, StringRef Name, MDFieldList &Result);
197197 LocalVar, // %foo %"foo"
198198 MetadataVar, // !foo
199199 StringConstant, // "foo"
200 DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
200201
201202 // Type valued tokens (TyVal).
202203 Type,
12901290 SlotTracker *Machine, const Module *Context) {
12911291 Out << "!GenericDebugNode(";
12921292 FieldSeparator FS;
1293 // Always output the line, since 0 is a relevant and important value for it.
1294 Out << FS << "tag: " << N->getTag();
1293 Out << FS << "tag: ";
1294 if (const char *Tag = dwarf::TagString(N->getTag()))
1295 Out << Tag;
1296 else
1297 Out << N->getTag();
12951298 if (!N->getHeader().empty()) {
12961299 Out << FS << "header: \"";
12971300 PrintEscapedString(N->getHeader(), Out);
0 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
11 ; RUN: verify-uselistorder %s
22
3 ; CHECK: !named = !{!0, !1, !1, !2, !2, !2, !2, !3, !4}
4 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
3 ; CHECK: !named = !{!0, !1, !1, !2, !2, !2, !2, !3, !4, !2}
4 !named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
55
66 ; CHECK: !0 = !{}
77 !0 = !{}
88
9 ; CHECK-NEXT: !1 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!0, !2, !2})
9 ; CHECK-NEXT: !1 = !GenericDebugNode(tag: DW_TAG_entry_point, header: "some\00header", operands: {!0, !2, !2})
1010 !1 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!0, !3, !4})
1111 !2 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!{}, !3, !4})
1212
13 ; CHECK-NEXT: !2 = !GenericDebugNode(tag: 3)
13 ; CHECK-NEXT: !2 = !GenericDebugNode(tag: DW_TAG_entry_point)
1414 !3 = !GenericDebugNode(tag: 3)
1515 !4 = !GenericDebugNode(tag: 3, header: "")
1616 !5 = !GenericDebugNode(tag: 3, operands: {})
1717 !6 = !GenericDebugNode(tag: 3, header: "", operands: {})
1818
19 ; CHECK-NEXT: !3 = distinct !GenericDebugNode(tag: 3)
19 ; CHECK-NEXT: !3 = distinct !GenericDebugNode(tag: DW_TAG_entry_point)
2020 !7 = distinct !GenericDebugNode(tag: 3)
2121
2222 ; CHECK-NEXT: !4 = !GenericDebugNode(tag: 65535)
2323 !8 = !GenericDebugNode(tag: 65535)
24
25 ; CHECK-NOT: !
26 !9 = !GenericDebugNode(tag: DW_TAG_entry_point)
0 ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
1
2 ; CHECK: :[[@LINE+1]]:29: error: invalid DWARF tag 'DW_TAG_badtag'
3 !0 = !GenericDebugNode(tag: DW_TAG_badtag)
0 ; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
1
2 ; CHECK: :[[@LINE+1]]:29: error: expected DWARF tag
3 !0 = !GenericDebugNode(tag: "string")
7676 syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*$/
7777 syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*[=!]/
7878 syn match llvmType /!\zs\a\+\ze\s*(/
79 syn match llvmConstant /\/
7980
8081 " Syntax-highlight dejagnu test commands.
8182 syn match llvmSpecialComment /;\s*RUN:.*$/