summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:17:35 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-02-13 01:17:35 +0000
commitcd6636c3bf05e86396b097ce1623ab9993d5adcb (patch)
tree440463e3b81aafeefc8090ad6aad10a8a8289160 /llvm/lib
parent09e03f38d664ed09b6add37050c2df6cf1116272 (diff)
downloadbcm5719-llvm-cd6636c3bf05e86396b097ce1623ab9993d5adcb.tar.gz
bcm5719-llvm-cd6636c3bf05e86396b097ce1623ab9993d5adcb.zip
AsmWriter: MDBasicType: Recognize DW_ATE in 'encoding'
llvm-svn: 229006
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/LLLexer.cpp14
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp24
-rw-r--r--llvm/lib/AsmParser/LLToken.h1
-rw-r--r--llvm/lib/IR/AsmWriter.cpp9
4 files changed, 40 insertions, 8 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index eb16608ad1e..64a67c0ef2a 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -738,11 +738,15 @@ 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;
- }
+#define DWKEYWORD(TYPE, TOKEN) \
+ if (Len >= strlen("DW_" #TYPE "_") && \
+ !memcmp(StartChar, "DW_" #TYPE "_", strlen("DW_" #TYPE "_"))) { \
+ StrVal.assign(StartChar, CurPtr); \
+ return lltok::TOKEN; \
+ }
+ DWKEYWORD(TAG, DwarfTag);
+ DWKEYWORD(ATE, DwarfAttEncoding);
+#undef DWKEYWORD
// 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.
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 802421356ad..992ad1092be 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -2946,6 +2946,9 @@ struct ColumnField : public MDUnsignedField {
struct DwarfTagField : public MDUnsignedField {
DwarfTagField() : MDUnsignedField(0, dwarf::DW_TAG_hi_user) {}
};
+struct DwarfAttEncodingField : public MDUnsignedField {
+ DwarfAttEncodingField() : MDUnsignedField(0, dwarf::DW_ATE_hi_user) {}
+};
struct MDSignedField : public MDFieldImpl<int64_t> {
int64_t Min;
@@ -3016,6 +3019,25 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfTagField &Result) {
template <>
bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
+ DwarfAttEncodingField &Result) {
+ if (Lex.getKind() == lltok::APSInt)
+ return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
+
+ if (Lex.getKind() != lltok::DwarfAttEncoding)
+ return TokError("expected DWARF type attribute encoding");
+
+ unsigned Encoding = dwarf::getAttributeEncoding(Lex.getStrVal());
+ if (!Encoding)
+ return TokError("invalid DWARF type attribute encoding" + Twine(" '") +
+ Lex.getStrVal() + "'");
+ assert(Encoding <= Result.Max && "Expected valid DWARF language");
+ Result.assign(Encoding);
+ Lex.Lex();
+ return false;
+}
+
+template <>
+bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
MDSignedField &Result) {
if (Lex.getKind() != lltok::APSInt)
return TokError("expected signed integer");
@@ -3202,7 +3224,7 @@ bool LLParser::ParseMDBasicType(MDNode *&Result, bool IsDistinct) {
OPTIONAL(name, MDStringField, ); \
OPTIONAL(size, MDUnsignedField, (0, UINT32_MAX)); \
OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
- OPTIONAL(encoding, MDUnsignedField, (0, UINT32_MAX));
+ OPTIONAL(encoding, DwarfAttEncodingField, );
PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS
diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h
index 4e5af1e89bd..65c59b5654b 100644
--- a/llvm/lib/AsmParser/LLToken.h
+++ b/llvm/lib/AsmParser/LLToken.h
@@ -199,6 +199,7 @@ namespace lltok {
MetadataVar, // !foo
StringConstant, // "foo"
DwarfTag, // DW_TAG_foo (includes "DW_TAG_")
+ DwarfAttEncoding, // DW_ATE_foo (includes "DW_ATE_")
// Type valued tokens (TyVal).
Type,
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index f7ed216f79a..c2d25140d7a 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1377,8 +1377,13 @@ static void writeMDBasicType(raw_ostream &Out, const MDBasicType *N,
Out << FS << "size: " << N->getSizeInBits();
if (N->getAlignInBits())
Out << FS << "align: " << N->getAlignInBits();
- if (N->getEncoding())
- Out << FS << "encoding: " << N->getEncoding();
+ if (unsigned Encoding = N->getEncoding()) {
+ Out << FS << "encoding: ";
+ if (const char *S = dwarf::AttributeEncodingString(Encoding))
+ Out << S;
+ else
+ Out << Encoding;
+ }
Out << ")";
}
OpenPOWER on IntegriCloud