Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Classes | Functions
stmt.cpp File Reference

File with definitions classes related to statements in the language. More...

#include "stmt.h"
#include "ctx.h"
#include "expr.h"
#include "func.h"
#include "llvmutil.h"
#include "module.h"
#include "sym.h"
#include "type.h"
#include "util.h"
#include <map>
#include <stdio.h>
#include <llvm/IR/CallingConv.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Metadata.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/Support/raw_ostream.h>
Include dependency graph for stmt.cpp:

Go to the source code of this file.

Classes

struct  VaryingBCCheckInfo
 
struct  SwitchVisitInfo
 

Functions

static bool lHasUnsizedArrays (const Type *type)
 
static bool checkInit (const Type *type, Expr **init)
 
static void lEmitIfStatements (FunctionEmitContext *ctx, Stmt *stmts, const char *trueOrFalse)
 
static bool lIsVaryingFor (ASTNode *node)
 
static bool lVaryingBCPreFunc (ASTNode *node, void *d)
 
static ASTNodelVaryingBCPostFunc (ASTNode *node, void *d)
 
static bool lHasVaryingBreakOrContinue (Stmt *stmt)
 
static llvm::Value * lUpdateVaryingCounter (int dim, int nDims, FunctionEmitContext *ctx, llvm::Value *uniformCounterPtr, llvm::Value *varyingCounterPtr, const std::vector< int > &spans)
 
static int lLog2 (int i)
 
static void lGetSpans (int dimsLeft, int nDims, int itemsLeft, bool isTiled, int *a)
 
static bool lCheckMask (Stmt *stmts)
 
static bool lSwitchASTPreVisit (ASTNode *node, void *d)
 
static char lEncodeType (const Type *t)
 
static llvm::Value * lProcessPrintArg (Expr *expr, FunctionEmitContext *ctx, std::string &argTypes)
 

Detailed Description

File with definitions classes related to statements in the language.

Definition in file stmt.cpp.

Function Documentation

◆ checkInit()

static bool checkInit ( const Type type,
Expr **  init 
)
static

◆ lCheckMask()

static bool lCheckMask ( Stmt stmts)
static

Given the statements following a 'case' or 'default' label, this function determines whether the mask should be checked to see if it is "all off" immediately after the label, before executing the code for the statements.

Definition at line 2135 of file stmt.cpp.

References ForeachUniqueStmt::EstimateCost(), PREDICATE_SAFE_IF_STATEMENT_COST, and SafeToRunWithMaskAllOff().

Referenced by CaseStmt::EmitCode(), and DefaultStmt::EmitCode().

◆ lEmitIfStatements()

static void lEmitIfStatements ( FunctionEmitContext ctx,
Stmt stmts,
const char *  trueOrFalse 
)
static

◆ lEncodeType()

static char lEncodeType ( const Type t)
static

◆ lGetSpans()

static void lGetSpans ( int  dimsLeft,
int  nDims,
int  itemsLeft,
bool  isTiled,
int *  a 
)
static

Definition at line 1207 of file stmt.cpp.

References lLog2().

Referenced by ForeachStmt::EmitCode().

◆ lHasUnsizedArrays()

static bool lHasUnsizedArrays ( const Type type)
static

Definition at line 100 of file stmt.cpp.

References ArrayType::GetElementCount(), and ArrayType::GetElementType().

Referenced by DeclStmt::EmitCode().

◆ lHasVaryingBreakOrContinue()

static bool lHasVaryingBreakOrContinue ( Stmt stmt)
static

Given a statment, walk through it to see if there is a 'break' or 'continue' statement inside if its children, under varying control flow. We need to detect this case for loops since what might otherwise look like a 'uniform' loop needs to have code emitted to do all of the lane management stuff if this is the case.

Definition at line 749 of file stmt.cpp.

References VaryingBCCheckInfo::foundVaryingBreakOrContinue, lVaryingBCPostFunc(), lVaryingBCPreFunc(), and WalkAST().

Referenced by ForStmt::EmitCode(), SwitchStmt::EmitCode(), DoStmt::EstimateCost(), ForStmt::EstimateCost(), DoStmt::TypeCheck(), and ForStmt::TypeCheck().

◆ lIsVaryingFor()

static bool lIsVaryingFor ( ASTNode node)
static

Returns true if the given node is an 'if' statement where the test condition has varying type.

Definition at line 697 of file stmt.cpp.

References Expr::GetType(), Type::IsVaryingType(), and IfStmt::test.

Referenced by lVaryingBCPostFunc(), and lVaryingBCPreFunc().

◆ lLog2()

static int lLog2 ( int  i)
static

Returns the integer log2 of the given integer.

Definition at line 1189 of file stmt.cpp.

Referenced by lGetSpans().

◆ lProcessPrintArg()

static llvm::Value* lProcessPrintArg ( Expr expr,
FunctionEmitContext ctx,
std::string &  argTypes 
)
static

◆ lSwitchASTPreVisit()

static bool lSwitchASTPreVisit ( ASTNode node,
void *  d 
)
static

Definition at line 2228 of file stmt.cpp.

References Error(), ASTNode::pos, and CaseStmt::value.

Referenced by SwitchStmt::EmitCode().

◆ lUpdateVaryingCounter()

static llvm::Value* lUpdateVaryingCounter ( int  dim,
int  nDims,
FunctionEmitContext ctx,
llvm::Value *  uniformCounterPtr,
llvm::Value *  varyingCounterPtr,
const std::vector< int > &  spans 
)
static

◆ lVaryingBCPostFunc()

static ASTNode* lVaryingBCPostFunc ( ASTNode node,
void *  d 
)
static

Postorder callback function for checking for varying breaks or continues; decrement the varying control flow depth after the node's children have been processed, if this is a varying if statement.

Definition at line 736 of file stmt.cpp.

References lIsVaryingFor(), and VaryingBCCheckInfo::varyingControlFlowDepth.

Referenced by lHasVaryingBreakOrContinue().

◆ lVaryingBCPreFunc()

static bool lVaryingBCPreFunc ( ASTNode node,
void *  d 
)
static

Preorder callback function for checking for varying breaks or continues.

Definition at line 708 of file stmt.cpp.

References VaryingBCCheckInfo::foundVaryingBreakOrContinue, lIsVaryingFor(), and VaryingBCCheckInfo::varyingControlFlowDepth.

Referenced by lHasVaryingBreakOrContinue().