Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
General functionality related to abstract syntax trees and traversal of them. More...
#include "ast.h"
#include "expr.h"
#include "func.h"
#include "stmt.h"
#include "sym.h"
#include "util.h"
Go to the source code of this file.
Classes | |
struct | CostData |
Functions | |
ASTNode * | WalkAST (ASTNode *node, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc, void *data) |
static ASTNode * | lOptimizeNode (ASTNode *node, void *) |
ASTNode * | Optimize (ASTNode *root) |
Expr * | Optimize (Expr *expr) |
Stmt * | Optimize (Stmt *stmt) |
static ASTNode * | lTypeCheckNode (ASTNode *node, void *) |
ASTNode * | TypeCheck (ASTNode *root) |
Expr * | TypeCheck (Expr *expr) |
Stmt * | TypeCheck (Stmt *stmt) |
static bool | lCostCallbackPre (ASTNode *node, void *d) |
static ASTNode * | lCostCallbackPost (ASTNode *node, void *d) |
int | EstimateCost (ASTNode *root) |
static bool | lCheckAllOffSafety (ASTNode *node, void *data) |
bool | SafeToRunWithMaskAllOff (ASTNode *root) |
General functionality related to abstract syntax trees and traversal of them.
Definition in file ast.cpp.
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().
|
static |
Given an AST node, check to see if it's safe if we happen to run the code for that node with the execution mask all off.
Definition at line 280 of file ast.cpp.
References Assert, IndexExpr::baseExpr, MemberExpr::dereferenceExpr, BinaryExpr::Div, FunctionCallExpr::func, PointerType::GetBaseType(), CollectionType::GetElementCount(), Type::GetReferenceTarget(), Expr::GetType(), AssignExpr::GetType(), ConstExpr::GetValues(), IndexExpr::index, ISPC_MAX_NVEC, FunctionType::isSafe, Type::IsUniformType(), BinaryExpr::Mod, and BinaryExpr::op.
Referenced by SafeToRunWithMaskAllOff().
Definition at line 264 of file ast.cpp.
References CostData::foreachDepth.
Referenced by EstimateCost().
|
static |
Definition at line 255 of file ast.cpp.
References CostData::cost, ASTNode::EstimateCost(), and CostData::foreachDepth.
Referenced by EstimateCost().
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().
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().
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().
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().
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().
Convenience version of TypeCheck() for Expr *s that returns an Expr *.
Definition at line 244 of file ast.cpp.
References ASTNode::TypeCheck().
Convenience version of TypeCheck() for Stmt *s that returns an Stmt *.
Definition at line 246 of file ast.cpp.
References ASTNode::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 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().