LLVM API Documentation
00001 //===- llvm/Analysis/Expressions.h - Expression Analysis Utils --*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines a package of expression analysis utilties: 00011 // 00012 // ClassifyExpr: Analyze an expression to determine the complexity of the 00013 // expression, and which other variables it depends on. 00014 // 00015 //===----------------------------------------------------------------------===// 00016 00017 #ifndef LLVM_ANALYSIS_EXPRESSIONS_H 00018 #define LLVM_ANALYSIS_EXPRESSIONS_H 00019 00020 namespace llvm { 00021 00022 class Type; 00023 class Value; 00024 class ConstantInt; 00025 00026 struct ExprType; 00027 00028 /// ClassifyExpr - Analyze an expression to determine the complexity of the 00029 /// expression, and which other values it depends on. 00030 /// 00031 ExprType ClassifyExpr(Value *Expr); 00032 00033 /// ExprType Class - Represent an expression of the form CONST*VAR+CONST 00034 /// or simpler. The expression form that yields the least information about the 00035 /// expression is just the Linear form with no offset. 00036 /// 00037 struct ExprType { 00038 enum ExpressionType { 00039 Constant, // Expr is a simple constant, Offset is value 00040 Linear, // Expr is linear expr, Value is Var+Offset 00041 ScaledLinear, // Expr is scaled linear exp, Value is Scale*Var+Offset 00042 } ExprTy; 00043 00044 const ConstantInt *Offset; // Offset of expr, or null if 0 00045 Value *Var; // Var referenced, if Linear or above (null if 0) 00046 const ConstantInt *Scale; // Scale of var if ScaledLinear expr (null if 1) 00047 00048 inline ExprType(const ConstantInt *CPV = 0) { 00049 Offset = CPV; Var = 0; Scale = 0; 00050 ExprTy = Constant; 00051 } 00052 ExprType(Value *Val); // Create a linear or constant expression 00053 ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset); 00054 00055 /// If this expression has an intrinsic type, return it. If it is zero, 00056 /// return the specified type. 00057 /// 00058 const Type *getExprType(const Type *Default) const; 00059 }; 00060 00061 } // End llvm namespace 00062 00063 #endif