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
21 // ClassifyExpression: Analyze an expression to determine the complexity of the
22 // expression, and which other values it depends on.
24 ExprType ClassifyExpression(Value *Expr);
26 // ExprType - Represent an expression of the form CONST*VAR+CONST
27 // or simpler. The expression form that yields the least information about the
28 // expression is just the Linear form with no offset.
32 Constant, // Expr is a simple constant, Offset is value
33 Linear, // Expr is linear expr, Value is Var+Offset
34 ScaledLinear, // Expr is scaled linear exp, Value is Scale*Var+Offset
37 const ConstPoolInt *Offset; // Offset of expr, or null if 0
38 Value *Var; // Var referenced, if Linear or above (null if 0)
39 const ConstPoolInt *Scale; // Scale of var if ScaledLinear expr (null if 1)
41 inline ExprType(const ConstPoolInt *CPV = 0) {
42 Offset = CPV; Var = 0; Scale = 0;
45 inline ExprType(Value *Val) {
46 Var = Val; Offset = Scale = 0;
47 ExprTy = Var ? Linear : Constant;
49 inline ExprType(const ConstPoolInt *scale, Value *var,
50 const ConstPoolInt *offset) {
51 Scale = scale; Var = var; Offset = offset;
52 ExprTy = Scale ? ScaledLinear : (Var ? Linear : Constant);
56 } // End namespace analysis