2003-09-30 18:37:50 +00:00
|
|
|
//===- llvm/Analysis/Expressions.h - Expression Analysis Utils --*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// 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.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-20 19:17:55 +00:00
|
|
|
//
|
|
|
|
// This file defines a package of expression analysis utilties:
|
|
|
|
//
|
2003-12-23 08:03:40 +00:00
|
|
|
// ClassifyExpr: Analyze an expression to determine the complexity of the
|
|
|
|
// expression, and which other variables it depends on.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2001-07-20 19:17:55 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_EXPRESSIONS_H
|
|
|
|
#define LLVM_ANALYSIS_EXPRESSIONS_H
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
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
|
|
|
|
2004-03-11 23:08:20 +00:00
|
|
|
/// ClassifyExpr - Analyze an expression to determine the complexity of the
|
2003-12-23 08:03:40 +00:00
|
|
|
/// expression, and which other values it depends on.
|
|
|
|
///
|
|
|
|
ExprType ClassifyExpr(Value *Expr);
|
2001-07-20 19:17:55 +00:00
|
|
|
|
2004-03-11 23:08:20 +00:00
|
|
|
/// 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.
|
|
|
|
///
|
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
|
|
|
|
2004-03-11 23:08:20 +00:00
|
|
|
/// If this expression has an intrinsic type, return it. If it is zero,
|
|
|
|
/// return the specified type.
|
|
|
|
///
|
2001-09-11 04:27:34 +00:00
|
|
|
const Type *getExprType(const Type *Default) const;
|
2001-07-20 19:17:55 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-07-20 19:17:55 +00:00
|
|
|
#endif
|