1 //===- llvm/Analysis/Expressions.h - Expression Analysis Utils --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file defines a package of expression analysis utilties:
12 // ClassifyExpr: Analyze an expression to determine the complexity of the
13 // expression, and which other variables it depends on.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_ANALYSIS_EXPRESSIONS_H
18 #define LLVM_ANALYSIS_EXPRESSIONS_H
28 /// ClassifyExpr - Analyze an expression to determine the complexity of the
29 /// expression, and which other values it depends on.
31 ExprType ClassifyExpr(Value *Expr);
33 /// ExprType Class - 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.
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
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)
48 inline ExprType(const ConstantInt *CPV = 0) {
49 Offset = CPV; Var = 0; Scale = 0;
52 ExprType(Value *Val); // Create a linear or constant expression
53 ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
55 /// If this expression has an intrinsic type, return it. If it is zero,
56 /// return the specified type.
58 const Type *getExprType(const Type *Default) const;
61 } // End llvm namespace