[clang] [Clang][C++23] Core language changes from P1467R9 extended floating-point types and standard names. (PR #78503)
Zahira Ammarguellat via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 22 12:00:44 PST 2024
================
@@ -112,6 +112,85 @@ enum FloatingRank {
Ibm128Rank
};
+constexpr unsigned CXX23FloatRankToIndex(clang::BuiltinType::Kind Kind) {
+ switch (Kind) {
+ case clang::BuiltinType::Float16:
+ return 0;
+ case clang::BuiltinType::BFloat16:
+ return 1;
+ case clang::BuiltinType::Float:
+ return 2;
+ case clang::BuiltinType::Double:
+ return 3;
+ case clang::BuiltinType::LongDouble:
+ return 4;
+ default:
+ // Both __float128 and __ibm128 are compiler extensions, not extended floating points.
+ // __float128 also predates the invention of floating-point types.
+ llvm_unreachable("Not a CXX23+ floating point builtin type");
+ }
+}
+
+// C++23 6.8.6p2 [conv.rank]
+// Grid to determine the rank of a floating point type when compared with
+// another floating point type.
+constexpr std::array<std::array<FloatConvRankCompareResult, 5>, 5>
+ CXX23FloatingPointConversionRankMap = {
+ {// Float16 x Float16
+ // Float16 x BFloat16
+ // Float16 x Float
+ // Float16 x Double
+ // Float16 x LongDouble
+ {{FloatConvRankCompareResult::FRCR_Equal,
+ FloatConvRankCompareResult::FRCR_Unordered,
+ FloatConvRankCompareResult::FRCR_Lesser,
+ FloatConvRankCompareResult::FRCR_Lesser,
+ FloatConvRankCompareResult::FRCR_Lesser}},
+
+ // BFloat16 x Float16
+ // BFloat16 x BFloat16
+ // BFloat16 x Float
+ // BFloat16 x Double
+ // BFloat16 x LongDouble
+ {{FloatConvRankCompareResult::FRCR_Unordered,
+ FloatConvRankCompareResult::FRCR_Equal,
+ FloatConvRankCompareResult::FRCR_Lesser,
+ FloatConvRankCompareResult::FRCR_Lesser,
+ FloatConvRankCompareResult::FRCR_Lesser}},
+
+ // Float x Float16
+ // Float x BFloat16
+ // Float x Float
+ // Float x Double
+ // Float x LongDouble
+ {{FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Equal,
+ FloatConvRankCompareResult::FRCR_Lesser,
+ FloatConvRankCompareResult::FRCR_Lesser}},
+
+ // Double x Float16
+ // Double x BFloat16
+ // Double x Float
+ // Double x Double
+ // Double x LongDouble
+ {{FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Equal,
+ FloatConvRankCompareResult::FRCR_Lesser}},
+
+ // LongDouble x Float16
+ // LongDouble x BFloat16
+ // LongDouble x Float
+ // LongDouble x Double
+ // LongDouble x LongDouble
+ {{FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Greater,
+ FloatConvRankCompareResult::FRCR_Equal}}}};
+
----------------
zahiraam wrote:
Shouldn't we have cases here where we generate FRCR_Equal_Lesser_Subrank or FRCR_Equal_Greater_Subrank?
https://github.com/llvm/llvm-project/pull/78503
More information about the cfe-commits
mailing list