Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
Binary expression. More...
#include <expr.h>
Public Types | |
enum | Op { Add, Sub, Mul, Div, Mod, Shl, Shr, Lt, Gt, Le, Ge, Equal, NotEqual, BitAnd, BitXor, BitOr, LogicalAnd, LogicalOr, Comma } |
Public Types inherited from ASTNode | |
enum | ASTNodeTy { AddressOfExprID, AssignExprID, BinaryExprID, ConstExprID, DerefExprID, PtrDerefExprID, RefDerefExprID, ExprListID, FunctionCallExprID, FunctionSymbolExprID, IndexExprID, StructMemberExprID, VectorMemberExprID, NewExprID, NullPointerExprID, ReferenceExprID, SelectExprID, SizeOfExprID, SymbolExprID, SyncExprID, TypeCastExprID, UnaryExprID, MaxExprID, AssertStmtID, BreakStmtID, CaseStmtID, ContinueStmtID, DeclStmtID, DefaultStmtID, DeleteStmtID, DoStmtID, ExprStmtID, ForeachActiveStmtID, ForeachStmtID, ForeachUniqueStmtID, ForStmtID, GotoStmtID, IfStmtID, LabeledStmtID, PrintStmtID, ReturnStmtID, StmtListID, SwitchStmtID, UnmaskedStmtID } |
Public Member Functions | |
BinaryExpr (Op o, Expr *a, Expr *b, SourcePos p) | |
llvm::Value * | GetValue (FunctionEmitContext *ctx) const |
const Type * | GetType () const |
const Type * | GetLValueType () const |
void | Print () const |
Expr * | Optimize () |
Expr * | TypeCheck () |
int | EstimateCost () const |
std::pair< llvm::Constant *, bool > | GetStorageConstant (const Type *type) const |
std::pair< llvm::Constant *, bool > | GetConstant (const Type *type) const |
Public Member Functions inherited from Expr | |
Expr (SourcePos p, unsigned scid) | |
virtual llvm::Value * | GetLValue (FunctionEmitContext *ctx) const |
virtual Symbol * | GetBaseSymbol () const |
Public Member Functions inherited from ASTNode | |
ASTNode (SourcePos p, unsigned scid) | |
virtual | ~ASTNode () |
unsigned | getValueID () const |
Static Public Member Functions | |
static bool | classof (BinaryExpr const *) |
static bool | classof (ASTNode const *N) |
Static Public Member Functions inherited from Expr | |
static bool | classof (Expr const *) |
static bool | classof (ASTNode const *N) |
Static Public Member Functions inherited from ASTNode | |
static bool | classof (ASTNode const *) |
Public Attributes | |
const Op | op |
Expr * | arg0 |
Expr * | arg1 |
Public Attributes inherited from ASTNode | |
SourcePos | pos |
enum BinaryExpr::Op |
Definition at line 1571 of file expr.cpp.
Referenced by MakeBinaryExpr(), and Optimize().
|
inlinestatic |
|
inlinestatic |
Definition at line 170 of file expr.h.
References ASTNode::BinaryExprID, ASTNode::EstimateCost(), Expr::GetConstant(), Expr::GetLValueType(), Expr::GetStorageConstant(), Expr::GetType(), Expr::GetValue(), ASTNode::getValueID(), Expr::Optimize(), Expr::Print(), and Expr::TypeCheck().
|
virtual |
Estimate the execution cost of the node (not including the cost of the children. The value returned should be based on the COST_* enumerant values defined in ispc.h.
Implements ASTNode.
Definition at line 2646 of file expr.cpp.
References arg0, arg1, COST_COMPLEX_ARITH_OP, COST_SIMPLE_ARITH_LOGIC_OP, Div, Mod, and op.
Referenced by lEmitLogicalOp().
|
virtual |
If this is a constant expression that can be converted to a constant of the given type, this method should return the corresponding llvm::Constant value and a flag denoting if it's valid for multi-target compilation for use as an initializer of a global variable. Otherwise it should return the llvm::constant value as NULL.
Reimplemented from Expr.
Definition at line 2753 of file expr.cpp.
References lGetBinaryExprStorageConstant().
|
virtual |
Returns the type of the value returned by GetLValueType(); this should be a pointer type of some sort (uniform or varying).
Reimplemented from Expr.
Definition at line 2636 of file expr.cpp.
References GetType().
Referenced by lGetBinaryExprStorageConstant().
|
virtual |
If this is a constant expression that can be converted to a constant of storage type of the given type, this method should return the corresponding llvm::Constant value and a flag denoting if it's valid for multi-target compilation for use as an initializer of a global variable. Otherwise it should return the llvm::constant value as NULL.
Reimplemented from Expr.
Definition at line 2749 of file expr.cpp.
References lGetBinaryExprStorageConstant().
|
virtual |
Returns the Type of the expression.
Implements Expr.
Definition at line 1936 of file expr.cpp.
References Add, arg0, arg1, AssertPos, BitAnd, BitOr, BitXor, Comma, Div, Equal, FATAL, Opt::force32BitAddressing, g, Ge, Type::GetAsVaryingType(), Expr::GetType(), Gt, Target::is32Bit(), Type::IsVaryingType(), Le, lMatchingBoolType(), LogicalAnd, LogicalOr, lOpString(), Lt, Mod, Type::MoreGeneralType(), Mul, NotEqual, op, Globals::opt, Shl, Shr, Sub, Globals::target, AtomicType::UniformInt32, and AtomicType::UniformInt64.
Referenced by GetLValueType(), Optimize(), and Print().
|
virtual |
This is the main method for Expr implementations to implement. It should call methods in the FunctionEmitContext to emit LLVM IR instructions to the current basic block in order to generate an llvm::Value that represents the expression's value.
Implements Expr.
Definition at line 1885 of file expr.cpp.
References Add, arg0, arg1, AssertPos, BitAnd, BitOr, BitXor, Comma, Div, Equal, Module::errorCount, FATAL, Ge, Expr::GetType(), Expr::GetValue(), Gt, Type::IsUnsignedType(), Le, lEmitBinaryArith(), lEmitBinaryBitOp(), lEmitBinaryCmp(), lEmitLogicalOp(), lIsDifficultShiftAmount(), LogicalAnd, LogicalOr, Lt, m, Mod, Mul, NotEqual, op, PerformanceWarning(), ASTNode::pos, FunctionEmitContext::SetDebugPos(), Shl, Shr, and Sub.
|
virtual |
This method should perform early optimizations of the expression (constant folding, etc.) and return a pointer to the resulting expression. If an error is encountered during optimization, NULL should be returned.
Implements Expr.
Definition at line 2200 of file expr.cpp.
References arg0, arg1, Assert, AssertPos, BinaryExpr(), Debug(), Div, Type::Equal(), Type::EqualIgnoringConst(), ExprList::exprs, Opt::fastMath, g, Type::GetAsNonConstType(), Expr::GetType(), GetType(), ConstExpr::GetValues(), ISPC_MAX_NVEC, lCanImproveVectorDivide(), lConstFoldBinaryLogicalOp(), lConstFoldBoolBinaryOp(), SymbolTable::LookupFunction(), m, Mul, op, Globals::opt, Optimize(), ASTNode::pos, Module::symbolTable, TypeCheck(), AtomicType::UniformBool, AtomicType::UniformDouble, AtomicType::UniformFloat, AtomicType::UniformInt16, AtomicType::UniformInt32, AtomicType::UniformInt64, AtomicType::UniformInt8, AtomicType::UniformUInt16, AtomicType::UniformUInt32, AtomicType::UniformUInt64, AtomicType::UniformUInt8, AtomicType::VaryingBool, AtomicType::VaryingDouble, AtomicType::VaryingFloat, AtomicType::VaryingInt16, AtomicType::VaryingInt32, AtomicType::VaryingInt64, AtomicType::VaryingInt8, AtomicType::VaryingUInt16, AtomicType::VaryingUInt32, AtomicType::VaryingUInt64, AtomicType::VaryingUInt8, and Warning().
|
virtual |
Prints the expression to standard output (used for debugging).
Implements Expr.
Definition at line 2653 of file expr.cpp.
References arg0, arg1, GetType(), lOpString(), op, Expr::Print(), and SourcePos::Print().
|
virtual |
This method should perform type checking of the expression and return a pointer to the resulting expression. If an error is encountered, NULL should be returned.
Implements Expr.
Definition at line 2327 of file expr.cpp.
References Add, arg0, arg1, AssertPos, BitAnd, BitOr, BitXor, Comma, Div, Equal, Error(), FATAL, g, Ge, Type::GetAsVaryingType(), PointerType::GetBaseType(), VectorType::GetElementCount(), Type::GetSOAWidth(), Type::GetString(), PointerType::GetString(), Expr::GetType(), Gt, Target::is32Bit(), Type::IsBoolType(), Type::IsFloatType(), Type::IsIntType(), Type::IsNumericType(), Type::IsUniformType(), Type::IsVaryingType(), PointerType::IsVoidPointer(), lArrayToPointer(), Le, lIsAllIntZeros(), LogicalAnd, LogicalOr, lOpString(), Lt, Mod, Type::MoreGeneralType(), Mul, NotEqual, op, ASTNode::pos, Shl, Shr, Sub, Globals::target, TypeConvertExpr(), AtomicType::UniformBool, AtomicType::UniformInt32, AtomicType::UniformInt64, Union(), and AtomicType::VaryingBool.
Referenced by Optimize().
Expr* BinaryExpr::arg0 |
Definition at line 184 of file expr.h.
Referenced by BinaryExpr(), EstimateCost(), GetType(), GetValue(), lCreateBinaryOperatorCall(), lGetBinaryExprStorageConstant(), Optimize(), Print(), TypeCheck(), and WalkAST().
Expr * BinaryExpr::arg1 |
Definition at line 184 of file expr.h.
Referenced by BinaryExpr(), EstimateCost(), GetType(), GetValue(), lCanImproveVectorDivide(), lCreateBinaryOperatorCall(), lGetBinaryExprStorageConstant(), Optimize(), Print(), TypeCheck(), and WalkAST().
const Op BinaryExpr::op |
Definition at line 183 of file expr.h.
Referenced by EstimateCost(), GetType(), GetValue(), lCheckAllOffSafety(), lGetBinaryExprStorageConstant(), MakeBinaryExpr(), Optimize(), Print(), and TypeCheck().