Small cleanup: allocate storage for the full mask in the FunctionEmitContext constructor

This commit is contained in:
Matt Pharr
2011-12-10 13:33:28 -08:00
parent 034507a35b
commit f6605ee465
3 changed files with 13 additions and 11 deletions

11
ctx.cpp
View File

@@ -171,8 +171,11 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
internalMaskPointer = AllocaInst(LLVMTypes::MaskType, "internal_mask_memory"); internalMaskPointer = AllocaInst(LLVMTypes::MaskType, "internal_mask_memory");
StoreInst(LLVMMaskAllOn, internalMaskPointer); StoreInst(LLVMMaskAllOn, internalMaskPointer);
functionMaskValue = LLVMMaskAllOn; functionMaskValue = LLVMMaskAllOn;
fullMaskPointer = NULL;
fullMaskPointer = AllocaInst(LLVMTypes::MaskType, "full_mask_memory");
StoreInst(LLVMMaskAllOn, fullMaskPointer);
loopMask = NULL; loopMask = NULL;
breakLanesPtr = continueLanesPtr = NULL; breakLanesPtr = continueLanesPtr = NULL;
@@ -286,9 +289,9 @@ FunctionEmitContext::GetFullMask() {
} }
void llvm::Value *
FunctionEmitContext::SetMaskPointer(llvm::Value *p) { FunctionEmitContext::GetFullMaskPointer() {
fullMaskPointer = p; return fullMaskPointer;
} }

6
ctx.h
View File

@@ -98,9 +98,9 @@ public:
the function entry mask and the internal mask. */ the function entry mask and the internal mask. */
llvm::Value *GetFullMask(); llvm::Value *GetFullMask();
/** Provides the alloca'd pointer to memory to store the full function /** Returns a pointer to storage in memory that stores the current full
mask. This is only used to wire up the __mask builtin variable. */ mask. */
void SetMaskPointer(llvm::Value *p); llvm::Value *GetFullMaskPointer();
/** Provides the value of the mask at function entry */ /** Provides the value of the mask at function entry */
void SetFunctionMask(llvm::Value *val); void SetFunctionMask(llvm::Value *val);

View File

@@ -189,10 +189,9 @@ lCopyInTaskParameter(int i, llvm::Value *structArgPtr, const std::vector<Symbol
void void
Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function, Function::emitCode(FunctionEmitContext *ctx, llvm::Function *function,
SourcePos firstStmtPos) { SourcePos firstStmtPos) {
llvm::Value *maskPtr = ctx->AllocaInst(LLVMTypes::MaskType, "mask_memory"); // Connect the __mask builtin to the location in memory that stores its
ctx->StoreInst(LLVMMaskAllOn, maskPtr); // value
maskSymbol->storagePtr = maskPtr; maskSymbol->storagePtr = ctx->GetFullMaskPointer();
ctx->SetMaskPointer(maskPtr);
// add debugging info for __mask, programIndex, ... // add debugging info for __mask, programIndex, ...
maskSymbol->pos = firstStmtPos; maskSymbol->pos = firstStmtPos;