Move more functionality over to LLVMContext.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-07-13 23:50:59 +00:00
parent 47728a2819
commit 385396221b
4 changed files with 19 additions and 91 deletions

View File

@ -692,26 +692,8 @@ public:
/// ConstantExpr::get* - Return some common constants without having to /// ConstantExpr::get* - Return some common constants without having to
/// specify the full Instruction::OPCODE identifier. /// specify the full Instruction::OPCODE identifier.
/// ///
static Constant *getAdd(Constant *C1, Constant *C2);
static Constant *getFAdd(Constant *C1, Constant *C2);
static Constant *getSub(Constant *C1, Constant *C2);
static Constant *getFSub(Constant *C1, Constant *C2);
static Constant *getMul(Constant *C1, Constant *C2);
static Constant *getFMul(Constant *C1, Constant *C2);
static Constant *getUDiv(Constant *C1, Constant *C2);
static Constant *getSDiv(Constant *C1, Constant *C2);
static Constant *getFDiv(Constant *C1, Constant *C2);
static Constant *getURem(Constant *C1, Constant *C2); // unsigned rem
static Constant *getSRem(Constant *C1, Constant *C2); // signed rem
static Constant *getFRem(Constant *C1, Constant *C2);
static Constant *getAnd(Constant *C1, Constant *C2);
static Constant *getOr(Constant *C1, Constant *C2);
static Constant *getXor(Constant *C1, Constant *C2);
static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getICmp(unsigned short pred, Constant *LHS, Constant *RHS);
static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS); static Constant *getFCmp(unsigned short pred, Constant *LHS, Constant *RHS);
static Constant *getShl(Constant *C1, Constant *C2);
static Constant *getLShr(Constant *C1, Constant *C2);
static Constant *getAShr(Constant *C1, Constant *C2);
/// Getelementptr form. std::vector<Value*> is only accepted for convenience: /// Getelementptr form. std::vector<Value*> is only accepted for convenience:
/// all elements must be Constant's. /// all elements must be Constant's.

View File

@ -1722,7 +1722,7 @@ const SCEV *ScalarEvolution::getUDivExpr(const SCEV *LHS,
if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS)) { if (const SCEVConstant *LHSC = dyn_cast<SCEVConstant>(LHS)) {
Constant *LHSCV = LHSC->getValue(); Constant *LHSCV = LHSC->getValue();
Constant *RHSCV = RHSC->getValue(); Constant *RHSCV = RHSC->getValue();
return getConstant(cast<ConstantInt>(ConstantExpr::getUDiv(LHSCV, return getConstant(cast<ConstantInt>(Context->getConstantExprUDiv(LHSCV,
RHSCV))); RHSCV)));
} }
} }

View File

@ -754,65 +754,11 @@ const SmallVector<unsigned, 4> &ConstantExpr::getIndices() const {
return cast<InsertValueConstantExpr>(this)->Indices; return cast<InsertValueConstantExpr>(this)->Indices;
} }
Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2) {
return get(Instruction::Add, C1, C2);
}
Constant *ConstantExpr::getFAdd(Constant *C1, Constant *C2) {
return get(Instruction::FAdd, C1, C2);
}
Constant *ConstantExpr::getSub(Constant *C1, Constant *C2) {
return get(Instruction::Sub, C1, C2);
}
Constant *ConstantExpr::getFSub(Constant *C1, Constant *C2) {
return get(Instruction::FSub, C1, C2);
}
Constant *ConstantExpr::getMul(Constant *C1, Constant *C2) {
return get(Instruction::Mul, C1, C2);
}
Constant *ConstantExpr::getFMul(Constant *C1, Constant *C2) {
return get(Instruction::FMul, C1, C2);
}
Constant *ConstantExpr::getUDiv(Constant *C1, Constant *C2) {
return get(Instruction::UDiv, C1, C2);
}
Constant *ConstantExpr::getSDiv(Constant *C1, Constant *C2) {
return get(Instruction::SDiv, C1, C2);
}
Constant *ConstantExpr::getFDiv(Constant *C1, Constant *C2) {
return get(Instruction::FDiv, C1, C2);
}
Constant *ConstantExpr::getURem(Constant *C1, Constant *C2) {
return get(Instruction::URem, C1, C2);
}
Constant *ConstantExpr::getSRem(Constant *C1, Constant *C2) {
return get(Instruction::SRem, C1, C2);
}
Constant *ConstantExpr::getFRem(Constant *C1, Constant *C2) {
return get(Instruction::FRem, C1, C2);
}
Constant *ConstantExpr::getAnd(Constant *C1, Constant *C2) {
return get(Instruction::And, C1, C2);
}
Constant *ConstantExpr::getOr(Constant *C1, Constant *C2) {
return get(Instruction::Or, C1, C2);
}
Constant *ConstantExpr::getXor(Constant *C1, Constant *C2) {
return get(Instruction::Xor, C1, C2);
}
unsigned ConstantExpr::getPredicate() const { unsigned ConstantExpr::getPredicate() const {
assert(getOpcode() == Instruction::FCmp || assert(getOpcode() == Instruction::FCmp ||
getOpcode() == Instruction::ICmp); getOpcode() == Instruction::ICmp);
return ((const CompareConstantExpr*)this)->predicate; return ((const CompareConstantExpr*)this)->predicate;
} }
Constant *ConstantExpr::getShl(Constant *C1, Constant *C2) {
return get(Instruction::Shl, C1, C2);
}
Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2) {
return get(Instruction::LShr, C1, C2);
}
Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2) {
return get(Instruction::AShr, C1, C2);
}
/// getWithOperandReplaced - Return a constant expression identical to this /// getWithOperandReplaced - Return a constant expression identical to this
/// one, but with the specified operand set to the specified value. /// one, but with the specified operand set to the specified value.

