Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
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

◆ ASTPostCallBackFunc

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

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

Definition at line 160 of file ast.h.

◆ ASTPreCallBackFunc

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

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

Definition at line 155 of file ast.h.

Function Documentation

◆ EstimateCost()

int EstimateCost ( ASTNode root)

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

Definition at line 271 of file ast.cpp.

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

Referenced by Function::emitCode().

◆ Optimize() [1/3]

ASTNode* Optimize ( ASTNode root)

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

Definition at line 234 of file ast.cpp.

References lOptimizeNode(), and WalkAST().

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

◆ Optimize() [2/3]

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 236 of file ast.cpp.

References ASTNode::Optimize().

◆ Optimize() [3/3]

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 238 of file ast.cpp.

References ASTNode::Optimize().

◆ SafeToRunWithMaskAllOff()

bool SafeToRunWithMaskAllOff ( ASTNode root)

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

Definition at line 417 of file ast.cpp.

References lCheckAllOffSafety(), and WalkAST().

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

◆ TypeCheck() [1/3]

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 242 of file ast.cpp.

References lTypeCheckNode(), and WalkAST().

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

◆ TypeCheck() [2/3]

Expr* TypeCheck ( Expr )

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

Definition at line 244 of file ast.cpp.

References ASTNode::TypeCheck().

◆ TypeCheck() [3/3]

Stmt* TypeCheck ( Stmt )

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

Definition at line 246 of file ast.cpp.

References ASTNode::TypeCheck().

◆ WalkAST()

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 68 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, ReturnStmt::expr, MemberExpr::expr, SwitchStmt::expr, TypeCastExpr::expr, AssertStmt::expr, ReferenceExpr::expr, DeleteStmt::expr, DerefExpr::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, DeclStmt::vars, and WalkAST().

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