blob: 4d8897e7fffd2d7065328aa90fb49cd8f86183a6 [file] [log] [blame]
Chris Lattnercf3056d2003-10-13 03:32:08 +00001//===- Expressions.cpp - Expression Analysis Utilities --------------------===//
John Criswellb576c942003-10-20 19:43:21 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner369bbeb2001-07-20 19:17:55 +00009//
10// This file defines a package of expression analysis utilties:
11//
12// ClassifyExpression: Analyze an expression to determine the complexity of the
13// expression, and which other variables it depends on.
14//
15//===----------------------------------------------------------------------===//
16
17#include "llvm/Analysis/Expressions.h"
Chris Lattner968ddc92002-04-08 20:18:09 +000018#include "llvm/ConstantHandling.h"
Chris Lattnere590ff22002-03-26 17:55:33 +000019#include "llvm/Function.h"
Chris Lattner19f31f22001-07-21 19:07:19 +000020
Chris Lattner69f8ce02001-09-11 04:27:34 +000021ExprType::ExprType(Value *Val) {
Chris Lattner1d87bcf2001-10-01 20:11:19 +000022 if (Val)
Chris Lattnere9bb2df2001-12-03 22:26:30 +000023 if (ConstantInt *CPI = dyn_cast<ConstantInt>(Val)) {
Chris Lattner1d87bcf2001-10-01 20:11:19 +000024 Offset = CPI;
25 Var = 0;
26 ExprTy = Constant;
27 Scale = 0;
28 return;
29 }
30
31 Var = Val; Offset = 0;
32 ExprTy = Var ? Linear : Constant;
Chris Lattner69f8ce02001-09-11 04:27:34 +000033 Scale = 0;
34}
35
Chris Lattnere9bb2df2001-12-03 22:26:30 +000036ExprType::ExprType(const ConstantInt *scale, Value *var,
37 const ConstantInt *offset) {
Chris Lattner50020222001-11-26 18:53:07 +000038 Scale = var ? scale : 0; Var = var; Offset = offset;
Chris Lattner69f8ce02001-09-11 04:27:34 +000039 ExprTy = Scale ? ScaledLinear : (Var ? Linear : Constant);
Chris Lattnerce8a1492002-09-03 01:05:48 +000040 if (Scale && Scale->isNullValue()) { // Simplify 0*Var + const
Chris Lattner69f8ce02001-09-11 04:27:34 +000041 Scale = 0; Var = 0;
42 ExprTy = Constant;
43 }
44}
45
46
47const Type *ExprType::getExprType(const Type *Default) const {
48 if (Offset) return Offset->getType();
49 if (Scale) return Scale->getType();
50 return Var ? Var->getType() : Default;
51}
52
53
54
Chris Lattner19f31f22001-07-21 19:07:19 +000055class DefVal {
Chris Lattnere9bb2df2001-12-03 22:26:30 +000056 const ConstantInt * const Val;
Chris Lattner19f31f22001-07-21 19:07:19 +000057 const Type * const Ty;
58protected:
Chris Lattnere9bb2df2001-12-03 22:26:30 +000059 inline DefVal(const ConstantInt *val, const Type *ty) : Val(val), Ty(ty) {}
Chris Lattner19f31f22001-07-21 19:07:19 +000060public:
61 inline const Type *getType() const { return Ty; }
Chris Lattnere9bb2df2001-12-03 22:26:30 +000062 inline const ConstantInt *getVal() const { return Val; }
63 inline operator const ConstantInt * () const { return Val; }
64 inline const ConstantInt *operator->() const { return Val; }
Chris Lattner19f31f22001-07-21 19:07:19 +000065};
66
67struct DefZero : public DefVal {
Chris Lattnere9bb2df2001-12-03 22:26:30 +000068 inline DefZero(const ConstantInt *val, const Type *ty) : DefVal(val, ty) {}
69 inline DefZero(const ConstantInt *val) : DefVal(val, val->getType()) {}
Chris Lattner19f31f22001-07-21 19:07:19 +000070};
71
72struct DefOne : public DefVal {
Chris Lattnere9bb2df2001-12-03 22:26:30 +000073 inline DefOne(const ConstantInt *val, const Type *ty) : DefVal(val, ty) {}
Chris Lattner19f31f22001-07-21 19:07:19 +000074};
75
Chris Lattner369bbeb2001-07-20 19:17:55 +000076
Chris Lattner9b534262002-03-14 22:35:50 +000077// getUnsignedConstant - Return a constant value of the specified type. If the
78// constant value is not valid for the specified type, return null. This cannot
79// happen for values in the range of 0 to 127.
80//
Chris Lattnere9bb2df2001-12-03 22:26:30 +000081static ConstantInt *getUnsignedConstant(uint64_t V, const Type *Ty) {
Chris Lattner9b625032002-05-06 16:15:30 +000082 if (isa<PointerType>(Ty)) Ty = Type::ULongTy;
Chris Lattner9b534262002-03-14 22:35:50 +000083 if (Ty->isSigned()) {
84 // If this value is not a valid unsigned value for this type, return null!
85 if (V > 127 && ((int64_t)V < 0 ||
86 !ConstantSInt::isValueValidForType(Ty, (int64_t)V)))
87 return 0;
88 return ConstantSInt::get(Ty, V);
89 } else {
90 // If this value is not a valid unsigned value for this type, return null!
91 if (V > 255 && !ConstantUInt::isValueValidForType(Ty, V))
92 return 0;
93 return ConstantUInt::get(Ty, V);
94 }
Chris Lattner369bbeb2001-07-20 19:17:55 +000095}
96
Chris Lattner369bbeb2001-07-20 19:17:55 +000097// Add - Helper function to make later code simpler. Basically it just adds
98// the two constants together, inserts the result into the constant pool, and
99// returns it. Of course life is not simple, and this is no exception. Factors
100// that complicate matters:
101// 1. Either argument may be null. If this is the case, the null argument is
102// treated as either 0 (if DefOne = false) or 1 (if DefOne = true)
103// 2. Types get in the way. We want to do arithmetic operations without
104// regard for the underlying types. It is assumed that the constants are
105// integral constants. The new value takes the type of the left argument.
106// 3. If DefOne is true, a null return value indicates a value of 1, if DefOne
107// is false, a null return value indicates a value of 0.
108//
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000109static const ConstantInt *Add(const ConstantInt *Arg1,
110 const ConstantInt *Arg2, bool DefOne) {
Chris Lattner369bbeb2001-07-20 19:17:55 +0000111 assert(Arg1 && Arg2 && "No null arguments should exist now!");
Chris Lattner19f31f22001-07-21 19:07:19 +0000112 assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!");
Chris Lattner369bbeb2001-07-20 19:17:55 +0000113
114 // Actually perform the computation now!
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000115 Constant *Result = *Arg1 + *Arg2;
Chris Lattner19f31f22001-07-21 19:07:19 +0000116 assert(Result && Result->getType() == Arg1->getType() &&
117 "Couldn't perform addition!");
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000118 ConstantInt *ResultI = cast<ConstantInt>(Result);
Chris Lattner369bbeb2001-07-20 19:17:55 +0000119
120 // Check to see if the result is one of the special cases that we want to
121 // recognize...
Chris Lattner69f8ce02001-09-11 04:27:34 +0000122 if (ResultI->equalsInt(DefOne ? 1 : 0))
123 return 0; // Yes it is, simply return null.
Chris Lattner369bbeb2001-07-20 19:17:55 +0000124
Chris Lattner369bbeb2001-07-20 19:17:55 +0000125 return ResultI;
126}
127
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000128inline const ConstantInt *operator+(const DefZero &L, const DefZero &R) {
Chris Lattner19f31f22001-07-21 19:07:19 +0000129 if (L == 0) return R;
130 if (R == 0) return L;
Chris Lattner8e195e02001-09-07 16:31:04 +0000131 return Add(L, R, false);
Chris Lattner19f31f22001-07-21 19:07:19 +0000132}
Chris Lattner369bbeb2001-07-20 19:17:55 +0000133
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000134inline const ConstantInt *operator+(const DefOne &L, const DefOne &R) {
Chris Lattner19f31f22001-07-21 19:07:19 +0000135 if (L == 0) {
136 if (R == 0)
Chris Lattner69f8ce02001-09-11 04:27:34 +0000137 return getUnsignedConstant(2, L.getType());
Chris Lattner19f31f22001-07-21 19:07:19 +0000138 else
Chris Lattner69f8ce02001-09-11 04:27:34 +0000139 return Add(getUnsignedConstant(1, L.getType()), R, true);
Chris Lattner19f31f22001-07-21 19:07:19 +0000140 } else if (R == 0) {
Chris Lattner69f8ce02001-09-11 04:27:34 +0000141 return Add(L, getUnsignedConstant(1, L.getType()), true);
Chris Lattner19f31f22001-07-21 19:07:19 +0000142 }
Chris Lattner8e195e02001-09-07 16:31:04 +0000143 return Add(L, R, true);
Chris Lattner369bbeb2001-07-20 19:17:55 +0000144}
145
146
Chris Lattner19f31f22001-07-21 19:07:19 +0000147// Mul - Helper function to make later code simpler. Basically it just
Chris Lattner369bbeb2001-07-20 19:17:55 +0000148// multiplies the two constants together, inserts the result into the constant
149// pool, and returns it. Of course life is not simple, and this is no
150// exception. Factors that complicate matters:
151// 1. Either argument may be null. If this is the case, the null argument is
152// treated as either 0 (if DefOne = false) or 1 (if DefOne = true)
153// 2. Types get in the way. We want to do arithmetic operations without
154// regard for the underlying types. It is assumed that the constants are
155// integral constants.
156// 3. If DefOne is true, a null return value indicates a value of 1, if DefOne
157// is false, a null return value indicates a value of 0.
158//
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000159inline const ConstantInt *Mul(const ConstantInt *Arg1,
160 const ConstantInt *Arg2, bool DefOne) {
Chris Lattner369bbeb2001-07-20 19:17:55 +0000161 assert(Arg1 && Arg2 && "No null arguments should exist now!");
Chris Lattner19f31f22001-07-21 19:07:19 +0000162 assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!");
Chris Lattner369bbeb2001-07-20 19:17:55 +0000163
164 // Actually perform the computation now!
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000165 Constant *Result = *Arg1 * *Arg2;
Chris Lattner19f31f22001-07-21 19:07:19 +0000166 assert(Result && Result->getType() == Arg1->getType() &&
Chris Lattner50020222001-11-26 18:53:07 +0000167 "Couldn't perform multiplication!");
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000168 ConstantInt *ResultI = cast<ConstantInt>(Result);
Chris Lattner369bbeb2001-07-20 19:17:55 +0000169
170 // Check to see if the result is one of the special cases that we want to
171 // recognize...
Chris Lattner69f8ce02001-09-11 04:27:34 +0000172 if (ResultI->equalsInt(DefOne ? 1 : 0))
173 return 0; // Yes it is, simply return null.
Chris Lattner369bbeb2001-07-20 19:17:55 +0000174
Chris Lattner369bbeb2001-07-20 19:17:55 +0000175 return ResultI;
176}
177
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000178inline const ConstantInt *operator*(const DefZero &L, const DefZero &R) {
Chris Lattner19f31f22001-07-21 19:07:19 +0000179 if (L == 0 || R == 0) return 0;
Chris Lattner8e195e02001-09-07 16:31:04 +0000180 return Mul(L, R, false);
Chris Lattner19f31f22001-07-21 19:07:19 +0000181}
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000182inline const ConstantInt *operator*(const DefOne &L, const DefZero &R) {
Chris Lattner69f8ce02001-09-11 04:27:34 +0000183 if (R == 0) return getUnsignedConstant(0, L.getType());
Chris Lattner19f31f22001-07-21 19:07:19 +0000184 if (L == 0) return R->equalsInt(1) ? 0 : R.getVal();
Chris Lattner50020222001-11-26 18:53:07 +0000185 return Mul(L, R, true);
Chris Lattner19f31f22001-07-21 19:07:19 +0000186}
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000187inline const ConstantInt *operator*(const DefZero &L, const DefOne &R) {
Chris Lattner50020222001-11-26 18:53:07 +0000188 if (L == 0 || R == 0) return L.getVal();
189 return Mul(R, L, false);
Chris Lattner19f31f22001-07-21 19:07:19 +0000190}
191
Chris Lattner69f8ce02001-09-11 04:27:34 +0000192// handleAddition - Add two expressions together, creating a new expression that
193// represents the composite of the two...
194//
195static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) {
196 const Type *Ty = V->getType();
197 if (Left.ExprTy > Right.ExprTy)
Chris Lattner697954c2002-01-20 22:54:45 +0000198 std::swap(Left, Right); // Make left be simpler than right
Chris Lattner69f8ce02001-09-11 04:27:34 +0000199
200 switch (Left.ExprTy) {
201 case ExprType::Constant:
Chris Lattner50020222001-11-26 18:53:07 +0000202 return ExprType(Right.Scale, Right.Var,
203 DefZero(Right.Offset, Ty) + DefZero(Left.Offset, Ty));
Chris Lattner69f8ce02001-09-11 04:27:34 +0000204 case ExprType::Linear: // RHS side must be linear or scaled
205 case ExprType::ScaledLinear: // RHS must be scaled
206 if (Left.Var != Right.Var) // Are they the same variables?
Chris Lattner50020222001-11-26 18:53:07 +0000207 return V; // if not, we don't know anything!
Chris Lattner69f8ce02001-09-11 04:27:34 +0000208
209 return ExprType(DefOne(Left.Scale , Ty) + DefOne(Right.Scale , Ty),
Chris Lattner50020222001-11-26 18:53:07 +0000210 Right.Var,
Chris Lattner69f8ce02001-09-11 04:27:34 +0000211 DefZero(Left.Offset, Ty) + DefZero(Right.Offset, Ty));
212 default:
213 assert(0 && "Dont' know how to handle this case!");
214 return ExprType();
215 }
216}
217
218// negate - Negate the value of the specified expression...
219//
220static inline ExprType negate(const ExprType &E, Value *V) {
221 const Type *Ty = V->getType();
Chris Lattnercb05e782002-03-11 20:50:24 +0000222 ConstantInt *Zero = getUnsignedConstant(0, Ty);
223 ConstantInt *One = getUnsignedConstant(1, Ty);
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000224 ConstantInt *NegOne = cast<ConstantInt>(*Zero - *One);
Chris Lattner69f8ce02001-09-11 04:27:34 +0000225 if (NegOne == 0) return V; // Couldn't subtract values...
226
227 return ExprType(DefOne (E.Scale , Ty) * NegOne, E.Var,
228 DefZero(E.Offset, Ty) * NegOne);
229}
Chris Lattner19f31f22001-07-21 19:07:19 +0000230
Chris Lattner369bbeb2001-07-20 19:17:55 +0000231
232// ClassifyExpression: Analyze an expression to determine the complexity of the
233// expression, and which other values it depends on.
234//
235// Note that this analysis cannot get into infinite loops because it treats PHI
236// nodes as being an unknown linear expression.
237//
Chris Lattnerc74cb862002-08-30 22:53:53 +0000238ExprType ClassifyExpression(Value *Expr) {
Chris Lattner369bbeb2001-07-20 19:17:55 +0000239 assert(Expr != 0 && "Can't classify a null expression!");
Chris Lattner0da29c82001-12-05 19:38:29 +0000240 if (Expr->getType() == Type::FloatTy || Expr->getType() == Type::DoubleTy)
241 return Expr; // FIXME: Can't handle FP expressions
242
Chris Lattner369bbeb2001-07-20 19:17:55 +0000243 switch (Expr->getValueType()) {
244 case Value::InstructionVal: break; // Instruction... hmmm... investigate.
245 case Value::TypeVal: case Value::BasicBlockVal:
Chris Lattner96d0f302002-04-28 04:50:00 +0000246 case Value::FunctionVal: default:
Chris Lattner481fafe2001-12-13 00:45:06 +0000247 //assert(0 && "Unexpected expression type to classify!");
Chris Lattner697954c2002-01-20 22:54:45 +0000248 std::cerr << "Bizarre thing to expr classify: " << Expr << "\n";
Chris Lattner481fafe2001-12-13 00:45:06 +0000249 return Expr;
Chris Lattnere590ff22002-03-26 17:55:33 +0000250 case Value::GlobalVariableVal: // Global Variable & Function argument:
Chris Lattner73e21422002-04-09 19:48:49 +0000251 case Value::ArgumentVal: // nothing known, return variable itself
Chris Lattner369bbeb2001-07-20 19:17:55 +0000252 return Expr;
253 case Value::ConstantVal: // Constant value, just return constant
Chris Lattnerac7ad682003-04-16 22:50:19 +0000254 if (ConstantInt *CPI = dyn_cast<ConstantInt>(cast<Constant>(Expr)))
255 // It's an integral constant!
Chris Lattnerce8a1492002-09-03 01:05:48 +0000256 return ExprType(CPI->isNullValue() ? 0 : CPI);
Chris Lattner369bbeb2001-07-20 19:17:55 +0000257 return Expr;
258 }
259
Chris Lattner9636a912001-10-01 16:18:37 +0000260 Instruction *I = cast<Instruction>(Expr);
Chris Lattner19f31f22001-07-21 19:07:19 +0000261 const Type *Ty = I->getType();
Chris Lattner369bbeb2001-07-20 19:17:55 +0000262
Misha Brukman1ba31382003-07-14 17:26:34 +0000263 switch (I->getOpcode()) { // Handle each instruction type separately
Chris Lattner369bbeb2001-07-20 19:17:55 +0000264 case Instruction::Add: {
Chris Lattner19f31f22001-07-21 19:07:19 +0000265 ExprType Left (ClassifyExpression(I->getOperand(0)));
266 ExprType Right(ClassifyExpression(I->getOperand(1)));
Chris Lattner69f8ce02001-09-11 04:27:34 +0000267 return handleAddition(Left, Right, I);
Chris Lattner369bbeb2001-07-20 19:17:55 +0000268 } // end case Instruction::Add
269
Chris Lattner69f8ce02001-09-11 04:27:34 +0000270 case Instruction::Sub: {
271 ExprType Left (ClassifyExpression(I->getOperand(0)));
272 ExprType Right(ClassifyExpression(I->getOperand(1)));
Chris Lattner50020222001-11-26 18:53:07 +0000273 ExprType RightNeg = negate(Right, I);
274 if (RightNeg.Var == I && !RightNeg.Offset && !RightNeg.Scale)
275 return I; // Could not negate value...
276 return handleAddition(Left, RightNeg, I);
Chris Lattner69f8ce02001-09-11 04:27:34 +0000277 } // end case Instruction::Sub
278
Chris Lattner369bbeb2001-07-20 19:17:55 +0000279 case Instruction::Shl: {
Chris Lattner19f31f22001-07-21 19:07:19 +0000280 ExprType Right(ClassifyExpression(I->getOperand(1)));
281 if (Right.ExprTy != ExprType::Constant) break;
282 ExprType Left(ClassifyExpression(I->getOperand(0)));
283 if (Right.Offset == 0) return Left; // shl x, 0 = x
284 assert(Right.Offset->getType() == Type::UByteTy &&
Chris Lattner369bbeb2001-07-20 19:17:55 +0000285 "Shift amount must always be a unsigned byte!");
Chris Lattner28a128e2003-07-23 15:16:40 +0000286 uint64_t ShiftAmount = cast<ConstantUInt>(Right.Offset)->getValue();
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000287 ConstantInt *Multiplier = getUnsignedConstant(1ULL << ShiftAmount, Ty);
Chris Lattner9b534262002-03-14 22:35:50 +0000288
289 // We don't know how to classify it if they are shifting by more than what
290 // is reasonable. In most cases, the result will be zero, but there is one
291 // class of cases where it is not, so we cannot optimize without checking
292 // for it. The case is when you are shifting a signed value by 1 less than
293 // the number of bits in the value. For example:
294 // %X = shl sbyte %Y, ubyte 7
295 // will try to form an sbyte multiplier of 128, which will give a null
296 // multiplier, even though the result is not 0. Until we can check for this
297 // case, be conservative. TODO.
298 //
299 if (Multiplier == 0)
300 return Expr;
301
Chris Lattner8e195e02001-09-07 16:31:04 +0000302 return ExprType(DefOne(Left.Scale, Ty) * Multiplier, Left.Var,
303 DefZero(Left.Offset, Ty) * Multiplier);
Chris Lattner369bbeb2001-07-20 19:17:55 +0000304 } // end case Instruction::Shl
305
Chris Lattner19f31f22001-07-21 19:07:19 +0000306 case Instruction::Mul: {
307 ExprType Left (ClassifyExpression(I->getOperand(0)));
308 ExprType Right(ClassifyExpression(I->getOperand(1)));
309 if (Left.ExprTy > Right.ExprTy)
Chris Lattner697954c2002-01-20 22:54:45 +0000310 std::swap(Left, Right); // Make left be simpler than right
Chris Lattner19f31f22001-07-21 19:07:19 +0000311
312 if (Left.ExprTy != ExprType::Constant) // RHS must be > constant
313 return I; // Quadratic eqn! :(
314
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000315 const ConstantInt *Offs = Left.Offset;
Chris Lattner19f31f22001-07-21 19:07:19 +0000316 if (Offs == 0) return ExprType();
Chris Lattner8e195e02001-09-07 16:31:04 +0000317 return ExprType( DefOne(Right.Scale , Ty) * Offs, Right.Var,
318 DefZero(Right.Offset, Ty) * Offs);
Chris Lattner19f31f22001-07-21 19:07:19 +0000319 } // end case Instruction::Mul
320
321 case Instruction::Cast: {
322 ExprType Src(ClassifyExpression(I->getOperand(0)));
Chris Lattner69f8ce02001-09-11 04:27:34 +0000323 const Type *DestTy = I->getType();
Chris Lattner9b625032002-05-06 16:15:30 +0000324 if (isa<PointerType>(DestTy))
Chris Lattner69f8ce02001-09-11 04:27:34 +0000325 DestTy = Type::ULongTy; // Pointer types are represented as ulong
Chris Lattner19f31f22001-07-21 19:07:19 +0000326
Chris Lattner5fd60912003-07-01 21:08:52 +0000327 const Type *SrcValTy = Src.getExprType(0);
328 if (!SrcValTy) return I;
329 if (!SrcValTy->isLosslesslyConvertibleTo(DestTy)) {
Chris Lattner882572a2001-11-26 16:53:50 +0000330 if (Src.ExprTy != ExprType::Constant)
331 return I; // Converting cast, and not a constant value...
332 }
Chris Lattner19f31f22001-07-21 19:07:19 +0000333
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000334 const ConstantInt *Offset = Src.Offset;
335 const ConstantInt *Scale = Src.Scale;
Chris Lattner882572a2001-11-26 16:53:50 +0000336 if (Offset) {
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000337 const Constant *CPV = ConstantFoldCastInstruction(Offset, DestTy);
Chris Lattner882572a2001-11-26 16:53:50 +0000338 if (!CPV) return I;
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000339 Offset = cast<ConstantInt>(CPV);
Chris Lattner882572a2001-11-26 16:53:50 +0000340 }
341 if (Scale) {
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000342 const Constant *CPV = ConstantFoldCastInstruction(Scale, DestTy);
Chris Lattner882572a2001-11-26 16:53:50 +0000343 if (!CPV) return I;
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000344 Scale = cast<ConstantInt>(CPV);
Chris Lattner882572a2001-11-26 16:53:50 +0000345 }
346 return ExprType(Scale, Src.Var, Offset);
Chris Lattner19f31f22001-07-21 19:07:19 +0000347 } // end case Instruction::Cast
Chris Lattner793d6782001-07-25 22:47:32 +0000348 // TODO: Handle SUB, SHR?
Chris Lattner369bbeb2001-07-20 19:17:55 +0000349
350 } // end switch
351
352 // Otherwise, I don't know anything about this value!
Chris Lattner19f31f22001-07-21 19:07:19 +0000353 return I;
Chris Lattner369bbeb2001-07-20 19:17:55 +0000354}