[llvm-commits] [llvm-gcc] Cumulative Patch for Arbitrary BitWidth Integers (please commit)

Chris Lattner clattner at apple.com
Thu Jan 11 23:23:35 PST 2007


On Jan 11, 2007, at 11:10 PM, Reid Spencer wrote:

> Now that the arbitrary bit-width integers feature has been committed,
> there is yet again some adjustment for llvm-gcc. This cumulative patch
> contains my previous two today and should cleanly apply to r247 of the
> mirror. To see what changed in this patch, run diff on this patch and
> the last one I sent. Its not much.

I committed:

Index: llvm-convert.cpp
===================================================================
--- llvm-convert.cpp    (revision 122351)
+++ llvm-convert.cpp    (working copy)
@@ -3322,12 +3322,14 @@
                                         const char *I64Name,Function  
*&I64Cache){
    const char *Name;
    Function  **FCache;
-  switch (InVal->getType()->getTypeID()) {
+  const IntegerType *ITy = cast<IntegerType>(InVal->getType());
+
+  switch (ITy->getBitWidth()) {
    default: assert(0 && "Unknown Integer type!");
-  case Type::Int8TyID:  Name = I8Name;  FCache = &I8Cache ; break;
-  case Type::Int16TyID: Name = I16Name; FCache = &I16Cache; break;
-  case Type::Int32TyID:   Name = I32Name; FCache = &I32Cache; break;
-  case Type::Int64TyID:  Name = I64Name; FCache = &I64Cache; break;
+  case 8 : Name = I8Name;  FCache = &I8Cache ; break;
+  case 16: Name = I16Name; FCache = &I16Cache; break;
+  case 32: Name = I32Name; FCache = &I32Cache; break;
+  case 64: Name = I64Name; FCache = &I64Cache; break;
    }

    if (*FCache == 0)
@@ -4048,7 +4050,8 @@
      // like "struct X{ unsigned long long x:50; unsigned y:2; }"  
when accessing
      // y.  We want to access the field as a ulong, not as a uint  
with an offset.
      if (LLVMFieldTy->isInteger() &&
-        LLVMFieldTy->getPrimitiveSize() > FieldTy->getPrimitiveSize())
+        LLVMFieldTy->getPrimitiveSizeInBits() >
+          FieldTy->getPrimitiveSizeInBits())
        FieldTy = LLVMFieldTy;

      // We are now loading/storing through a casted pointer type, whose


Your generalization to support variable int types wouldn't work  
anyway, so I just switch on valid widths.

-Chris



More information about the llvm-commits mailing list