[llvm-commits] [llvm-gcc-4.2] r79605 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Fri Aug 21 03:59:19 PDT 2009
Hi Bill,
> - if (isa<PointerType>(In->getType()))
> - In = Builder.CreatePtrToInt(In, Amt->getType(),
> + if (isa<PointerType>(In->getType())) {
> + const Type *Ty = 0;
> +
> + switch (getInt64(TYPE_SIZE (TREE_TYPE (TREE_OPERAND (exp, 0))), true)) {
> + default: assert(0 && "Pointer size in bits not a power of 2!");
> + case 1: Ty = Type::getInt1Ty(Context); break;
> + case 8: Ty = Type::getInt8Ty(Context); break;
> + case 16: Ty = Type::getInt16Ty(Context); break;
> + case 32: Ty = Type::getInt32Ty(Context); break;
> + case 64: Ty = Type::getInt64Ty(Context); break;
> + }
> +
> + In = Builder.CreatePtrToInt(In, Ty,
> (In->getNameStr()+".cast").c_str());
why don't you use the result type of the expression (isn't it
an integer?). If it's a pointer too, then you can replace the
above with:
Ty = IntegerType::get(Context, TYPE_PRECISION(TREE_TYPE (TREE_OPERAND
(exp, 0))));
Ciao,
Duncan.
More information about the llvm-commits
mailing list