mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
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
This commit is contained in:
parent
6adbfa3815
commit
1602e58745
@ -738,6 +738,12 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
INSTKEYWORD(landingpad, LandingPad);
|
||||
#undef INSTKEYWORD
|
||||
|
||||
if (Len >= strlen("DW_TAG_") &&
|
||||
!memcmp(StartChar, "DW_TAG_", strlen("DW_TAG_"))) {
|
||||
StrVal.assign(StartChar, CurPtr);
|
||||
return lltok::DwarfTag;
|
||||
}
|
||||
|
||||
// Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
|
||||
// the CFE to avoid forcing it to deal with 64-bit numbers.
|
||||
if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/Operator.h"
|
||||
#include "llvm/IR/ValueSymbolTable.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/SaveAndRestore.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
@ -2936,6 +2937,28 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
|
||||
if (Lex.getKind() == lltok::APSInt)
|
||||
return ParseMDField(Loc, Name,
|
||||
static_cast<MDUnsignedField<uint32_t> &>(Result));
|
||||
|
||||
if (Result.Seen)
|
||||
return Error(Loc,
|
||||
"field '" + Name + "' cannot be specified more than once");
|
||||
|
||||
if (Lex.getKind() != lltok::DwarfTag)
|
||||
return TokError("expected DWARF tag");
|
||||
|
||||
unsigned Tag = dwarf::getTag(Lex.getStrVal());
|
||||
if (Tag == dwarf::DW_TAG_invalid)
|
||||
return TokError("invalid DWARF tag" + Twine(" '") + Lex.getStrVal() + "'");
|
||||
assert(Tag < 1u << 16 && "Expected valid DWARF tag");
|
||||
|
||||
Result.assign(Tag);
|
||||
Lex.Lex();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LLParser::ParseMDField(LocTy Loc, StringRef Name, MDField &Result) {
|
||||
Metadata *MD;
|
||||
if (ParseMetadata(MD, nullptr))
|
||||
@ -3056,7 +3079,7 @@ bool LLParser::ParseMDLocation(MDNode *&Result, bool IsDistinct) {
|
||||
/// ::= !GenericDebugNode(tag: 15, header: "...", operands: {...})
|
||||
bool LLParser::ParseGenericDebugNode(MDNode *&Result, bool IsDistinct) {
|
||||
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
|
||||
REQUIRED(tag, MDUnsignedField<uint32_t>, (0, ~0u >> 16)); \
|
||||
REQUIRED(tag, DwarfTagField, ); \
|
||||
OPTIONAL(header, MDStringField, ); \
|
||||
OPTIONAL(operands, MDFieldList, );
|
||||
PARSE_MD_FIELDS();
|
||||
|
@ -102,6 +102,9 @@ namespace llvm {
|
||||
NumTy Max = std::numeric_limits<NumTy>::max())
|
||||
: ImplTy(Default), Max(Max) {}
|
||||
};
|
||||
struct DwarfTagField : public MDUnsignedField<uint32_t> {
|
||||
DwarfTagField() : MDUnsignedField<uint32_t>(0, ~0u >> 16) {}
|
||||
};
|
||||
struct MDField : public MDFieldImpl<Metadata *> {
|
||||
MDField() : ImplTy(nullptr) {}
|
||||
};
|
||||
@ -427,6 +430,7 @@ namespace llvm {
|
||||
|
||||
bool ParseMDField(LocTy Loc, StringRef Name,
|
||||
MDUnsignedField<uint32_t> &Result);
|
||||
bool ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result);
|
||||
bool ParseMDField(LocTy Loc, StringRef Name, MDField &Result);
|
||||
bool ParseMDField(LocTy Loc, StringRef Name, MDStringField &Result);
|
||||
bool ParseMDField(LocTy Loc, StringRef Name, MDFieldList &Result);
|
||||
|
@ -198,6 +198,7 @@ namespace lltok {
|
||||
LocalVar, // %foo %"foo"
|
||||
MetadataVar, // !foo
|
||||
StringConstant, // "foo"
|
||||
DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
|
||||
|
||||
// Type valued tokens (TyVal).
|
||||
Type,
|
||||
|
@ -1291,8 +1291,11 @@ static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N,
|
||||
SlotTracker *Machine, const Module *Context) {
|
||||
Out << "!GenericDebugNode(";
|
||||
FieldSeparator FS;
|
||||
// Always output the line, since 0 is a relevant and important value for it.
|
||||
Out << FS << "tag: " << N->getTag();
|
||||
Out << FS << "tag: ";
|
||||
if (const char *Tag = dwarf::TagString(N->getTag()))
|
||||
Out << Tag;
|
||||
else
|
||||
Out << N->getTag();
|
||||
if (!N->getHeader().empty()) {
|
||||
Out << FS << "header: \"";
|
||||
PrintEscapedString(N->getHeader(), Out);
|
||||
|
@ -1,24 +1,27 @@
|
||||
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
|
||||
; RUN: verify-uselistorder %s
|
||||
|
||||
; CHECK: !named = !{!0, !1, !1, !2, !2, !2, !2, !3, !4}
|
||||
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8}
|
||||
; CHECK: !named = !{!0, !1, !1, !2, !2, !2, !2, !3, !4, !2}
|
||||
!named = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
|
||||
|
||||
; CHECK: !0 = !{}
|
||||
!0 = !{}
|
||||
|
||||
; CHECK-NEXT: !1 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!0, !2, !2})
|
||||
; CHECK-NEXT: !1 = !GenericDebugNode(tag: DW_TAG_entry_point, header: "some\00header", operands: {!0, !2, !2})
|
||||
!1 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!0, !3, !4})
|
||||
!2 = !GenericDebugNode(tag: 3, header: "some\00header", operands: {!{}, !3, !4})
|
||||
|
||||
; CHECK-NEXT: !2 = !GenericDebugNode(tag: 3)
|
||||
; CHECK-NEXT: !2 = !GenericDebugNode(tag: DW_TAG_entry_point)
|
||||
!3 = !GenericDebugNode(tag: 3)
|
||||
!4 = !GenericDebugNode(tag: 3, header: "")
|
||||
!5 = !GenericDebugNode(tag: 3, operands: {})
|
||||
!6 = !GenericDebugNode(tag: 3, header: "", operands: {})
|
||||
|
||||
; CHECK-NEXT: !3 = distinct !GenericDebugNode(tag: 3)
|
||||
; CHECK-NEXT: !3 = distinct !GenericDebugNode(tag: DW_TAG_entry_point)
|
||||
!7 = distinct !GenericDebugNode(tag: 3)
|
||||
|
||||
; CHECK-NEXT: !4 = !GenericDebugNode(tag: 65535)
|
||||
!8 = !GenericDebugNode(tag: 65535)
|
||||
|
||||
; CHECK-NOT: !
|
||||
!9 = !GenericDebugNode(tag: DW_TAG_entry_point)
|
||||
|
4
test/Assembler/invalid-generic-debug-node-tag-bad.ll
Normal file
4
test/Assembler/invalid-generic-debug-node-tag-bad.ll
Normal file
@ -0,0 +1,4 @@
|
||||
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: <stdin>:[[@LINE+1]]:29: error: invalid DWARF tag 'DW_TAG_badtag'
|
||||
!0 = !GenericDebugNode(tag: DW_TAG_badtag)
|
@ -0,0 +1,4 @@
|
||||
; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: <stdin>:[[@LINE+1]]:29: error: expected DWARF tag
|
||||
!0 = !GenericDebugNode(tag: "string")
|
@ -77,6 +77,7 @@ syn match llvmIdentifier /[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*/
|
||||
syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*$/
|
||||
syn match llvmIdentifier /![-a-zA-Z$._][-a-zA-Z$._0-9]*\ze\s*[=!]/
|
||||
syn match llvmType /!\zs\a\+\ze\s*(/
|
||||
syn match llvmConstant /\<DW_TAG_[a-z_]\+\>/
|
||||
|
||||
" Syntax-highlight dejagnu test commands.
|
||||
syn match llvmSpecialComment /;\s*RUN:.*$/
|
||||
|
Loading…
Reference in New Issue
Block a user