aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/Module.h
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-02-11 11:38:06 +0000
committerBill Wendling <isanbard@gmail.com>2012-02-11 11:38:06 +0000
commitd34cb1e09f5e4b3feb7305346655b83ad2f67773 (patch)
tree3c9b16358ee97a16da10b8eb0ed4e75420ed6b72 /include/llvm/Module.h
parenta819c397e71adf0fede275ad4abde1947bb21086 (diff)
[WIP] Initial code for module flags.
Module flags are key-value pairs associated with the module. They include a 'behavior' value, indicating how module flags react when mergine two files. Normally, it's just the union of the two module flags. But if two module flags have the same key, then the resulting flags are dictated by the behaviors. Allowable behaviors are: Error Emits an error if two values disagree. Warning Emits a warning if two values disagree. Require Emits an error when the specified value is not present or doesn't have the specified value. It is an error for two (or more) llvm.module.flags with the same ID to have the Require behavior but different values. There may be multiple Require flags per ID. Override Uses the specified value if the two values disagree. It is an error for two (or more) llvm.module.flags with the same ID to have the Override behavior but different values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150300 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Module.h')
-rw-r--r--include/llvm/Module.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/llvm/Module.h b/include/llvm/Module.h
index 8ce5ec4f1d..046798845b 100644
--- a/include/llvm/Module.h
+++ b/include/llvm/Module.h
@@ -154,6 +154,31 @@ public:
/// An enumeration for describing the size of a pointer on the target machine.
enum PointerSize { AnyPointerSize, Pointer32, Pointer64 };
+ /// An enumeration for the supported behaviors of module flags. The following
+ /// module flags behavior values are supported:
+ ///
+ /// Value Behavior
+ /// ----- --------
+ /// 1 Error
+ /// Emits an error if two values disagree.
+ ///
+ /// 2 Warning
+ /// Emits a warning if two values disagree.
+ ///
+ /// 3 Require
+ /// Emits an error when the specified value is not present
+ /// or doesn't have the specified value. It is an error for
+ /// two (or more) llvm.module.flags with the same ID to have
+ /// the Require behavior but different values. There may be
+ /// multiple Require flags per ID.
+ ///
+ /// 4 Override
+ /// Uses the specified value if the two values disagree. It
+ /// is an error for two (or more) llvm.module.flags with the
+ /// same ID to have the Override behavior but different
+ /// values.
+ enum ModAttrBehavior { Error = 1, Warning = 2, Require = 3, Override = 4 };
+
/// @}
/// @name Member Variables
/// @{
@@ -373,6 +398,27 @@ public:
void eraseNamedMetadata(NamedMDNode *NMD);
/// @}
+/// @name Module Flags Accessors
+/// @{
+
+ /// getModuleFlagsMetadata - Returns the NamedMDNode in the module that
+ /// represents module-level flags. This method returns null if there are no
+ /// module-level flags.
+ NamedMDNode *getModuleFlagsMetadata() const;
+
+ /// getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module
+ /// that represents module-level flags. If module-level flags aren't found,
+ /// it creates the named metadata that contains them.
+ NamedMDNode *getOrInsertModuleFlagsMetadata();
+
+ /// addModuleFlag - Add a module-level flag to the module-level flags
+ /// metadata. It will create the module-level flags named metadata if it
+ /// doesn't already exist.
+ void addModuleFlag(ModAttrBehavior Behavior, StringRef Key, Value *Val);
+ void addModuleFlag(ModAttrBehavior Behavior, StringRef Key, uint32_t Val);
+ void addModuleFlag(MDNode *Node);
+
+/// @}
/// @name Materialization
/// @{