Intel SPMD Program Compiler  1.9.1
Classes | Functions
expr.h File Reference

Expr abstract base class and expression implementations. More...

#include "ispc.h"
#include "ast.h"
#include "type.h"
Include dependency graph for expr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Expr
 Expr is the abstract base class that defines the interface that all expression types must implement. More...
 
class  UnaryExpr
 Unary expression. More...
 
class  BinaryExpr
 Binary expression. More...
 
class  AssignExpr
 Assignment expression. More...
 
class  SelectExpr
 Selection expression, corresponding to "test ? a : b". More...
 
class  ExprList
 A list of expressions. More...
 
class  FunctionCallExpr
 Expression representing a function call. More...
 
class  IndexExpr
 Expression representing indexing into something with an integer offset. More...
 
class  MemberExpr
 Expression representing member selection ("foo.bar"). More...
 
class  ConstExpr
 Expression representing a compile-time constant value. More...
 
class  TypeCastExpr
 Expression representing a type cast of the given expression to a probably-different type. More...
 
class  ReferenceExpr
 Expression that represents taking a reference of a (non-reference) variable. More...
 
class  DerefExpr
 Common base class that provides shared functionality for PtrDerefExpr and RefDerefExpr. More...
 
class  PtrDerefExpr
 Expression that represents dereferencing a pointer to get its value. More...
 
class  RefDerefExpr
 Expression that represents dereferencing a reference to get its value. More...
 
class  AddressOfExpr
 
class  SizeOfExpr
 
class  SymbolExpr
 Expression representing a symbol reference in the program. More...
 
class  FunctionSymbolExpr
 Expression representing a function symbol in the program (generally used for a function call). More...
 
class  SyncExpr
 A sync statement in the program (waits for all launched tasks before proceeding). More...
 
class  NullPointerExpr
 An expression that represents a NULL pointer. More...
 
class  NewExpr
 

Functions

bool CanConvertTypes (const Type *fromType, const Type *toType, const char *errorMsgBase=NULL, SourcePos pos=SourcePos())
 
ExprTypeConvertExpr (Expr *expr, const Type *toType, const char *errorMsgBase)
 
ExprMakeBinaryExpr (BinaryExpr::Op o, Expr *a, Expr *b, SourcePos p)
 
void InitSymbol (llvm::Value *lvalue, const Type *symType, Expr *initExpr, FunctionEmitContext *ctx, SourcePos pos)
 
bool PossiblyResolveFunctionOverloads (Expr *expr, const Type *type)
 

Detailed Description

Expr abstract base class and expression implementations.

Definition in file expr.h.

Function Documentation

bool CanConvertTypes ( const Type fromType,
const Type toType,
const char *  errorMsgBase = NULL,
SourcePos  pos = SourcePos() 
)

This function indicates whether it's legal to convert from fromType to toType. If the optional errorMsgBase and source position parameters are provided, then an error message is issued if the type conversion isn't possible.

Definition at line 587 of file expr.cpp.

References lDoTypeConv().

Referenced by FunctionSymbolExpr::computeOverloadCost(), and FunctionCallExpr::TypeCheck().

void InitSymbol ( llvm::Value *  ptr,
const Type symType,
Expr initExpr,
FunctionEmitContext ctx,
SourcePos  pos 
)

Utility routine that emits code to initialize a symbol given an initializer expression.

Parameters
lvalueMemory location of storage for the symbol's data
symNameName of symbol (used in error messages)
symTypeType of variable being initialized
initExprExpression for the initializer
ctxFunctionEmitContext to use for generating instructions
posSource file position of the variable being initialized

Utility routine that emits code to initialize a symbol given an initializer expression.

Parameters
ptrMemory location of storage for the symbol's data
symNameName of symbol (used in error messages)
symTypeType of variable being initialized
initExprExpression for the initializer
ctxFunctionEmitContext to use for generating instructions
posSource file position of the variable being initialized

Definition at line 648 of file expr.cpp.

References FunctionEmitContext::AddElementOffset(), AssertPos, Globals::ctx, Type::Equal(), Error(), Module::errorCount, ExprList::exprs, FATAL, g, Type::GetAsUniformType(), Expr::GetConstant(), FunctionEmitContext::GetCurrentBasicBlock(), CollectionType::GetElementCount(), FunctionEmitContext::GetElementPtrInst(), CollectionType::GetElementType(), Type::GetSOAWidth(), Variability::GetString(), Type::GetString(), ReferenceType::GetString(), Expr::GetType(), PointerType::GetUniform(), Expr::GetValue(), Type::GetVariability(), Type::IsBasicType(), Type::IsSOAType(), LLVMInt32(), Type::LLVMType(), m, FunctionEmitContext::MemcpyInst(), Module::module, ASTNode::pos, PossiblyResolveFunctionOverloads(), Target::SizeOf(), FunctionEmitContext::StoreInst(), Globals::target, and TypeConvertExpr().

Referenced by DeclStmt::EmitCode(), and NewExpr::GetValue().

Expr* MakeBinaryExpr ( BinaryExpr::Op  o,
Expr a,
Expr b,
SourcePos  p 
)

Definition at line 1722 of file expr.cpp.

References lCreateBinaryOperatorCall().

bool PossiblyResolveFunctionOverloads ( Expr expr,
const Type type 
)
Expr* TypeConvertExpr ( Expr expr,
const Type toType,
const char *  errorMsgBase 
)

This function attempts to convert the given expression to the given type, returning a pointer to a new expression that is the result. If the required type conversion is illegal, it returns NULL and prints an error message using the provided string to indicate the context for which type conversion was being applied (e.g. "function call parameter").

Definition at line 595 of file expr.cpp.

References Debug(), Type::GetString(), Expr::GetType(), lDoTypeConv(), and ASTNode::pos.

Referenced by Module::AddGlobalVariable(), FunctionEmitContext::CurrentLanesReturned(), DeclStmt::EmitCode(), ExprList::GetConstant(), FunctionCallExpr::GetValue(), InitSymbol(), lEmitLogicalOp(), DeclStmt::TypeCheck(), UnaryExpr::TypeCheck(), IfStmt::TypeCheck(), BinaryExpr::TypeCheck(), DoStmt::TypeCheck(), ForStmt::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), ForeachStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), TypeCastExpr::TypeCheck(), AssertStmt::TypeCheck(), and NewExpr::TypeCheck().