Add $$select. "--fp-math" options. Fixed issue with accidentally silent error on failed vector conversions.

This commit is contained in:
Christoffer Lerno
2023-09-08 09:03:00 +02:00
committed by Christoffer Lerno
parent b894e5be69
commit 4ef74a1205
23 changed files with 366 additions and 162 deletions

View File

@@ -60,7 +60,12 @@ typedef enum
AR_COFF,
} ArFormat;
typedef enum
{
STRICT,
RELAXED,
FAST
} FastMathOption;
static bool llvm_link(ObjFormat format, const char **args, int arg_count, const char** error_string)
{
@@ -179,6 +184,26 @@ extern "C" {
machine->Options.UseInitArray = use_init_array;
}
void LLVMBuilderSetFastMathFlags(LLVMBuilderRef Builder, FastMathOption option)
{
llvm::FastMathFlags math_flags {};
switch (option)
{
case RELAXED:
math_flags.setAllowReassoc(true);
math_flags.setAllowReciprocal(true);
math_flags.setAllowContract(true);
break;
case FAST:
math_flags.setFast(true);
break;
case STRICT:
default:
return;
}
llvm::unwrap(Builder)->setFastMathFlags(math_flags);
}
LLVMValueRef LLVMConstBswap(LLVMValueRef ConstantVal)
{
llvm::Constant *Val = llvm::unwrap<llvm::Constant>(ConstantVal);