}
Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
- Constant *C1, Constant *C2, unsigned short pred) {
+ Constant *C1, Constant *C2) {
if (Opcode == Instruction::Shl || Opcode == Instruction::LShr ||
Opcode == Instruction::AShr)
return getShiftTy(ReqTy, Opcode, C1, C2);
- if (Opcode == Instruction::ICmp)
- return getICmp(pred, C1, C2);
- if (Opcode == Instruction::FCmp)
- return getFCmp(pred, C1, C2);
// Check the operands for consistency first
assert(Opcode >= Instruction::BinaryOpsBegin &&
return FC; // Fold a few common cases...
std::vector<Constant*> argVec(1, C1); argVec.push_back(C2);
- ExprMapKeyType Key(Opcode, argVec, pred);
+ ExprMapKeyType Key(Opcode, argVec);
return ExprConstants->getOrCreate(ReqTy, Key);
}
-Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2, unsigned short pred) {
+Constant *ConstantExpr::getCompareTy(unsigned Opcode, unsigned short predicate,
+ Constant *C1, Constant *C2) {
+ if (Opcode == Instruction::ICmp)
+ return getICmp(predicate, C1, C2);
+ return getFCmp(predicate, C1, C2);
+}
+
+Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
#ifndef NDEBUG
switch (Opcode) {
case Instruction::Add:
case Instruction::SetGE: case Instruction::SetEQ: case Instruction::SetNE:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
break;
- case Instruction::FCmp:
- case Instruction::ICmp:
- assert(C1->getType() == C2->getType() && "Op types should be identical!");
- break;
case Instruction::Shl:
case Instruction::LShr:
case Instruction::AShr:
}
#endif
- if (Instruction::isComparison(Opcode))
- return getTy(Type::BoolTy, Opcode, C1, C2, pred);
- else
- return getTy(C1->getType(), Opcode, C1, C2, pred);
+ return getTy(C1->getType(), Opcode, C1, C2);
+}
+
+Constant *ConstantExpr::getCompare(unsigned Opcode, unsigned short pred,
+ Constant *C1, Constant *C2) {
+ assert(C1->getType() == C2->getType() && "Op types should be identical!");
+ return getCompareTy(Opcode, pred, C1, C2);
}
Constant *ConstantExpr::getSelectTy(const Type *ReqTy, Constant *C,
return ExprConstants->getOrCreate(ReqTy, Key);
}
-
Constant *ConstantExpr::getGetElementPtrTy(const Type *ReqTy, Constant *C,
const std::vector<Value*> &IdxList) {
assert(GetElementPtrInst::getIndexedType(C->getType(), IdxList, true) &&