Expand the pass to unify all of the unwind blocks as well
[oota-llvm.git] / include / llvm / Analysis / Expressions.h
1 //===- llvm/Analysis/Expressions.h - Expression Analysis Utils ---*- C++ -*--=//
2 //
3 // This file defines a package of expression analysis utilties:
4 //
5 // ClassifyExpression: Analyze an expression to determine the complexity of the
6 //   expression, and which other variables it depends on.  
7 // 
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_ANALYSIS_EXPRESSIONS_H
11 #define LLVM_ANALYSIS_EXPRESSIONS_H
12
13 class Type;
14 class Value;
15 class ConstantInt;
16
17 struct ExprType;
18
19 // ClassifyExpression: Analyze an expression to determine the complexity of the
20 // expression, and which other values it depends on.  
21 //
22 ExprType ClassifyExpression(Value *Expr);
23
24 // ExprType - Represent an expression of the form CONST*VAR+CONST
25 // or simpler.  The expression form that yields the least information about the
26 // expression is just the Linear form with no offset.
27 //
28 struct ExprType {
29   enum ExpressionType {
30     Constant,            // Expr is a simple constant, Offset is value
31     Linear,              // Expr is linear expr, Value is Var+Offset
32     ScaledLinear,        // Expr is scaled linear exp, Value is Scale*Var+Offset
33   } ExprTy;
34
35   const ConstantInt *Offset;  // Offset of expr, or null if 0
36   Value             *Var;     // Var referenced, if Linear or above (null if 0)
37   const ConstantInt *Scale;   // Scale of var if ScaledLinear expr (null if 1)
38
39   inline ExprType(const ConstantInt *CPV = 0) {
40     Offset = CPV; Var = 0; Scale = 0;
41     ExprTy = Constant;
42   }
43   ExprType(Value *Val);        // Create a linear or constant expression
44   ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
45
46   // If this expression has an intrinsic type, return it.  If it is zero, return
47   // the specified type.
48   //
49   const Type *getExprType(const Type *Default) const;
50 };
51
52 #endif