SpirvShader: Implement GLSLstd450Pow
Bug: b/126873455
Tests: dEQP-VK.glsl.builtin.precision.pow.*
Change-Id: I74797e69adc78e4c06ec4a8b2923b78166afbc18
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28439
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/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 46abd51..c04b300 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -566,6 +566,7 @@
func_.emplace("acoshf", reinterpret_cast<void*>(acoshf));
func_.emplace("atanhf", reinterpret_cast<void*>(atanhf));
func_.emplace("atan2f", reinterpret_cast<void*>(atan2f));
+ func_.emplace("powf", reinterpret_cast<void*>(powf));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
@@ -3174,6 +3175,13 @@
return RValue<Float4>(V(out));
}
+ RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y)
+ {
+ auto func = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::pow,
+ { T(Float4::getType()), T(Float4::getType()) } );
+ return RValue<Float4>(V(::builder->CreateCall(func, { V(x.value), V(y.value) })));
+ }
+
Type *Float4::getType()
{
return T(llvm::VectorType::get(T(Float::getType()), 4));