33 PointerType *voidPointerType = PointerType::get(IntegerType::get(module->getContext(), 8), 0);
39 new StoreInst(eventIdValue, eventIdPtrValue,
"", block);
47 contextValue->setName(
"chainWorkerContext");
49 BitCastInst *compositionStateAsVoidPointer =
new BitCastInst(compositionStateValue, voidPointerType,
"", block);
52 BitCastInst *eventIdPtrValueAsVoidPointer =
new BitCastInst(eventIdPtrValue, voidPointerType,
"", block);
63 return new BitCastInst(contextValue, voidPointerType,
"", block);
72 Type *voidPointerType = contextValue->getType();
73 Type *voidPointerPointerType = PointerType::get(voidPointerType, 0);
77 Value *contextValueAsVoidPointerArray =
new BitCastInst(contextValue, voidPointerPointerType,
"", block);
79 return new BitCastInst(compositionStateAsVoidPointer, compositionStatePointerType,
"", block);
87 Type *eventIdPtrType = PointerType::get(IntegerType::get(module->getContext(), 64), 0);
88 Type *voidPointerType = contextValue->getType();
89 Type *voidPointerPointerType = PointerType::get(voidPointerType, 0);
94 Value *contextValueAsVoidPointerArray =
new BitCastInst(contextValue, voidPointerPointerType,
"", block);
96 Value *eventIdPtrValue =
new BitCastInst(eventIdPtrValueAsVoidPointer, eventIdPtrType,
"", block);
97 return new LoadInst(eventIdPtrValue,
"", block);
112 const char *functionName =
"vuoFreeChainWorkerContext";
113 Function *function =
module->getFunction(functionName);
116 PointerType *voidPointerType = PointerType::get(IntegerType::get(module->getContext(), 8), 0);
117 PointerType *voidPointerPointerType = PointerType::get(voidPointerType, 0);
118 ConstantInt *zeroValue = ConstantInt::get(module->getContext(), APInt(64, 0));
119 ConstantInt *oneValue = ConstantInt::get(module->getContext(), APInt(64, 1));
123 FunctionType *functionType = FunctionType::get(Type::getVoidTy(module->getContext()), voidPointerType,
false);
124 function = Function::Create(functionType, GlobalValue::InternalLinkage, functionName, module);
125 BasicBlock *block = BasicBlock::Create(module->getContext(),
"", function, 0);
127 Value *contextValue = function->arg_begin();
128 BitCastInst *contextValueAsVoidPointerArray =
new BitCastInst(contextValue, voidPointerPointerType,
"", block);
130 Value *compositionStateVariable = GetElementPtrInst::Create(voidPointerType, contextValueAsVoidPointerArray, zeroValue,
"", block);
131 Value *compositionStateValue =
new LoadInst(compositionStateVariable,
"", block);
134 Value *eventIdPtrVariable = GetElementPtrInst::Create(voidPointerType, contextValueAsVoidPointerArray, oneValue,
"", block);
135 Value *eventIdPtrValue =
new LoadInst(eventIdPtrVariable,
"", block);
136 CallInst::Create(freeFunction, eventIdPtrValue,
"", block);
138 CallInst::Create(freeFunction, contextValue,
"", block);
140 ReturnInst::Create(module->getContext(), block);
152 Value *contextValue,
string triggerIdentifier,
153 int minThreadsNeeded,
int maxThreadsNeeded,
size_t chainIndex,
154 vector<size_t> upstreamChainIndices)
156 Type *voidPointerType = contextValue->getType();
157 FunctionType *workerFunctionType = FunctionType::get(Type::getVoidTy(module->getContext()), voidPointerType,
false);
161 workerFunctionName +=
"__loop";
162 workerFunctionName +=
"__worker";
163 Function *workerFunction = Function::Create(workerFunctionType, GlobalValue::InternalLinkage, workerFunctionName, module);
170 minThreadsNeeded, maxThreadsNeeded,
171 eventIdValue, compositionStateValue, chainIndex, upstreamChainIndices);
173 return workerFunction;