Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
Expression representing a function symbol in the program (generally used for a function call). More...
#include <expr.h>
Public Member Functions | |
FunctionSymbolExpr (const char *name, const std::vector< Symbol *> &candFuncs, SourcePos pos) | |
llvm::Value * | GetValue (FunctionEmitContext *ctx) const |
const Type * | GetType () const |
Symbol * | GetBaseSymbol () const |
Expr * | TypeCheck () |
Expr * | Optimize () |
void | Print () const |
int | EstimateCost () const |
std::pair< llvm::Constant *, bool > | GetConstant (const Type *type) const |
bool | ResolveOverloads (SourcePos argPos, const std::vector< const Type *> &argTypes, const std::vector< bool > *argCouldBeNULL=NULL, const std::vector< bool > *argIsConstant=NULL) |
Symbol * | GetMatchingFunction () |
Public Member Functions inherited from Expr | |
Expr (SourcePos p, unsigned scid) | |
virtual llvm::Value * | GetLValue (FunctionEmitContext *ctx) const |
virtual const Type * | GetLValueType () const |
virtual std::pair< llvm::Constant *, bool > | GetStorageConstant (const Type *type) const |
Public Member Functions inherited from ASTNode | |
ASTNode (SourcePos p, unsigned scid) | |
virtual | ~ASTNode () |
unsigned | getValueID () const |
Static Public Member Functions | |
static bool | classof (FunctionSymbolExpr 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 *) |
Private Member Functions | |
std::vector< Symbol * > | getCandidateFunctions (int argCount) const |
Static Private Member Functions | |
static int | computeOverloadCost (const FunctionType *ftype, const std::vector< const Type *> &argTypes, const std::vector< bool > *argCouldBeNULL, const std::vector< bool > *argIsConstant, int *cost) |
Private Attributes | |
std::string | name |
std::vector< Symbol * > | candidateFunctions |
Symbol * | matchingFunc |
bool | triedToResolve |
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 |
Expression representing a function symbol in the program (generally used for a function call).
FunctionSymbolExpr::FunctionSymbolExpr | ( | const char * | name, |
const std::vector< Symbol *> & | candFuncs, | ||
SourcePos | pos | ||
) |
Definition at line 7657 of file expr.cpp.
References candidateFunctions, matchingFunc, name, and triedToResolve.
|
inlinestatic |
|
inlinestatic |
Definition at line 660 of file expr.h.
References ASTNode::EstimateCost(), ASTNode::FunctionSymbolExprID, Expr::GetBaseSymbol(), Expr::GetConstant(), Expr::GetType(), Expr::GetValue(), ASTNode::getValueID(), Expr::Optimize(), Expr::Print(), and Expr::TypeCheck().
|
staticprivate |
This function computes the value of a cost function that represents the cost of calling a function of the given type with arguments of the given types. If it's not possible to call the function, regardless of any type conversions applied, a cost of -1 is returned.
Definition at line 7817 of file expr.cpp.
References CanConvertTypes(), Type::Equal(), Type::EqualIgnoringConst(), Type::GetAsNonConstType(), Type::GetAsVaryingType(), FunctionType::GetParameterType(), Type::GetReferenceTarget(), Type::IsConstType(), Type::IsUniformType(), Type::IsVaryingType(), lArgIsPointerType(), and lIsMatchWithTypeWidening().
Referenced by ResolveOverloads().
|
virtual |
|
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 from Expr.
Definition at line 7678 of file expr.cpp.
References matchingFunc.
|
private |
Definition at line 7779 of file expr.cpp.
References AssertPos, candidateFunctions, FunctionType::GetNumParameters(), and FunctionType::GetParameterDefault().
Referenced by ResolveOverloads().
|
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 7694 of file expr.cpp.
References Type::Equal(), Error(), Symbol::function, Type::GetString(), matchingFunc, and Symbol::type.
Symbol * FunctionSymbolExpr::GetMatchingFunction | ( | ) |
Definition at line 8038 of file expr.cpp.
References matchingFunc.
|
virtual |
Returns the Type of the expression.
Implements Expr.
Definition at line 7665 of file expr.cpp.
References Error(), matchingFunc, name, triedToResolve, and Symbol::type.
Referenced by 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 7674 of file expr.cpp.
References Symbol::function, and matchingFunc.
|
virtual |
|
virtual |
Prints the expression to standard output (used for debugging).
Implements Expr.
Definition at line 7686 of file expr.cpp.
References GetType(), matchingFunc, Symbol::name, and SourcePos::Print().
bool FunctionSymbolExpr::ResolveOverloads | ( | SourcePos | argPos, |
const std::vector< const Type *> & | argTypes, | ||
const std::vector< bool > * | argCouldBeNULL = NULL , |
||
const std::vector< bool > * | argIsConstant = NULL |
||
) |
Given the types of the function arguments, in the presence of function overloading, this method resolves which actual function the arguments match best. If the argCouldBeNULL parameter is non-NULL, each element indicates whether the corresponding argument is the number zero, indicating that it could be a NULL pointer, and if argIsConstant is non-NULL, each element indicates whether the corresponding argument is a compile-time constant value. Both of these parameters may be NULL (for cases where overload resolution is being done just given type information without the parameter argument expressions being available. This function returns true on success.
Definition at line 7939 of file expr.cpp.
References AssertPos, candidateFunctions, computeOverloadCost(), Error(), getCandidateFunctions(), lGetOverloadCandidateMessage(), matchingFunc, name, triedToResolve, and Warning().
Referenced by FunctionCallExpr::GetType(), PossiblyResolveFunctionOverloads(), and FunctionCallExpr::TypeCheck().
|
virtual |
|
private |
All of the functions with the name given in the function call; there may be more then one, in which case we need to resolve which overload is the best match.
Definition at line 700 of file expr.h.
Referenced by FunctionSymbolExpr(), getCandidateFunctions(), and ResolveOverloads().
|
private |
The actual matching function found after overload resolution.
Definition at line 703 of file expr.h.
Referenced by FunctionSymbolExpr(), GetBaseSymbol(), GetConstant(), GetMatchingFunction(), GetType(), GetValue(), Print(), and ResolveOverloads().
|
private |
Name of the function that is being called.
Definition at line 695 of file expr.h.
Referenced by FunctionSymbolExpr(), GetType(), and ResolveOverloads().
|
private |
Definition at line 705 of file expr.h.
Referenced by FunctionSymbolExpr(), GetType(), and ResolveOverloads().