SpirvShader: Implement GLSLstd450Atanh
Bug: b/126873455
Tests: dEQP-VK.glsl.builtin.precision.atanh.*
Change-Id: Ie58753a4a0bdef18ec317129f2c4a7f0c0c314b4
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28694
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 c630bfa..9156aff 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -3385,7 +3385,11 @@
}
case GLSLstd450Atanh:
{
- UNIMPLEMENTED("GLSLstd450Atanh");
+ auto val = GenericValue(this, routine, insn.word(5));
+ for (auto i = 0u; i < type.sizeInComponents; i++)
+ {
+ dst.move(i, Atanh(val.Float(i)));
+ }
break;
}
case GLSLstd450Atan2:
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index f31119e..4e9ffb0 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -564,6 +564,7 @@
func_.emplace("tanhf", reinterpret_cast<void*>(tanhf));
func_.emplace("asinhf", reinterpret_cast<void*>(asinhf));
func_.emplace("acoshf", reinterpret_cast<void*>(acoshf));
+ func_.emplace("atanhf", reinterpret_cast<void*>(atanhf));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
@@ -3150,6 +3151,11 @@
return TransformFloat4PerElement(v, "acoshf");
}
+ RValue<Float4> Atanh(RValue<Float4> v)
+ {
+ return TransformFloat4PerElement(v, "atanhf");
+ }
+
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 7609307..bbbb9b3 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -2219,6 +2219,7 @@
RValue<Float4> Tanh(RValue<Float4> x);
RValue<Float4> Asinh(RValue<Float4> x);
RValue<Float4> Acosh(RValue<Float4> x);
+ RValue<Float4> Atanh(RValue<Float4> x);
template<class T>
class Pointer : public LValue<Pointer<T>>