Add missing roundtointegral builtin functions for some FP instructions to be generated from C-written codes
To generate FROUND instructions in https://reviews.llvm.org/D143982, we need to use llvm intrinsics in IR files. Now I add some corresponding builtin functions to make sure these roundtointegral instructions can be generated from C codes. Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D144935
This commit is contained in:
@@ -350,6 +350,11 @@ BUILTIN(__builtin_roundf, "ff" , "Fnc")
|
||||
BUILTIN(__builtin_roundf16, "hh" , "Fnc")
|
||||
BUILTIN(__builtin_roundl, "LdLd" , "Fnc")
|
||||
BUILTIN(__builtin_roundf128, "LLdLLd" , "Fnc")
|
||||
BUILTIN(__builtin_roundeven, "dd" , "Fnc")
|
||||
BUILTIN(__builtin_roundevenf, "ff" , "Fnc")
|
||||
BUILTIN(__builtin_roundevenf16, "hh" , "Fnc")
|
||||
BUILTIN(__builtin_roundevenl, "LdLd" , "Fnc")
|
||||
BUILTIN(__builtin_roundevenf128, "LLdLLd" , "Fnc")
|
||||
BUILTIN(__builtin_scalbln , "ddLi", "Fne")
|
||||
BUILTIN(__builtin_scalblnf, "ffLi", "Fne")
|
||||
BUILTIN(__builtin_scalblnl, "LdLdLi", "Fne")
|
||||
@@ -1420,6 +1425,10 @@ LIBBUILTIN(round, "dd", "fnc", MATH_H, ALL_LANGUAGES)
|
||||
LIBBUILTIN(roundf, "ff", "fnc", MATH_H, ALL_LANGUAGES)
|
||||
LIBBUILTIN(roundl, "LdLd", "fnc", MATH_H, ALL_LANGUAGES)
|
||||
|
||||
LIBBUILTIN(roundeven, "dd", "fnc", MATH_H, ALL_LANGUAGES)
|
||||
LIBBUILTIN(roundevenf, "ff", "fnc", MATH_H, ALL_LANGUAGES)
|
||||
LIBBUILTIN(roundevenl, "LdLd", "fnc", MATH_H, ALL_LANGUAGES)
|
||||
|
||||
LIBBUILTIN(scalbln, "ddLi", "fne", MATH_H, ALL_LANGUAGES)
|
||||
LIBBUILTIN(scalblnf, "ffLi", "fne", MATH_H, ALL_LANGUAGES)
|
||||
LIBBUILTIN(scalblnl, "LdLdLi", "fne", MATH_H, ALL_LANGUAGES)
|
||||
|
||||
@@ -2444,6 +2444,18 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
|
||||
Intrinsic::round,
|
||||
Intrinsic::experimental_constrained_round));
|
||||
|
||||
case Builtin::BIroundeven:
|
||||
case Builtin::BIroundevenf:
|
||||
case Builtin::BIroundevenl:
|
||||
case Builtin::BI__builtin_roundeven:
|
||||
case Builtin::BI__builtin_roundevenf:
|
||||
case Builtin::BI__builtin_roundevenf16:
|
||||
case Builtin::BI__builtin_roundevenl:
|
||||
case Builtin::BI__builtin_roundevenf128:
|
||||
return RValue::get(emitUnaryMaybeConstrainedFPBuiltin(*this, E,
|
||||
Intrinsic::roundeven,
|
||||
Intrinsic::experimental_constrained_roundeven));
|
||||
|
||||
case Builtin::BIsin:
|
||||
case Builtin::BIsinf:
|
||||
case Builtin::BIsinl:
|
||||
|
||||
@@ -411,6 +411,15 @@ void test_float_builtin_ops(float F, double D, long double LD) {
|
||||
resld = __builtin_roundl(LD);
|
||||
// CHECK: call x86_fp80 @llvm.round.f80
|
||||
|
||||
resf = __builtin_roundevenf(F);
|
||||
// CHECK: call float @llvm.roundeven.f32
|
||||
|
||||
resd = __builtin_roundeven(D);
|
||||
// CHECK: call double @llvm.roundeven.f64
|
||||
|
||||
resld = __builtin_roundevenl(LD);
|
||||
// CHECK: call x86_fp80 @llvm.roundeven.f80
|
||||
|
||||
resli = __builtin_lroundf (F);
|
||||
// CHECK: call i64 @llvm.lround.i64.f32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user