24 this->lastNodeInLoop = lastNodeInLoop;
33 PointerType *voidPointerType = PointerType::get(IntegerType::get(module->getContext(), 8), 0);
39 new StoreInst(eventIdValue, eventIdPtrValue,
"", block);
48 BitCastInst *compositionStateAsVoidPointer =
new BitCastInst(compositionStateValue, voidPointerType,
"", block);
51 BitCastInst *eventIdPtrValueAsVoidPointer =
new BitCastInst(eventIdPtrValue, voidPointerType,
"", block);
62 return new BitCastInst(contextValue, voidPointerType,
"", block);
71 Type *voidPointerType = contextValue->getType();
72 Type *voidPointerPointerType = PointerType::get(voidPointerType, 0);
76 Value *contextValueAsVoidPointerArray =
new BitCastInst(contextValue, voidPointerPointerType,
"", block);
78 return new BitCastInst(compositionStateAsVoidPointer, compositionStatePointerType,
"", block);
86 Type *eventIdPtrType = PointerType::get(IntegerType::get(module->getContext(), 64), 0);
87 Type *voidPointerType = contextValue->getType();
88 Type *voidPointerPointerType = PointerType::get(voidPointerType, 0);
93 Value *contextValueAsVoidPointerArray =
new BitCastInst(contextValue, voidPointerPointerType,
"", block);
95 Value *eventIdPtrValue =
new BitCastInst(eventIdPtrValueAsVoidPointer, eventIdPtrType,
"", block);
96 return new LoadInst(eventIdPtrValue,
"", block);
111 const char *functionName =
"vuoFreeChainWorkerContext";
112 Function *
function = module->getFunction(functionName);
115 PointerType *voidPointerType = PointerType::get(IntegerType::get(module->getContext(), 8), 0);
116 PointerType *voidPointerPointerType = PointerType::get(voidPointerType, 0);
117 ConstantInt *zeroValue = ConstantInt::get(module->getContext(), APInt(64, 0));
118 ConstantInt *oneValue = ConstantInt::get(module->getContext(), APInt(64, 1));
122 FunctionType *functionType = FunctionType::get(Type::getVoidTy(module->getContext()), voidPointerType,
false);
123 function = Function::Create(functionType, GlobalValue::InternalLinkage, functionName, module);
124 BasicBlock *block = BasicBlock::Create(module->getContext(),
"",
function, 0);
126 Value *contextValue =
function->arg_begin();
127 BitCastInst *contextValueAsVoidPointerArray =
new BitCastInst(contextValue, voidPointerPointerType,
"", block);
129 Value *compositionStateVariable = GetElementPtrInst::Create(contextValueAsVoidPointerArray, zeroValue,
"", block);
130 Value *compositionStateValue =
new LoadInst(compositionStateVariable,
"", block);
133 Value *eventIdPtrVariable = GetElementPtrInst::Create(contextValueAsVoidPointerArray, oneValue,
"", block);
134 Value *eventIdPtrValue =
new LoadInst(eventIdPtrVariable,
"", block);
135 CallInst::Create(freeFunction, eventIdPtrValue,
"", block);
137 CallInst::Create(freeFunction, contextValue,
"", block);
139 ReturnInst::Create(module->getContext(), block);
151 Value *contextValue,
string triggerIdentifier,
152 int minThreadsNeeded,
int maxThreadsNeeded,
size_t chainIndex,
153 vector<size_t> upstreamChainIndices)
155 Type *voidPointerType = contextValue->getType();
156 FunctionType *workerFunctionType = FunctionType::get(Type::getVoidTy(module->getContext()), voidPointerType,
false);
160 workerFunctionName +=
"__loop";
161 workerFunctionName +=
"__worker";
162 Function *workerFunction = Function::Create(workerFunctionType, GlobalValue::InternalLinkage, workerFunctionName, module);
169 minThreadsNeeded, maxThreadsNeeded,
170 eventIdValue, compositionStateValue, chainIndex, upstreamChainIndices);
172 return workerFunction;
188 return lastNodeInLoop;