SpirvShader: Implement GLSLstd450Asinh
Bug: b/126873455
Tests: dEQP-VK.glsl.builtin.precision.asinh.*
Change-Id: I83b425bea2d693c5bcab3b1685252be0ba9fb023
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28692
Tested-by: Ben Clayton <bclayton@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 7d9646e..d70e0ea 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -3367,7 +3367,11 @@
}
case GLSLstd450Asinh:
{
- UNIMPLEMENTED("GLSLstd450Asinh");
+ auto val = GenericValue(this, routine, insn.word(5));
+ for (auto i = 0u; i < type.sizeInComponents; i++)
+ {
+ dst.move(i, Asinh(val.Float(i)));
+ }
break;
}
case GLSLstd450Acosh:
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index aebcfd6..d105d3e 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -562,6 +562,7 @@
func_.emplace("sinhf", reinterpret_cast<void*>(sinhf));
func_.emplace("coshf", reinterpret_cast<void*>(coshf));
func_.emplace("tanhf", reinterpret_cast<void*>(tanhf));
+ func_.emplace("asinhf", reinterpret_cast<void*>(asinhf));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
@@ -3138,6 +3139,11 @@
return TransformFloat4PerElement(v, "tanhf");
}
+ RValue<Float4> Asinh(RValue<Float4> v)
+ {
+ return TransformFloat4PerElement(v, "asinhf");
+ }
+
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 1c92c9b..ffbd7c8 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -2217,6 +2217,7 @@
RValue<Float4> Sinh(RValue<Float4> x);
RValue<Float4> Cosh(RValue<Float4> x);
RValue<Float4> Tanh(RValue<Float4> x);
+ RValue<Float4> Asinh(RValue<Float4> x);
template<class T>
class Pointer : public LValue<Pointer<T>>