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/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp
index 4ce3306..08b3b43 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -3432,7 +3432,11 @@
 		}
 		case GLSLstd450Exp2:
 		{
-			UNIMPLEMENTED("GLSLstd450Exp2");
+			auto val = GenericValue(this, routine, insn.word(5));
+			for (auto i = 0u; i < type.sizeInComponents; i++)
+			{
+				dst.move(i, Exp2(val.Float(i)));
+			}
 			break;
 		}
 		case GLSLstd450Log2:
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));
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index d9df970..86e3b70 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -2227,6 +2227,7 @@
 	RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y);
 	RValue<Float4> Exp(RValue<Float4> x);
 	RValue<Float4> Log(RValue<Float4> x);
+	RValue<Float4> Exp2(RValue<Float4> x);
 
 	template<class T>
 	class Pointer : public LValue<Pointer<T>>