mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-19 18:24:00 +00:00
[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
This commit is contained in:
@ -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
|
||||
/// @{
|
||||
@ -372,6 +397,27 @@ public:
|
||||
/// and delete it.
|
||||
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
|
||||
/// @{
|
||||
|
Reference in New Issue
Block a user