[llvm] r229019 - AsmWriter/Bitcode: MDTemplate{Type,Value}Parameter
Duncan P. N. Exon Smith
dexonsmith at apple.com
Thu Feb 12 17:34:33 PST 2015
Author: dexonsmith
Date: Thu Feb 12 19:34:32 2015
New Revision: 229019
URL: http://llvm.org/viewvc/llvm-project?rev=229019&view=rev
Log:
AsmWriter/Bitcode: MDTemplate{Type,Value}Parameter
Added:
llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-parent.ll
llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-type.ll
llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-parent.ll
llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-tag.ll
llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-type.ll
llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-value.ll
llvm/trunk/test/Assembler/mdtemplateparameter.ll
Modified:
llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/IR/AsmWriter.cpp
Modified: llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h?rev=229019&r1=229018&r2=229019&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h (original)
+++ llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h Thu Feb 12 19:34:32 2015
@@ -159,7 +159,9 @@ namespace bitc {
METADATA_SUBPROGRAM = 21, // [distinct, ...]
METADATA_LEXICAL_BLOCK = 22, // [distinct, scope, file, line, column]
METADATA_LEXICAL_BLOCK_FILE=23,//[distinct, scope, file, discriminator]
- METADATA_NAMESPACE = 24 // [distinct, scope, file, name, line]
+ METADATA_NAMESPACE = 24, // [distinct, scope, file, name, line]
+ METADATA_TEMPLATE_TYPE = 25, // [distinct, scope, name, type, ...]
+ METADATA_TEMPLATE_VALUE= 26 // [distinct, scope, name, type, value, ...]
};
// The constants block (CONSTANTS_BLOCK_ID) describes emission for each
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=229019&r1=229018&r2=229019&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Thu Feb 12 19:34:32 2015
@@ -1129,6 +1129,8 @@ public:
StringRef getName() const { return getStringOperand(1); }
Metadata *getType() const { return getOperand(2); }
+ MDString *getRawName() const { return getOperandAs<MDString>(1); }
+
static bool classof(const Metadata *MD) {
return MD->getMetadataID() == MDTemplateTypeParameterKind ||
MD->getMetadataID() == MDTemplateValueParameterKind;
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=229019&r1=229018&r2=229019&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Feb 12 19:34:32 2015
@@ -3513,12 +3513,41 @@ bool LLParser::ParseMDNamespace(MDNode *
return false;
}
+/// ParseMDTemplateTypeParameter:
+/// ::= !MDTemplateTypeParameter(scope: !0, name: "Ty", type: !1)
bool LLParser::ParseMDTemplateTypeParameter(MDNode *&Result, bool IsDistinct) {
- return TokError("unimplemented parser");
+#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
+ REQUIRED(scope, MDField, ); \
+ OPTIONAL(name, MDStringField, ); \
+ REQUIRED(type, MDField, );
+ PARSE_MD_FIELDS();
+#undef VISIT_MD_FIELDS
+
+ Result = GET_OR_DISTINCT(MDTemplateTypeParameter,
+ (Context, scope.Val, name.Val, type.Val));
+ return false;
}
+
+/// ParseMDTemplateValueParameter:
+/// ::= !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter,
+/// scope: !0, name: "V", type: !1,
+/// value: i32 7)
bool LLParser::ParseMDTemplateValueParameter(MDNode *&Result, bool IsDistinct) {
- return TokError("unimplemented parser");
+#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
+ REQUIRED(tag, DwarfTagField, ); \
+ REQUIRED(scope, MDField, ); \
+ OPTIONAL(name, MDStringField, ); \
+ REQUIRED(type, MDField, ); \
+ REQUIRED(value, MDField, );
+ PARSE_MD_FIELDS();
+#undef VISIT_MD_FIELDS
+
+ Result = GET_OR_DISTINCT(
+ MDTemplateValueParameter,
+ (Context, tag.Val, scope.Val, name.Val, type.Val, value.Val));
+ return false;
}
+
bool LLParser::ParseMDGlobalVariable(MDNode *&Result, bool IsDistinct) {
return TokError("unimplemented parser");
}
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=229019&r1=229018&r2=229019&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Feb 12 19:34:32 2015
@@ -1502,6 +1502,29 @@ std::error_code BitcodeReader::ParseMeta
NextMDValueNo++);
break;
}
+ case bitc::METADATA_TEMPLATE_TYPE: {
+ if (Record.size() != 4)
+ return Error("Invalid record");
+
+ MDValueList.AssignValue(
+ GET_OR_DISTINCT(MDTemplateTypeParameter, Record[0],
+ (Context, getMDOrNull(Record[1]),
+ getMDString(Record[2]), getMDOrNull(Record[3]))),
+ NextMDValueNo++);
+ break;
+ }
+ case bitc::METADATA_TEMPLATE_VALUE: {
+ if (Record.size() != 6)
+ return Error("Invalid record");
+
+ MDValueList.AssignValue(
+ GET_OR_DISTINCT(MDTemplateValueParameter, Record[0],
+ (Context, Record[1], getMDOrNull(Record[2]),
+ getMDString(Record[3]), getMDOrNull(Record[4]),
+ getMDOrNull(Record[5]))),
+ NextMDValueNo++);
+ break;
+ }
case bitc::METADATA_STRING: {
std::string String(Record.begin(), Record.end());
llvm::UpgradeMDStringConstant(String);
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=229019&r1=229018&r2=229019&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Thu Feb 12 19:34:32 2015
@@ -1021,20 +1021,36 @@ static void WriteMDNamespace(const MDNam
Record.clear();
}
-static void WriteMDTemplateTypeParameter(const MDTemplateTypeParameter *,
- const ValueEnumerator &,
- BitstreamWriter &,
- SmallVectorImpl<uint64_t> &,
- unsigned) {
- llvm_unreachable("write not implemented");
+static void WriteMDTemplateTypeParameter(const MDTemplateTypeParameter *N,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(VE.getMetadataOrNullID(N->getScope()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
+ Record.push_back(VE.getMetadataOrNullID(N->getType()));
+
+ Stream.EmitRecord(bitc::METADATA_TEMPLATE_TYPE, Record, Abbrev);
+ Record.clear();
}
-static void WriteMDTemplateValueParameter(const MDTemplateValueParameter *,
- const ValueEnumerator &,
- BitstreamWriter &,
- SmallVectorImpl<uint64_t> &,
- unsigned) {
- llvm_unreachable("write not implemented");
+
+static void WriteMDTemplateValueParameter(const MDTemplateValueParameter *N,
+ const ValueEnumerator &VE,
+ BitstreamWriter &Stream,
+ SmallVectorImpl<uint64_t> &Record,
+ unsigned Abbrev) {
+ Record.push_back(N->isDistinct());
+ Record.push_back(N->getTag());
+ Record.push_back(VE.getMetadataOrNullID(N->getScope()));
+ Record.push_back(VE.getMetadataOrNullID(N->getRawName()));
+ Record.push_back(VE.getMetadataOrNullID(N->getType()));
+ Record.push_back(VE.getMetadataOrNullID(N->getValue()));
+
+ Stream.EmitRecord(bitc::METADATA_TEMPLATE_VALUE, Record, Abbrev);
+ Record.clear();
}
+
static void WriteMDGlobalVariable(const MDGlobalVariable *,
const ValueEnumerator &, BitstreamWriter &,
SmallVectorImpl<uint64_t> &, unsigned) {
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=229019&r1=229018&r2=229019&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Thu Feb 12 19:34:32 2015
@@ -1678,18 +1678,39 @@ static void writeMDNamespace(raw_ostream
Out << ")";
}
-static void writeMDTemplateTypeParameter(raw_ostream &,
- const MDTemplateTypeParameter *,
- TypePrinting *, SlotTracker *,
- const Module *) {
- llvm_unreachable("write not implemented");
+static void writeMDTemplateTypeParameter(raw_ostream &Out,
+ const MDTemplateTypeParameter *N,
+ TypePrinting *TypePrinter,
+ SlotTracker *Machine,
+ const Module *Context) {
+ Out << "!MDTemplateTypeParameter(";
+ FieldSeparator FS;
+ Out << FS << "scope: ";
+ writeMetadataAsOperand(Out, N->getScope(), TypePrinter, Machine, Context);
+ Out << FS << "name: \"" << N->getName() << "\"";
+ Out << FS << "type: ";
+ writeMetadataAsOperand(Out, N->getType(), TypePrinter, Machine, Context);
+ Out << ")";
}
-static void writeMDTemplateValueParameter(raw_ostream &,
- const MDTemplateValueParameter *,
- TypePrinting *, SlotTracker *,
- const Module *) {
- llvm_unreachable("write not implemented");
+
+static void writeMDTemplateValueParameter(raw_ostream &Out,
+ const MDTemplateValueParameter *N,
+ TypePrinting *TypePrinter,
+ SlotTracker *Machine,
+ const Module *Context) {
+ Out << "!MDTemplateValueParameter(";
+ FieldSeparator FS;
+ writeTag(Out, FS, N);
+ Out << FS << "scope: ";
+ writeMetadataAsOperand(Out, N->getScope(), TypePrinter, Machine, Context);
+ Out << FS << "name: \"" << N->getName() << "\"";
+ Out << FS << "type: ";
+ writeMetadataAsOperand(Out, N->getType(), TypePrinter, Machine, Context);
+ Out << FS << "value: ";
+ writeMetadataAsOperand(Out, N->getValue(), TypePrinter, Machine, Context);
+ Out << ")";
}
+
static void writeMDGlobalVariable(raw_ostream &, const MDGlobalVariable *,
TypePrinting *, SlotTracker *,
const Module *) {
Added: llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-parent.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-parent.ll?rev=229019&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-parent.ll (added)
+++ llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-parent.ll Thu Feb 12 19:34:32 2015
@@ -0,0 +1,4 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: [[@LINE+1]]:40: error: missing required field 'scope'
+!0 = !MDTemplateTypeParameter(type: !{})
Added: llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-type.ll?rev=229019&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-type.ll (added)
+++ llvm/trunk/test/Assembler/invalid-mdtemplatetypeparameter-missing-type.ll Thu Feb 12 19:34:32 2015
@@ -0,0 +1,4 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: [[@LINE+1]]:41: error: missing required field 'type'
+!0 = !MDTemplateTypeParameter(scope: !{})
Added: llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-parent.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-parent.ll?rev=229019&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-parent.ll (added)
+++ llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-parent.ll Thu Feb 12 19:34:32 2015
@@ -0,0 +1,5 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: [[@LINE+2]]:44: error: missing required field 'scope'
+!0 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter, type: !{},
+ value: i32 7)
Added: llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-tag.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-tag.ll?rev=229019&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-tag.ll (added)
+++ llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-tag.ll Thu Feb 12 19:34:32 2015
@@ -0,0 +1,4 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: [[@LINE+1]]:67: error: missing required field 'tag'
+!0 = !MDTemplateValueParameter(scope: !{}, type: !{}, value: i32 7)
Added: llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-type.ll?rev=229019&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-type.ll (added)
+++ llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-type.ll Thu Feb 12 19:34:32 2015
@@ -0,0 +1,5 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: [[@LINE+2]]:56: error: missing required field 'type'
+!0 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter,
+ scope: !{}, value: i32 7)
Added: llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-value.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-value.ll?rev=229019&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-value.ll (added)
+++ llvm/trunk/test/Assembler/invalid-mdtemplatevalueparameter-missing-value.ll Thu Feb 12 19:34:32 2015
@@ -0,0 +1,5 @@
+; RUN: not llvm-as < %s -disable-output 2>&1 | FileCheck %s
+
+; CHECK: [[@LINE+2]]:53: error: missing required field 'value'
+!0 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter,
+ scope: !{}, type: !{})
Added: llvm/trunk/test/Assembler/mdtemplateparameter.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/mdtemplateparameter.ll?rev=229019&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/mdtemplateparameter.ll (added)
+++ llvm/trunk/test/Assembler/mdtemplateparameter.ll Thu Feb 12 19:34:32 2015
@@ -0,0 +1,24 @@
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
+; RUN: verify-uselistorder %s
+
+; CHECK: !named = !{!0, !1, !2, !3, !3, !4, !5, !5}
+!named = !{!0, !1, !2, !3, !4, !5, !6, !7}
+
+!0 = distinct !{}
+!1 = distinct !{}
+; CHECK: !1 = distinct !{}
+
+; CHECK-NEXT: !2 = !MDTemplateTypeParameter(scope: !0, name: "Ty", type: !1)
+; CHECK-NEXT: !3 = !MDTemplateTypeParameter(scope: !0, name: "", type: !1)
+!2 = !MDTemplateTypeParameter(scope: !0, name: "Ty", type: !1)
+!3 = !MDTemplateTypeParameter(scope: !0, type: !1)
+!4 = !MDTemplateTypeParameter(scope: !0, name: "", type: !1)
+
+; CHECK-NEXT: !4 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter, scope: !0, name: "V", type: !1, value: i32 7)
+; CHECK-NEXT: !5 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter, scope: !0, name: "", type: !1, value: i32 7)
+!5 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter,
+ scope: !0, name: "V", type: !1, value: i32 7)
+!6 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter,
+ scope: !0, type: !1, value: i32 7)
+!7 = !MDTemplateValueParameter(tag: DW_TAG_template_value_parameter,
+ scope: !0, name: "", type: !1, value: i32 7)
More information about the llvm-commits
mailing list