mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 18:16:42 +00:00
[libc++][format] Adds ABI tags to inline constexpr variables. (#86293)
This uses the macro on record types and inline constexpr variables. The tagged declarations are very likely to change in future versions of libc++: - __fields are internal types used to control the formatter's parse functions which fields to expect. Newer formatters may add new fields. For example the filesystem::path formatter accepted in the recent Tokyo meeting added a new 'g' flag, which differs from the 'g' type. - The Unicode tables. The number of entries in these table likely differ between Unicode versions. The tables contain only a part of all Unicode properties. Typically they are stored in a 32-bit entry where some bits contain the properties and other bits the size of the range. Changes in the Unicode or C++ algorithms may require more properties to be available in C++. This may affect the number of bits available in the range. If needed, other declarations get the macro. This is mainly a first time to review this approach. This was originally https://reviews.llvm.org/D143494 where a new macro _LIBCPP_HIDE_FROM_ABI_TYPE was defined. Testing revealed the existing macro _LIBCPP_HIDE_FROM_ABI could be used. The "parts" of the macro that do not affect records are not harmful. Based on this information the existing macro was used and additional documentation was written.
This commit is contained in:
parent
2745f72a81
commit
d179176f3e
@ -805,6 +805,12 @@ typedef __char32_t char32_t;
|
||||
// the implementation of a virtual function in an ABI-incompatible way in the first place,
|
||||
// since that would be an ABI break anyway. Hence, the lack of ABI tag should not be noticeable.
|
||||
//
|
||||
// The macro can be applied to record and enum types. When the tagged type is nested in
|
||||
// a record this "parent" record needs to have the macro too. Another use case for applying
|
||||
// this macro to records and unions is to apply an ABI tag to inline constexpr variables.
|
||||
// This can be useful for inline variables that are implementation details which are expected
|
||||
// to change in the future.
|
||||
//
|
||||
// TODO: We provide a escape hatch with _LIBCPP_NO_ABI_TAG for folks who want to avoid increasing
|
||||
// the length of symbols with an ABI tag. In practice, we should remove the escape hatch and
|
||||
// use compression mangling instead, see https://github.com/itanium-cxx-abi/cxx-abi/issues/70.
|
||||
|
@ -110,7 +110,7 @@ namespace __escaped_output_table {
|
||||
/// - bits [0, 10] The size of the range, allowing 2048 elements.
|
||||
/// - bits [11, 31] The lower bound code point of the range. The upper bound of
|
||||
/// the range is lower bound + size.
|
||||
inline constexpr uint32_t __entries[893] = {
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[893] = {
|
||||
0x00000020,
|
||||
0x0003f821,
|
||||
0x00056800,
|
||||
|
@ -125,7 +125,7 @@ enum class __property : uint8_t {
|
||||
/// following benchmark.
|
||||
/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
|
||||
// clang-format off
|
||||
inline constexpr uint32_t __entries[1496] = {
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[1496] = {
|
||||
0x00000091,
|
||||
0x00005005,
|
||||
0x00005811,
|
||||
|
@ -129,8 +129,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr uint32_t __substitute_arg_id(basic_format_arg<_C
|
||||
///
|
||||
/// They default to false so when a new field is added it needs to be opted in
|
||||
/// explicitly.
|
||||
// TODO FMT Use an ABI tag for this struct.
|
||||
struct __fields {
|
||||
struct _LIBCPP_HIDE_FROM_ABI __fields {
|
||||
uint16_t __sign_ : 1 {false};
|
||||
uint16_t __alternate_form_ : 1 {false};
|
||||
uint16_t __zero_padding_ : 1 {false};
|
||||
|
@ -119,7 +119,7 @@ namespace __width_estimation_table {
|
||||
/// - bits [0, 13] The size of the range, allowing 16384 elements.
|
||||
/// - bits [14, 31] The lower bound code point of the range. The upper bound of
|
||||
/// the range is lower bound + size.
|
||||
inline constexpr uint32_t __entries[108] = {
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[108] = {
|
||||
0x0440005f /* 00001100 - 0000115f [ 96] */, //
|
||||
0x08c68001 /* 0000231a - 0000231b [ 2] */, //
|
||||
0x08ca4001 /* 00002329 - 0000232a [ 2] */, //
|
||||
|
@ -124,7 +124,7 @@ DATA_ARRAY_TEMPLATE = """
|
||||
/// - bits [0, 10] The size of the range, allowing 2048 elements.
|
||||
/// - bits [11, 31] The lower bound code point of the range. The upper bound of
|
||||
/// the range is lower bound + size.
|
||||
inline constexpr uint32_t __entries[{size}] = {{
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[{size}] = {{
|
||||
{entries}}};
|
||||
|
||||
/// At the end of the valid Unicode code points space a lot of code points are
|
||||
|
@ -113,7 +113,7 @@ DATA_ARRAY_TEMPLATE = """
|
||||
/// following benchmark.
|
||||
/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
|
||||
// clang-format off
|
||||
inline constexpr uint32_t __entries[{size}] = {{
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[{size}] = {{
|
||||
{entries}}};
|
||||
// clang-format on
|
||||
|
||||
|
@ -143,7 +143,7 @@ DATA_ARRAY_TEMPLATE = """
|
||||
/// - bits [0, 13] The size of the range, allowing 16384 elements.
|
||||
/// - bits [14, 31] The lower bound code point of the range. The upper bound of
|
||||
/// the range is lower bound + size.
|
||||
inline constexpr uint32_t __entries[{size}] = {{
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr uint32_t __entries[{size}] = {{
|
||||
{entries}}};
|
||||
|
||||
/// The upper bound entry of EastAsianWidth.txt.
|
||||
|
Loading…
x
Reference in New Issue
Block a user