Put all LLVM code into the llvm namespace, as per bug 109.
[oota-llvm.git] / include / llvm / Analysis / Expressions.h
1 //===- llvm/Analysis/Expressions.h - Expression Analysis Utils --*- C++ -*-===//
2 // 
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 //===----------------------------------------------------------------------===//
9 //
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 #ifndef LLVM_ANALYSIS_EXPRESSIONS_H
18 #define LLVM_ANALYSIS_EXPRESSIONS_H
19
20 namespace llvm {
21
22 class Type;
23 class Value;
24 class ConstantInt;
25
26 struct ExprType;
27
28 // ClassifyExpression: Analyze an expression to determine the complexity of the
29 // expression, and which other values it depends on.  
30 //
31 ExprType ClassifyExpression(Value *Expr);
32
33 // ExprType - Represent an expression of the form CONST*VAR+CONST
34 // or simpler.  The expression form that yields the least information about the
35 // expression is just the Linear form with no offset.
36 //
37 struct ExprType {
38   enum ExpressionType {
39     Constant,            // Expr is a simple constant, Offset is value
40     Linear,              // Expr is linear expr, Value is Var+Offset
41     ScaledLinear,        // Expr is scaled linear exp, Value is Scale*Var+Offset
42   } ExprTy;
43
44   const ConstantInt *Offset;  // Offset of expr, or null if 0
45   Value             *Var;     // Var referenced, if Linear or above (null if 0)
46   const ConstantInt *Scale;   // Scale of var if ScaledLinear expr (null if 1)
47
48   inline ExprType(const ConstantInt *CPV = 0) {
49     Offset = CPV; Var = 0; Scale = 0;
50     ExprTy = Constant;
51   }
52   ExprType(Value *Val);        // Create a linear or constant expression
53   ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
54
55   // If this expression has an intrinsic type, return it.  If it is zero, return
56   // the specified type.
57   //
58   const Type *getExprType(const Type *Default) const;
59 };
60
61 } // End llvm namespace
62
63 #endif