Intel SPMD Program Compiler  1.9.1
Classes | Typedefs | Functions
ast.h File Reference
#include "ispc.h"
#include <vector>
Include dependency graph for ast.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ASTNode
 Abstract base class for nodes in the abstract syntax tree (AST). More...
 
class  AST
 

Typedefs

typedef bool(* ASTPreCallBackFunc) (ASTNode *node, void *data)
 
typedef ASTNode *(* ASTPostCallBackFunc) (ASTNode *node, void *data)
 

Functions

ASTNodeWalkAST (ASTNode *root, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc, void *data)
 
ASTNodeOptimize (ASTNode *root)
 
ExprOptimize (Expr *)
 
StmtOptimize (Stmt *)
 
ASTNodeTypeCheck (ASTNode *root)
 
ExprTypeCheck (Expr *)
 
StmtTypeCheck (Stmt *)
 
int EstimateCost (ASTNode *root)
 
bool SafeToRunWithMaskAllOff (ASTNode *root)
 

Typedef Documentation

typedef ASTNode*(* ASTPostCallBackFunc) (ASTNode *node, void *data)

Callback function type for postorder traversial visiting function for the AST walk.

Definition at line 167 of file ast.h.

typedef bool(* ASTPreCallBackFunc) (ASTNode *node, void *data)

Callback function type for preorder traversial visiting function for the AST walk.

Definition at line 162 of file ast.h.

Function Documentation

int EstimateCost ( ASTNode root)

Returns an estimate of the execution cost of the tree starting at the given root.

Definition at line 352 of file ast.cpp.

References CostData::cost, lCostCallbackPost(), lCostCallbackPre(), and WalkAST().

Referenced by Function::emitCode(), lCheckMask(), and lEmitLogicalOp().

ASTNode* Optimize ( ASTNode root)

Perform simple optimizations on the AST or portion thereof passed to this function, returning the resulting AST.

Definition at line 282 of file ast.cpp.

References lOptimizeNode(), and WalkAST().

Referenced by Module::AddGlobalVariable(), Module::CompileFile(), Function::Function(), Declarator::InitFromType(), lArrayToPointer(), BinaryExpr::Optimize(), and Optimize().

Expr* Optimize ( Expr )

Convenience version of Optimize() for Expr *s that returns an Expr * (rather than an ASTNode *, which would require the caller to cast back to an Expr *).

Definition at line 288 of file ast.cpp.

References Optimize().

Stmt* Optimize ( Stmt )

Convenience version of Optimize() for Expr *s that returns an Stmt * (rather than an ASTNode *, which would require the caller to cast back to a Stmt *).

Definition at line 294 of file ast.cpp.

References Optimize().

bool SafeToRunWithMaskAllOff ( ASTNode root)

Returns true if it would be safe to run the given code with an "all off" mask.

Definition at line 506 of file ast.cpp.

References lCheckAllOffSafety(), and WalkAST().

Referenced by IfStmt::emitVaryingIf(), SelectExpr::GetValue(), lCheckMask(), and lEmitLogicalOp().

ASTNode* TypeCheck ( ASTNode root)

Perform type-checking on the given AST (or portion of one), returning a pointer to the root of the resulting AST.

Definition at line 306 of file ast.cpp.

References lTypeCheckNode(), and WalkAST().

Referenced by Module::AddGlobalVariable(), Function::Function(), Declarator::InitFromType(), lArrayToPointer(), TypeCheck(), and TypeCastExpr::TypeCheck().

Expr* TypeCheck ( Expr )

Convenience version of TypeCheck() for Expr *s that returns an Expr *.

Definition at line 312 of file ast.cpp.

References TypeCheck().

Stmt* TypeCheck ( Stmt )

Convenience version of TypeCheck() for Stmt *s that returns an Stmt *.

Definition at line 318 of file ast.cpp.

References TypeCheck().

ASTNode* WalkAST ( ASTNode root,
ASTPreCallBackFunc  preFunc,
ASTPostCallBackFunc  postFunc,
void *  data 
)

Walk (some portion of) an AST, starting from the given root node. At each node, if preFunc is non-NULL, call it, passing the given void data pointer; if the call to preFunc function returns false, then the children of the node aren't visited. This function then makes recursive calls to WalkAST() to process the node's children; after doing so, calls postFunc, at the node. The return value from the postFunc call is ignored.

Definition at line 74 of file ast.cpp.

References BinaryExpr::arg0, BinaryExpr::arg1, FunctionCallExpr::args, Assert, IndexExpr::baseExpr, DoStmt::bodyStmts, NewExpr::countExpr, ForeachStmt::endExprs, ExprStmt::expr, UnaryExpr::expr, ForeachUniqueStmt::expr, MemberExpr::expr, ReturnStmt::expr, SwitchStmt::expr, TypeCastExpr::expr, ReferenceExpr::expr, DerefExpr::expr, AssertStmt::expr, DeleteStmt::expr, AddressOfExpr::expr, SizeOfExpr::expr, SelectExpr::expr1, SelectExpr::expr2, ExprList::exprs, IfStmt::falseStmts, FATAL, FunctionCallExpr::func, IndexExpr::index, ForStmt::init, NewExpr::initExpr, FunctionCallExpr::launchCountExpr, AssignExpr::lvalue, AssignExpr::rvalue, ForeachStmt::startExprs, ForStmt::step, LabeledStmt::stmt, ForStmt::stmts, ForeachStmt::stmts, ForeachActiveStmt::stmts, ForeachUniqueStmt::stmts, UnmaskedStmt::stmts, CaseStmt::stmts, DefaultStmt::stmts, SwitchStmt::stmts, StmtList::stmts, IfStmt::test, ForStmt::test, SelectExpr::test, DoStmt::testExpr, IfStmt::trueStmts, PrintStmt::values, and DeclStmt::vars.

Referenced by SwitchStmt::EmitCode(), EstimateCost(), FunctionEmitContext::InitializeLabelMap(), lHasVaryingBreakOrContinue(), Optimize(), SafeToRunWithMaskAllOff(), and TypeCheck().