diff --git a/llvm/include/llvm/CodeGen/RuntimeLibcalls.def b/llvm/include/llvm/CodeGen/RuntimeLibcalls.def index 4facc90635f7..7ed90d959f01 100644 --- a/llvm/include/llvm/CodeGen/RuntimeLibcalls.def +++ b/llvm/include/llvm/CodeGen/RuntimeLibcalls.def @@ -251,6 +251,7 @@ HANDLE_LIBCALL(FMAX_PPCF128, "fmaxl") // Conversion HANDLE_LIBCALL(FPEXT_F32_PPCF128, "__gcc_stoq") HANDLE_LIBCALL(FPEXT_F64_PPCF128, "__gcc_dtoq") +HANDLE_LIBCALL(FPEXT_F80_F128, "__extendxftf2") HANDLE_LIBCALL(FPEXT_F64_F128, "__extenddftf2") HANDLE_LIBCALL(FPEXT_F32_F128, "__extendsftf2") HANDLE_LIBCALL(FPEXT_F32_F64, "__extendsfdf2") @@ -267,6 +268,7 @@ HANDLE_LIBCALL(FPROUND_PPCF128_F32, "__gcc_qtos") HANDLE_LIBCALL(FPROUND_F80_F64, "__truncxfdf2") HANDLE_LIBCALL(FPROUND_F128_F64, "__trunctfdf2") HANDLE_LIBCALL(FPROUND_PPCF128_F64, "__gcc_qtod") +HANDLE_LIBCALL(FPROUND_F128_F80, "__trunctfxf2") HANDLE_LIBCALL(FPTOSINT_F32_I32, "__fixsfsi") HANDLE_LIBCALL(FPTOSINT_F32_I64, "__fixsfdi") HANDLE_LIBCALL(FPTOSINT_F32_I128, "__fixsfti") diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index b29a33ac1c14..4dcb705934c5 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -192,6 +192,9 @@ RTLIB::Libcall RTLIB::getFPEXT(EVT OpVT, EVT RetVT) { return FPEXT_F64_F128; else if (RetVT == MVT::ppcf128) return FPEXT_F64_PPCF128; + } else if (OpVT == MVT::f80) { + if (RetVT == MVT::f128) + return FPEXT_F80_F128; } return UNKNOWN_LIBCALL; @@ -227,6 +230,9 @@ RTLIB::Libcall RTLIB::getFPROUND(EVT OpVT, EVT RetVT) { return FPROUND_F128_F64; if (OpVT == MVT::ppcf128) return FPROUND_PPCF128_F64; + } else if (RetVT == MVT::f80) { + if (OpVT == MVT::f128) + return FPROUND_F128_F80; } return UNKNOWN_LIBCALL; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp index 18d914f01339..46a937561ce1 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp @@ -309,6 +309,7 @@ RuntimeLibcallSignatures[RTLIB::UNKNOWN_LIBCALL] = { // CONVERSION /* FPEXT_F32_PPCF128 */ unsupported, /* FPEXT_F64_PPCF128 */ unsupported, +/* FPEXT_F80_F128 */ unsupported, /* FPEXT_F64_F128 */ func_iPTR_f64, /* FPEXT_F32_F128 */ func_iPTR_f32, /* FPEXT_F32_F64 */ f64_func_f32, @@ -325,6 +326,7 @@ RuntimeLibcallSignatures[RTLIB::UNKNOWN_LIBCALL] = { /* FPROUND_F80_F64 */ unsupported, /* FPROUND_F128_F64 */ f64_func_i64_i64, /* FPROUND_PPCF128_F64 */ unsupported, +/* FPROUND_F128_F80 */ unsupported, /* FPTOSINT_F32_I32 */ i32_func_f32, /* FPTOSINT_F32_I64 */ i64_func_f32, /* FPTOSINT_F32_I128 */ i64_i64_func_f32, @@ -804,6 +806,7 @@ RuntimeLibcallNames[RTLIB::UNKNOWN_LIBCALL] = { /* FMAX_PPCF128 */ nullptr, /* FPEXT_F32_PPCF128 */ nullptr, /* FPEXT_F64_PPCF128 */ nullptr, +/* FPEXT_F80_F128 */ nullptr, /* FPEXT_F64_F128 */ "__extenddftf2", /* FPEXT_F32_F128 */ "__extendsftf2", /* FPEXT_F32_F64 */ "__extendsfdf2", @@ -820,6 +823,7 @@ RuntimeLibcallNames[RTLIB::UNKNOWN_LIBCALL] = { /* FPROUND_F80_F64 */ "__truncxfdf2", /* FPROUND_F128_F64 */ "__trunctfdf2", /* FPROUND_PPCF128_F64 */ nullptr, +/* FPROUND_F128_F80 */ nullptr, /* FPTOSINT_F32_I32 */ "__fixsfsi", /* FPTOSINT_F32_I64 */ "__fixsfdi", /* FPTOSINT_F32_I128 */ "__fixsfti", diff --git a/llvm/test/CodeGen/X86/fp128-cast.ll b/llvm/test/CodeGen/X86/fp128-cast.ll index 3e49f6715081..bfcc18d54a17 100644 --- a/llvm/test/CodeGen/X86/fp128-cast.ll +++ b/llvm/test/CodeGen/X86/fp128-cast.ll @@ -12,6 +12,7 @@ @vu64 = common global i64 0, align 8 @vf32 = common global float 0.000000e+00, align 4 @vf64 = common global double 0.000000e+00, align 8 +@vf80 = common global x86_fp80 0xK00000000000000000000, align 8 @vf128 = common global fp128 0xL00000000000000000000000000000000, align 16 define void @TestFPExtF32_F128() { @@ -52,6 +53,19 @@ entry: ; X64: ret } +define void @TestFPExtF80_F128() { +entry: + %0 = load x86_fp80, x86_fp80* @vf80, align 8 + %conv = fpext x86_fp80 %0 to fp128 + store fp128 %conv, fp128* @vf128, align 16 + ret void +; X32-LABEL: TestFPExtF80_F128: +; X32: calll __extendxftf2 +; +; X64-LABEL: TestFPExtF80_F128: +; X64: callq __extendxftf2 +} + define void @TestFPToSIF128_I32() { entry: %0 = load fp128, fp128* @vf128, align 16 @@ -160,6 +174,19 @@ entry: ; X64: retq } +define void @TestFPTruncF128_F80() { +entry: + %0 = load fp128, fp128* @vf128, align 16 + %conv = fptrunc fp128 %0 to x86_fp80 + store x86_fp80 %conv, x86_fp80* @vf80, align 8 + ret void +; X32-LABEL: TestFPTruncF128_F80: +; X32: calll __trunctfxf2 +; +; X64-LABEL: TestFPTruncF128_F80: +; X64: callq __trunctfxf2 +} + define void @TestSIToFPI32_F128() { entry: %0 = load i32, i32* @vi32, align 4