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.
Reid.
Index: gcc/llvm-backend.cpp =================================================================== --- gcc/llvm-backend.cpp (revision 247) +++ gcc/llvm-backend.cpp (working copy) @@ -569,7 +569,7 @@ // If this has already been processed, don't emit duplicate error messages. if (DECL_LLVM_SET_P(decl)) { // Error state encoded into DECL_LLVM. - return cast<ConstantBool>(DECL_LLVM(decl))->getValue(); + return cast<ConstantInt>(DECL_LLVM(decl))->getZExtValue(); } /* Detect errors in declaring global registers. */ @@ -593,10 +593,10 @@ if (TREE_THIS_VOLATILE(decl)) warning("volatile register variables don%'t work as you might wish"); - SET_DECL_LLVM(decl, ConstantBool::getFalse()); + SET_DECL_LLVM(decl, ConstantInt::getFalse()); return false; // Everything ok. } - SET_DECL_LLVM(decl, ConstantBool::getTrue()); + SET_DECL_LLVM(decl, ConstantInt::getTrue()); return true; } Index: gcc/llvm-convert.cpp =================================================================== --- gcc/llvm-convert.cpp (revision 247) +++ gcc/llvm-convert.cpp (working copy) @@ -221,7 +221,8 @@ // If this is just a mismatch between integer types, this is due // to K&R prototypes, where the forward proto defines the arg as int // and the actual impls is a short or char. - assert(ArgVal->getType() == Type::Int32Ty && LLVMTy->isIntegral() && + assert(ArgVal->getType()->isIntegral() && LLVMTy->isIntegral() && + cast<IntegerType>(ArgVal->getType())->getBitWidth() == 32 && "Lowerings don't match?"); ArgVal = new TruncInst(ArgVal, LLVMTy, NameStack.back(), CurBB); } @@ -713,7 +714,7 @@ // Handle cast (cast bool X to T2) to bool as X, because this occurs all over // the place. if (CastInst *CI = dyn_cast<CastInst>(V)) - if (Ty == Type::BoolTy && CI->getOperand(0)->getType() == Type::BoolTy) + if (Ty == Type::Int1Ty && CI->getOperand(0)->getType() == Type::Int1Ty) return CI->getOperand(0); return CastInst::create(Instruction::CastOps(opcode), V, Ty, V->getName(), CurBB); @@ -1384,10 +1385,10 @@ } Value *TreeToLLVM::EmitCOND_EXPR(tree exp) { - // Emit the conditional expression and trunc/bitcast to BoolTy + // Emit the conditional expression and trunc/bitcast to Int1Ty Value *Cond = Emit(COND_EXPR_COND(exp), 0); // If its not already a bool, insert a comparison against zero to make it so. - if (Cond->getType() != Type::BoolTy) + if (Cond->getType() != Type::Int1Ty) Cond = new ICmpInst(ICmpInst::ICMP_NE, Cond, Constant::getNullValue(Cond->getType()), "toBool", CurBB); @@ -2376,7 +2377,7 @@ Value *TreeToLLVM::EmitTRUTH_NOT_EXPR(tree exp) { Value *V = Emit(TREE_OPERAND(exp, 0), 0); - if (V->getType() != Type::BoolTy) + if (V->getType() != Type::Int1Ty) V = new ICmpInst(ICmpInst::ICMP_NE, V, Constant::getNullValue(V->getType()), "toBool", CurBB); V = BinaryOperator::createNot(V, V->getName()+"not", CurBB); @@ -3322,13 +3323,22 @@ const char *I64Name,Function *&I64Cache){ const char *Name; Function **FCache; - switch (InVal->getType()->getTypeID()) { - 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; - } + const IntegerType *ITy = cast<IntegerType>(InVal->getType()); + unsigned BitWidth = ITy->getBitWidth(); + if (BitWidth <= 8) { + Name = I8Name; + FCache = &I8Cache; + } else if (BitWidth <= 16) { + Name = I16Name; + FCache = &I16Cache; + } else if (BitWidth <= 32) { + Name = I32Name; + FCache = &I32Cache; + } else if (BitWidth <= 64) { + Name = I64Name; + FCache = &I64Cache; + } else + assert(0 && "Integer types > 64 bits not supported!"); if (*FCache == 0) *FCache = cast<Function>(TheModule->getOrInsertFunction(Name, @@ -4038,7 +4048,7 @@ // If the field result is a bool, cast to a ubyte instead. It is not // possible to access all bits of a memory object with a bool (only the low // bit) but it is possible to access them with a byte. - if (FieldTy == Type::BoolTy) + if (FieldTy == Type::Int1Ty) FieldTy = Type::Int8Ty; assert(FieldTy->isInteger() && "Invalid bitfield"); @@ -4048,7 +4058,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 Index: gcc/llvm-types.cpp =================================================================== --- gcc/llvm-types.cpp (revision 247) +++ gcc/llvm-types.cpp (working copy) @@ -288,8 +288,8 @@ case UNION_TYPE: return ConvertUNION(type, orig_type); case BOOLEAN_TYPE: if (TREE_INT_CST_LOW(TYPE_SIZE(type)) <= 8) - return SET_TYPE_LLVM(type, Type::BoolTy); - else { // Bools on some platforms take more space than LLVM bool (e.g. PPC). + return SET_TYPE_LLVM(type, Type::Int1Ty); + else { // Int1s on some platforms take more space than LLVM bool (e.g. PPC). if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; const Type *Ty = getIntegerType(TREE_INT_CST_LOW(TYPE_SIZE(type)), true); @@ -517,7 +517,7 @@ if (LLVMTy == Type::FloatTy) LLVMTy = Type::DoubleTy; else if (LLVMTy == Type::Int16Ty || LLVMTy == Type::Int8Ty || - LLVMTy == Type::BoolTy) + LLVMTy == Type::Int1Ty) LLVMTy = Type::Int32Ty; } ArgTypes.push_back(LLVMTy);
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits