Add IRBuilder methods for creating an exact udiv, like for exact sdiv.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125002 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands 2011-02-07 09:21:52 +00:00
parent cf9efa5966
commit 1dbf0df996
6 changed files with 37 additions and 1 deletions

View File

@ -321,6 +321,27 @@ public:
return BO;
}
/// CreateExactUDiv - Create a UDiv operator with the exact flag set.
///
static BinaryOperator *CreateExactUDiv(Value *V1, Value *V2,
const Twine &Name = "") {
BinaryOperator *BO = CreateUDiv(V1, V2, Name);
BO->setIsExact(true);
return BO;
}
static BinaryOperator *CreateExactUDiv(Value *V1, Value *V2,
const Twine &Name, BasicBlock *BB) {
BinaryOperator *BO = CreateUDiv(V1, V2, Name, BB);
BO->setIsExact(true);
return BO;
}
static BinaryOperator *CreateExactUDiv(Value *V1, Value *V2,
const Twine &Name, Instruction *I) {
BinaryOperator *BO = CreateUDiv(V1, V2, Name, I);
BO->setIsExact(true);
return BO;
}
/// CreateExactSDiv - Create an SDiv operator with the exact flag set.
///
static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2,

View File

@ -228,7 +228,7 @@ public:
}
};
/// UDivOperator - An Operator with opcode Instruction::SDiv.
/// UDivOperator - An Operator with opcode Instruction::UDiv.
///
class UDivOperator : public PossiblyExactOperator {
public:

View File

@ -72,6 +72,9 @@ public:
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getUDiv(LHS, RHS);
}
Constant *CreateExactUDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getExactUDiv(LHS, RHS);
}
Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
return ConstantExpr::getSDiv(LHS, RHS);
}

View File

@ -527,6 +527,12 @@ public:
return Insert(Folder.CreateUDiv(LC, RC), Name);
return Insert(BinaryOperator::CreateUDiv(LHS, RHS), Name);
}
Value *CreateExactUDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Insert(Folder.CreateExactUDiv(LC, RC), Name);
return Insert(BinaryOperator::CreateExactUDiv(LHS, RHS), Name);
}
Value *CreateSDiv(Value *LHS, Value *RHS, const Twine &Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))

View File

@ -77,6 +77,9 @@ public:
Instruction *CreateUDiv(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateUDiv(LHS, RHS);
}
Instruction *CreateExactUDiv(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateExactUDiv(LHS, RHS);
}
Instruction *CreateSDiv(Constant *LHS, Constant *RHS) const {
return BinaryOperator::CreateSDiv(LHS, RHS);
}

View File

@ -85,6 +85,9 @@ public:
Constant *CreateUDiv(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getUDiv(LHS, RHS));
}
Constant *CreateExactUDiv(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getExactUDiv(LHS, RHS));
}
Constant *CreateSDiv(Constant *LHS, Constant *RHS) const {
return Fold(ConstantExpr::getSDiv(LHS, RHS));
}