gallivm: add lp_create_builder with an unsafe_fpmath option

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Marek Olšák 2016-11-12 23:08:51 +01:00
parent 171e349782
commit 41d20d4920
2 changed files with 17 additions and 0 deletions

View 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;
}

View 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