mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-07 11:33:44 +00:00
Add convenience functions for creating nsw add operators.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78707 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8409bfbbc3
commit
d6474fa1f1
@ -636,6 +636,7 @@ public:
|
|||||||
static Constant *getIntToPtr(Constant *C, const Type *Ty);
|
static Constant *getIntToPtr(Constant *C, const Type *Ty);
|
||||||
static Constant *getBitCast (Constant *C, const Type *Ty);
|
static Constant *getBitCast (Constant *C, const Type *Ty);
|
||||||
|
|
||||||
|
static Constant* getNSWAdd(Constant* C1, Constant* C2);
|
||||||
static Constant* getExactSDiv(Constant* C1, Constant* C2);
|
static Constant* getExactSDiv(Constant* C1, Constant* C2);
|
||||||
|
|
||||||
/// Transparently provide more efficient getOperand methods.
|
/// Transparently provide more efficient getOperand methods.
|
||||||
|
@ -196,6 +196,27 @@ public:
|
|||||||
#include "llvm/Instruction.def"
|
#include "llvm/Instruction.def"
|
||||||
|
|
||||||
|
|
||||||
|
/// CreateNSWAdd - Create an Add operator with the NSW flag set.
|
||||||
|
///
|
||||||
|
static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2,
|
||||||
|
const Twine &Name = "") {
|
||||||
|
BinaryOperator *BO = CreateAdd(V1, V2, Name);
|
||||||
|
cast<AddOperator>(BO)->setHasNoSignedOverflow(true);
|
||||||
|
return BO;
|
||||||
|
}
|
||||||
|
static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2,
|
||||||
|
const Twine &Name, BasicBlock *BB) {
|
||||||
|
BinaryOperator *BO = CreateAdd(V1, V2, Name, BB);
|
||||||
|
cast<AddOperator>(BO)->setHasNoSignedOverflow(true);
|
||||||
|
return BO;
|
||||||
|
}
|
||||||
|
static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2,
|
||||||
|
const Twine &Name, Instruction *I) {
|
||||||
|
BinaryOperator *BO = CreateAdd(V1, V2, Name, I);
|
||||||
|
cast<AddOperator>(BO)->setHasNoSignedOverflow(true);
|
||||||
|
return BO;
|
||||||
|
}
|
||||||
|
|
||||||
/// CreateExactSDiv - Create an SDiv operator with the exact flag set.
|
/// CreateExactSDiv - Create an SDiv operator with the exact flag set.
|
||||||
///
|
///
|
||||||
static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2,
|
static BinaryOperator *CreateExactSDiv(Value *V1, Value *V2,
|
||||||
|
@ -35,6 +35,9 @@ public:
|
|||||||
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
|
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
|
||||||
return ConstantExpr::getAdd(LHS, RHS);
|
return ConstantExpr::getAdd(LHS, RHS);
|
||||||
}
|
}
|
||||||
|
Constant *CreateNSWAdd(Constant *LHS, Constant *RHS) const {
|
||||||
|
return ConstantExpr::getNSWAdd(LHS, RHS);
|
||||||
|
}
|
||||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||||
return ConstantExpr::getFAdd(LHS, RHS);
|
return ConstantExpr::getFAdd(LHS, RHS);
|
||||||
}
|
}
|
||||||
|
@ -199,6 +199,12 @@ public:
|
|||||||
return Folder.CreateAdd(LC, RC);
|
return Folder.CreateAdd(LC, RC);
|
||||||
return Insert(BinaryOperator::CreateAdd(LHS, RHS), Name);
|
return Insert(BinaryOperator::CreateAdd(LHS, RHS), Name);
|
||||||
}
|
}
|
||||||
|
Value *CreateNSWAdd(Value *LHS, Value *RHS, const char *Name = "") {
|
||||||
|
if (Constant *LC = dyn_cast<Constant>(LHS))
|
||||||
|
if (Constant *RC = dyn_cast<Constant>(RHS))
|
||||||
|
return Folder.CreateNSWAdd(LC, RC);
|
||||||
|
return Insert(BinaryOperator::CreateNSWAdd(LHS, RHS), Name);
|
||||||
|
}
|
||||||
Value *CreateFAdd(Value *LHS, Value *RHS, const char *Name = "") {
|
Value *CreateFAdd(Value *LHS, Value *RHS, const char *Name = "") {
|
||||||
if (Constant *LC = dyn_cast<Constant>(LHS))
|
if (Constant *LC = dyn_cast<Constant>(LHS))
|
||||||
if (Constant *RC = dyn_cast<Constant>(RHS))
|
if (Constant *RC = dyn_cast<Constant>(RHS))
|
||||||
|
@ -42,6 +42,9 @@ public:
|
|||||||
Value *CreateAdd(Constant *LHS, Constant *RHS) const {
|
Value *CreateAdd(Constant *LHS, Constant *RHS) const {
|
||||||
return BinaryOperator::CreateAdd(LHS, RHS);
|
return BinaryOperator::CreateAdd(LHS, RHS);
|
||||||
}
|
}
|
||||||
|
Value *CreateNSWAdd(Constant *LHS, Constant *RHS) const {
|
||||||
|
return BinaryOperator::CreateNSWAdd(LHS, RHS);
|
||||||
|
}
|
||||||
Value *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
Value *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||||
return BinaryOperator::CreateFAdd(LHS, RHS);
|
return BinaryOperator::CreateFAdd(LHS, RHS);
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,9 @@ public:
|
|||||||
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
|
Constant *CreateAdd(Constant *LHS, Constant *RHS) const {
|
||||||
return Fold(ConstantExpr::getAdd(LHS, RHS));
|
return Fold(ConstantExpr::getAdd(LHS, RHS));
|
||||||
}
|
}
|
||||||
|
Constant *CreateNSWAdd(Constant *LHS, Constant *RHS) const {
|
||||||
|
return Fold(ConstantExpr::getNSWAdd(LHS, RHS));
|
||||||
|
}
|
||||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||||
return Fold(ConstantExpr::getFAdd(LHS, RHS));
|
return Fold(ConstantExpr::getFAdd(LHS, RHS));
|
||||||
}
|
}
|
||||||
|
@ -605,6 +605,15 @@ Constant* ConstantVector::get(Constant* const* Vals, unsigned NumVals) {
|
|||||||
return get(std::vector<Constant*>(Vals, Vals+NumVals));
|
return get(std::vector<Constant*>(Vals, Vals+NumVals));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) {
|
||||||
|
Constant *C = getAdd(C1, C2);
|
||||||
|
// Set nsw attribute, assuming constant folding didn't eliminate the
|
||||||
|
// Add.
|
||||||
|
if (AddOperator *Add = dyn_cast<AddOperator>(C))
|
||||||
|
Add->setHasNoSignedOverflow(true);
|
||||||
|
return C;
|
||||||
|
}
|
||||||
|
|
||||||
Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) {
|
Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) {
|
||||||
Constant *C = getSDiv(C1, C2);
|
Constant *C = getSDiv(C1, C2);
|
||||||
// Set exact attribute, assuming constant folding didn't eliminate the
|
// Set exact attribute, assuming constant folding didn't eliminate the
|
||||||
|
Loading…
Reference in New Issue
Block a user