|
Intel SPMD Program Compiler
1.3.0
|
#include <ctx.h>

Public Member Functions | |
| FunctionEmitContext (Function *function, Symbol *funSym, llvm::Function *llvmFunction, SourcePos firstStmtPos) | |
| ~FunctionEmitContext () | |
| const Function * | GetFunction () const |
Current basic block management | |
| llvm::BasicBlock * | GetCurrentBasicBlock () |
| void | SetCurrentBasicBlock (llvm::BasicBlock *bblock) |
Mask management | |
| llvm::Value * | GetFunctionMask () |
| llvm::Value * | GetInternalMask () |
| llvm::Value * | GetFullMask () |
| llvm::Value * | GetFullMaskPointer () |
| void | SetFunctionMask (llvm::Value *val) |
| void | SetInternalMask (llvm::Value *val) |
| void | SetInternalMaskAnd (llvm::Value *oldMask, llvm::Value *val) |
| void | SetInternalMaskAndNot (llvm::Value *oldMask, llvm::Value *test) |
| void | BranchIfMaskAny (llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) |
| void | BranchIfMaskAll (llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) |
| void | BranchIfMaskNone (llvm::BasicBlock *btrue, llvm::BasicBlock *bfalse) |
Small helper/utility routines | |
| llvm::Value * | Any (llvm::Value *mask) |
| llvm::Value * | All (llvm::Value *mask) |
| llvm::Value * | None (llvm::Value *mask) |
| llvm::Value * | LaneMask (llvm::Value *mask) |
| llvm::Value * | MasksAllEqual (llvm::Value *mask1, llvm::Value *mask2) |
| llvm::Value * | GetStringPtr (const std::string &str) |
| llvm::BasicBlock * | CreateBasicBlock (const char *name) |
| llvm::Value * | I1VecToBoolVec (llvm::Value *b) |
| void | AddInstrumentationPoint (const char *note) |
Debugging support | |
| void | SetDebugPos (SourcePos pos) |
| SourcePos | GetDebugPos () const |
| void | AddDebugPos (llvm::Value *instruction, const SourcePos *pos=NULL, llvm::DIScope *scope=NULL) |
| void | StartScope () |
| void | EndScope () |
| llvm::DIScope | GetDIScope () const |
| void | EmitVariableDebugInfo (Symbol *sym) |
| void | EmitFunctionParameterDebugInfo (Symbol *sym, int parameterNum) |
IR instruction emission | |
These methods generally closely correspond to LLVM IR instructions. See the LLVM assembly language reference manual (http://llvm.org/docs/LangRef.html) and the LLVM doxygen documentaion (http://llvm.org/doxygen) for more information. Here we will only document significant generalizations to the functionality of the corresponding basic LLVM instructions. Beyond actually emitting the instruction, the implementations of these methods in FunctionEmitContext also handle adding debugging metadata if debugging symbols are enabled, adding the instructions to the current basic block, and handling generalizations like 'varying' lvalues, arithmetic operations with VectorType operands, etc. | |
| llvm::Value * | BinaryOperator (llvm::Instruction::BinaryOps inst, llvm::Value *v0, llvm::Value *v1, const char *name=NULL) |
| llvm::Value * | NotOperator (llvm::Value *v, const char *name=NULL) |
| llvm::Value * | CmpInst (llvm::Instruction::OtherOps inst, llvm::CmpInst::Predicate pred, llvm::Value *v0, llvm::Value *v1, const char *name=NULL) |
| llvm::Value * | SmearUniform (llvm::Value *value, const char *name=NULL) |
| llvm::Value * | BitCastInst (llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| llvm::Value * | PtrToIntInst (llvm::Value *value, const char *name=NULL) |
| llvm::Value * | PtrToIntInst (llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| llvm::Value * | IntToPtrInst (llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| llvm::Instruction * | TruncInst (llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| llvm::Instruction * | CastInst (llvm::Instruction::CastOps op, llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| llvm::Instruction * | FPCastInst (llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| llvm::Instruction * | SExtInst (llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| llvm::Instruction * | ZExtInst (llvm::Value *value, llvm::Type *type, const char *name=NULL) |
| void | MatchIntegerTypes (llvm::Value **v0, llvm::Value **v1) |
| llvm::Value * | MakeSlicePointer (llvm::Value *ptr, llvm::Value *offset) |
| llvm::Value * | GetElementPtrInst (llvm::Value *basePtr, llvm::Value *index, const Type *ptrType, const char *name=NULL) |
| llvm::Value * | GetElementPtrInst (llvm::Value *basePtr, llvm::Value *index0, llvm::Value *index1, const Type *ptrType, const char *name=NULL) |
| llvm::Value * | AddElementOffset (llvm::Value *basePtr, int elementNum, const Type *ptrType, const char *name=NULL, const PointerType **resultPtrType=NULL) |
| llvm::Value * | LoadInst (llvm::Value *ptr, llvm::Value *mask, const Type *ptrType, const char *name=NULL) |
| llvm::Value * | LoadInst (llvm::Value *ptr, const char *name=NULL) |
| llvm::Value * | AllocaInst (llvm::Type *llvmType, const char *name=NULL, int align=0, bool atEntryBlock=true) |
| void | StoreInst (llvm::Value *value, llvm::Value *ptr) |
| void | StoreInst (llvm::Value *value, llvm::Value *ptr, llvm::Value *storeMask, const Type *valueType, const Type *ptrType) |
| void | MemcpyInst (llvm::Value *dest, llvm::Value *src, llvm::Value *count, llvm::Value *align=NULL) |
| void | BranchInst (llvm::BasicBlock *block) |
| void | BranchInst (llvm::BasicBlock *trueBlock, llvm::BasicBlock *falseBlock, llvm::Value *test) |
| llvm::Value * | ExtractInst (llvm::Value *v, int elt, const char *name=NULL) |
| llvm::Value * | InsertInst (llvm::Value *v, llvm::Value *eltVal, int elt, const char *name=NULL) |
| llvm::PHINode * | PhiNode (llvm::Type *type, int count, const char *name=NULL) |
| llvm::Instruction * | SelectInst (llvm::Value *test, llvm::Value *val0, llvm::Value *val1, const char *name=NULL) |
| llvm::Value * | CallInst (llvm::Value *func, const FunctionType *funcType, const std::vector< llvm::Value * > &args, const char *name=NULL) |
| llvm::Value * | CallInst (llvm::Value *func, const FunctionType *funcType, llvm::Value *arg, const char *name=NULL) |
| llvm::Value * | CallInst (llvm::Value *func, const FunctionType *funcType, llvm::Value *arg0, llvm::Value *arg1, const char *name=NULL) |
| llvm::Value * | LaunchInst (llvm::Value *callee, std::vector< llvm::Value * > &argVals, llvm::Value *launchCount) |
| void | SyncInst () |
| llvm::Instruction * | ReturnInst () |
Private Member Functions | |
| llvm::Value * | pointerVectorToVoidPointers (llvm::Value *value) |
| bool | ifsInCFAllUniform (int cfType) const |
| void | jumpIfAllLoopLanesAreDone (llvm::BasicBlock *target) |
| llvm::Value * | emitGatherCallback (llvm::Value *lvalue, llvm::Value *retPtr) |
| llvm::Value * | applyVaryingGEP (llvm::Value *basePtr, llvm::Value *index, const Type *ptrType) |
| void | restoreMaskGivenReturns (llvm::Value *oldMask) |
| void | addSwitchMaskCheck (llvm::Value *mask) |
| bool | inSwitchStatement () const |
| llvm::Value * | getMaskAtSwitchEntry () |
| CFInfo * | popCFState () |
| void | scatter (llvm::Value *value, llvm::Value *ptr, const Type *valueType, const Type *ptrType, llvm::Value *mask) |
| void | maskedStore (llvm::Value *value, llvm::Value *ptr, const Type *ptrType, llvm::Value *mask) |
| void | storeUniformToSOA (llvm::Value *value, llvm::Value *ptr, llvm::Value *mask, const Type *valueType, const PointerType *ptrType) |
| llvm::Value * | loadUniformFromSOA (llvm::Value *ptr, llvm::Value *mask, const PointerType *ptrType, const char *name) |
| llvm::Value * | gather (llvm::Value *ptr, const PointerType *ptrType, llvm::Value *mask, const char *name) |
| llvm::Value * | addVaryingOffsetsIfNeeded (llvm::Value *ptr, const Type *ptrType) |
Static Private Member Functions | |
| static bool | initLabelBBlocks (ASTNode *node, void *data) |
| static void | addGSMetadata (llvm::Value *inst, SourcePos pos) |
Private Attributes | |
| Function * | function |
| llvm::Function * | llvmFunction |
| llvm::BasicBlock * | allocaBlock |
| llvm::BasicBlock * | bblock |
| llvm::Value * | fullMaskPointer |
| llvm::Value * | internalMaskPointer |
| llvm::Value * | functionMaskValue |
| SourcePos | currentPos |
| SourcePos | funcStartPos |
| llvm::Value * | loopMask |
| llvm::Value * | breakLanesPtr |
| llvm::Value * | continueLanesPtr |
| llvm::BasicBlock * | breakTarget |
| llvm::BasicBlock * | continueTarget |
| llvm::Value * | returnedLanesPtr |
| llvm::Value * | returnValuePtr |
| std::vector< CFInfo * > | controlFlowInfo |
| llvm::DIFile | diFile |
| llvm::DISubprogram | diSubprogram |
| std::vector< llvm::DILexicalBlock > | debugScopes |
| bool | launchedTasks |
| llvm::Value * | launchGroupHandlePtr |
| int | disableGSWarningCount |
| std::map< std::string, llvm::BasicBlock * > | labelMap |
Switch statement state | |
These variables store various state that's active when we're generating code for a switch statement. They should all be NULL outside of a switch. | |
| llvm::Value * | switchExpr |
| const std::vector< std::pair < int, llvm::BasicBlock * > > * | caseBlocks |
| llvm::BasicBlock * | defaultBlock |
| const std::map < llvm::BasicBlock *, llvm::BasicBlock * > * | nextBlocks |
| bool | switchConditionWasUniform |
Control flow management | |
| enum | ForeachType { FOREACH_REGULAR, FOREACH_ACTIVE, FOREACH_UNIQUE } |
| void | StartUniformIf () |
| void | StartVaryingIf (llvm::Value *oldMask) |
| void | EndIf () |
| void | StartLoop (llvm::BasicBlock *breakTarget, llvm::BasicBlock *continueTarget, bool uniformControlFlow) |
| void | SetLoopMask (llvm::Value *mask) |
| void | EndLoop () |
| void | StartForeach (ForeachType ft) |
| void | EndForeach () |
| void | Break (bool doCoherenceCheck) |
| void | Continue (bool doCoherenceCheck) |
| void | RestoreContinuedLanes () |
| void | StartSwitch (bool isUniform, llvm::BasicBlock *bbAfterSwitch) |
| void | EndSwitch () |
| void | SwitchInst (llvm::Value *expr, llvm::BasicBlock *defaultBlock, const std::vector< std::pair< int, llvm::BasicBlock * > > &caseBlocks, const std::map< llvm::BasicBlock *, llvm::BasicBlock * > &nextBlocks) |
| void | EmitDefaultLabel (bool checkMask, SourcePos pos) |
| void | EmitCaseLabel (int value, bool checkMask, SourcePos pos) |
| int | VaryingCFDepth () const |
| bool | InForeachLoop () const |
| void | DisableGatherScatterWarnings () |
| void | EnableGatherScatterWarnings () |
| void | SetContinueTarget (llvm::BasicBlock *bb) |
| void | InitializeLabelMap (Stmt *code) |
| llvm::BasicBlock * | GetLabeledBasicBlock (const std::string &label) |
| std::vector< std::string > | GetLabels () |
| void | CurrentLanesReturned (Expr *value, bool doCoherenceCheck) |
FunctionEmitContext is one of the key classes in ispc; it is used to help with emitting the intermediate representation of a function during compilation. It carries information the current program context during IR emission (e.g. the basic block into which instructions should be added; or, the current source file and line number, so debugging symbols can be correctly generated). This class also provides a number of helper routines that are useful for code that emits IR.
| FunctionEmitContext::FunctionEmitContext | ( | Function * | function, |
| Symbol * | funSym, | ||
| llvm::Function * | llvmFunction, | ||
| SourcePos | firstStmtPos | ||
| ) |
Create a new FunctionEmitContext.
| function | The Function object representing the function |
| funSym | Symbol that corresponds to the function |
| llvmFunction | LLVM function in the current module that corresponds to the function |
| firstStmtPos | Source file position of the first statement in the function |
Definition at line 230 of file ctx.cpp.
References allocaBlock, AllocaInst(), AssertPos, bblock, breakLanesPtr, breakTarget, caseBlocks, continueLanesPtr, continueTarget, Globals::ctx, currentPos, defaultBlock, Module::diBuilder, diFile, disableGSWarningCount, Opt::disableMaskAllOnOptimizations, diSubprogram, Type::Equal(), Module::errorCount, SourcePos::first_line, fullMaskPointer, funcStartPos, functionMaskValue, g, SourcePos::GetDIFile(), Target::GetISAString(), internalMaskPointer, launchedTasks, launchGroupHandlePtr, Opt::level, llvmFunction, LLVMMaskAllOff, LLVMMaskAllOn, Type::LLVMType(), LoadInst(), loopMask, m, LLVMTypes::MaskType, Module::module, Symbol::name, nextBlocks, NULL, Globals::opt, Symbol::pos, returnedLanesPtr, returnValuePtr, SC_STATIC, SetInternalMaskAnd(), StartScope(), Symbol::storageClass, StoreInst(), switchExpr, Globals::target, AtomicType::Void, LLVMTypes::VoidPointerType, and LLVMTypes::VoidType.
| FunctionEmitContext::~FunctionEmitContext | ( | ) |
Definition at line 367 of file ctx.cpp.
References AssertPos, controlFlowInfo, currentPos, debugScopes, Module::diBuilder, and m.
| void FunctionEmitContext::AddDebugPos | ( | llvm::Value * | instruction, |
| const SourcePos * | pos = NULL, |
||
| llvm::DIScope * | scope = NULL |
||
| ) |
Adds debugging metadata to the given instruction. If pos == NULL, use FunctionEmitContext::currentPos as the source file position for the instruction. Similarly, if a DIScope is provided, it's used and otherwise the scope is found from a GetDIScope() call. This takes a llvm::Value for the instruction rather than an llvm::Instruction for convenience; in calling code we often have Instructions stored using Value pointers; the code here returns silently if it's not actually given an instruction.
Definition at line 1466 of file ctx.cpp.
References currentPos, Module::diBuilder, SourcePos::first_column, SourcePos::first_line, GetDIScope(), m, and NULL.
Referenced by BinaryOperator(), BitCastInst(), BranchInst(), CallInst(), CastInst(), CmpInst(), EmitFunctionParameterDebugInfo(), EmitVariableDebugInfo(), ExtractInst(), FPCastInst(), GetElementPtrInst(), InsertInst(), IntToPtrInst(), LoadInst(), NotOperator(), PhiNode(), PtrToIntInst(), ReturnInst(), SelectInst(), SExtInst(), StoreInst(), SwitchInst(), TruncInst(), and ZExtInst().
| llvm::Value * FunctionEmitContext::AddElementOffset | ( | llvm::Value * | basePtr, |
| int | elementNum, | ||
| const Type * | ptrType, | ||
| const char * | name = NULL, |
||
| const PointerType ** | resultPtrType = NULL |
||
| ) |
This method returns a new pointer that represents offsetting the given base pointer to point at the given element number of the structure type that the base pointer points to. (The provided pointer must be a pointer to a structure type. The ptrType gives the type of the pointer, though it may be NULL if the base pointer is uniform.
Definition at line 2249 of file ctx.cpp.
References AssertPos, bblock, BinaryOperator(), Globals::ctx, currentPos, Module::errorCount, ExtractInst(), Opt::force32BitAddressing, g, PointerType::GetBaseType(), CollectionType::GetElementType(), SequentialType::GetElementType(), Type::GetReferenceTarget(), PointerType::GetUniform(), PointerType::GetVariability(), LLVMTypes::Int64VectorType, Target::is32Bit, PointerType::IsConstType(), PointerType::IsSlice(), Type::IsUniformType(), LLVMInt32(), LLVMInt64(), Type::LLVMType(), StructType::LLVMType(), m, MakeSlicePointer(), NULL, Globals::opt, SExtInst(), Target::SizeOf(), SmearUniform(), Target::StructOffset(), and Globals::target.
Referenced by PrintStmt::EmitCode(), gather(), MemberExpr::GetLValue(), MemberExpr::GetValue(), VectorMemberExpr::GetValue(), InitSymbol(), LaunchInst(), loadUniformFromSOA(), maskedStore(), scatter(), and storeUniformToSOA().
| void FunctionEmitContext::addGSMetadata | ( | llvm::Value * | v, |
| SourcePos | pos | ||
| ) | [static, private] |
Add metadata to the given instruction to encode the current source file position. This data is used in the lGetSourcePosFromMetadata() function in opt.cpp.
Definition at line 2612 of file ctx.cpp.
References Globals::ctx, SourcePos::first_column, SourcePos::first_line, g, SourcePos::last_column, SourcePos::last_line, LLVMInt32(), SourcePos::name, and NULL.
| void FunctionEmitContext::AddInstrumentationPoint | ( | const char * | note | ) |
If the user has asked to compile the program with instrumentation, this inserts a callback to the user-supplied instrumentation function at the current point in the code.
Definition at line 1433 of file ctx.cpp.
References AssertPos, bblock, CallInst(), currentPos, Globals::emitInstrumentation, SourcePos::first_line, g, GetFullMask(), LaneMask(), lGetStringAsValue(), LLVMInt32(), m, Module::module, SourcePos::name, and NULL.
Referenced by Continue(), CurrentLanesReturned(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), gather(), jumpIfAllLoopLanesAreDone(), lEmitIfStatements(), and scatter().
| void FunctionEmitContext::addSwitchMaskCheck | ( | llvm::Value * | mask | ) | [private] |
Emit code to check for an "all off" mask before the code for a case or default label in a "switch" statement.
Definition at line 942 of file ctx.cpp.
References AssertPos, bblock, BranchInst(), CreateBasicBlock(), currentPos, nextBlocks, None(), and SetCurrentBasicBlock().
Referenced by EmitCaseLabel(), and EmitDefaultLabel().
| llvm::Value * FunctionEmitContext::addVaryingOffsetsIfNeeded | ( | llvm::Value * | ptr, |
| const Type * | ptrType | ||
| ) | [private] |
When we gathering from or scattering to a varying atomic type, we need to add an appropriate offset to the final address for each lane right before we use it. Given a varying pointer we're about to use and its type, this function determines whether these offsets are needed and returns an updated pointer that incorporates these offsets if needed.
Definition at line 3479 of file ctx.cpp.
References AssertPos, bblock, BinaryOperator(), Globals::ctx, currentPos, Opt::force32BitAddressing, g, Type::GetAsUniformType(), Type::GetBaseType(), InsertInst(), LLVMTypes::Int64VectorType, Target::is32Bit, Type::IsBasicType(), Type::IsVaryingType(), LLVMInt32(), LLVMInt64(), Type::LLVMType(), Globals::opt, SExtInst(), Target::SizeOf(), SmearUniform(), Globals::target, and Target::vectorWidth.
| llvm::Value * FunctionEmitContext::All | ( | llvm::Value * | mask | ) |
Given a boolean mask value of type LLVMTypes::MaskType, return an i1 value that indicates if all of the mask lanes are on.
Definition at line 1305 of file ctx.cpp.
References CmpInst(), g, LaneMask(), LLVMGetName(), LLVMInt64(), Globals::target, and Target::vectorWidth.
Referenced by BranchIfMaskAll(), IfStmt::emitMaskAllOn(), IfStmt::emitVaryingIf(), jumpIfAllLoopLanesAreDone(), lEmitLogicalOp(), and MasksAllEqual().
| llvm::Value * FunctionEmitContext::AllocaInst | ( | llvm::Type * | llvmType, |
| const char * | name = NULL, |
||
| int | align = 0, |
||
| bool | atEntryBlock = true |
||
| ) |
Emits an alloca instruction to allocate stack storage for the given type. If a non-zero alignment is specified, the object is also allocated at the given alignment. By default, the alloca instruction is added at the start of the function in the entry basic block; if it should be added to the current basic block, then the atEntryBlock parameter should be false.
Definition at line 2640 of file ctx.cpp.
References allocaBlock, AssertPos, bblock, currentPos, Module::errorCount, g, m, Target::nativeVectorWidth, NULL, and Globals::target.
Referenced by CallInst(), DeclStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), PrintStmt::EmitCode(), FunctionEmitContext(), SelectExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), ReferenceExpr::GetValue(), VectorMemberExpr::GetValue(), lEmitLogicalOp(), lEmitVaryingSelect(), lProcessPrintArg(), StartForeach(), StartLoop(), and StartSwitch().
| llvm::Value * FunctionEmitContext::Any | ( | llvm::Value * | mask | ) |
Given a boolean mask value of type LLVMTypes::MaskType, return an i1 value that indicates if any of the mask lanes are on.
Definition at line 1297 of file ctx.cpp.
References CmpInst(), LaneMask(), LLVMGetName(), and LLVMInt64().
Referenced by BranchIfMaskAny(), CallInst(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), and lEmitSelectExprCode().
| llvm::Value * FunctionEmitContext::applyVaryingGEP | ( | llvm::Value * | basePtr, |
| llvm::Value * | index, | ||
| const Type * | ptrType | ||
| ) | [private] |
Utility routine used by the GetElementPtrInst() methods; given a pointer to some type (either uniform or varying) and an index (also either uniform or varying), this returns the new pointer (varying if appropriate) given by offsetting the base pointer by the index times the size of the object that the pointer points to.
Definition at line 1947 of file ctx.cpp.
References AssertPos, bblock, BinaryOperator(), Globals::ctx, currentPos, Opt::force32BitAddressing, g, Type::GetBaseType(), LLVMTypes::Int32Type, LLVMTypes::Int32VectorType, LLVMTypes::Int64Type, LLVMTypes::Int64VectorType, Target::is32Bit, LLVMGetName(), Type::LLVMType(), NULL, Globals::opt, SExtInst(), Target::SizeOf(), SmearUniform(), Globals::target, and TruncInst().
Referenced by GetElementPtrInst().
| llvm::Value * FunctionEmitContext::BinaryOperator | ( | llvm::Instruction::BinaryOps | inst, |
| llvm::Value * | v0, | ||
| llvm::Value * | v1, | ||
| const char * | name = NULL |
||
| ) |
Emit the binary operator given by the inst parameter. If llvm::Values corresponding to VectorTypes are given as operands, this also handles applying the given operation to the vector elements.
Definition at line 1590 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, ExtractInst(), InsertInst(), lArrayVectorWidth(), m, and NULL.
Referenced by AddElementOffset(), addVaryingOffsetsIfNeeded(), applyVaryingGEP(), Break(), CallInst(), Continue(), CurrentLanesReturned(), EmitCaseLabel(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), EmitDefaultLabel(), EndIf(), GetFullMask(), NewExpr::GetValue(), jumpIfAllLoopLanesAreDone(), lComputeSliceIndex(), lEmitBinaryArith(), lEmitBinaryBitOp(), lEmitBinaryPointerArith(), lEmitLogicalOp(), lEmitNegate(), lEmitPrePostIncDec(), lEmitSelectExprCode(), lUpdateVaryingCounter(), maskedStore(), RestoreContinuedLanes(), restoreMaskGivenReturns(), SetInternalMaskAnd(), and SetInternalMaskAndNot().
| llvm::Value * FunctionEmitContext::BitCastInst | ( | llvm::Value * | value, |
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1743 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, and NULL.
Referenced by PrintStmt::EmitCode(), DeleteStmt::EmitCode(), GetStringPtr(), TypeCastExpr::GetValue(), NewExpr::GetValue(), LaunchInst(), lFinalSliceOffset(), lProcessPrintArg(), and MemcpyInst().
| void FunctionEmitContext::BranchIfMaskAll | ( | llvm::BasicBlock * | btrue, |
| llvm::BasicBlock * | bfalse | ||
| ) |
Emits a branch instruction to the basic block btrue if all of the lanes of current mask are on and bfalse if none are on.
Definition at line 468 of file ctx.cpp.
References All(), AssertPos, bblock, BranchInst(), currentPos, GetFullMask(), and NULL.
Referenced by DoStmt::EmitCode(), and ForStmt::EmitCode().
| void FunctionEmitContext::BranchIfMaskAny | ( | llvm::BasicBlock * | btrue, |
| llvm::BasicBlock * | bfalse | ||
| ) |
Emits a branch instruction to the basic block btrue if any of the lanes of current mask are on and bfalse if none are on.
Definition at line 457 of file ctx.cpp.
References Any(), AssertPos, bblock, BranchInst(), currentPos, GetFullMask(), and NULL.
Referenced by BranchIfMaskNone(), DoStmt::EmitCode(), and ForStmt::EmitCode().
| void FunctionEmitContext::BranchIfMaskNone | ( | llvm::BasicBlock * | btrue, |
| llvm::BasicBlock * | bfalse | ||
| ) |
Emits a branch instruction to the basic block btrue if none of the lanes of current mask are on and bfalse if none are on.
Definition at line 479 of file ctx.cpp.
References AssertPos, bblock, BranchIfMaskAny(), currentPos, and NULL.
| void FunctionEmitContext::BranchInst | ( | llvm::BasicBlock * | block | ) |
Definition at line 3052 of file ctx.cpp.
References AddDebugPos(), and bblock.
Referenced by addSwitchMaskCheck(), BranchIfMaskAll(), BranchIfMaskAny(), Break(), CallInst(), Continue(), CurrentLanesReturned(), EmitCaseLabel(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), SwitchStmt::EmitCode(), GotoStmt::EmitCode(), LabeledStmt::EmitCode(), EmitDefaultLabel(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), SelectExpr::GetValue(), NewExpr::GetValue(), jumpIfAllLoopLanesAreDone(), lEmitLogicalOp(), lEmitSelectExprCode(), SwitchInst(), and SyncInst().
| void FunctionEmitContext::BranchInst | ( | llvm::BasicBlock * | trueBlock, |
| llvm::BasicBlock * | falseBlock, | ||
| llvm::Value * | test | ||
| ) |
Definition at line 3059 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, m, and NULL.
| void FunctionEmitContext::Break | ( | bool | doCoherenceCheck | ) |
Emit code for a 'break' statement in a loop. If doCoherenceCheck is true, then if we're in a 'varying' loop, code will be emitted to see if all of the lanes want to break, in which case a jump to the break target will be taken. (For 'uniform' loops, the jump is always done).
Definition at line 682 of file ctx.cpp.
References AssertPos, bblock, BinaryOperator(), BranchInst(), breakLanesPtr, breakTarget, continueTarget, controlFlowInfo, currentPos, Error(), GetInternalMask(), ifsInCFAllUniform(), inSwitchStatement(), jumpIfAllLoopLanesAreDone(), LLVMMaskAllOff, LoadInst(), CFInfo::Loop, NULL, SetInternalMask(), StoreInst(), CFInfo::Switch, switchConditionWasUniform, and Warning().
Referenced by BreakStmt::EmitCode().
| llvm::Value * FunctionEmitContext::CallInst | ( | llvm::Value * | func, |
| const FunctionType * | funcType, | ||
| const std::vector< llvm::Value * > & | args, | ||
| const char * | name = NULL |
||
| ) |
Emits IR to do a function call with the given arguments. If the function type is a varying function pointer type, its full type must be provided in funcType. funcType can be NULL if func is a uniform function pointer.
Definition at line 3174 of file ctx.cpp.
References AddDebugPos(), AllocaInst(), Any(), AssertPos, bblock, BinaryOperator(), BranchInst(), CmpInst(), CreateBasicBlock(), Globals::ctx, currentPos, Module::errorCount, g, GetFullMask(), GetInternalMask(), FunctionType::GetReturnType(), PointerType::GetUniform(), I1VecToBoolVec(), LLVMTypes::Int32Type, IntToPtrInst(), LaneMask(), lCalleeArgCount(), FunctionType::LLVMFunctionType(), LLVMMaskAllOn, Type::LLVMType(), LoadInst(), m, LLVMTypes::MaskType, Module::module, NULL, SetCurrentBasicBlock(), SetInternalMask(), SmearUniform(), StoreInst(), TruncInst(), and LLVMTypes::VoidType.
Referenced by AddInstrumentationPoint(), CallInst(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), PrintStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), gather(), FunctionCallExpr::GetValue(), NewExpr::GetValue(), LaneMask(), LaunchInst(), maskedStore(), MemcpyInst(), scatter(), and SyncInst().
| llvm::Value * FunctionEmitContext::CallInst | ( | llvm::Value * | func, |
| const FunctionType * | funcType, | ||
| llvm::Value * | arg, | ||
| const char * | name = NULL |
||
| ) |
This is a convenience method that issues a call instruction to a function that takes just a single argument.
Definition at line 3332 of file ctx.cpp.
References CallInst().
| llvm::Value * FunctionEmitContext::CallInst | ( | llvm::Value * | func, |
| const FunctionType * | funcType, | ||
| llvm::Value * | arg0, | ||
| llvm::Value * | arg1, | ||
| const char * | name = NULL |
||
| ) |
This is a convenience method that issues a call instruction to a function that takes two arguments.
Definition at line 3341 of file ctx.cpp.
References CallInst().
| llvm::Instruction * FunctionEmitContext::CastInst | ( | llvm::Instruction::CastOps | op, |
| llvm::Value * | value, | ||
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1864 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, and NULL.
Referenced by lTypeConvAtomic().
| llvm::Value * FunctionEmitContext::CmpInst | ( | llvm::Instruction::OtherOps | inst, |
| llvm::CmpInst::Predicate | pred, | ||
| llvm::Value * | v0, | ||
| llvm::Value * | v1, | ||
| const char * | name = NULL |
||
| ) |
Emit a comparison instruction. If the operands are VectorTypes, then a value for the corresponding boolean VectorType is returned.
Definition at line 1676 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, ExtractInst(), InsertInst(), lArrayVectorWidth(), lGetMatchingBoolVectorType(), m, and NULL.
Referenced by All(), Any(), CallInst(), EmitCaseLabel(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), EmitDefaultLabel(), TypeCastExpr::GetValue(), NewExpr::GetValue(), lEmitBinaryCmp(), lEmitLogicalOp(), lTypeConvAtomic(), MasksAllEqual(), None(), and SyncInst().
| void FunctionEmitContext::Continue | ( | bool | doCoherenceCheck | ) |
Emit code for a 'continue' statement in a loop. If doCoherenceCheck is true, then if we're in a 'varying' loop, code will be emitted to see if all of the lanes want to continue, in which case a jump to the continue target will be taken. (For 'uniform' loops, the jump is always done).
Definition at line 764 of file ctx.cpp.
References AddInstrumentationPoint(), AssertPos, bblock, BinaryOperator(), BranchInst(), continueLanesPtr, continueTarget, controlFlowInfo, currentPos, Error(), GetInternalMask(), ifsInCFAllUniform(), jumpIfAllLoopLanesAreDone(), lEnclosingLoopIsForeachActive(), LLVMMaskAllOff, LoadInst(), CFInfo::Loop, NULL, SetInternalMask(), StoreInst(), and Warning().
Referenced by ContinueStmt::EmitCode().
| llvm::BasicBlock * FunctionEmitContext::CreateBasicBlock | ( | const char * | name | ) |
Create a new basic block with given name
Definition at line 1378 of file ctx.cpp.
References Globals::ctx, g, and llvmFunction.
Referenced by addSwitchMaskCheck(), CallInst(), CurrentLanesReturned(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), SwitchStmt::EmitCode(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), SelectExpr::GetValue(), NewExpr::GetValue(), initLabelBBlocks(), jumpIfAllLoopLanesAreDone(), lEmitLogicalOp(), lEmitSelectExprCode(), lSwitchASTPreVisit(), and SyncInst().
| void FunctionEmitContext::CurrentLanesReturned | ( | Expr * | value, |
| bool | doCoherenceCheck | ||
| ) |
Called to generate code for 'return' statement; value is the expression in the return statement (if non-NULL), and doCoherenceCheck indicates whether instructions should be generated to see if all of the currently-running lanes have returned (if we're under varying control flow).
Definition at line 1221 of file ctx.cpp.
References AddInstrumentationPoint(), bblock, BinaryOperator(), BranchInst(), CreateBasicBlock(), Type::Equal(), Error(), funcStartPos, functionMaskValue, GetInternalMask(), Type::GetString(), Expr::GetType(), PointerType::GetUniform(), Expr::GetValue(), Type::IsUniformType(), LLVMMaskAllOff, LoadInst(), MasksAllEqual(), NULL, returnedLanesPtr, ReturnInst(), returnValuePtr, SetInternalMask(), StoreInst(), TypeConvertExpr(), VaryingCFDepth(), and AtomicType::Void.
Referenced by ReturnStmt::EmitCode().
| void FunctionEmitContext::DisableGatherScatterWarnings | ( | ) |
Temporarily disables emission of performance warnings from gathers and scatters from subsequent code.
Definition at line 1160 of file ctx.cpp.
References disableGSWarningCount.
Referenced by ForeachStmt::EmitCode().
| void FunctionEmitContext::EmitCaseLabel | ( | int | value, |
| bool | checkMask, | ||
| SourcePos | pos | ||
| ) |
Generates code for a "case" label after a "switch" statement. See the documentation for EmitDefaultLabel() for discussion of the checkMask parameter.
Definition at line 1036 of file ctx.cpp.
References addSwitchMaskCheck(), AssertPos, bblock, BinaryOperator(), BranchInst(), caseBlocks, CmpInst(), currentPos, Error(), GetInternalMask(), getMaskAtSwitchEntry(), I1VecToBoolVec(), inSwitchStatement(), LLVMTypes::Int32VectorType, LLVMInt32Vector(), LLVMInt64Vector(), NULL, SetCurrentBasicBlock(), SetInternalMask(), switchConditionWasUniform, and switchExpr.
Referenced by CaseStmt::EmitCode().
| void FunctionEmitContext::EmitDefaultLabel | ( | bool | checkMask, |
| SourcePos | pos | ||
| ) |
Generates code for a "default" label after a "switch" statement. The checkMask parameter indicates whether additional code should be generated to check to see if the execution mask is all off after the default label (in which case a jump to the following label will be issued.
Definition at line 973 of file ctx.cpp.
References addSwitchMaskCheck(), AssertPos, bblock, BinaryOperator(), BranchInst(), caseBlocks, CmpInst(), currentPos, defaultBlock, Error(), GetInternalMask(), getMaskAtSwitchEntry(), I1VecToBoolVec(), inSwitchStatement(), LLVMTypes::Int32VectorType, LLVMInt32Vector(), LLVMInt64Vector(), NotOperator(), NULL, SetCurrentBasicBlock(), SetInternalMask(), switchConditionWasUniform, and switchExpr.
Referenced by DefaultStmt::EmitCode().
| void FunctionEmitContext::EmitFunctionParameterDebugInfo | ( | Symbol * | sym, |
| int | parameterNum | ||
| ) |
Emits debugging information for the function parameter represented by sym.
Definition at line 1540 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::diBuilder, diSubprogram, SourcePos::first_line, SourcePos::GetDIFile(), Type::GetDIType(), m, Symbol::name, NULL, Symbol::pos, Symbol::storagePtr, and Symbol::type.
| llvm::Value* FunctionEmitContext::emitGatherCallback | ( | llvm::Value * | lvalue, |
| llvm::Value * | retPtr | ||
| ) | [private] |
| void FunctionEmitContext::EmitVariableDebugInfo | ( | Symbol * | sym | ) |
Emits debugging information for the variable represented by sym.
Definition at line 1517 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::diBuilder, SourcePos::first_line, SourcePos::GetDIFile(), GetDIScope(), Type::GetDIType(), m, Symbol::name, NULL, Symbol::pos, Symbol::storagePtr, and Symbol::type.
Referenced by DeclStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), and ForeachUniqueStmt::EmitCode().
| void FunctionEmitContext::EnableGatherScatterWarnings | ( | ) |
Reenables emission of gather/scatter performance warnings.
Definition at line 1166 of file ctx.cpp.
References disableGSWarningCount.
Referenced by ForeachStmt::EmitCode().
| void FunctionEmitContext::EndForeach | ( | ) |
Definition at line 641 of file ctx.cpp.
References AssertPos, currentPos, CFInfo::IsForeach(), and popCFState().
Referenced by ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), and ForeachUniqueStmt::EmitCode().
| void FunctionEmitContext::EndIf | ( | ) |
Notifies the FunctionEmitConitext that we're done emitting the IR for an 'if' statement.
Definition at line 502 of file ctx.cpp.
References AssertPos, bblock, BinaryOperator(), breakLanesPtr, continueLanesPtr, currentPos, GetInternalMask(), CFInfo::IsIf(), CFInfo::IsUniform(), LLVMMaskAllOff, LoadInst(), NotOperator(), NULL, popCFState(), restoreMaskGivenReturns(), CFInfo::savedMask, and SetInternalMask().
Referenced by IfStmt::EmitCode(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), and IfStmt::emitVaryingIf().
| void FunctionEmitContext::EndLoop | ( | ) |
Informs FunctionEmitContext that code generation for a loop is finished.
Definition at line 592 of file ctx.cpp.
References AssertPos, currentPos, CFInfo::IsLoop(), CFInfo::IsUniform(), popCFState(), restoreMaskGivenReturns(), and CFInfo::savedMask.
Referenced by DoStmt::EmitCode(), and ForStmt::EmitCode().
| void FunctionEmitContext::EndScope | ( | ) |
Inform the debugging information generation code that the current scope is ending in the source program.
Definition at line 1501 of file ctx.cpp.
References AssertPos, currentPos, debugScopes, Module::diBuilder, m, and NULL.
Referenced by DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), StmtList::EmitCode(), and lEmitIfStatements().
| void FunctionEmitContext::EndSwitch | ( | ) |
Indicates the end of code generation for a "switch" statement.
Definition at line 929 of file ctx.cpp.
References AssertPos, bblock, currentPos, CFInfo::IsVarying(), NULL, popCFState(), restoreMaskGivenReturns(), and CFInfo::savedMask.
Referenced by SwitchStmt::EmitCode().
| llvm::Value * FunctionEmitContext::ExtractInst | ( | llvm::Value * | v, |
| int | elt, | ||
| const char * | name = NULL |
||
| ) |
This convenience method maps to an llvm::ExtractElementInst if the given value is a llvm::VectorType, and to an llvm::ExtractValueInst otherwise.
Definition at line 3074 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), LLVMInt32(), m, and NULL.
Referenced by AddElementOffset(), BinaryOperator(), CmpInst(), GetElementPtrInst(), SelectExpr::GetValue(), TypeCastExpr::GetValue(), NewExpr::GetValue(), I1VecToBoolVec(), lEmitBinaryPointerArith(), lFinalSliceOffset(), lUniformValueToVarying(), maskedStore(), NotOperator(), scatter(), and storeUniformToSOA().
| llvm::Instruction * FunctionEmitContext::FPCastInst | ( | llvm::Value * | value, |
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1884 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, and NULL.
Referenced by lTypeConvAtomic().
| llvm::Value * FunctionEmitContext::gather | ( | llvm::Value * | ptr, |
| const PointerType * | ptrType, | ||
| llvm::Value * | mask, | ||
| const char * | name | ||
| ) | [private] |
Definition at line 2522 of file ctx.cpp.
References AddElementOffset(), addGSMetadata(), AddInstrumentationPoint(), addVaryingOffsetsIfNeeded(), AssertPos, CallInst(), Globals::ctx, currentPos, disableGSWarningCount, LLVMTypes::DoubleVectorType, LLVMTypes::FloatVectorType, g, Type::GetAsVaryingType(), PointerType::GetBaseType(), CollectionType::GetElementCount(), InsertInst(), LLVMTypes::Int16VectorType, LLVMTypes::Int32VectorType, LLVMTypes::Int64VectorType, LLVMTypes::Int8VectorType, Target::is32Bit, PointerType::IsSlice(), Type::IsVaryingType(), lFinalSliceOffset(), Type::LLVMType(), LoadInst(), m, Module::module, NULL, and Globals::target.
Referenced by LoadInst().
| llvm::BasicBlock * FunctionEmitContext::GetCurrentBasicBlock | ( | ) |
Returns the current basic block pointer
Definition at line 380 of file ctx.cpp.
References bblock.
Referenced by ExprStmt::EmitCode(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), BreakStmt::EmitCode(), ContinueStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), UnmaskedStmt::EmitCode(), ReturnStmt::EmitCode(), SwitchStmt::EmitCode(), GotoStmt::EmitCode(), LabeledStmt::EmitCode(), PrintStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskedTrueAndFalse(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), SelectExpr::GetValue(), SizeOfExpr::GetValue(), NewExpr::GetValue(), InitSymbol(), and lEmitBinaryPointerArith().
| SourcePos FunctionEmitContext::GetDebugPos | ( | ) | const |
Definition at line 1460 of file ctx.cpp.
References currentPos.
Referenced by IfStmt::emitMaskedTrueAndFalse().
| llvm::DIScope FunctionEmitContext::GetDIScope | ( | ) | const |
Returns the llvm::DIScope corresponding to the current program scope.
Definition at line 1510 of file ctx.cpp.
References AssertPos, currentPos, and debugScopes.
Referenced by AddDebugPos(), and EmitVariableDebugInfo().
| llvm::Value * FunctionEmitContext::GetElementPtrInst | ( | llvm::Value * | basePtr, |
| llvm::Value * | index, | ||
| const Type * | ptrType, | ||
| const char * | name = NULL |
||
| ) |
These GEP methods are generalizations of the standard ones in LLVM; they support both uniform and varying basePtr values as well as uniform and varying index values (arrays of indices). Varying base pointers are expected to come in as vectors of i32/i64 (depending on the target), since LLVM doesn't currently support vectors of pointers. The underlying type of the base pointer must be provided via the ptrType parameter
Definition at line 2103 of file ctx.cpp.
References AddDebugPos(), applyVaryingGEP(), AssertPos, bblock, currentPos, Module::errorCount, ExtractInst(), PointerType::GetAsNonSlice(), PointerType::GetBaseType(), Type::GetReferenceTarget(), Type::GetSOAWidth(), PointerType::GetUniform(), PointerType::IsFrozenSlice(), PointerType::IsSlice(), Type::IsUniformType(), Type::IsVaryingType(), lComputeSliceIndex(), m, MakeSlicePointer(), and NULL.
Referenced by ForeachUniqueStmt::EmitCode(), GetElementPtrInst(), IndexExpr::GetLValue(), IndexExpr::GetValue(), InitSymbol(), lAddVaryingOffsetsIfNeeded(), lEmitBinaryPointerArith(), lEmitPrePostIncDec(), and lFinalSliceOffset().
| llvm::Value * FunctionEmitContext::GetElementPtrInst | ( | llvm::Value * | basePtr, |
| llvm::Value * | index0, | ||
| llvm::Value * | index1, | ||
| const Type * | ptrType, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 2172 of file ctx.cpp.
References AddDebugPos(), applyVaryingGEP(), AssertPos, bblock, currentPos, Module::errorCount, ExtractInst(), PointerType::GetAsNonSlice(), PointerType::GetBaseType(), GetElementPtrInst(), SequentialType::GetElementType(), Type::GetReferenceTarget(), Type::GetSOAWidth(), PointerType::GetUniform(), PointerType::GetVarying(), PointerType::IsFrozenSlice(), PointerType::IsSlice(), Type::IsUniformType(), lComputeSliceIndex(), m, MakeSlicePointer(), and NULL.
| llvm::Value * FunctionEmitContext::GetFullMask | ( | ) |
Returns the complete current mask value--i.e. the logical AND of the function entry mask and the internal mask.
Definition at line 404 of file ctx.cpp.
References BinaryOperator(), functionMaskValue, and GetInternalMask().
Referenced by AddInstrumentationPoint(), BranchIfMaskAll(), BranchIfMaskAny(), CallInst(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), PrintStmt::EmitCode(), AssertStmt::EmitCode(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), SelectExpr::GetValue(), DerefExpr::GetValue(), VectorMemberExpr::GetValue(), LaunchInst(), lEmitLogicalOp(), lMaskForSymbol(), LoadInst(), SetFunctionMask(), SetInternalMask(), and StoreInst().
| llvm::Value * FunctionEmitContext::GetFullMaskPointer | ( | ) |
Returns a pointer to storage in memory that stores the current full mask.
Definition at line 411 of file ctx.cpp.
References fullMaskPointer.
| const Function * FunctionEmitContext::GetFunction | ( | ) | const |
Returns the Function * corresponding to the function that we're currently generating code for.
Definition at line 374 of file ctx.cpp.
Referenced by DeclStmt::EmitCode(), ForeachStmt::EmitCode(), ReturnStmt::EmitCode(), and lMaskForSymbol().
| llvm::Value * FunctionEmitContext::GetFunctionMask | ( | ) |
Returns the mask value at entry to the current function.
Definition at line 392 of file ctx.cpp.
References functionMaskValue.
Referenced by DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), UnmaskedStmt::EmitCode(), and IfStmt::emitMaskAllOn().
| llvm::Value * FunctionEmitContext::GetInternalMask | ( | ) |
Returns the mask value corresponding to "varying" control flow within the current function. (i.e. this doesn't include the effect of the mask at function entry.
Definition at line 398 of file ctx.cpp.
References internalMaskPointer, and LoadInst().
Referenced by Break(), CallInst(), Continue(), CurrentLanesReturned(), EmitCaseLabel(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), UnmaskedStmt::EmitCode(), EmitDefaultLabel(), IfStmt::emitVaryingIf(), EndIf(), GetFullMask(), SelectExpr::GetValue(), lEmitLogicalOp(), lMaskForSymbol(), RestoreContinuedLanes(), StartForeach(), StartLoop(), StartSwitch(), and StartUniformIf().
| llvm::BasicBlock * FunctionEmitContext::GetLabeledBasicBlock | ( | const std::string & | label | ) |
If there is a label in the function with the given name, return the new basic block that it starts.
Definition at line 1199 of file ctx.cpp.
References labelMap, and NULL.
Referenced by GotoStmt::EmitCode(), and LabeledStmt::EmitCode().
| std::vector< std::string > FunctionEmitContext::GetLabels | ( | ) |
Returns a vector of all labels in the context. This is simply the key set of the labelMap
Definition at line 1207 of file ctx.cpp.
References labelMap.
Referenced by GotoStmt::EmitCode().
| llvm::Value * FunctionEmitContext::getMaskAtSwitchEntry | ( | ) | [private] |
Returns the execution mask at entry to the first enclosing "switch" statement.
Definition at line 962 of file ctx.cpp.
References AssertPos, controlFlowInfo, currentPos, and CFInfo::Switch.
Referenced by EmitCaseLabel(), and EmitDefaultLabel().
| llvm::Value * FunctionEmitContext::GetStringPtr | ( | const std::string & | str | ) |
Given a string, create an anonymous global variable to hold its value and return the pointer to the string.
Definition at line 1362 of file ctx.cpp.
References bblock, BitCastInst(), Globals::ctx, g, m, Module::module, and LLVMTypes::VoidPointerType.
Referenced by PrintStmt::EmitCode(), and AssertStmt::EmitCode().
| llvm::Value * FunctionEmitContext::I1VecToBoolVec | ( | llvm::Value * | b | ) |
Given a vector with element type i1, return a vector of type LLVMTypes::BoolVectorType. This method handles the conversion for the targets where the bool vector element type is, for example, i32.
Definition at line 1384 of file ctx.cpp.
References AssertPos, LLVMTypes::BoolVectorType, currentPos, Module::errorCount, ExtractInst(), g, InsertInst(), LLVMGetName(), m, Target::maskBitCount, NULL, SExtInst(), and Globals::target.
Referenced by CallInst(), EmitCaseLabel(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), EmitDefaultLabel(), TypeCastExpr::GetValue(), lEmitBinaryCmp(), lEmitLogicalOp(), lTypeConvAtomic(), and MasksAllEqual().
| bool FunctionEmitContext::ifsInCFAllUniform | ( | int | type | ) | const [private] |
This function checks to see if all of the 'if' statements (if any) between the current scope and the first enclosing loop/switch of given control flow type have 'uniform' tests.
Definition at line 817 of file ctx.cpp.
References AssertPos, controlFlowInfo, and currentPos.
Referenced by Break(), and Continue().
| bool FunctionEmitContext::InForeachLoop | ( | ) | const |
Definition at line 1151 of file ctx.cpp.
References controlFlowInfo.
Referenced by ReturnStmt::EmitCode(), and GotoStmt::EmitCode().
| void FunctionEmitContext::InitializeLabelMap | ( | Stmt * | code | ) |
Step through the code and find label statements; create a basic block for each one, so that subsequent calls to GetLabeledBasicBlock() return the corresponding basic block.
Definition at line 1192 of file ctx.cpp.
References initLabelBBlocks(), labelMap, and NULL.
| bool FunctionEmitContext::initLabelBBlocks | ( | ASTNode * | node, |
| void * | data | ||
| ) | [static, private] |
Definition at line 1173 of file ctx.cpp.
References CreateBasicBlock(), Error(), labelMap, LabeledStmt::name, and NULL.
Referenced by InitializeLabelMap().
| llvm::Value * FunctionEmitContext::InsertInst | ( | llvm::Value * | v, |
| llvm::Value * | eltVal, | ||
| int | elt, | ||
| const char * | name = NULL |
||
| ) |
This convenience method maps to an llvm::InsertElementInst if the given value is a llvm::VectorType, and to an llvm::InsertValueInst otherwise.
Definition at line 3097 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), LLVMInt32(), m, and NULL.
Referenced by addVaryingOffsetsIfNeeded(), BinaryOperator(), CmpInst(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), gather(), SelectExpr::GetValue(), TypeCastExpr::GetValue(), I1VecToBoolVec(), lAddVaryingOffsetsIfNeeded(), lConvertToSlicePointer(), loadUniformFromSOA(), lUniformValueToVarying(), lUpdateVaryingCounter(), MakeSlicePointer(), NotOperator(), and SmearUniform().
| bool FunctionEmitContext::inSwitchStatement | ( | ) | const [private] |
Returns "true" if the first enclosing non-if control flow expression is a "switch" statement.
Definition at line 668 of file ctx.cpp.
References controlFlowInfo.
Referenced by Break(), EmitCaseLabel(), and EmitDefaultLabel().
| llvm::Value * FunctionEmitContext::IntToPtrInst | ( | llvm::Value * | value, |
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1812 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, NULL, TruncInst(), and ZExtInst().
Referenced by CallInst(), ForeachUniqueStmt::EmitCode(), TypeCastExpr::GetValue(), and NewExpr::GetValue().
| void FunctionEmitContext::jumpIfAllLoopLanesAreDone | ( | llvm::BasicBlock * | target | ) | [private] |
Definition at line 835 of file ctx.cpp.
References AddInstrumentationPoint(), All(), AssertPos, bblock, BinaryOperator(), BranchInst(), breakLanesPtr, continueLanesPtr, CreateBasicBlock(), currentPos, LoadInst(), loopMask, MasksAllEqual(), NULL, and returnedLanesPtr.
Referenced by Break(), and Continue().
| llvm::Value * FunctionEmitContext::LaneMask | ( | llvm::Value * | mask | ) |
Given a boolean mask value of type LLVMTypes::MaskType, return an i64 value wherein the i'th bit is on if and only if the i'th lane of the mask is on.
Definition at line 1325 of file ctx.cpp.
References AssertPos, CallInst(), currentPos, g, LLVMGetName(), SymbolTable::LookupFunction(), m, Target::maskBitCount, NULL, Module::symbolTable, and Globals::target.
Referenced by AddInstrumentationPoint(), All(), Any(), CallInst(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), PrintStmt::EmitCode(), MasksAllEqual(), and None().
| llvm::Value * FunctionEmitContext::LaunchInst | ( | llvm::Value * | callee, |
| std::vector< llvm::Value * > & | argVals, | ||
| llvm::Value * | launchCount | ||
| ) |
Launch an asynchronous task to run the given function, passing it he given argument values.
Definition at line 3376 of file ctx.cpp.
References AddElementOffset(), AssertPos, bblock, BitCastInst(), CallInst(), currentPos, Module::errorCount, g, GetFullMask(), LLVMTypes::Int64Type, launchedTasks, launchGroupHandlePtr, LLVMInt32(), m, Module::module, Target::nativeVectorWidth, NULL, RoundUpPow2(), Target::SizeOf(), StoreInst(), Globals::target, LLVMTypes::VoidPointerType, and ZExtInst().
Referenced by FunctionCallExpr::GetValue().
| llvm::Value * FunctionEmitContext::LoadInst | ( | llvm::Value * | ptr, |
| llvm::Value * | mask, | ||
| const Type * | ptrType, | ||
| const char * | name = NULL |
||
| ) |
Load from the memory location(s) given by lvalue, using the given mask. The lvalue may be varying, in which case this corresponds to a gather from the multiple memory locations given by the array of pointer values given by the lvalue. If the lvalue is not varying, then both the mask pointer and the type pointer may be NULL.
Definition at line 2465 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, gather(), PointerType::GetBaseType(), GetFullMask(), Type::GetReferenceTarget(), PointerType::GetUniform(), PointerType::IsSlice(), Type::IsUniformType(), Type::IsVaryingType(), LLVMGetName(), loadUniformFromSOA(), m, and NULL.
Referenced by Break(), CallInst(), Continue(), CurrentLanesReturned(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), EndIf(), FunctionEmitContext(), gather(), GetInternalMask(), SelectExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), DerefExpr::GetValue(), SymbolExpr::GetValue(), VectorMemberExpr::GetValue(), jumpIfAllLoopLanesAreDone(), lEmitLogicalOp(), lEmitOpAssign(), lEmitVaryingSelect(), LoadInst(), loadUniformFromSOA(), lUpdateVaryingCounter(), maskedStore(), RestoreContinuedLanes(), restoreMaskGivenReturns(), ReturnInst(), and SyncInst().
| llvm::Value * FunctionEmitContext::LoadInst | ( | llvm::Value * | ptr, |
| const char * | name = NULL |
||
| ) |
Definition at line 2364 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), LoadInst(), m, and NULL.
| llvm::Value * FunctionEmitContext::loadUniformFromSOA | ( | llvm::Value * | ptr, |
| llvm::Value * | mask, | ||
| const PointerType * | ptrType, | ||
| const char * | name | ||
| ) | [private] |
Utility routine that loads from a uniform pointer to soa<> data, returning a regular uniform (non-SOA result).
Definition at line 2431 of file ctx.cpp.
References AddElementOffset(), Globals::ctx, g, Type::GetAsUniformType(), PointerType::GetBaseType(), CollectionType::GetElementCount(), InsertInst(), lFinalSliceOffset(), Type::LLVMType(), LoadInst(), and NULL.
Referenced by LoadInst().
| llvm::Value * FunctionEmitContext::MakeSlicePointer | ( | llvm::Value * | ptr, |
| llvm::Value * | offset | ||
| ) |
Create a new slice pointer out of the given pointer to an soa type and an integer offset to a slice within that type.
Definition at line 2085 of file ctx.cpp.
References Globals::ctx, g, InsertInst(), and LLVMGetName().
Referenced by AddElementOffset(), GetElementPtrInst(), and TypeCastExpr::GetValue().
| void FunctionEmitContext::maskedStore | ( | llvm::Value * | value, |
| llvm::Value * | ptr, | ||
| const Type * | ptrType, | ||
| llvm::Value * | mask | ||
| ) | [private] |
Code to store the given varying value to the given location, only storing the elements that correspond to active program instances as given by the provided storeMask value. Note that the lvalue is only a single pointer, not a varying lvalue of one pointer per program instance (that case is handled by scatters).
Definition at line 2686 of file ctx.cpp.
References AddElementOffset(), Assert, AssertPos, BinaryOperator(), CallInst(), currentPos, Type::Equal(), Module::errorCount, ExtractInst(), g, PointerType::GetAsNonSlice(), Type::GetBaseType(), CollectionType::GetElementCount(), CollectionType::GetElementType(), PointerType::GetUniform(), Target::is32Bit, Type::IsBasicType(), PointerType::IsSlice(), Type::IsUniformType(), Type::IsVaryingType(), LLVMMaskAllOn, LoadInst(), m, Target::maskBitCount, Module::module, NULL, StoreInst(), Globals::target, AtomicType::VaryingBool, AtomicType::VaryingDouble, AtomicType::VaryingFloat, AtomicType::VaryingInt16, AtomicType::VaryingInt32, AtomicType::VaryingInt64, AtomicType::VaryingInt8, AtomicType::VaryingUInt16, AtomicType::VaryingUInt32, AtomicType::VaryingUInt64, and AtomicType::VaryingUInt8.
Referenced by StoreInst().
| llvm::Value * FunctionEmitContext::MasksAllEqual | ( | llvm::Value * | mask1, |
| llvm::Value * | mask2 | ||
| ) |
Given two masks of type LLVMTypes::MaskType, return an i1 value that indicates whether the two masks are equal.
Definition at line 1343 of file ctx.cpp.
References All(), CmpInst(), I1VecToBoolVec(), LaneMask(), and LLVMGetName().
Referenced by CurrentLanesReturned(), and jumpIfAllLoopLanesAreDone().
| void FunctionEmitContext::MatchIntegerTypes | ( | llvm::Value ** | v0, |
| llvm::Value ** | v1 | ||
| ) |
Given two integer-typed values (but possibly one vector and the other not, and or of possibly-different bit-widths), update their values as needed so that the two have the same (more general) type.
Definition at line 2012 of file ctx.cpp.
References LLVMTypes::Int32VectorType, LLVMTypes::Int64VectorType, SExtInst(), and SmearUniform().
Referenced by lComputeSliceIndex(), and lEmitBinaryPointerArith().
| void FunctionEmitContext::MemcpyInst | ( | llvm::Value * | dest, |
| llvm::Value * | src, | ||
| llvm::Value * | count, | ||
| llvm::Value * | align = NULL |
||
| ) |
Copy count bytes of memory from the location pointed to by src to the location pointed to by dest. (src and dest must not be overlapping.)
Definition at line 3022 of file ctx.cpp.
References AssertPos, BitCastInst(), LLVMTypes::BoolType, CallInst(), currentPos, LLVMTypes::Int32Type, LLVMTypes::Int64Type, LLVMFalse, LLVMInt32(), m, Module::module, NULL, LLVMTypes::VoidPointerType, LLVMTypes::VoidType, and ZExtInst().
Referenced by InitSymbol().
| llvm::Value * FunctionEmitContext::None | ( | llvm::Value * | mask | ) |
Given a boolean mask value of type LLVMTypes::MaskType, return an i1 value that indicates if all of the mask lanes are off.
Definition at line 1317 of file ctx.cpp.
References CmpInst(), LaneMask(), LLVMGetName(), and LLVMInt64().
Referenced by addSwitchMaskCheck().
| llvm::Value * FunctionEmitContext::NotOperator | ( | llvm::Value * | v, |
| const char * | name = NULL |
||
| ) |
Emit the "not" operator. Like BinaryOperator(), this also handles a VectorType-based operand.
Definition at line 1624 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, ExtractInst(), InsertInst(), lArrayVectorWidth(), m, and NULL.
Referenced by ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), EmitDefaultLabel(), EndIf(), UnaryExpr::GetValue(), SelectExpr::GetValue(), lEmitLogicalOp(), and restoreMaskGivenReturns().
| llvm::PHINode * FunctionEmitContext::PhiNode | ( | llvm::Type * | type, |
| int | count, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 3122 of file ctx.cpp.
References AddDebugPos(), and bblock.
Referenced by SelectExpr::GetValue().
| llvm::Value* FunctionEmitContext::pointerVectorToVoidPointers | ( | llvm::Value * | value | ) | [private] |
| CFInfo * FunctionEmitContext::popCFState | ( | ) | [private] |
Definition at line 3519 of file ctx.cpp.
References AssertPos, breakLanesPtr, breakTarget, caseBlocks, continueLanesPtr, continueTarget, controlFlowInfo, currentPos, defaultBlock, loopMask, nextBlocks, switchConditionWasUniform, and switchExpr.
Referenced by EndForeach(), EndIf(), EndLoop(), and EndSwitch().
| llvm::Value * FunctionEmitContext::PtrToIntInst | ( | llvm::Value * | value, |
| const char * | name = NULL |
||
| ) |
Definition at line 1760 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, NULL, and LLVMTypes::PointerIntType.
Referenced by TypeCastExpr::GetValue(), lEmitBinaryPointerArith(), PtrToIntInst(), and SmearUniform().
| llvm::Value * FunctionEmitContext::PtrToIntInst | ( | llvm::Value * | value, |
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1780 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, NULL, PtrToIntInst(), TruncInst(), and ZExtInst().
| void FunctionEmitContext::RestoreContinuedLanes | ( | ) |
This method is called by code emitting IR for a loop at the end of the loop body; it restores the lanes of the mask that executed a 'continue' statement when going through the loop body in the previous iteration.
Definition at line 885 of file ctx.cpp.
References BinaryOperator(), continueLanesPtr, GetInternalMask(), LLVMMaskAllOff, LoadInst(), NULL, SetInternalMask(), and StoreInst().
Referenced by DoStmt::EmitCode(), ForStmt::EmitCode(), and ForeachStmt::EmitCode().
| void FunctionEmitContext::restoreMaskGivenReturns | ( | llvm::Value * | oldMask | ) | [private] |
Definition at line 648 of file ctx.cpp.
References bblock, BinaryOperator(), LoadInst(), NotOperator(), returnedLanesPtr, and SetInternalMask().
Referenced by EndIf(), EndLoop(), and EndSwitch().
| llvm::Instruction * FunctionEmitContext::ReturnInst | ( | ) |
Definition at line 3352 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, Globals::ctx, currentPos, Type::Equal(), function, g, launchedTasks, LoadInst(), NULL, returnValuePtr, SyncInst(), and AtomicType::Void.
Referenced by CurrentLanesReturned().
| void FunctionEmitContext::scatter | ( | llvm::Value * | value, |
| llvm::Value * | ptr, | ||
| const Type * | valueType, | ||
| const Type * | origPt, | ||
| llvm::Value * | mask | ||
| ) | [private] |
Scatter the given varying value to the locations given by the varying lvalue (which should be an array of pointers with size equal to the target's vector width. We want to store each rvalue element at the corresponding pointer's location, *if* the mask for the corresponding program instance are on. If they're off, don't do anything.
Definition at line 2808 of file ctx.cpp.
References AddElementOffset(), addGSMetadata(), AddInstrumentationPoint(), addVaryingOffsetsIfNeeded(), AssertPos, CallInst(), currentPos, disableGSWarningCount, LLVMTypes::DoubleVectorType, ExtractInst(), LLVMTypes::FloatVectorType, g, PointerType::GetAsSlice(), Type::GetAsVaryingType(), PointerType::GetBaseType(), CollectionType::GetElementType(), PointerType::GetVarying(), LLVMTypes::Int16VectorType, LLVMTypes::Int32VectorType, LLVMTypes::Int64VectorType, LLVMTypes::Int8VectorType, Target::is32Bit, Type::IsBasicType(), PointerType::IsSlice(), Type::IsUniformType(), Type::IsVaryingType(), lFinalSliceOffset(), m, Module::module, NULL, SmearUniform(), and Globals::target.
Referenced by StoreInst().
| llvm::Instruction * FunctionEmitContext::SelectInst | ( | llvm::Value * | test, |
| llvm::Value * | val0, | ||
| llvm::Value * | val1, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 3132 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, and NULL.
Referenced by SelectExpr::GetValue().
| void FunctionEmitContext::SetContinueTarget | ( | llvm::BasicBlock * | bb | ) | [inline] |
Definition at line 245 of file ctx.h.
Referenced by ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), and ForeachUniqueStmt::EmitCode().
| void FunctionEmitContext::SetCurrentBasicBlock | ( | llvm::BasicBlock * | bblock | ) |
Set the given llvm::BasicBlock to be the basic block to emit forthcoming instructions into.
Definition at line 386 of file ctx.cpp.
References bblock.
Referenced by addSwitchMaskCheck(), CallInst(), EmitCaseLabel(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), SwitchStmt::EmitCode(), GotoStmt::EmitCode(), LabeledStmt::EmitCode(), EmitDefaultLabel(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), SelectExpr::GetValue(), NewExpr::GetValue(), lEmitLogicalOp(), lEmitSelectExprCode(), and SyncInst().
| void FunctionEmitContext::SetDebugPos | ( | SourcePos | pos | ) |
Set the current source file position; subsequent emitted instructions will have this position associated with them if debugging information is being generated.
Definition at line 1454 of file ctx.cpp.
References currentPos.
Referenced by ExprStmt::EmitCode(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), BreakStmt::EmitCode(), ContinueStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), ReturnStmt::EmitCode(), StmtList::EmitCode(), PrintStmt::EmitCode(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), SymbolExpr::GetLValue(), UnaryExpr::GetValue(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), FunctionCallExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), ConstExpr::GetValue(), TypeCastExpr::GetValue(), ReferenceExpr::GetValue(), DerefExpr::GetValue(), AddressOfExpr::GetValue(), SizeOfExpr::GetValue(), SymbolExpr::GetValue(), SyncExpr::GetValue(), VectorMemberExpr::GetValue(), lEmitNegate(), lEmitOpAssign(), and lEmitPrePostIncDec().
| void FunctionEmitContext::SetFunctionMask | ( | llvm::Value * | val | ) |
Provides the value of the mask at function entry
Definition at line 417 of file ctx.cpp.
References bblock, fullMaskPointer, functionMaskValue, GetFullMask(), NULL, and StoreInst().
Referenced by DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), UnmaskedStmt::EmitCode(), and IfStmt::emitMaskAllOn().
| void FunctionEmitContext::SetInternalMask | ( | llvm::Value * | val | ) |
Sets the internal mask to a new value
Definition at line 431 of file ctx.cpp.
References fullMaskPointer, GetFullMask(), internalMaskPointer, and StoreInst().
Referenced by Break(), CallInst(), Continue(), CurrentLanesReturned(), EmitCaseLabel(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), UnmaskedStmt::EmitCode(), EmitDefaultLabel(), IfStmt::emitMaskAllOn(), EndIf(), SelectExpr::GetValue(), lEmitLogicalOp(), lEmitSelectExprCode(), RestoreContinuedLanes(), restoreMaskGivenReturns(), SetInternalMaskAnd(), SetInternalMaskAndNot(), and SwitchInst().
| void FunctionEmitContext::SetInternalMaskAnd | ( | llvm::Value * | oldMask, |
| llvm::Value * | val | ||
| ) |
Sets the internal mask to (oldMask & val)
Definition at line 439 of file ctx.cpp.
References BinaryOperator(), and SetInternalMask().
Referenced by DoStmt::EmitCode(), ForStmt::EmitCode(), IfStmt::emitMaskedTrueAndFalse(), IfStmt::emitMaskMixed(), FunctionEmitContext(), SelectExpr::GetValue(), and lEmitLogicalOp().
| void FunctionEmitContext::SetInternalMaskAndNot | ( | llvm::Value * | oldMask, |
| llvm::Value * | test | ||
| ) |
Sets the internal mask to (oldMask & ~val)
Definition at line 447 of file ctx.cpp.
References BinaryOperator(), LLVMMaskAllOn, and SetInternalMask().
Referenced by IfStmt::EmitCode(), IfStmt::emitMaskedTrueAndFalse(), IfStmt::emitMaskMixed(), and SelectExpr::GetValue().
| void FunctionEmitContext::SetLoopMask | ( | llvm::Value * | mask | ) |
Informs FunctionEmitContext of the value of the mask at the start of a loop body.
Definition at line 425 of file ctx.cpp.
References loopMask.
Referenced by DoStmt::EmitCode(), and ForStmt::EmitCode().
| llvm::Instruction * FunctionEmitContext::SExtInst | ( | llvm::Value * | value, |
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1903 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, and NULL.
Referenced by AddElementOffset(), addVaryingOffsetsIfNeeded(), applyVaryingGEP(), NewExpr::GetValue(), I1VecToBoolVec(), lTypeConvAtomic(), and MatchIntegerTypes().
| llvm::Value * FunctionEmitContext::SmearUniform | ( | llvm::Value * | value, |
| const char * | name = NULL |
||
| ) |
Given a scalar value, return a vector of the same type (or an array, for pointer types).
Definition at line 1710 of file ctx.cpp.
References AssertPos, currentPos, Module::errorCount, g, InsertInst(), m, NULL, PtrToIntInst(), Globals::target, Target::vectorWidth, and LLVMTypes::VoidPointerVectorType.
Referenced by AddElementOffset(), addVaryingOffsetsIfNeeded(), applyVaryingGEP(), CallInst(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), TypeCastExpr::GetValue(), NewExpr::GetValue(), lEmitBinaryPointerArith(), lTypeConvAtomic(), lUniformValueToVarying(), MatchIntegerTypes(), and scatter().
| void FunctionEmitContext::StartForeach | ( | ForeachType | ft | ) |
Definition at line 607 of file ctx.cpp.
References AllocaInst(), breakLanesPtr, breakTarget, continueLanesPtr, continueTarget, controlFlowInfo, currentPos, Error(), FOREACH_REGULAR, CFInfo::ForeachRegular, CFInfo::GetForeach(), GetInternalMask(), LLVMMaskAllOff, loopMask, LLVMTypes::MaskType, NULL, and StoreInst().
Referenced by ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), and ForeachUniqueStmt::EmitCode().
| void FunctionEmitContext::StartLoop | ( | llvm::BasicBlock * | breakTarget, |
| llvm::BasicBlock * | continueTarget, | ||
| bool | uniformControlFlow | ||
| ) |
Notifies the FunctionEmitContext that we're starting to emit IR for a loop. Basic blocks are provides for where 'break' and 'continue' statements should jump to (if all running lanes want to break or continue), uniformControlFlow indicates whether the loop condition is 'uniform'.
Definition at line 563 of file ctx.cpp.
References AllocaInst(), breakLanesPtr, breakTarget, continueLanesPtr, continueTarget, controlFlowInfo, GetInternalMask(), CFInfo::GetLoop(), LLVMMaskAllOff, loopMask, LLVMTypes::MaskType, NULL, and StoreInst().
Referenced by DoStmt::EmitCode(), and ForStmt::EmitCode().
| void FunctionEmitContext::StartScope | ( | ) |
Inform the debugging information generation code that a new scope is starting in the source program.
Definition at line 1482 of file ctx.cpp.
References AssertPos, currentPos, debugScopes, Module::diBuilder, diFile, diSubprogram, SourcePos::first_column, SourcePos::first_line, m, and NULL.
Referenced by DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), StmtList::EmitCode(), FunctionEmitContext(), and lEmitIfStatements().
| void FunctionEmitContext::StartSwitch | ( | bool | isUniform, |
| llvm::BasicBlock * | bbAfterSwitch | ||
| ) |
Indicates that code generation for a "switch" statement is about to start. isUniform indicates whether the "switch" value is uniform, and bbAfterSwitch gives the basic block immediately following the "switch" statement. (For example, if the switch condition is uniform, we jump here upon executing a "break" statement.)
Definition at line 903 of file ctx.cpp.
References AllocaInst(), breakLanesPtr, breakTarget, caseBlocks, continueLanesPtr, continueTarget, controlFlowInfo, defaultBlock, GetInternalMask(), CFInfo::GetSwitch(), LLVMMaskAllOff, loopMask, LLVMTypes::MaskType, nextBlocks, NULL, StoreInst(), switchConditionWasUniform, and switchExpr.
Referenced by SwitchStmt::EmitCode().
| void FunctionEmitContext::StartUniformIf | ( | ) |
Notifies the FunctionEmitContext that we're starting emission of an 'if' statement with a uniform test.
Definition at line 490 of file ctx.cpp.
References controlFlowInfo, CFInfo::GetIf(), and GetInternalMask().
Referenced by IfStmt::EmitCode().
| void FunctionEmitContext::StartVaryingIf | ( | llvm::Value * | oldMask | ) |
Notifies the FunctionEmitContext that we're starting emission of an 'if' statement with a varying test. The value of the mask going into the 'if' statement is provided in the oldMask parameter.
Definition at line 496 of file ctx.cpp.
References controlFlowInfo, and CFInfo::GetIf().
Referenced by IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), and IfStmt::emitVaryingIf().
| void FunctionEmitContext::StoreInst | ( | llvm::Value * | value, |
| llvm::Value * | ptr | ||
| ) |
Standard store instruction; for this variant, the lvalue must be a single pointer, not a varying lvalue.
Definition at line 2925 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, m, and NULL.
Referenced by Break(), CallInst(), Continue(), CurrentLanesReturned(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), PrintStmt::EmitCode(), FunctionEmitContext(), SelectExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), ReferenceExpr::GetValue(), VectorMemberExpr::GetValue(), InitSymbol(), LaunchInst(), lEmitLogicalOp(), lEmitSelectExprCode(), lEmitVaryingSelect(), lProcessPrintArg(), lStoreAssignResult(), lUpdateVaryingCounter(), maskedStore(), RestoreContinuedLanes(), SetFunctionMask(), SetInternalMask(), StartForeach(), StartLoop(), StartSwitch(), StoreInst(), storeUniformToSOA(), and SyncInst().
| void FunctionEmitContext::StoreInst | ( | llvm::Value * | value, |
| llvm::Value * | ptr, | ||
| llvm::Value * | storeMask, | ||
| const Type * | valueType, | ||
| const Type * | ptrType | ||
| ) |
In this variant of StoreInst(), the lvalue may be varying. If so, this corresponds to a scatter. Whether the lvalue is uniform of varying, the given storeMask is used to mask the stores so that they only execute for the active program instances.
Definition at line 2948 of file ctx.cpp.
References AssertPos, currentPos, Opt::disableMaskAllOnOptimizations, Module::errorCount, g, PointerType::GetBaseType(), GetFullMask(), Type::GetReferenceTarget(), PointerType::GetUniform(), PointerType::IsSlice(), Type::IsUniformType(), Type::IsVaryingType(), LLVMMaskAllOn, m, maskedStore(), NULL, Globals::opt, scatter(), StoreInst(), and storeUniformToSOA().
| void FunctionEmitContext::storeUniformToSOA | ( | llvm::Value * | value, |
| llvm::Value * | ptr, | ||
| llvm::Value * | mask, | ||
| const Type * | valueType, | ||
| const PointerType * | ptrType | ||
| ) | [private] |
Store a uniform type to SOA-laid-out memory.
Definition at line 2992 of file ctx.cpp.
References AddElementOffset(), AssertPos, currentPos, Type::EqualIgnoringConst(), ExtractInst(), Type::GetAsUniformType(), PointerType::GetBaseType(), CollectionType::GetElementCount(), CollectionType::GetElementType(), Type::IsBasicType(), lFinalSliceOffset(), NULL, and StoreInst().
Referenced by StoreInst().
| void FunctionEmitContext::SwitchInst | ( | llvm::Value * | expr, |
| llvm::BasicBlock * | defaultBlock, | ||
| const std::vector< std::pair< int, llvm::BasicBlock * > > & | caseBlocks, | ||
| const std::map< llvm::BasicBlock *, llvm::BasicBlock * > & | nextBlocks | ||
| ) |
Emits code for a "switch" statement in the program.
| expr | Gives the value of the expression after the "switch" |
| defaultBlock | Basic block to execute for the "default" case. This should be NULL if there is no "default" label inside the switch. |
| caseBlocks | vector that stores the mapping from label values after "case" statements to basic blocks corresponding to the "case" labels. |
| nextBlocks | For each basic block for a "case" or "default" label, this gives the basic block for the immediately-following "case" or "default" label (or the basic block after the "switch" statement for the last label.) |
Definition at line 1088 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, BranchInst(), caseBlocks, controlFlowInfo, currentPos, defaultBlock, LLVMTypes::Int32Type, LLVMTypes::Int64Type, LLVMInt32(), LLVMInt64(), LLVMMaskAllOff, nextBlocks, NULL, s, SetInternalMask(), switchConditionWasUniform, and switchExpr.
Referenced by SwitchStmt::EmitCode().
| void FunctionEmitContext::SyncInst | ( | ) |
Definition at line 3445 of file ctx.cpp.
References BranchInst(), CallInst(), CmpInst(), CreateBasicBlock(), FATAL, launchGroupHandlePtr, LoadInst(), m, Module::module, NULL, SetCurrentBasicBlock(), StoreInst(), and LLVMTypes::VoidPointerType.
Referenced by SyncExpr::GetValue(), and ReturnInst().
| llvm::Instruction * FunctionEmitContext::TruncInst | ( | llvm::Value * | value, |
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1845 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, and NULL.
Referenced by applyVaryingGEP(), CallInst(), ForeachActiveStmt::EmitCode(), NewExpr::GetValue(), IntToPtrInst(), lComputeSliceIndex(), lEmitBinaryPointerArith(), lTypeConvAtomic(), and PtrToIntInst().
| int FunctionEmitContext::VaryingCFDepth | ( | ) | const |
Returns the current number of nested levels of 'varying' control flow
Definition at line 1141 of file ctx.cpp.
References controlFlowInfo.
Referenced by CurrentLanesReturned(), DeclStmt::EmitCode(), GotoStmt::EmitCode(), and lStoreAssignResult().
| llvm::Instruction * FunctionEmitContext::ZExtInst | ( | llvm::Value * | value, |
| llvm::Type * | type, | ||
| const char * | name = NULL |
||
| ) |
Definition at line 1922 of file ctx.cpp.
References AddDebugPos(), AssertPos, bblock, currentPos, Module::errorCount, LLVMGetName(), m, and NULL.
Referenced by DeleteStmt::EmitCode(), IntToPtrInst(), LaunchInst(), lTypeConvAtomic(), MemcpyInst(), and PtrToIntInst().
llvm::BasicBlock* FunctionEmitContext::allocaBlock [private] |
The basic block into which we add any alloca instructions that need to go at the very start of the function.
Definition at line 541 of file ctx.h.
Referenced by AllocaInst(), and FunctionEmitContext().
llvm::BasicBlock* FunctionEmitContext::bblock [private] |
The current basic block into which we're emitting new instructions
Definition at line 545 of file ctx.h.
Referenced by AddElementOffset(), AddInstrumentationPoint(), addSwitchMaskCheck(), addVaryingOffsetsIfNeeded(), AllocaInst(), applyVaryingGEP(), BinaryOperator(), BitCastInst(), BranchIfMaskAll(), BranchIfMaskAny(), BranchIfMaskNone(), BranchInst(), Break(), CallInst(), CastInst(), CmpInst(), Continue(), CurrentLanesReturned(), EmitCaseLabel(), EmitDefaultLabel(), EmitFunctionParameterDebugInfo(), EmitVariableDebugInfo(), EndIf(), EndSwitch(), ExtractInst(), FPCastInst(), FunctionEmitContext(), GetCurrentBasicBlock(), GetElementPtrInst(), GetStringPtr(), InsertInst(), IntToPtrInst(), jumpIfAllLoopLanesAreDone(), LaunchInst(), LoadInst(), NotOperator(), PhiNode(), PtrToIntInst(), restoreMaskGivenReturns(), ReturnInst(), SelectInst(), SetCurrentBasicBlock(), SetFunctionMask(), SExtInst(), StoreInst(), SwitchInst(), TruncInst(), and ZExtInst().
llvm::Value* FunctionEmitContext::breakLanesPtr [private] |
If currently in a loop body or switch statement, this is a pointer to memory to store a mask value that represents which of the lanes have executed a 'break' statement. If we're not in a loop body or switch, this should be NULL.
Definition at line 576 of file ctx.h.
Referenced by Break(), EndIf(), FunctionEmitContext(), jumpIfAllLoopLanesAreDone(), popCFState(), StartForeach(), StartLoop(), and StartSwitch().
llvm::BasicBlock* FunctionEmitContext::breakTarget [private] |
If we're inside a loop or switch statement, this gives the basic block immediately after the current loop or switch, which we will jump to if all of the lanes have executed a break statement or are otherwise done with it.
Definition at line 587 of file ctx.h.
Referenced by Break(), FunctionEmitContext(), popCFState(), StartForeach(), StartLoop(), and StartSwitch().
const std::vector<std::pair<int, llvm::BasicBlock *> >* FunctionEmitContext::caseBlocks [private] |
Map from case label numbers to the basic block that will hold code for that case.
Definition at line 607 of file ctx.h.
Referenced by EmitCaseLabel(), EmitDefaultLabel(), FunctionEmitContext(), popCFState(), StartSwitch(), and SwitchInst().
llvm::Value* FunctionEmitContext::continueLanesPtr [private] |
Similar to breakLanesPtr, if we're inside a loop, this is a pointer to memory to record which of the program instances have executed a 'continue' statement.
Definition at line 581 of file ctx.h.
Referenced by Continue(), EndIf(), FunctionEmitContext(), jumpIfAllLoopLanesAreDone(), popCFState(), RestoreContinuedLanes(), StartForeach(), StartLoop(), and StartSwitch().
llvm::BasicBlock* FunctionEmitContext::continueTarget [private] |
If we're inside a loop, this gives the block to jump to if all of the running lanes have executed a 'continue' statement.
Definition at line 591 of file ctx.h.
Referenced by Break(), Continue(), FunctionEmitContext(), popCFState(), StartForeach(), StartLoop(), and StartSwitch().
std::vector<CFInfo *> FunctionEmitContext::controlFlowInfo [private] |
The CFInfo structure records information about a nesting level of control flow. This vector lets us see what control flow is going around outside the current position in the function being emitted.
Definition at line 641 of file ctx.h.
Referenced by Break(), Continue(), getMaskAtSwitchEntry(), ifsInCFAllUniform(), InForeachLoop(), inSwitchStatement(), popCFState(), StartForeach(), StartLoop(), StartSwitch(), StartUniformIf(), StartVaryingIf(), SwitchInst(), VaryingCFDepth(), and ~FunctionEmitContext().
SourcePos FunctionEmitContext::currentPos [private] |
Current source file position; if debugging information is being generated, this position is used to set file/line information for instructions.
Definition at line 562 of file ctx.h.
Referenced by AddDebugPos(), AddElementOffset(), AddInstrumentationPoint(), addSwitchMaskCheck(), addVaryingOffsetsIfNeeded(), AllocaInst(), applyVaryingGEP(), BinaryOperator(), BitCastInst(), BranchIfMaskAll(), BranchIfMaskAny(), BranchIfMaskNone(), BranchInst(), Break(), CallInst(), CastInst(), CmpInst(), Continue(), EmitCaseLabel(), EmitDefaultLabel(), EmitFunctionParameterDebugInfo(), EmitVariableDebugInfo(), EndForeach(), EndIf(), EndLoop(), EndScope(), EndSwitch(), ExtractInst(), FPCastInst(), FunctionEmitContext(), gather(), GetDebugPos(), GetDIScope(), GetElementPtrInst(), getMaskAtSwitchEntry(), I1VecToBoolVec(), ifsInCFAllUniform(), InsertInst(), IntToPtrInst(), jumpIfAllLoopLanesAreDone(), LaneMask(), LaunchInst(), LoadInst(), maskedStore(), MemcpyInst(), NotOperator(), popCFState(), PtrToIntInst(), ReturnInst(), scatter(), SelectInst(), SetDebugPos(), SExtInst(), SmearUniform(), StartForeach(), StartScope(), StoreInst(), storeUniformToSOA(), SwitchInst(), TruncInst(), ZExtInst(), and ~FunctionEmitContext().
std::vector<llvm::DILexicalBlock> FunctionEmitContext::debugScopes [private] |
These correspond to the current set of nested scopes in the function.
Definition at line 653 of file ctx.h.
Referenced by EndScope(), GetDIScope(), StartScope(), and ~FunctionEmitContext().
llvm::BasicBlock* FunctionEmitContext::defaultBlock [private] |
The basic block of code to run for the "default" label in the switch statement.
Definition at line 611 of file ctx.h.
Referenced by EmitDefaultLabel(), FunctionEmitContext(), popCFState(), StartSwitch(), and SwitchInst().
llvm::DIFile FunctionEmitContext::diFile [private] |
DIFile object corresponding to the source file where the current function was defined (used for debugging info).
Definition at line 645 of file ctx.h.
Referenced by FunctionEmitContext(), and StartScope().
int FunctionEmitContext::disableGSWarningCount [private] |
Nesting count of the number of times calling code has disabled (and not yet reenabled) gather/scatter performance warnings.
Definition at line 665 of file ctx.h.
Referenced by DisableGatherScatterWarnings(), EnableGatherScatterWarnings(), FunctionEmitContext(), gather(), and scatter().
llvm::DISubprogram FunctionEmitContext::diSubprogram [private] |
DISubprogram corresponding to this function (used for debugging info).
Definition at line 649 of file ctx.h.
Referenced by EmitFunctionParameterDebugInfo(), FunctionEmitContext(), and StartScope().
llvm::Value* FunctionEmitContext::fullMaskPointer [private] |
Pointer to stack-allocated memory that stores the current value of the full program mask.
Definition at line 549 of file ctx.h.
Referenced by FunctionEmitContext(), GetFullMaskPointer(), SetFunctionMask(), and SetInternalMask().
SourcePos FunctionEmitContext::funcStartPos [private] |
Source file position where the function definition started. Used for error messages and debugging symbols.
Definition at line 566 of file ctx.h.
Referenced by CurrentLanesReturned(), and FunctionEmitContext().
Function* FunctionEmitContext::function [private] |
Pointer to the Function for which we're currently generating code.
Definition at line 534 of file ctx.h.
Referenced by ReturnInst().
llvm::Value* FunctionEmitContext::functionMaskValue [private] |
Value of the program mask when the function starts execution.
Definition at line 557 of file ctx.h.
Referenced by CurrentLanesReturned(), FunctionEmitContext(), GetFullMask(), GetFunctionMask(), and SetFunctionMask().
llvm::Value* FunctionEmitContext::internalMaskPointer [private] |
Pointer to stack-allocated memory that stores the current value of the program mask representing varying control flow within the function.
Definition at line 554 of file ctx.h.
Referenced by FunctionEmitContext(), GetInternalMask(), and SetInternalMask().
std::map<std::string, llvm::BasicBlock *> FunctionEmitContext::labelMap [private] |
Definition at line 667 of file ctx.h.
Referenced by GetLabeledBasicBlock(), GetLabels(), InitializeLabelMap(), and initLabelBBlocks().
bool FunctionEmitContext::launchedTasks [private] |
True if a 'launch' statement has been encountered in the function.
Definition at line 656 of file ctx.h.
Referenced by FunctionEmitContext(), LaunchInst(), and ReturnInst().
llvm::Value* FunctionEmitContext::launchGroupHandlePtr [private] |
This is a pointer to a void * that is passed to the ISPCLaunch(), ISPCAlloc(), and ISPCSync() routines as a handle to the group ot tasks launched from the current function.
Definition at line 661 of file ctx.h.
Referenced by FunctionEmitContext(), LaunchInst(), and SyncInst().
llvm::Function* FunctionEmitContext::llvmFunction [private] |
LLVM function representation for the current function.
Definition at line 537 of file ctx.h.
Referenced by CreateBasicBlock(), and FunctionEmitContext().
llvm::Value* FunctionEmitContext::loopMask [private] |
If currently in a loop body, the value of the mask at the start of the loop.
Definition at line 570 of file ctx.h.
Referenced by FunctionEmitContext(), jumpIfAllLoopLanesAreDone(), popCFState(), SetLoopMask(), StartForeach(), StartLoop(), and StartSwitch().
const std::map<llvm::BasicBlock *, llvm::BasicBlock *>* FunctionEmitContext::nextBlocks [private] |
For each basic block for the code for cases (and the default label, if present), this map gives the basic block for the immediately following case/default label.
Definition at line 616 of file ctx.h.
Referenced by addSwitchMaskCheck(), FunctionEmitContext(), popCFState(), StartSwitch(), and SwitchInst().
llvm::Value* FunctionEmitContext::returnedLanesPtr [private] |
A pointer to memory that records which of the program instances have executed a 'return' statement (and are thus really truly done running any more instructions in this functions.
Definition at line 629 of file ctx.h.
Referenced by CurrentLanesReturned(), FunctionEmitContext(), jumpIfAllLoopLanesAreDone(), and restoreMaskGivenReturns().
llvm::Value* FunctionEmitContext::returnValuePtr [private] |
A pointer to memory to store the return value for the function. Since difference program instances may execute 'return' statements at different times, we need to accumulate the return values as they come in until we return for real.
Definition at line 635 of file ctx.h.
Referenced by CurrentLanesReturned(), FunctionEmitContext(), and ReturnInst().
bool FunctionEmitContext::switchConditionWasUniform [private] |
Records whether the switch condition was uniform; this is a distinct notion from whether the switch represents uniform or varying control flow; we may have varying control flow from a uniform switch condition if there is a 'break' inside the switch that's under varying control flow.
Definition at line 623 of file ctx.h.
Referenced by Break(), EmitCaseLabel(), EmitDefaultLabel(), popCFState(), StartSwitch(), and SwitchInst().
llvm::Value* FunctionEmitContext::switchExpr [private] |
The value of the expression used to determine which case in the statements after the switch to execute.
Definition at line 603 of file ctx.h.
Referenced by EmitCaseLabel(), EmitDefaultLabel(), FunctionEmitContext(), popCFState(), StartSwitch(), and SwitchInst().
1.7.5.1