[llvm-commits] CVS: llvm/lib/Linker/LinkModules.cpp

Reid Spencer reid at x10sys.com
Thu Jan 11 23:06:07 PST 2007



Changes in directory llvm/lib/Linker:

LinkModules.cpp updated: 1.125 -> 1.126
---
Log message:

For PR1064: http://llvm.org/PR1064 :
Implement the arbitrary bit-width integer feature. The feature allows
integers of any bitwidth (up to 64) to be defined instead of just 1, 8, 
16, 32, and 64 bit integers.  

This change does several things:
1. Introduces a new Derived Type, IntegerType, to represent the number of
   bits in an integer. The Type classes SubclassData field is used to
   store the number of bits. This allows 2^23 bits in an integer type. 
2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and
   64-bit integers. These are replaced with just IntegerType which is not
   a primitive any more. 
3. Adjust the rest of LLVM to account for this change.

Note that while this incremental change lays the foundation for arbitrary
bit-width integers, LLVM has not yet been converted to actually deal with 
them in any significant way. Most optimization passes, for example, will 
still only deal with the byte-width integer types.  Future increments
will rectify this situation.



---
Diffs of the changes:  (+7 -1)

 LinkModules.cpp |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletion(-)


Index: llvm/lib/Linker/LinkModules.cpp
diff -u llvm/lib/Linker/LinkModules.cpp:1.125 llvm/lib/Linker/LinkModules.cpp:1.126
--- llvm/lib/Linker/LinkModules.cpp:1.125	Sat Jan  6 01:24:43 2007
+++ llvm/lib/Linker/LinkModules.cpp	Fri Jan 12 01:05:13 2007
@@ -111,6 +111,12 @@
 
   // Otherwise, resolve the used type used by this derived type...
   switch (DestTyT->getTypeID()) {
+  case Type::IntegerTyID: {
+    if (cast<IntegerType>(DestTyT)->getBitWidth() !=
+        cast<IntegerType>(SrcTyT)->getBitWidth())
+      return true;
+    return false;
+  }
   case Type::FunctionTyID: {
     if (cast<FunctionType>(DestTyT)->isVarArg() !=
         cast<FunctionType>(SrcTyT)->isVarArg() ||
@@ -275,7 +281,7 @@
   Value *Result = 0;
   if (const Constant *CPV = dyn_cast<Constant>(In)) {
     if ((!isa<DerivedType>(CPV->getType()) && !isa<ConstantExpr>(CPV)) ||
-        isa<ConstantAggregateZero>(CPV))
+        isa<ConstantInt>(CPV) || isa<ConstantAggregateZero>(CPV))
       return const_cast<Constant*>(CPV);   // Simple constants stay identical.
 
     if (const ConstantArray *CPA = dyn_cast<ConstantArray>(CPV)) {






More information about the llvm-commits mailing list