Subzero: implement coroutines for Win32

Coroutines are emulated by using fibers.

Bug: b/145754674
Change-Id: I3f4bf29d26a75a2386ed812dd821d8a7a8276305
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40548
Tested-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 9d2677f..a696532 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -1302,9 +1302,9 @@
 	return reinterpret_cast<Type *>(t);
 }
 
-inline std::vector<llvm::Type *> &T(std::vector<Type *> &t)
+inline const std::vector<llvm::Type *> &T(const std::vector<Type *> &t)
 {
-	return reinterpret_cast<std::vector<llvm::Type *> &>(t);
+	return reinterpret_cast<const std::vector<llvm::Type *> &>(t);
 }
 
 inline llvm::BasicBlock *B(BasicBlock *t)
@@ -1506,7 +1506,7 @@
 	jit->builder->SetInsertPoint(B(basicBlock));
 }
 
-void Nucleus::createFunction(Type *ReturnType, std::vector<Type *> &Params)
+void Nucleus::createFunction(Type *ReturnType, const std::vector<Type *> &Params)
 {
 	jit->function = rr::createFunction("", T(ReturnType), T(Params));
 
@@ -4964,7 +4964,7 @@
 
 namespace rr {
 
-void Nucleus::createCoroutine(Type *YieldType, std::vector<Type *> &Params)
+void Nucleus::createCoroutine(Type *YieldType, const std::vector<Type *> &Params)
 {
 	// Coroutines are initially created as a regular function.
 	// Upon the first call to Yield(), the function is promoted to a true
@@ -5123,4 +5123,9 @@
 	return routine;
 }
 
+Nucleus::CoroutineHandle Nucleus::invokeCoroutineBegin(Routine &routine, std::function<Nucleus::CoroutineHandle()> func)
+{
+	return func();
+}
+
 }  // namespace rr