new method
[oota-llvm.git] / include / llvm / Analysis / Expressions.h
index c21599f18e883589eb7b1cc9944040bc7a55a285..b04d787929e27db69f6f629532eade68206742dd 100644 (file)
@@ -1,60 +1,63 @@
-//===- llvm/Analysis/Expressions.h - Expression Analysis Utils ---*- C++ -*--=//
+//===- llvm/Analysis/Expressions.h - Expression Analysis Utils --*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
 //
 // This file defines a package of expression analysis utilties:
 //
-// ClassifyExpression: Analyze an expression to determine the complexity of the
-//   expression, and which other variables it depends on.  
-// 
+// ClassifyExpr: Analyze an expression to determine the complexity of the
+// expression, and which other variables it depends on.
+//
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_ANALYSIS_EXPRESSIONS_H
 #define LLVM_ANALYSIS_EXPRESSIONS_H
 
-#include <assert.h>
+namespace llvm {
+
+class Type;
 class Value;
-class ConstPoolInt;
-struct ExprAnalysisResult;
+class ConstantInt;
 
-// ClassifyExpression: Analyze an expression to determine the complexity of the
-// expression, and which other values it depends on.  
-//
-ExprAnalysisResult ClassifyExpression(Value *Expr);
+struct ExprType;
 
-// ExprAnalysisResult - Represent an expression of the form CONST*VAR+CONST
-// or simpler.  The expression form that yields the least information about the
-// expression is just the Linear form with no offset.
-//
-struct ExprAnalysisResult {
+/// ClassifyExpr - Analyze an expression to determine the complexity of the
+/// expression, and which other values it depends on.
+///
+ExprType ClassifyExpr(Value *Expr);
+
+/// ExprType Class - Represent an expression of the form CONST*VAR+CONST
+/// or simpler.  The expression form that yields the least information about the
+/// expression is just the Linear form with no offset.
+///
+struct ExprType {
   enum ExpressionType {
     Constant,            // Expr is a simple constant, Offset is value
     Linear,              // Expr is linear expr, Value is Var+Offset
     ScaledLinear,        // Expr is scaled linear exp, Value is Scale*Var+Offset
-  } ExprType;
+  } ExprTy;
 
-  const ConstPoolInt *Offset;  // Offset of expr, or null if 0
-  Value              *Var;     // Var referenced, if Linear or above (null if 0)
-  const ConstPoolInt *Scale;   // Scale of var if ScaledLinear expr (null if 1)
+  const ConstantInt *Offset;  // Offset of expr, or null if 0
+  Value             *Var;     // Var referenced, if Linear or above (null if 0)
+  const ConstantInt *Scale;   // Scale of var if ScaledLinear expr (null if 1)
 
-  inline ExprAnalysisResult(const ConstPoolInt *CPV = 0) {
+  inline ExprType(const ConstantInt *CPV = 0) {
     Offset = CPV; Var = 0; Scale = 0;
-    ExprType = Constant;
-  }
-  inline ExprAnalysisResult(Value *Val) {
-    Var = Val; Offset = Scale = 0;
-    ExprType = Var ? Linear : Constant;
+    ExprTy = Constant;
   }
-  inline ExprAnalysisResult(const ConstPoolInt *scale, Value *var, 
-                           const ConstPoolInt *offset) {
-    assert(!(Scale && !Var) && "Can't have scaled nonvariable!");
-    Scale = scale; Var = var; Offset = offset;
-    ExprType = Scale ? ScaledLinear : (Var ? Linear : Constant);
-  }
-
+  ExprType(Value *Val);        // Create a linear or constant expression
+  ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
 
-private:
-  friend ExprAnalysisResult ClassifyExpression(Value *);
-  inline ExprAnalysisResult operator+(const ConstPoolInt *Offset);
-  
+  /// If this expression has an intrinsic type, return it.  If it is zero,
+  /// return the specified type.
+  ///
+  const Type *getExprType(const Type *Default) const;
 };
 
+} // End llvm namespace
+
 #endif