return get(Instruction::Shr, C1, C2);
}
+Constant *ConstantExpr::getUShr(Constant *C1, Constant *C2) {
+ if (C1->getType()->isUnsigned()) return getShr(C1, C2);
+ return getCast(getShr(getCast(C1,
+ C1->getType()->getUnsignedVersion()), C2), C1->getType());
+}
+Constant *ConstantExpr::getSShr(Constant *C1, Constant *C2) {
+ if (C1->getType()->isSigned()) return getShr(C1, C2);
+ return getCast(getShr(getCast(C1,
+ C1->getType()->getSignedVersion()), C2), C1->getType());
+}
//===----------------------------------------------------------------------===//
} else if (getOpcode() == Instruction::Cast) {
assert(getOperand(0) == From && "Cast only has one use!");
Replacement = ConstantExpr::getCast(To, getType());
+ } else if (getOpcode() == Instruction::Select) {
+ Constant *C1 = getOperand(0);
+ Constant *C2 = getOperand(1);
+ Constant *C3 = getOperand(2);
+ if (C1 == From) C1 = To;
+ if (C2 == From) C2 = To;
+ if (C3 == From) C3 = To;
+ Replacement = ConstantExpr::getSelect(C1, C2, C3);
} else if (getNumOperands() == 2) {
Constant *C1 = getOperand(0);
Constant *C2 = getOperand(1);
return ExprConstants.getOrCreate(Ty, Key);
}
+Constant *ConstantExpr::getSignExtend(Constant *C, const Type *Ty) {
+ assert(C->getType()->isInteger() && Ty->isInteger() &&
+ C->getType()->getPrimitiveSize() <= Ty->getPrimitiveSize() &&
+ "This is an illegal sign extension!");
+ C = ConstantExpr::getCast(C, C->getType()->getSignedVersion());
+ return ConstantExpr::getCast(C, Ty);
+}
+
+Constant *ConstantExpr::getZeroExtend(Constant *C, const Type *Ty) {
+ assert(C->getType()->isInteger() && Ty->isInteger() &&
+ C->getType()->getPrimitiveSize() <= Ty->getPrimitiveSize() &&
+ "This is an illegal zero extension!");
+ C = ConstantExpr::getCast(C, C->getType()->getUnsignedVersion());
+ return ConstantExpr::getCast(C, Ty);
+}
+
Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
Constant *C1, Constant *C2) {
if (Opcode == Instruction::Shl || Opcode == Instruction::Shr)