1 //===- llvm/Analysis/Expressions.h - Expression Analysis Utils ---*- C++ -*--=//
3 // This file defines a package of expression analysis utilties:
5 // ClassifyExpression: Analyze an expression to determine the complexity of the
6 // expression, and which other variables it depends on.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_ANALYSIS_EXPRESSIONS_H
11 #define LLVM_ANALYSIS_EXPRESSIONS_H
20 // ClassifyExpression: Analyze an expression to determine the complexity of the
21 // expression, and which other values it depends on.
23 ExprType ClassifyExpression(Value *Expr);
25 // ExprType - Represent an expression of the form CONST*VAR+CONST
26 // or simpler. The expression form that yields the least information about the
27 // expression is just the Linear form with no offset.
31 Constant, // Expr is a simple constant, Offset is value
32 Linear, // Expr is linear expr, Value is Var+Offset
33 ScaledLinear, // Expr is scaled linear exp, Value is Scale*Var+Offset
36 const ConstantInt *Offset; // Offset of expr, or null if 0
37 Value *Var; // Var referenced, if Linear or above (null if 0)
38 const ConstantInt *Scale; // Scale of var if ScaledLinear expr (null if 1)
40 inline ExprType(const ConstantInt *CPV = 0) {
41 Offset = CPV; Var = 0; Scale = 0;
44 ExprType(Value *Val); // Create a linear or constant expression
45 ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
47 // If this expression has an intrinsic type, return it. If it is zero, return
48 // the specified type.
50 const Type *getExprType(const Type *Default) const;