2001-07-20 19:17:55 +00:00
|
|
|
//===- llvm/Analysis/Expressions.h - Expression Analysis Utils ---*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_EXPRESSIONS_H
|
|
|
|
#define LLVM_ANALYSIS_EXPRESSIONS_H
|
|
|
|
|
2001-09-11 04:27:34 +00:00
|
|
|
class Type;
|
2001-07-20 19:17:55 +00:00
|
|
|
class Value;
|
2001-12-03 22:26:30 +00:00
|
|
|
class ConstantInt;
|
2001-07-21 19:07:19 +00:00
|
|
|
|
|
|
|
struct ExprType;
|
2001-07-20 19:17:55 +00:00
|
|
|
|
|
|
|
// ClassifyExpression: Analyze an expression to determine the complexity of the
|
|
|
|
// expression, and which other values it depends on.
|
|
|
|
//
|
2001-07-21 19:07:19 +00:00
|
|
|
ExprType ClassifyExpression(Value *Expr);
|
2001-07-20 19:17:55 +00:00
|
|
|
|
2001-07-21 19:07:19 +00:00
|
|
|
// ExprType - Represent an expression of the form CONST*VAR+CONST
|
2001-07-20 19:17:55 +00:00
|
|
|
// or simpler. The expression form that yields the least information about the
|
|
|
|
// expression is just the Linear form with no offset.
|
|
|
|
//
|
2001-07-21 19:07:19 +00:00
|
|
|
struct ExprType {
|
2001-07-20 19:17:55 +00:00
|
|
|
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
|
2001-07-21 19:07:19 +00:00
|
|
|
} ExprTy;
|
2001-07-20 19:17:55 +00:00
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
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)
|
2001-07-20 19:17:55 +00:00
|
|
|
|
2001-12-03 22:26:30 +00:00
|
|
|
inline ExprType(const ConstantInt *CPV = 0) {
|
2001-07-20 19:17:55 +00:00
|
|
|
Offset = CPV; Var = 0; Scale = 0;
|
2001-07-21 19:07:19 +00:00
|
|
|
ExprTy = Constant;
|
2001-07-20 19:17:55 +00:00
|
|
|
}
|
2001-09-11 04:27:34 +00:00
|
|
|
ExprType(Value *Val); // Create a linear or constant expression
|
2001-12-03 22:26:30 +00:00
|
|
|
ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
|
2001-09-11 04:27:34 +00:00
|
|
|
|
|
|
|
// If this expression has an intrinsic type, return it. If it is zero, return
|
|
|
|
// the specified type.
|
|
|
|
//
|
|
|
|
const Type *getExprType(const Type *Default) const;
|
2001-07-20 19:17:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|