summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Module.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-02-15 22:34:20 +0000
committerBill Wendling <isanbard@gmail.com>2012-02-15 22:34:20 +0000
commit0294932a43109d91d650332ff178e49803c66e6c (patch)
tree0c6b250526883512ffade04dddba690b067618d4 /llvm/lib/VMCore/Module.cpp
parent5986c3e90a26a5308642b41456c8fed07c5d22b3 (diff)
downloadbcm5719-llvm-0294932a43109d91d650332ff178e49803c66e6c.tar.gz
bcm5719-llvm-0294932a43109d91d650332ff178e49803c66e6c.zip
Add a module flags accessor method which returns the flags in a vector.
llvm-svn: 150623
Diffstat (limited to 'llvm/lib/VMCore/Module.cpp')
-rw-r--r--llvm/lib/VMCore/Module.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp
index 09468184cc1..9de5db5a2b2 100644
--- a/llvm/lib/VMCore/Module.cpp
+++ b/llvm/lib/VMCore/Module.cpp
@@ -328,6 +328,21 @@ void Module::eraseNamedMetadata(NamedMDNode *NMD) {
NamedMDList.erase(NMD);
}
+/// getModuleFlagsMetadata - Returns the module flags in the provided vector.
+void Module::
+getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const {
+ const NamedMDNode *ModFlags = getModuleFlagsMetadata();
+ if (!ModFlags) return;
+
+ for (unsigned i = 0, e = ModFlags->getNumOperands(); i != e; ++i) {
+ MDNode *Flag = ModFlags->getOperand(i);
+ ConstantInt *Behavior = cast<ConstantInt>(Flag->getOperand(0));
+ MDString *Key = cast<MDString>(Flag->getOperand(1));
+ Value *Val = Flag->getOperand(2);
+ Flags.push_back(ModuleFlagEntry(Behavior->getZExtValue(), Key, Val));
+ }
+}
+
/// getModuleFlagsMetadata - Returns the NamedMDNode in the module that
/// represents module-level flags. This method returns null if there are no
/// module-level flags.
OpenPOWER on IntegriCloud