Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
FunctionSymbolExpr Class Reference

Expression representing a function symbol in the program (generally used for a function call). More...

#include <expr.h>

Inheritance diagram for FunctionSymbolExpr:
Inheritance graph
[legend]
Collaboration diagram for FunctionSymbolExpr:
Collaboration graph
[legend]

Public Member Functions

 FunctionSymbolExpr (const char *name, const std::vector< Symbol *> &candFuncs, SourcePos pos)
 
llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
SymbolGetBaseSymbol () const
 
ExprTypeCheck ()
 
ExprOptimize ()
 
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)
 
SymbolGetMatchingFunction ()
 
- Public Member Functions inherited from Expr
 Expr (SourcePos p, unsigned scid)
 
virtual llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
virtual const TypeGetLValueType () 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
 
SymbolmatchingFunc
 
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
 

Detailed Description

Expression representing a function symbol in the program (generally used for a function call).

Definition at line 655 of file expr.h.

Constructor & Destructor Documentation

◆ FunctionSymbolExpr()

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.

Member Function Documentation

◆ classof() [1/2]

static bool FunctionSymbolExpr::classof ( FunctionSymbolExpr const *  )
inlinestatic

Definition at line 659 of file expr.h.

◆ classof() [2/2]

static bool FunctionSymbolExpr::classof ( ASTNode const *  N)
inlinestatic

◆ computeOverloadCost()

int FunctionSymbolExpr::computeOverloadCost ( const FunctionType ftype,
const std::vector< const Type *> &  argTypes,
const std::vector< bool > *  argCouldBeNULL,
const std::vector< bool > *  argIsConstant,
int *  cost 
)
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().

◆ EstimateCost()

int FunctionSymbolExpr::EstimateCost ( ) const
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 7684 of file expr.cpp.

◆ GetBaseSymbol()

Symbol * FunctionSymbolExpr::GetBaseSymbol ( ) const
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.

◆ getCandidateFunctions()

std::vector< Symbol * > FunctionSymbolExpr::getCandidateFunctions ( int  argCount) const
private

◆ GetConstant()

std::pair< llvm::Constant *, bool > FunctionSymbolExpr::GetConstant ( const Type type) const
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.

◆ GetMatchingFunction()

Symbol * FunctionSymbolExpr::GetMatchingFunction ( )

Definition at line 8038 of file expr.cpp.

References matchingFunc.

◆ GetType()

const Type * FunctionSymbolExpr::GetType ( ) const
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().

◆ GetValue()

llvm::Value * FunctionSymbolExpr::GetValue ( FunctionEmitContext ctx) const
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.

◆ Optimize()

Expr * FunctionSymbolExpr::Optimize ( )
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 7682 of file expr.cpp.

◆ Print()

void FunctionSymbolExpr::Print ( ) const
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().

◆ ResolveOverloads()

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().

◆ TypeCheck()

Expr * FunctionSymbolExpr::TypeCheck ( )
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 7680 of file expr.cpp.

Member Data Documentation

◆ candidateFunctions

std::vector<Symbol *> FunctionSymbolExpr::candidateFunctions
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().

◆ matchingFunc

Symbol* FunctionSymbolExpr::matchingFunc
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().

◆ name

std::string FunctionSymbolExpr::name
private

Name of the function that is being called.

Definition at line 695 of file expr.h.

Referenced by FunctionSymbolExpr(), GetType(), and ResolveOverloads().

◆ triedToResolve

bool FunctionSymbolExpr::triedToResolve
private

Definition at line 705 of file expr.h.

Referenced by FunctionSymbolExpr(), GetType(), and ResolveOverloads().


The documentation for this class was generated from the following files: