gallivm: add lp_create_builder with an unsafe_fpmath option
authorMarek Olšák <marek.olsak@amd.com>
Sat, 12 Nov 2016 22:08:51 +0000 (23:08 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 15 Nov 2016 18:17:56 +0000 (19:17 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
src/gallium/auxiliary/gallivm/lp_bld_misc.h

index bd4d4d3c0947380d73e13e2df6da4ff3432c54d3..da3cbdd53c57f063c1e42e335463bb3e11b85122 100644 (file)
@@ -733,3 +733,17 @@ lp_is_function(LLVMValueRef v)
        return llvm::isa<llvm::Function>(llvm::unwrap(v));
 #endif
 }
+
+extern "C" LLVMBuilderRef
+lp_create_builder(LLVMContextRef ctx, bool unsafe_fpmath)
+{
+   LLVMBuilderRef builder = LLVMCreateBuilderInContext(ctx);
+
+   if (unsafe_fpmath) {
+      llvm::FastMathFlags flags;
+      flags.setUnsafeAlgebra();
+      llvm::unwrap(builder)->setFastMathFlags(flags);
+   }
+
+   return builder;
+}
index a55c6bd508d1c1b9580187339792e9506e2426f0..c499a6f51ebbea43b7f3decf02586c11b1f1c83b 100644 (file)
@@ -82,6 +82,9 @@ lp_get_called_value(LLVMValueRef call);
 extern bool
 lp_is_function(LLVMValueRef v);
 
+extern LLVMBuilderRef
+lp_create_builder(LLVMContextRef ctx, bool unsafe_fpmath);
+
 #ifdef __cplusplus
 }
 #endif