Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
IfStmt Class Reference

Statement representing a single if statement, possibly with an else clause. More...

#include <stmt.h>

Inheritance diagram for IfStmt:
Inheritance graph
[legend]
Collaboration diagram for IfStmt:
Collaboration graph
[legend]

Public Member Functions

 IfStmt (Expr *testExpr, Stmt *trueStmts, Stmt *falseStmts, bool doAllCheck, SourcePos pos)
 
void EmitCode (FunctionEmitContext *ctx) const
 
void Print (int indent) const
 
StmtTypeCheck ()
 
int EstimateCost () const
 
- Public Member Functions inherited from Stmt
 Stmt (SourcePos p, unsigned scid)
 
virtual StmtOptimize ()
 
- 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

Exprtest
 
StmttrueStmts
 
StmtfalseStmts
 
- 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
}
 

Detailed Description

Statement representing a single if statement, possibly with an else clause.

Definition at line 119 of file stmt.h.

Constructor & Destructor Documentation

◆ IfStmt()

IfStmt::IfStmt ( Expr testExpr,
Stmt trueStmts,
Stmt falseStmts,
bool  doAllCheck,
SourcePos  pos 
)

Definition at line 333 of file stmt.cpp.

Member Function Documentation

◆ classof() [1/2]

static bool IfStmt::classof ( IfStmt const *  )
inlinestatic

Definition at line 123 of file stmt.h.

◆ classof() [2/2]

static bool IfStmt::classof ( ASTNode const *  N)
inlinestatic

◆ EmitCode()

void IfStmt::EmitCode ( FunctionEmitContext ctx) const
virtual

◆ emitMaskAllOn()

void IfStmt::emitMaskAllOn ( FunctionEmitContext ctx,
llvm::Value *  ltest,
llvm::BasicBlock *  bDone 
) const
private

◆ emitMaskedTrueAndFalse()

void IfStmt::emitMaskedTrueAndFalse ( FunctionEmitContext ctx,
llvm::Value *  oldMask,
llvm::Value *  test 
) const
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().

◆ emitMaskMixed()

void IfStmt::emitMaskMixed ( FunctionEmitContext ctx,
llvm::Value *  oldMask,
llvm::Value *  ltest,
llvm::BasicBlock *  bDone 
) const
private

◆ emitVaryingIf()

void IfStmt::emitVaryingIf ( FunctionEmitContext ctx,
llvm::Value *  ltest 
) const
private

◆ EstimateCost()

int IfStmt::EstimateCost ( ) const
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().

◆ Print()

void IfStmt::Print ( int  indent) const
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.

◆ TypeCheck()

Stmt * IfStmt::TypeCheck ( )
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.

Member Data Documentation

◆ doAllCheck

const bool IfStmt::doAllCheck
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().

◆ falseStmts

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().

◆ test

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().

◆ trueStmts

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().


The documentation for this class was generated from the following files: