SpirvShader: Implement GLSLstd450Asin

Bug: b/126873455
Tests: dEQP-VK.glsl.builtin.precision.asin.*
Change-Id: Ifb1e6b5f54b27abfb4324f5d2246717400da639f
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28671
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 14677f5..daea265 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -3311,6 +3311,15 @@
 			}
 			break;
 		}
+		case GLSLstd450Asin:
+		{
+			auto val = GenericValue(this, routine, insn.word(5));
+			for (auto i = 0u; i < type.sizeInComponents; i++)
+			{
+				dst.move(i, Asin(val.Float(i)));
+			}
+			break;
+		}
 		default:
 			UNIMPLEMENTED("Unhandled ExtInst %d", extInstIndex);
 		}
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index f7ad721..c97e9d3 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -556,6 +556,7 @@
 			func_.emplace("fmodf", reinterpret_cast<void*>(fmodf));
 			func_.emplace("sinf", reinterpret_cast<void*>(sinf));
 			func_.emplace("cosf", reinterpret_cast<void*>(cosf));
+			func_.emplace("asinf", reinterpret_cast<void*>(asinf));
 
 #ifdef __APPLE__
 			// LLVM uses this function on macOS for tan.
@@ -3089,6 +3090,19 @@
 		return Sin(v) / Cos(v);
 	}
 
+	RValue<Float4> Asin(RValue<Float4> v)
+	{
+		auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), {T(Float::getType())}, false);
+		auto func = ::module->getOrInsertFunction("asinf", funcTy);
+		llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
+		for (uint64_t i = 0; i < 4; i++)
+		{
+			auto el = ::builder->CreateCall(func, ::builder->CreateExtractElement(V(v.value), i));
+			out = ::builder->CreateInsertElement(out, el, i);
+		}
+		return RValue<Float4>(V(out));
+	}
+
 	Type *Float4::getType()
 	{
 		return T(llvm::VectorType::get(T(Float::getType()), 4));
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index ab3989e..6e25a16 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -2211,6 +2211,7 @@
 	RValue<Float4> Sin(RValue<Float4> x);
 	RValue<Float4> Cos(RValue<Float4> x);
 	RValue<Float4> Tan(RValue<Float4> x);
+	RValue<Float4> Asin(RValue<Float4> x);
 
 	template<class T>
 	class Pointer : public LValue<Pointer<T>>