Add a NullFolder class that doesn't fold constants.

This may be used as the second IRBuilder template
parameter, the idea being that people learning LLVM
may find it helpful (several people asked on IRC
if it was possible to turn off constant folding
because it made it hard for them to see what was
going on).  Compiles, but otherwise completely
untested.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54698 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2008-08-12 20:39:27 +00:00
parent 3837218ea0
commit fe24bd3a89
4 changed files with 210 additions and 8 deletions

View File

@ -493,14 +493,14 @@ public:
const char *Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateCompare(P, LC, RC);
return Folder.CreateICmp(P, LC, RC);
return Insert(new ICmpInst(P, LHS, RHS), Name);
}
Value *CreateFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateCompare(P, LC, RC);
return Folder.CreateFCmp(P, LC, RC);
return Insert(new FCmpInst(P, LHS, RHS), Name);
}
@ -508,14 +508,14 @@ public:
const char *Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateCompare(P, LC, RC);
return Folder.CreateVICmp(P, LC, RC);
return Insert(new VICmpInst(P, LHS, RHS), Name);
}
Value *CreateVFCmp(CmpInst::Predicate P, Value *LHS, Value *RHS,
const char *Name = "") {
if (Constant *LC = dyn_cast<Constant>(LHS))
if (Constant *RC = dyn_cast<Constant>(RHS))
return Folder.CreateCompare(P, LC, RC);
return Folder.CreateVFCmp(P, LC, RC);
return Insert(new VFCmpInst(P, LHS, RHS), Name);
}