summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer/ValueEnumerator.h
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 15:09:42 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-02 15:09:42 +0000
commit9342911f31ff177052d201f1b78c83ab0783a4d6 (patch)
tree44ce4d55fe1e481d3d9e551f3411358ead70c921 /llvm/lib/Bitcode/Writer/ValueEnumerator.h
parent8742de9b20eb8b1960403842b38dcf0c80aa586b (diff)
downloadbcm5719-llvm-9342911f31ff177052d201f1b78c83ab0783a4d6.tar.gz
bcm5719-llvm-9342911f31ff177052d201f1b78c83ab0783a4d6.zip
BitcodeWriter: Further unify function metadata, NFC
Further unify the handling of function-local metadata with global metadata, by exposing the same interface in ValueEnumerator. Both contexts use the same accessors: - getMDStrings(): get the strings for this block. - getNonMDStrings(): get the non-strings for this block. A future commit will start adding strings to the function-block. llvm-svn: 265224
Diffstat (limited to 'llvm/lib/Bitcode/Writer/ValueEnumerator.h')
-rw-r--r--llvm/lib/Bitcode/Writer/ValueEnumerator.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.h b/llvm/lib/Bitcode/Writer/ValueEnumerator.h
index 7bfe9d98655..0592382913a 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.h
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.h
@@ -65,7 +65,6 @@ private:
std::vector<const Metadata *> MDs;
typedef DenseMap<const Metadata *, unsigned> MetadataMapType;
MetadataMapType MetadataMap;
- unsigned NumMDStrings = 0;
bool ShouldPreserveUseListOrder;
typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
@@ -94,7 +93,8 @@ private:
/// When a function is incorporated, this is the size of the Metadatas list
/// before incorporation.
- unsigned NumModuleMDs;
+ unsigned NumModuleMDs = 0;
+ unsigned NumMDStrings = 0;
unsigned FirstFuncConstantID;
unsigned FirstInstID;
@@ -153,15 +153,18 @@ public:
}
const ValueList &getValues() const { return Values; }
- const std::vector<const Metadata *> &getMDs() const { return MDs; }
+
+ /// Check whether the current block has any metadata to emit.
+ bool hasMDs() const { return NumModuleMDs < MDs.size(); }
+
+ // Get the MDString metadata for this block.
ArrayRef<const Metadata *> getMDStrings() const {
- return makeArrayRef(MDs).slice(0, NumMDStrings);
+ return makeArrayRef(MDs).slice(NumModuleMDs, NumMDStrings);
}
+
+ // Get the non-MDString metadata for this block.
ArrayRef<const Metadata *> getNonMDStrings() const {
- return makeArrayRef(MDs).slice(NumMDStrings);
- }
- ArrayRef<const Metadata *> getFunctionMDs() const {
- return makeArrayRef(MDs).slice(NumModuleMDs);
+ return makeArrayRef(MDs).slice(NumModuleMDs).slice(NumMDStrings);
}
const TypeList &getTypes() const { return Types; }
OpenPOWER on IntegriCloud