Intel SPMD Program Compiler  1.9.1
Classes | Functions
stmt.cpp File Reference

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

#include "stmt.h"
#include "ctx.h"
#include "util.h"
#include "expr.h"
#include "type.h"
#include "func.h"
#include "sym.h"
#include "module.h"
#include "llvmutil.h"
#include <stdio.h>
#include <map>
#include <llvm/IR/Module.h>
#include <llvm/IR/Type.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/DerivedTypes.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Metadata.h>
#include <llvm/IR/CallingConv.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 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

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

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

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

static void lEmitIfStatements ( FunctionEmitContext ctx,
Stmt stmts,
const char *  trueOrFalse 
)
static
static char lEncodeType ( const Type t)
static
static void lGetSpans ( int  dimsLeft,
int  nDims,
int  itemsLeft,
bool  isTiled,
int *  a 
)
static

Definition at line 1633 of file stmt.cpp.

References lLog2().

Referenced by ForeachStmt::EmitCode().

static bool lHasUnsizedArrays ( const Type type)
static

Definition at line 134 of file stmt.cpp.

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

Referenced by DeclStmt::EmitCode().

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

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

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

Referenced by lVaryingBCPostFunc(), and lVaryingBCPreFunc().

static int lLog2 ( int  i)
static

Returns the integer log2 of the given integer.

Definition at line 1613 of file stmt.cpp.

Referenced by lGetSpans().

static llvm::Value* lProcessPrintArg ( Expr expr,
FunctionEmitContext ctx,
std::string &  argTypes 
)
static
static bool lSwitchASTPreVisit ( ASTNode node,
void *  d 
)
static

Definition at line 2802 of file stmt.cpp.

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

Referenced by SwitchStmt::EmitCode().

static llvm::Value* lUpdateVaryingCounter ( int  dim,
int  nDims,
FunctionEmitContext ctx,
llvm::Value *  uniformCounterPtr,
llvm::Value *  varyingCounterPtr,
const std::vector< int > &  spans 
)
static
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 997 of file stmt.cpp.

References lIsVaryingFor(), and VaryingBCCheckInfo::varyingControlFlowDepth.

Referenced by lHasVaryingBreakOrContinue().

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

Preorder callback function for checking for varying breaks or continues.

Definition at line 965 of file stmt.cpp.

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

Referenced by lHasVaryingBreakOrContinue().