Intel SPMD Program Compiler  1.9.1
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 128 of file stmt.h.

Constructor & Destructor Documentation

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

Definition at line 525 of file stmt.cpp.

Member Function Documentation

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

Definition at line 133 of file stmt.h.

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

Definition at line 134 of file stmt.h.

References ASTNode::getValueID(), and ASTNode::IfStmtID.

void IfStmt::EmitCode ( FunctionEmitContext ctx) const
virtual
void IfStmt::emitMaskAllOn ( FunctionEmitContext ctx,
llvm::Value *  ltest,
llvm::BasicBlock *  bDone 
) const
private
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 703 of file stmt.cpp.

References AssertPos, falseStmts, FunctionEmitContext::GetCurrentBasicBlock(), FunctionEmitContext::GetDebugPos(), lEmitIfStatements(), FunctionEmitContext::SetInternalMaskAnd(), FunctionEmitContext::SetInternalMaskAndNot(), and trueStmts.

Referenced by emitMaskAllOn(), and emitVaryingIf().

void IfStmt::emitMaskMixed ( FunctionEmitContext ctx,
llvm::Value *  oldMask,
llvm::Value *  ltest,
llvm::BasicBlock *  bDone 
) const
private
void IfStmt::emitVaryingIf ( FunctionEmitContext ctx,
llvm::Value *  ltest 
) const
private
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 672 of file stmt.cpp.

References COST_UNIFORM_IF, COST_VARYING_IF, Expr::GetType(), Type::IsUniformType(), and test.

Referenced by emitVaryingIf().

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 682 of file stmt.cpp.

References doAllCheck, falseStmts, ASTNode::pos, Stmt::Print(), Expr::Print(), SourcePos::Print(), test, and trueStmts.

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 653 of file stmt.cpp.

References Opt::disableUniformControlFlow, g, Expr::GetType(), Type::IsUniformType(), Globals::opt, test, TypeConvertExpr(), AtomicType::UniformBool, and AtomicType::VaryingBool.

Member Data Documentation

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 158 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 151 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 147 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 149 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: