[llvm-commits] CVS: llvm/lib/Analysis/Expressions.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon Jan 12 12:03:01 PST 2004
Changes in directory llvm/lib/Analysis:
Expressions.cpp updated: 1.40 -> 1.41
---
Log message:
Remove use of ConstantHandling itf
---
Diffs of the changes: (+11 -9)
Index: llvm/lib/Analysis/Expressions.cpp
diff -u llvm/lib/Analysis/Expressions.cpp:1.40 llvm/lib/Analysis/Expressions.cpp:1.41
--- llvm/lib/Analysis/Expressions.cpp:1.40 Tue Dec 23 02:04:02 2003
+++ llvm/lib/Analysis/Expressions.cpp Mon Jan 12 12:02:15 2004
@@ -15,8 +15,9 @@
//===----------------------------------------------------------------------===//
#include "llvm/Analysis/Expressions.h"
-#include "llvm/ConstantHandling.h"
+#include "llvm/Constants.h"
#include "llvm/Function.h"
+#include "llvm/Type.h"
using namespace llvm;
ExprType::ExprType(Value *Val) {
@@ -114,9 +115,8 @@
assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!");
// Actually perform the computation now!
- Constant *Result = *Arg1 + *Arg2;
- assert(Result && Result->getType() == Arg1->getType() &&
- "Couldn't perform addition!");
+ Constant *Result = ConstantExpr::get(Instruction::Add, (Constant*)Arg1,
+ (Constant*)Arg2);
ConstantInt *ResultI = cast<ConstantInt>(Result);
// Check to see if the result is one of the special cases that we want to
@@ -164,7 +164,8 @@
assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!");
// Actually perform the computation now!
- Constant *Result = *Arg1 * *Arg2;
+ Constant *Result = ConstantExpr::get(Instruction::Mul, (Constant*)Arg1,
+ (Constant*)Arg2);
assert(Result && Result->getType() == Arg1->getType() &&
"Couldn't perform multiplication!");
ConstantInt *ResultI = cast<ConstantInt>(Result);
@@ -225,7 +226,8 @@
const Type *Ty = V->getType();
ConstantInt *Zero = getUnsignedConstant(0, Ty);
ConstantInt *One = getUnsignedConstant(1, Ty);
- ConstantInt *NegOne = cast<ConstantInt>(*Zero - *One);
+ ConstantInt *NegOne = cast<ConstantInt>(ConstantExpr::get(Instruction::Sub,
+ Zero, One));
if (NegOne == 0) return V; // Couldn't subtract values...
return ExprType(DefOne (E.Scale , Ty) * NegOne, E.Var,
@@ -338,12 +340,12 @@
const ConstantInt *Offset = Src.Offset;
const ConstantInt *Scale = Src.Scale;
if (Offset) {
- const Constant *CPV = ConstantFoldCastInstruction(Offset, DestTy);
- if (!CPV) return I;
+ const Constant *CPV = ConstantExpr::getCast((Constant*)Offset, DestTy);
+ if (!isa<ConstantInt>(CPV)) return I;
Offset = cast<ConstantInt>(CPV);
}
if (Scale) {
- const Constant *CPV = ConstantFoldCastInstruction(Scale, DestTy);
+ const Constant *CPV = ConstantExpr::getCast((Constant*)Scale, DestTy);
if (!CPV) return I;
Scale = cast<ConstantInt>(CPV);
}
More information about the llvm-commits
mailing list