View File

@ -293,63 +293,63 @@ Constant* LLVMContext::getConstantExprNot(Constant* C) {
} }
Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) {
return ConstantExpr::getAdd(C1, C2); return getConstantExpr(Instruction::Add, C1, C2);
} }
Constant* LLVMContext::getConstantExprFAdd(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprFAdd(Constant* C1, Constant* C2) {
return ConstantExpr::getFAdd(C1, C2); return getConstantExpr(Instruction::FAdd, C1, C2);
} }
Constant* LLVMContext::getConstantExprSub(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprSub(Constant* C1, Constant* C2) {
return ConstantExpr::getSub(C1, C2); return getConstantExpr(Instruction::Sub, C1, C2);
} }
Constant* LLVMContext::getConstantExprFSub(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprFSub(Constant* C1, Constant* C2) {
return ConstantExpr::getFSub(C1, C2); return getConstantExpr(Instruction::FSub, C1, C2);
} }
Constant* LLVMContext::getConstantExprMul(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprMul(Constant* C1, Constant* C2) {
return ConstantExpr::getMul(C1, C2); return getConstantExpr(Instruction::Mul, C1, C2);
} }
Constant* LLVMContext::getConstantExprFMul(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprFMul(Constant* C1, Constant* C2) {
return ConstantExpr::getFMul(C1, C2); return getConstantExpr(Instruction::FMul, C1, C2);
} }
Constant* LLVMContext::getConstantExprUDiv(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprUDiv(Constant* C1, Constant* C2) {
return ConstantExpr::getUDiv(C1, C2); return getConstantExpr(Instruction::UDiv, C1, C2);
} }
Constant* LLVMContext::getConstantExprSDiv(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprSDiv(Constant* C1, Constant* C2) {
return ConstantExpr::getSDiv(C1, C2); return getConstantExpr(Instruction::SDiv, C1, C2);
} }
Constant* LLVMContext::getConstantExprFDiv(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprFDiv(Constant* C1, Constant* C2) {
return ConstantExpr::getFDiv(C1, C2); return getConstantExpr(Instruction::FDiv, C1, C2);
} }
Constant* LLVMContext::getConstantExprURem(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprURem(Constant* C1, Constant* C2) {
return ConstantExpr::getURem(C1, C2); return getConstantExpr(Instruction::URem, C1, C2);
} }
Constant* LLVMContext::getConstantExprSRem(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprSRem(Constant* C1, Constant* C2) {
return ConstantExpr::getSRem(C1, C2); return getConstantExpr(Instruction::SRem, C1, C2);
} }
Constant* LLVMContext::getConstantExprFRem(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprFRem(Constant* C1, Constant* C2) {
return ConstantExpr::getFRem(C1, C2); return getConstantExpr(Instruction::FRem, C1, C2);
} }
Constant* LLVMContext::getConstantExprAnd(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprAnd(Constant* C1, Constant* C2) {
return ConstantExpr::getAnd(C1, C2); return getConstantExpr(Instruction::And, C1, C2);
} }
Constant* LLVMContext::getConstantExprOr(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprOr(Constant* C1, Constant* C2) {
return ConstantExpr::getOr(C1, C2); return getConstantExpr(Instruction::Or, C1, C2);
} }
Constant* LLVMContext::getConstantExprXor(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprXor(Constant* C1, Constant* C2) {
return ConstantExpr::getXor(C1, C2); return getConstantExpr(Instruction::Xor, C1, C2);
} }
Constant* LLVMContext::getConstantExprICmp(unsigned short pred, Constant* LHS, Constant* LLVMContext::getConstantExprICmp(unsigned short pred, Constant* LHS,
@ -363,15 +363,15 @@ Constant* LLVMContext::getConstantExprFCmp(unsigned short pred, Constant* LHS,
} }
Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprShl(Constant* C1, Constant* C2) {
return ConstantExpr::getShl(C1, C2); return getConstantExpr(Instruction::Shl, C1, C2);
} }
Constant* LLVMContext::getConstantExprLShr(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprLShr(Constant* C1, Constant* C2) {
return ConstantExpr::getLShr(C1, C2); return getConstantExpr(Instruction::LShr, C1, C2);
} }
Constant* LLVMContext::getConstantExprAShr(Constant* C1, Constant* C2) { Constant* LLVMContext::getConstantExprAShr(Constant* C1, Constant* C2) {
return ConstantExpr::getAShr(C1, C2); return getConstantExpr(Instruction::AShr, C1, C2);
} }
Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C, Constant* LLVMContext::getConstantExprGetElementPtr(Constant* C,