Intel SPMD Program Compiler  1.9.1
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
 
llvm::Constant * 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
 
- 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 695 of file expr.h.

Constructor & Destructor Documentation

FunctionSymbolExpr::FunctionSymbolExpr ( const char *  name,
const std::vector< Symbol * > &  candFuncs,
SourcePos  pos 
)

Definition at line 8022 of file expr.cpp.

References candidateFunctions, matchingFunc, name, and triedToResolve.

Member Function Documentation

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

Definition at line 700 of file expr.h.

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

Definition at line 701 of file expr.h.

References ASTNode::FunctionSymbolExprID, and ASTNode::getValueID().

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 8225 of file expr.cpp.

References CanConvertTypes(), Type::Equal(), Type::GetAsNonConstType(), Type::GetAsVaryingType(), FunctionType::GetParameterType(), Type::GetReferenceTarget(), Type::IsConstType(), Type::IsUniformType(), Type::IsVaryingType(), lArgIsPointerType(), and lIsMatchWithTypeWidening().

Referenced by ResolveOverloads().

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 8070 of file expr.cpp.

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 8052 of file expr.cpp.

References matchingFunc.

std::vector< Symbol * > FunctionSymbolExpr::getCandidateFunctions ( int  argCount) const
private
llvm::Constant * 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. Otherwise it should return NULL.

Reimplemented from Expr.

Definition at line 8087 of file expr.cpp.

References Type::Equal(), Error(), Symbol::function, Type::GetString(), matchingFunc, and Symbol::type.

Symbol * FunctionSymbolExpr::GetMatchingFunction ( )

Definition at line 8464 of file expr.cpp.

References matchingFunc.

const Type * FunctionSymbolExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Definition at line 8034 of file expr.cpp.

References Error(), matchingFunc, name, triedToResolve, and Symbol::type.

Referenced by Print().

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 8046 of file expr.cpp.

References Symbol::function, and matchingFunc.

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 8064 of file expr.cpp.

void FunctionSymbolExpr::Print ( ) const
virtual

Prints the expression to standard output (used for debugging).

Implements Expr.

Definition at line 8076 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 8353 of file expr.cpp.

References AssertPos, candidateFunctions, computeOverloadCost(), Error(), getCandidateFunctions(), lGetOverloadCandidateMessage(), matchingFunc, name, triedToResolve, and Warning().

Referenced by FunctionCallExpr::GetType(), PossiblyResolveFunctionOverloads(), and FunctionCallExpr::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 8058 of file expr.cpp.

Member Data Documentation

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 746 of file expr.h.

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

Symbol* FunctionSymbolExpr::matchingFunc
private

The actual matching function found after overload resolution.

Definition at line 749 of file expr.h.

Referenced by FunctionSymbolExpr(), GetBaseSymbol(), GetConstant(), GetMatchingFunction(), GetType(), GetValue(), Print(), and ResolveOverloads().

std::string FunctionSymbolExpr::name
private

Name of the function that is being called.

Definition at line 741 of file expr.h.

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

bool FunctionSymbolExpr::triedToResolve
private

Definition at line 751 of file expr.h.

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


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