[llvm-commits] [llvm] r71427 - /llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp
Duncan Sands
baldrick at free.fr
Mon May 11 07:50:07 PDT 2009
Hi,
> +// Return the integer value Val zero-extended or truncated (if necessary) to
> +// type ITy. Any new instructions are inserted at InsertBefore.
this sounds like a generally useful thing, so shouldn't be here.
> +template<typename InsertType>
> +static Value *getZExtOrTrunc(Value *Val, const IntegerType *ITy,
> + InsertType InsertPoint) {
> + const IntegerType *ValTy = cast<IntegerType>(Val->getType());
> + if (ValTy == ITy)
> + return Val;
> + Constant *CVal = dyn_cast<Constant>(Val);
> + if (ValTy->getBitWidth() < ITy->getBitWidth()) {
> + if (CVal)
> + return ConstantExpr::getZExt(CVal, ITy);
> + return new ZExtInst(Val, ITy, "", InsertPoint);
> + } else {
> + if (CVal)
> + return ConstantExpr::getTrunc(CVal, ITy);
> + return new TruncInst(Val, ITy, "", InsertPoint);
> + }
> +}
Doesn't the IRBuilder stuff already do this? If so, why not just
use a builder here?
Ciao,
Duncan.
More information about the llvm-commits
mailing list