From 21cc4460efa104e8591b05a90f20130291614344 Mon Sep 17 00:00:00 2001
From: Nick Lewycky
Date: Sat, 4 Apr 2009 07:22:01 +0000
Subject: [PATCH] Add support for embedded metadata to LLVM. This introduces
two new types of Constant, MDString and MDNode which can only be used by
globals with a name that starts with "llvm." or as arguments to a function
with the same naming restriction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68420 91177308-0d34-0410-b5e6-96231b3b80d8
---
docs/LangRef.html | 38 ++++++++++
include/llvm/Bitcode/LLVMBitCodes.h | 4 +-
include/llvm/Constants.h | 104 +++++++++++++++++++++++++++
include/llvm/Type.h | 2 +-
include/llvm/Value.h | 4 +-
lib/AsmParser/LLLexer.cpp | 1 +
lib/AsmParser/LLParser.cpp | 43 ++++++++++-
lib/AsmParser/LLParser.h | 3 +
lib/AsmParser/LLToken.h | 3 +
lib/Bitcode/Reader/BitcodeReader.cpp | 29 +++++++-
lib/Bitcode/Writer/BitcodeWriter.cpp | 31 ++++++++
lib/VMCore/AsmWriter.cpp | 25 ++++++-
lib/VMCore/Constants.cpp | 80 +++++++++++++++++++++
lib/VMCore/Type.cpp | 2 +
lib/VMCore/Verifier.cpp | 51 ++++++++++++-
test/Feature/embeddedmetadata.ll | 11 +++
unittests/VMCore/MetadataTest.cpp | 96 +++++++++++++++++++++++++
17 files changed, 518 insertions(+), 9 deletions(-)
create mode 100644 test/Feature/embeddedmetadata.ll
create mode 100644 unittests/VMCore/MetadataTest.cpp
diff --git a/docs/LangRef.html b/docs/LangRef.html
index cac8fc79dad..457a56ab0cb 100644
--- a/docs/LangRef.html
+++ b/docs/LangRef.html
@@ -65,6 +65,7 @@
Global Variable and Function Addresses
Undefined Values
Constant Expressions
+ Embedded Metadata
Other Values
@@ -1847,6 +1848,14 @@ constants and smaller complex constants.
large arrays) and is always exactly equivalent to using explicit zero
initializers.
+
+
+
+
Embedded metadata provides a way to attach arbitrary data to the
+instruction stream without affecting the behaviour of the program. There are
+two metadata primitives, strings and nodes. All metadata has the type of an
+empty struct and is identified in syntax by a preceding exclamation point
+('!').
+
+
+
A metadata string is a string surrounded by double quotes. It can contain
+any character by escaping non-printable characters with "\xx" where "xx" is
+the two digit hex code. For example: "!"test\00"".
+
+
+
Metadata nodes are represented with notation similar to structure constants
+(a comma separated list of elements, surrounded by braces and preceeded by an
+exclamation point). For example: "!{ { } !"test\00", i32 10}".
+
+
+
Optimizations may rely on metadata to provide additional information about
+the program that isn't available in the instructions, or that isn't easily
+computable. Similarly, the code generator may expect a certain metadata format
+to be used to express debugging information.
+
+