[llvm-commits] CVS: llvm/include/llvm/Module.h
Chris Lattner
lattner at cs.uiuc.edu
Tue Apr 22 13:03:01 PDT 2003
Changes in directory llvm/include/llvm:
Module.h updated: 1.30 -> 1.31
---
Log message:
Add support for tracking whether a module is 64/32 bit and big/little endian
Also add a moduleID field which can be used for diagnostics
---
Diffs of the changes:
Index: llvm/include/llvm/Module.h
diff -u llvm/include/llvm/Module.h:1.30 llvm/include/llvm/Module.h:1.31
--- llvm/include/llvm/Module.h:1.30 Wed Nov 20 12:31:31 2002
+++ llvm/include/llvm/Module.h Tue Apr 22 13:02:02 2003
@@ -50,16 +50,22 @@
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
-private:
- GlobalListType GlobalList; // The Global Variables
- FunctionListType FunctionList; // The Functions
+ enum Endianness { LittleEndian, BigEndian };
+ enum PointerSize { Pointer32, Pointer64 };
- GlobalValueRefMap *GVRefMap;
+private:
+ GlobalListType GlobalList; // The Global Variables in the module
+ FunctionListType FunctionList; // The Functions in the module
+ GlobalValueRefMap *GVRefMap; // Keep track of GlobalValueRef's
+ SymbolTable *SymTab; // Symbol Table for the module
+ std::string ModuleID; // Human readable identifier for the module
- SymbolTable *SymTab;
+ // These flags are probably not the right long-term way to handle this kind of
+ // target information, but it is sufficient for now.
+ Endianness Endian; // True if target is little endian
+ PointerSize PtrSize; // True if target has 32-bit pointers (false = 64-bit)
- // Accessor for the underlying GlobalValRefMap... only through the
- // Constant class...
+ // Accessor for the underlying GVRefMap... only through the Constant class...
friend class Constant;
friend class ConstantPointerRef;
void mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV);
@@ -67,8 +73,22 @@
void destroyConstantPointerRef(ConstantPointerRef *CPR);
public:
- Module();
+ Module(const std::string &ModuleID);
~Module();
+
+ const std::string &getModuleIdentifier() const { return ModuleID; }
+
+ /// Target endian information...
+ bool isLittleEndian() const { return Endian == LittleEndian; }
+ bool isBigEndian() const { return Endian == BigEndian; }
+ Endianness getEndianness() const { return Endian; }
+ void setEndianness(Endianness E) { Endian = E; }
+
+ /// Target Pointer Size information...
+ bool has32BitPointers() const { return PtrSize == Pointer32; }
+ bool has64BitPointers() const { return PtrSize == Pointer64; }
+ PointerSize getPointerSize() const { return PtrSize; }
+ void setPointerSize(PointerSize PS) { PtrSize = PS; }
/// getOrInsertFunction - Look up the specified function in the module symbol
/// table. If it does not exist, add a prototype for the function and return
More information about the llvm-commits
mailing list