[llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Sat Nov 22 01:19:01 PST 2003


Changes in directory llvm/lib/Target/X86:

Printer.cpp updated: 1.72 -> 1.73

---
Log message:

Support constant casting constant pointers to ints/uints, and/or
the other way around, instead of failing a large, tumor-like assertion.


---
Diffs of the changes:  (+8 -4)

Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.72 llvm/lib/Target/X86/Printer.cpp:1.73
--- llvm/lib/Target/X86/Printer.cpp:1.72	Tue Nov 11 16:41:33 2003
+++ llvm/lib/Target/X86/Printer.cpp	Sat Nov 22 01:18:25 2003
@@ -185,15 +185,19 @@
     }
     case Instruction::Cast: {
       // Support only non-converting or widening casts for now, that is, ones
-      // that do not involve a change in value.  This assertion is not a
-      // complete check.
+      // that do not involve a change in value.  This assertion is really gross,
+      // and may not even be a complete check.
       Constant *Op = CE->getOperand(0);
       const Type *OpTy = Op->getType(), *Ty = CE->getType();
 
+      // Remember, kids, pointers on x86 can be losslessly converted back and
+      // forth into 32-bit or wider integers, regardless of signedness. :-P
       assert(((isa<PointerType>(OpTy)
-               && (Ty == Type::LongTy || Ty == Type::ULongTy))
+               && (Ty == Type::LongTy || Ty == Type::ULongTy
+                   || Ty == Type::IntTy || Ty == Type::UIntTy))
               || (isa<PointerType>(Ty)
-                  && (OpTy == Type::LongTy || OpTy == Type::ULongTy))
+                  && (OpTy == Type::LongTy || OpTy == Type::ULongTy
+                      || OpTy == Type::IntTy || OpTy == Type::UIntTy))
               || (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy))
                    && OpTy->isLosslesslyConvertibleTo(Ty))))
              && "FIXME: Don't yet support this kind of constant cast expr");





More information about the llvm-commits mailing list