Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
Statement representing a single if statement, possibly with an else clause. More...
#include <stmt.h>
Public Member Functions | |
IfStmt (Expr *testExpr, Stmt *trueStmts, Stmt *falseStmts, bool doAllCheck, SourcePos pos) | |
void | EmitCode (FunctionEmitContext *ctx) const |
void | Print (int indent) const |
Stmt * | TypeCheck () |
int | EstimateCost () const |
Public Member Functions inherited from Stmt | |
Stmt (SourcePos p, unsigned scid) | |
virtual Stmt * | Optimize () |
Public Member Functions inherited from ASTNode | |
ASTNode (SourcePos p, unsigned scid) | |
virtual | ~ASTNode () |
unsigned | getValueID () const |
Static Public Member Functions | |
static bool | classof (IfStmt const *) |
static bool | classof (ASTNode const *N) |
Static Public Member Functions inherited from Stmt | |
static bool | classof (Stmt const *) |
static bool | classof (ASTNode const *N) |
Static Public Member Functions inherited from ASTNode | |
static bool | classof (ASTNode const *) |
Public Attributes | |
Expr * | test |
Stmt * | trueStmts |
Stmt * | falseStmts |
Public Attributes inherited from ASTNode | |
SourcePos | pos |
Private Member Functions | |
void | emitMaskedTrueAndFalse (FunctionEmitContext *ctx, llvm::Value *oldMask, llvm::Value *test) const |
void | emitVaryingIf (FunctionEmitContext *ctx, llvm::Value *test) const |
void | emitMaskAllOn (FunctionEmitContext *ctx, llvm::Value *test, llvm::BasicBlock *bDone) const |
void | emitMaskMixed (FunctionEmitContext *ctx, llvm::Value *oldMask, llvm::Value *test, llvm::BasicBlock *bDone) const |
Private Attributes | |
const bool | doAllCheck |
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 } |
Statement representing a single if statement, possibly with an else clause.
|
inlinestatic |
Definition at line 124 of file stmt.h.
References Stmt::EmitCode(), ASTNode::EstimateCost(), ASTNode::getValueID(), ASTNode::IfStmtID, Stmt::Print(), and Stmt::TypeCheck().
|
virtual |
Returns true if the "true" block for the if statement consists of a single 'break' statement, and the "false" block is empty.
Implements Stmt.
Definition at line 372 of file stmt.cpp.
References FunctionEmitContext::BranchInst(), FunctionEmitContext::CreateBasicBlock(), doAllCheck, emitVaryingIf(), FunctionEmitContext::EndIf(), falseStmts, FunctionEmitContext::GetCurrentBasicBlock(), Expr::GetType(), Expr::GetValue(), Type::IsUniformType(), lEmitIfStatements(), ASTNode::pos, FunctionEmitContext::SetCurrentBasicBlock(), FunctionEmitContext::SetDebugPos(), FunctionEmitContext::StartUniformIf(), test, trueStmts, and Warning().
|
private |
Emits code for 'if' tests under the case where we know that the program mask is all on going into the 'if'.
Definition at line 571 of file stmt.cpp.
References FunctionEmitContext::All(), FunctionEmitContext::Any(), AssertPos, FunctionEmitContext::BranchInst(), FunctionEmitContext::CreateBasicBlock(), Opt::disableCoherentControlFlow, Opt::disableMaskAllOnOptimizations, emitMaskedTrueAndFalse(), FunctionEmitContext::EndIf(), falseStmts, g, FunctionEmitContext::GetCurrentBasicBlock(), FunctionEmitContext::GetFunctionMask(), lEmitIfStatements(), LLVMMaskAllOn, Globals::opt, ASTNode::pos, FunctionEmitContext::SetCurrentBasicBlock(), FunctionEmitContext::SetFunctionMask(), FunctionEmitContext::SetInternalMask(), FunctionEmitContext::StartVaryingIf(), and trueStmts.
Referenced by emitVaryingIf().
|
private |
Emit code to run both the true and false statements for the if test, with the mask set appropriately before running each one.
Definition at line 482 of file stmt.cpp.
References AssertPos, falseStmts, FunctionEmitContext::GetCurrentBasicBlock(), FunctionEmitContext::GetDebugPos(), lEmitIfStatements(), FunctionEmitContext::SetInternalMaskAnd(), FunctionEmitContext::SetInternalMaskAndNot(), and trueStmts.
Referenced by emitMaskAllOn(), and emitVaryingIf().
|
private |
Emit code for an 'if' test where the lane mask is known to be mixed on/off going into it.
Definition at line 638 of file stmt.cpp.
References FunctionEmitContext::Any(), AssertPos, FunctionEmitContext::BranchInst(), FunctionEmitContext::CreateBasicBlock(), FunctionEmitContext::EndIf(), falseStmts, FunctionEmitContext::GetCurrentBasicBlock(), FunctionEmitContext::GetFullMask(), lEmitIfStatements(), ASTNode::pos, FunctionEmitContext::SetCurrentBasicBlock(), FunctionEmitContext::SetInternalMaskAnd(), FunctionEmitContext::SetInternalMaskAndNot(), FunctionEmitContext::StartVaryingIf(), and trueStmts.
Referenced by emitVaryingIf().
|
private |
Emit code for an if test that checks the mask and the test values and tries to be smart about jumping over code that doesn't need to be run.
Definition at line 500 of file stmt.cpp.
References FunctionEmitContext::All(), AssertPos, FunctionEmitContext::BranchInst(), FunctionEmitContext::CreateBasicBlock(), Debug(), Opt::disableCoherentControlFlow, doAllCheck, emitMaskAllOn(), emitMaskedTrueAndFalse(), emitMaskMixed(), FunctionEmitContext::EndIf(), EstimateCost(), falseStmts, g, FunctionEmitContext::GetCurrentBasicBlock(), FunctionEmitContext::GetFullMask(), FunctionEmitContext::GetInternalMask(), Globals::opt, ASTNode::pos, PREDICATE_SAFE_IF_STATEMENT_COST, SafeToRunWithMaskAllOff(), FunctionEmitContext::SetCurrentBasicBlock(), FunctionEmitContext::StartVaryingIf(), and trueStmts.
Referenced by EmitCode().
|
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 455 of file stmt.cpp.
References COST_UNIFORM_IF, COST_VARYING_IF, Expr::GetType(), Type::IsUniformType(), and test.
Referenced by emitVaryingIf().
|
virtual |
Print a representation of the statement (and any children AST nodes) to standard output. This method is used for debuggins.
Implements Stmt.
Definition at line 463 of file stmt.cpp.
References doAllCheck, falseStmts, ASTNode::pos, Stmt::Print(), Expr::Print(), SourcePos::Print(), test, and trueStmts.
|
virtual |
Type checking should be performed by the node when this method is called. In the event of an error, a NULL value may be returned. As with ASTNode::Optimize(), the caller should store the returned pointer in place of the original ASTNode *.
Implements Stmt.
Definition at line 440 of file stmt.cpp.
References Opt::disableUniformControlFlow, g, Expr::GetType(), Type::IsUniformType(), Globals::opt, test, TypeConvertExpr(), AtomicType::UniformBool, and AtomicType::VaryingBool.
|
private |
This value records if this was a 'coherent' if statement in the source and thus, if the emitted code should check to see if all active program instances want to follow just one of the 'true' or 'false' blocks.
Definition at line 146 of file stmt.h.
Referenced by EmitCode(), emitVaryingIf(), and Print().
Stmt* IfStmt::falseStmts |
Statements to run if the 'if' test returns a false value
Definition at line 139 of file stmt.h.
Referenced by EmitCode(), emitMaskAllOn(), emitMaskedTrueAndFalse(), emitMaskMixed(), emitVaryingIf(), Print(), and WalkAST().
Expr* IfStmt::test |
Expression giving the 'if' test.
Definition at line 135 of file stmt.h.
Referenced by EmitCode(), EstimateCost(), lIsVaryingFor(), Print(), TypeCheck(), and WalkAST().
Stmt* IfStmt::trueStmts |
Statements to run if the 'if' test returns a true value
Definition at line 137 of file stmt.h.
Referenced by EmitCode(), emitMaskAllOn(), emitMaskedTrueAndFalse(), emitMaskMixed(), emitVaryingIf(), Print(), and WalkAST().