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");
StoreInst(LLVMMaskAllOn, internalMaskPointer);
functionMaskValue = LLVMMaskAllOn;
fullMaskPointer = NULL;
fullMaskPointer = AllocaInst(LLVMTypes::MaskType, "full_mask_memory");
StoreInst(LLVMMaskAllOn, fullMaskPointer);
loopMask = NULL;
breakLanesPtr = continueLanesPtr = NULL;
@@ -286,9 +289,9 @@ FunctionEmitContext::GetFullMask() {
}
void
FunctionEmitContext::SetMaskPointer(llvm::Value *p) {
fullMaskPointer = p;
llvm::Value *
FunctionEmitContext::GetFullMaskPointer() {
return fullMaskPointer;
}

6
ctx.h
View File

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

View File

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