Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
Expr is the abstract base class that defines the interface that all expression types must implement. More...
#include <expr.h>
Public Member Functions | |
Expr (SourcePos p, unsigned scid) | |
virtual llvm::Value * | GetValue (FunctionEmitContext *ctx) const =0 |
virtual llvm::Value * | GetLValue (FunctionEmitContext *ctx) const |
virtual const Type * | GetType () const =0 |
virtual const Type * | GetLValueType () const |
virtual Symbol * | GetBaseSymbol () const |
virtual std::pair< llvm::Constant *, bool > | GetStorageConstant (const Type *type) const |
virtual std::pair< llvm::Constant *, bool > | GetConstant (const Type *type) const |
virtual Expr * | Optimize ()=0 |
virtual Expr * | TypeCheck ()=0 |
virtual void | Print () const =0 |
Public Member Functions inherited from ASTNode | |
ASTNode (SourcePos p, unsigned scid) | |
virtual | ~ASTNode () |
virtual int | EstimateCost () const =0 |
unsigned | getValueID () const |
Static Public Member Functions | |
static bool | classof (Expr const *) |
static bool | classof (ASTNode const *N) |
Static Public Member Functions inherited from ASTNode | |
static bool | classof (ASTNode const *) |
Additional Inherited Members | |
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 Attributes inherited from ASTNode | |
SourcePos | pos |
Expr is the abstract base class that defines the interface that all expression types must implement.
|
inlinestatic |
Definition at line 52 of file expr.h.
References GetBaseSymbol(), GetConstant(), GetLValue(), GetLValueType(), GetStorageConstant(), GetType(), GetValue(), ASTNode::getValueID(), ASTNode::MaxExprID, Optimize(), Print(), and TypeCheck().
|
virtual |
For expressions that have values based on a symbol (e.g. regular symbol references, array indexing, etc.), this returns a pointer to that symbol.
Reimplemented in FunctionSymbolExpr, SymbolExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, MemberExpr, and IndexExpr.
Definition at line 90 of file expr.cpp.
References AtomicType::basicType, FATAL, AtomicType::GetString(), ASTNode::pos, AtomicType::TYPE_BOOL, AtomicType::TYPE_DOUBLE, AtomicType::TYPE_FLOAT, AtomicType::TYPE_INT16, AtomicType::TYPE_INT32, AtomicType::TYPE_INT64, AtomicType::TYPE_INT8, AtomicType::TYPE_UINT16, AtomicType::TYPE_UINT32, AtomicType::TYPE_UINT64, AtomicType::TYPE_UINT8, and Warning().
Referenced by classof(), IndexExpr::classof(), MemberExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), DerefExpr::classof(), AddressOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), IndexExpr::GetBaseSymbol(), MemberExpr::GetBaseSymbol(), TypeCastExpr::GetBaseSymbol(), ReferenceExpr::GetBaseSymbol(), DerefExpr::GetBaseSymbol(), AddressOfExpr::GetBaseSymbol(), AssignExpr::GetValue(), DerefExpr::GetValue(), and lEmitPrePostIncDec().
|
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 in NullPointerExpr, FunctionSymbolExpr, SizeOfExpr, AddressOfExpr, TypeCastExpr, ConstExpr, ExprList, and BinaryExpr.
Definition at line 85 of file expr.cpp.
Referenced by classof(), BinaryExpr::classof(), ExprList::classof(), ConstExpr::classof(), TypeCastExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), FunctionSymbolExpr::classof(), NullPointerExpr::classof(), DeclStmt::EmitCode(), TypeCastExpr::GetConstant(), AddressOfExpr::GetConstant(), GetStorageConstant(), lGetBinaryExprStorageConstant(), and lGetExprListConstant().
|
virtual |
For expressions that can provide an lvalue (e.g. array indexing), this function should emit IR that computes the expression's lvalue and returns the corresponding llvm::Value. Expressions that can't provide an lvalue should leave this unimplemented; the default implementation returns NULL.
Reimplemented in VectorMemberExpr, SymbolExpr, DerefExpr, TypeCastExpr, MemberExpr, IndexExpr, and FunctionCallExpr.
Definition at line 73 of file expr.cpp.
Referenced by classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), TypeCastExpr::classof(), DerefExpr::classof(), SymbolExpr::classof(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), AssignExpr::GetValue(), ReferenceExpr::GetValue(), AddressOfExpr::GetValue(), VectorMemberExpr::GetValue(), lEmitOpAssign(), and lEmitPrePostIncDec().
|
virtual |
Returns the type of the value returned by GetLValueType(); this should be a pointer type of some sort (uniform or varying).
Reimplemented in VectorMemberExpr, StructMemberExpr, SymbolExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, IndexExpr, FunctionCallExpr, and BinaryExpr.
Definition at line 78 of file expr.cpp.
Referenced by classof(), BinaryExpr::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), DerefExpr::classof(), AddressOfExpr::classof(), SymbolExpr::classof(), DeclStmt::EmitCode(), ReturnStmt::EmitCode(), MemberExpr::EstimateCost(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), IndexExpr::GetLValueType(), StructMemberExpr::GetLValueType(), VectorMemberExpr::GetLValueType(), StructMemberExpr::getStructType(), AddressOfExpr::GetType(), AssignExpr::GetValue(), FunctionCallExpr::GetValue(), MemberExpr::GetValue(), VectorMemberExpr::GetValue(), lEmitOpAssign(), lEmitPrePostIncDec(), and AddressOfExpr::TypeCheck().
|
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 in ConstExpr, ExprList, and BinaryExpr.
Definition at line 84 of file expr.cpp.
References GetConstant().
Referenced by Module::AddGlobalVariable(), classof(), BinaryExpr::classof(), ExprList::classof(), ConstExpr::classof(), InitSymbol(), lGetBinaryExprStorageConstant(), and lGetExprListConstant().
|
pure virtual |
Returns the Type of the expression.
Implemented in VectorMemberExpr, StructMemberExpr, NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, RefDerefExpr, PtrDerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, and UnaryExpr.
Referenced by classof(), UnaryExpr::classof(), BinaryExpr::classof(), AssignExpr::classof(), SelectExpr::classof(), ExprList::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), ConstExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), PtrDerefExpr::classof(), RefDerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), MemberExpr::create(), FunctionEmitContext::CurrentLanesReturned(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), ReturnStmt::EmitCode(), SwitchStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IfStmt::EstimateCost(), DoStmt::EstimateCost(), ForStmt::EstimateCost(), FunctionCallExpr::EstimateCost(), IndexExpr::EstimateCost(), SwitchStmt::EstimateCost(), PtrDerefExpr::EstimateCost(), FullResolveOverloads(), MemberExpr::getCandidateNearMatches(), TypeCastExpr::GetConstant(), AddressOfExpr::GetConstant(), SizeOfExpr::GetConstant(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), IndexExpr::GetLValueType(), ReferenceExpr::GetLValueType(), DerefExpr::GetLValueType(), AddressOfExpr::GetLValueType(), StructMemberExpr::GetLValueType(), VectorMemberExpr::GetLValueType(), StructMemberExpr::getStructType(), UnaryExpr::GetType(), BinaryExpr::GetType(), AssignExpr::GetType(), SelectExpr::GetType(), IndexExpr::GetType(), TypeCastExpr::GetType(), ReferenceExpr::GetType(), PtrDerefExpr::GetType(), RefDerefExpr::GetType(), AddressOfExpr::GetType(), StructMemberExpr::GetType(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), TypeCastExpr::GetValue(), ReferenceExpr::GetValue(), DerefExpr::GetValue(), AddressOfExpr::GetValue(), SizeOfExpr::GetValue(), VectorMemberExpr::GetValue(), InitSymbol(), lArrayToPointer(), lCanImproveVectorDivide(), lCheckAllOffSafety(), lCreateBinaryOperatorCall(), lDoTypeConv(), lEmitLogicalOp(), lEmitNegate(), lEmitOpAssign(), lEmitPrePostIncDec(), lEmitSelectExprCode(), lGetBinaryExprStorageConstant(), lGetFunctionType(), lIsAllIntZeros(), lIsDifficultShiftAmount(), lIsVaryingFor(), lProcessPrintArg(), DeclStmt::Optimize(), BinaryExpr::Optimize(), SizeOfExpr::Print(), IfStmt::TypeCheck(), UnaryExpr::TypeCheck(), DoStmt::TypeCheck(), BinaryExpr::TypeCheck(), ForStmt::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), FunctionCallExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), TypeCastExpr::TypeCheck(), AssertStmt::TypeCheck(), DeleteStmt::TypeCheck(), PtrDerefExpr::TypeCheck(), RefDerefExpr::TypeCheck(), AddressOfExpr::TypeCheck(), NewExpr::TypeCheck(), TypeConvertExpr(), and VectorMemberExpr::VectorMemberExpr().
|
pure 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.
Implemented in VectorMemberExpr, NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, and UnaryExpr.
Referenced by classof(), UnaryExpr::classof(), BinaryExpr::classof(), AssignExpr::classof(), SelectExpr::classof(), ExprList::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), ConstExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), DerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), FunctionEmitContext::CurrentLanesReturned(), ExprStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), SwitchStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), DerefExpr::GetLValue(), UnaryExpr::GetValue(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), FunctionCallExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), TypeCastExpr::GetValue(), ReferenceExpr::GetValue(), DerefExpr::GetValue(), AddressOfExpr::GetValue(), NewExpr::GetValue(), VectorMemberExpr::GetValue(), InitSymbol(), lEmitLogicalOp(), lEmitNegate(), lEmitOpAssign(), lEmitPrePostIncDec(), lEmitSelectExprCode(), and lProcessPrintArg().
|
pure 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 ASTNode.
Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, and UnaryExpr.
Referenced by classof(), UnaryExpr::classof(), BinaryExpr::classof(), AssignExpr::classof(), SelectExpr::classof(), ExprList::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), ConstExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), DerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), and lArrayToPointer().
|
pure virtual |
Prints the expression to standard output (used for debugging).
Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, RefDerefExpr, PtrDerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, and UnaryExpr.
Referenced by classof(), UnaryExpr::classof(), BinaryExpr::classof(), AssignExpr::classof(), SelectExpr::classof(), ExprList::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), ConstExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), PtrDerefExpr::classof(), RefDerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), ExprStmt::Print(), IfStmt::Print(), UnaryExpr::Print(), Declarator::Print(), DoStmt::Print(), BinaryExpr::Print(), ForStmt::Print(), AssignExpr::Print(), SelectExpr::Print(), FunctionCallExpr::Print(), ForeachUniqueStmt::Print(), IndexExpr::Print(), ReturnStmt::Print(), MemberExpr::Print(), SwitchStmt::Print(), TypeCastExpr::Print(), ReferenceExpr::Print(), PtrDerefExpr::Print(), RefDerefExpr::Print(), AddressOfExpr::Print(), and SizeOfExpr::Print().
|
pure 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 ASTNode.
Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, RefDerefExpr, PtrDerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, and UnaryExpr.
Referenced by classof(), UnaryExpr::classof(), BinaryExpr::classof(), AssignExpr::classof(), SelectExpr::classof(), ExprList::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), ConstExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), PtrDerefExpr::classof(), RefDerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), and lArrayToPointer().