[llvm-commits] [llvm] r150623 - in /llvm/trunk: include/llvm/Module.h lib/VMCore/Module.cpp
Bill Wendling
isanbard at gmail.com
Wed Feb 15 14:34:21 PST 2012
Author: void
Date: Wed Feb 15 16:34:20 2012
New Revision: 150623
URL: http://llvm.org/viewvc/llvm-project?rev=150623&view=rev
Log:
Add a module flags accessor method which returns the flags in a vector.
Modified:
llvm/trunk/include/llvm/Module.h
llvm/trunk/lib/VMCore/Module.cpp
Modified: llvm/trunk/include/llvm/Module.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Module.h?rev=150623&r1=150622&r2=150623&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Module.h (original)
+++ llvm/trunk/include/llvm/Module.h Wed Feb 15 16:34:20 2012
@@ -179,6 +179,14 @@
/// values.
enum ModAttrBehavior { Error = 1, Warning = 2, Require = 3, Override = 4 };
+ struct ModuleFlagEntry {
+ unsigned Behavior;
+ MDString *Key;
+ Value *Val;
+ ModuleFlagEntry(unsigned B, MDString *K, Value *V)
+ : Behavior(B), Key(K), Val(V) {}
+ };
+
/// @}
/// @name Member Variables
/// @{
@@ -401,6 +409,9 @@
/// @name Module Flags Accessors
/// @{
+ /// getModuleFlagsMetadata - Returns the module flags in the provided vector.
+ void getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const;
+
/// getModuleFlagsMetadata - Returns the NamedMDNode in the module that
/// represents module-level flags. This method returns null if there are no
/// module-level flags.
Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=150623&r1=150622&r2=150623&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Wed Feb 15 16:34:20 2012
@@ -328,6 +328,21 @@
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.
More information about the llvm-commits
mailing list