SpirvShader: Implement GLSLstd450Exp2
Bug: b/126873455
Tests: dEQP-VK.glsl.builtin.precision.exp2.*
Change-Id: I8a8f03a9dd1e30866b6f330c987d93bf4d95d265
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28442
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 0fbb92b..27d5251 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -569,6 +569,7 @@
func_.emplace("powf", reinterpret_cast<void*>(powf));
func_.emplace("expf", reinterpret_cast<void*>(expf));
func_.emplace("logf", reinterpret_cast<void*>(logf));
+ func_.emplace("exp2f", reinterpret_cast<void*>(exp2f));
#ifdef __APPLE__
// LLVM uses this function on macOS for tan.
@@ -3196,6 +3197,12 @@
return RValue<Float4>(V(::builder->CreateCall(func, { V(v.value) })));
}
+ RValue<Float4> Exp2(RValue<Float4> v)
+ {
+ auto func = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::exp2, { T(Float4::getType()) } );
+ return RValue<Float4>(V(::builder->CreateCall(func, { V(v.value) })));
+ }
+
Type *Float4::getType()
{
return T(llvm::VectorType::get(T(Float::getType()), 4));