SpirvShader: Implement GLSLstd450Log

Bug: b/126873455
Tests: dEQP-VK.glsl.builtin.precision.log.*
Change-Id: I14cc590230dbbf4cfd24a0903bc2fbfb3c5a5192
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28441
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 bc82fdb..4ce3306 100644
--- a/src/Pipeline/SpirvShader.cpp
+++ b/src/Pipeline/SpirvShader.cpp
@@ -3423,7 +3423,11 @@
 		}
 		case GLSLstd450Log:
 		{
-			UNIMPLEMENTED("GLSLstd450Log");
+			auto val = GenericValue(this, routine, insn.word(5));
+			for (auto i = 0u; i < type.sizeInComponents; i++)
+			{
+				dst.move(i, Log(val.Float(i)));
+			}
 			break;
 		}
 		case GLSLstd450Exp2:
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index e65f3fa..0fbb92b 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -568,6 +568,7 @@
 			func_.emplace("atan2f", reinterpret_cast<void*>(atan2f));
 			func_.emplace("powf", reinterpret_cast<void*>(powf));
 			func_.emplace("expf", reinterpret_cast<void*>(expf));
+			func_.emplace("logf", reinterpret_cast<void*>(logf));
 
 #ifdef __APPLE__
 			// LLVM uses this function on macOS for tan.
@@ -3189,6 +3190,12 @@
 		return RValue<Float4>(V(::builder->CreateCall(func, { V(v.value) })));
 	}
 
+	RValue<Float4> Log(RValue<Float4> v)
+	{
+		auto func = llvm::Intrinsic::getDeclaration(::module, llvm::Intrinsic::log, { 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 59f87ce..d9df970 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -2226,6 +2226,7 @@
 	// TODO: Currentlhy unimplemented for Subzero.
 	RValue<Float4> Pow(RValue<Float4> x, RValue<Float4> y);
 	RValue<Float4> Exp(RValue<Float4> x);
+	RValue<Float4> Log(RValue<Float4> x);
 
 	template<class T>
 	class Pointer : public LValue<Pointer<T>>