From: Juzhe-Zhong <juzhe.zhong@rivai.ai>
To: gcc-patches@gcc.gnu.org
Cc: kito.cheng@gmail.com, kito.cheng@sifive.com,
jeffreyalaw@gmail.com, rdapp.gcc@gmail.com,
Juzhe-Zhong <juzhe.zhong@rivai.ai>
Subject: [PATCH] RISC-V: Fix incorrect LCM delete bug [VSETVL PASS]
Date: Thu, 25 Jan 2024 20:33:49 +0800 [thread overview]
Message-ID: <20240125123349.981882-1-juzhe.zhong@rivai.ai> (raw)
This patch fixes the recent noticed bug in RV32 glibc.
We incorrectly deleted a vsetvl:
...
and a4,a4,a3
vmv.v.i v1,0 ---> Missed vsetvl cause illegal instruction report.
vse8.v v1,0(a5)
The root cause the laterin in LCM is incorrect.
BB 358:
avloc: n_bits = 2, set = {}
kill: n_bits = 2, set = {}
antloc: n_bits = 2, set = {}
transp: n_bits = 2, set = {}
avin: n_bits = 2, set = {}
avout: n_bits = 2, set = {}
del: n_bits = 2, set = {}
cause LCM let BB 360 delete the vsetvl:
BB 360:
avloc: n_bits = 2, set = {}
kill: n_bits = 2, set = {}
antloc: n_bits = 2, set = {}
transp: n_bits = 2, set = {0 1 }
avin: n_bits = 2, set = {}
avout: n_bits = 2, set = {}
del: n_bits = 2, set = {1}
Also, remove unknown vsetvl info into local computation since it is unnecessary.
Tested on both RV32/RV64 no regression.
PR target/113469
gcc/ChangeLog:
* config/riscv/riscv-vsetvl.cc (pre_vsetvl::compute_lcm_local_properties): Fix bug.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/autovec/pr113469.c: New test.
---
gcc/config/riscv/riscv-vsetvl.cc | 21 +-
.../gcc.target/riscv/rvv/autovec/pr113469.c | 1841 +++++++++++++++++
2 files changed, 1853 insertions(+), 9 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c
diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index da258b964fc..f300f00e62a 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -2543,8 +2543,10 @@ pre_vsetvl::compute_lcm_local_properties ()
vsetvl_info &header_info = block_info.get_entry_info ();
vsetvl_info &footer_info = block_info.get_exit_info ();
gcc_assert (footer_info.valid_p () || footer_info.unknown_p ());
- add_expr (m_exprs, header_info);
- add_expr (m_exprs, footer_info);
+ if (header_info.valid_p ())
+ add_expr (m_exprs, header_info);
+ if (footer_info.valid_p ())
+ add_expr (m_exprs, footer_info);
}
int num_exprs = m_exprs.length ();
@@ -2699,13 +2701,6 @@ pre_vsetvl::compute_lcm_local_properties ()
}
}
- for (const bb_info *bb : crtl->ssa->bbs ())
- {
- unsigned bb_index = bb->index ();
- bitmap_ior (m_kill[bb_index], m_transp[bb_index], m_avloc[bb_index]);
- bitmap_not (m_kill[bb_index], m_kill[bb_index]);
- }
-
for (const bb_info *bb : crtl->ssa->bbs ())
{
unsigned bb_index = bb->index ();
@@ -2713,8 +2708,16 @@ pre_vsetvl::compute_lcm_local_properties ()
{
bitmap_clear (m_antloc[bb_index]);
bitmap_clear (m_transp[bb_index]);
+ bitmap_clear (m_avloc[bb_index]);
}
}
+
+ for (const bb_info *bb : crtl->ssa->bbs ())
+ {
+ unsigned bb_index = bb->index ();
+ bitmap_ior (m_kill[bb_index], m_transp[bb_index], m_avloc[bb_index]);
+ bitmap_not (m_kill[bb_index], m_kill[bb_index]);
+ }
}
void
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c
new file mode 100644
index 00000000000..2502040772b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr113469.c
@@ -0,0 +1,1841 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32d -O3" } */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stddef.h>
+#include <string.h>
+
+static int read_int (const unsigned char * *pstr) {};
+static const char null[] = "(null)";
+extern size_t __strnlen (const char *__string, size_t __maxlen) __attribute__ ((__pure__));
+
+struct printf_info
+{
+ int prec;
+ int width;
+ wchar_t spec;
+ unsigned int is_long_double:1;
+ unsigned int is_short:1;
+ unsigned int is_long:1;
+ unsigned int alt:1;
+ unsigned int space:1;
+ unsigned int left:1;
+ unsigned int showsign:1;
+ unsigned int group:1;
+ unsigned int extra:1;
+ unsigned int is_char:1;
+ unsigned int wide:1;
+ unsigned int i18n:1;
+ unsigned int is_binary128:1;
+
+ unsigned int __pad:3;
+ unsigned short int user;
+ wchar_t pad;
+};
+
+enum {
+ ABDAY_1 = (((2) << 16) | (0)),
+ ABDAY_2,
+ ABDAY_3,
+ ABDAY_4,
+ ABDAY_5,
+ ABDAY_6,
+ ABDAY_7,
+ DAY_1,
+ DAY_2,
+ DAY_3,
+ DAY_4,
+ DAY_5,
+ DAY_6,
+ DAY_7,
+ ABMON_1,
+ ABMON_2,
+ ABMON_3,
+ ABMON_4,
+ ABMON_5,
+ ABMON_6,
+ ABMON_7,
+ ABMON_8,
+ ABMON_9,
+ ABMON_10,
+ ABMON_11,
+ ABMON_12,
+ MON_1,
+ MON_2,
+ MON_3,
+ MON_4,
+ MON_5,
+ MON_6,
+ MON_7,
+ MON_8,
+ MON_9,
+ MON_10,
+ MON_11,
+ MON_12,
+ AM_STR,
+ PM_STR,
+ D_T_FMT,
+ D_FMT,
+ T_FMT,
+ T_FMT_AMPM,
+ ERA,
+ __ERA_YEAR,
+ ERA_D_FMT,
+
+ ALT_DIGITS,
+
+ ERA_D_T_FMT,
+
+ ERA_T_FMT,
+ _NL_TIME_ERA_NUM_ENTRIES,
+ _NL_TIME_ERA_ENTRIES,
+
+ _NL_WABDAY_1,
+ _NL_WABDAY_2,
+ _NL_WABDAY_3,
+ _NL_WABDAY_4,
+ _NL_WABDAY_5,
+ _NL_WABDAY_6,
+ _NL_WABDAY_7,
+ _NL_WDAY_1,
+ _NL_WDAY_2,
+ _NL_WDAY_3,
+ _NL_WDAY_4,
+ _NL_WDAY_5,
+ _NL_WDAY_6,
+ _NL_WDAY_7,
+
+
+
+ _NL_WABMON_1,
+ _NL_WABMON_2,
+ _NL_WABMON_3,
+ _NL_WABMON_4,
+ _NL_WABMON_5,
+ _NL_WABMON_6,
+ _NL_WABMON_7,
+ _NL_WABMON_8,
+ _NL_WABMON_9,
+ _NL_WABMON_10,
+ _NL_WABMON_11,
+ _NL_WABMON_12,
+
+
+
+ _NL_WMON_1,
+ _NL_WMON_2,
+ _NL_WMON_3,
+ _NL_WMON_4,
+ _NL_WMON_5,
+ _NL_WMON_6,
+ _NL_WMON_7,
+ _NL_WMON_8,
+ _NL_WMON_9,
+ _NL_WMON_10,
+ _NL_WMON_11,
+ _NL_WMON_12,
+
+ _NL_WAM_STR,
+ _NL_WPM_STR,
+
+ _NL_WD_T_FMT,
+ _NL_WD_FMT,
+ _NL_WT_FMT,
+ _NL_WT_FMT_AMPM,
+
+ _NL_WERA_YEAR,
+ _NL_WERA_D_FMT,
+ _NL_WALT_DIGITS,
+ _NL_WERA_D_T_FMT,
+ _NL_WERA_T_FMT,
+
+ _NL_TIME_WEEK_NDAYS,
+ _NL_TIME_WEEK_1STDAY,
+ _NL_TIME_WEEK_1STWEEK,
+ _NL_TIME_FIRST_WEEKDAY,
+ _NL_TIME_FIRST_WORKDAY,
+ _NL_TIME_CAL_DIRECTION,
+ _NL_TIME_TIMEZONE,
+
+ _DATE_FMT,
+
+ _NL_W_DATE_FMT,
+
+ _NL_TIME_CODESET,
+
+ __ALTMON_1,
+ __ALTMON_2,
+ __ALTMON_3,
+ __ALTMON_4,
+ __ALTMON_5,
+ __ALTMON_6,
+ __ALTMON_7,
+ __ALTMON_8,
+ __ALTMON_9,
+ __ALTMON_10,
+ __ALTMON_11,
+ __ALTMON_12,
+ _NL_WALTMON_1,
+ _NL_WALTMON_2,
+ _NL_WALTMON_3,
+ _NL_WALTMON_4,
+ _NL_WALTMON_5,
+ _NL_WALTMON_6,
+ _NL_WALTMON_7,
+ _NL_WALTMON_8,
+ _NL_WALTMON_9,
+ _NL_WALTMON_10,
+ _NL_WALTMON_11,
+ _NL_WALTMON_12,
+
+ _NL_ABALTMON_1,
+ _NL_ABALTMON_2,
+ _NL_ABALTMON_3,
+ _NL_ABALTMON_4,
+ _NL_ABALTMON_5,
+ _NL_ABALTMON_6,
+ _NL_ABALTMON_7,
+ _NL_ABALTMON_8,
+ _NL_ABALTMON_9,
+ _NL_ABALTMON_10,
+ _NL_ABALTMON_11,
+ _NL_ABALTMON_12,
+
+ _NL_WABALTMON_1,
+ _NL_WABALTMON_2,
+ _NL_WABALTMON_3,
+ _NL_WABALTMON_4,
+ _NL_WABALTMON_5,
+ _NL_WABALTMON_6,
+ _NL_WABALTMON_7,
+ _NL_WABALTMON_8,
+ _NL_WABALTMON_9,
+ _NL_WABALTMON_10,
+ _NL_WABALTMON_11,
+ _NL_WABALTMON_12,
+
+ _NL_NUM_LC_TIME,
+
+ _NL_COLLATE_NRULES = (((3) << 16) | (0)),
+ _NL_COLLATE_RULESETS,
+ _NL_COLLATE_TABLEMB,
+ _NL_COLLATE_WEIGHTMB,
+ _NL_COLLATE_EXTRAMB,
+ _NL_COLLATE_INDIRECTMB,
+ _NL_COLLATE_GAP1,
+ _NL_COLLATE_GAP2,
+ _NL_COLLATE_GAP3,
+ _NL_COLLATE_TABLEWC,
+ _NL_COLLATE_WEIGHTWC,
+ _NL_COLLATE_EXTRAWC,
+ _NL_COLLATE_INDIRECTWC,
+ _NL_COLLATE_SYMB_HASH_SIZEMB,
+ _NL_COLLATE_SYMB_TABLEMB,
+ _NL_COLLATE_SYMB_EXTRAMB,
+ _NL_COLLATE_COLLSEQMB,
+ _NL_COLLATE_COLLSEQWC,
+ _NL_COLLATE_CODESET,
+ _NL_NUM_LC_COLLATE,
+ _NL_CTYPE_CLASS = (((0) << 16) | (0)),
+ _NL_CTYPE_TOUPPER,
+ _NL_CTYPE_GAP1,
+ _NL_CTYPE_TOLOWER,
+ _NL_CTYPE_GAP2,
+ _NL_CTYPE_CLASS32,
+ _NL_CTYPE_GAP3,
+ _NL_CTYPE_GAP4,
+ _NL_CTYPE_GAP5,
+ _NL_CTYPE_GAP6,
+ _NL_CTYPE_CLASS_NAMES,
+ _NL_CTYPE_MAP_NAMES,
+ _NL_CTYPE_WIDTH,
+ _NL_CTYPE_MB_CUR_MAX,
+ _NL_CTYPE_CODESET_NAME,
+ CODESET = _NL_CTYPE_CODESET_NAME,
+
+ _NL_CTYPE_TOUPPER32,
+ _NL_CTYPE_TOLOWER32,
+ _NL_CTYPE_CLASS_OFFSET,
+ _NL_CTYPE_MAP_OFFSET,
+ _NL_CTYPE_INDIGITS_MB_LEN,
+ _NL_CTYPE_INDIGITS0_MB,
+ _NL_CTYPE_INDIGITS1_MB,
+ _NL_CTYPE_INDIGITS2_MB,
+ _NL_CTYPE_INDIGITS3_MB,
+ _NL_CTYPE_INDIGITS4_MB,
+ _NL_CTYPE_INDIGITS5_MB,
+ _NL_CTYPE_INDIGITS6_MB,
+ _NL_CTYPE_INDIGITS7_MB,
+ _NL_CTYPE_INDIGITS8_MB,
+ _NL_CTYPE_INDIGITS9_MB,
+ _NL_CTYPE_INDIGITS_WC_LEN,
+ _NL_CTYPE_INDIGITS0_WC,
+ _NL_CTYPE_INDIGITS1_WC,
+ _NL_CTYPE_INDIGITS2_WC,
+ _NL_CTYPE_INDIGITS3_WC,
+ _NL_CTYPE_INDIGITS4_WC,
+ _NL_CTYPE_INDIGITS5_WC,
+ _NL_CTYPE_INDIGITS6_WC,
+ _NL_CTYPE_INDIGITS7_WC,
+ _NL_CTYPE_INDIGITS8_WC,
+ _NL_CTYPE_INDIGITS9_WC,
+ _NL_CTYPE_OUTDIGIT0_MB,
+ _NL_CTYPE_OUTDIGIT1_MB,
+ _NL_CTYPE_OUTDIGIT2_MB,
+ _NL_CTYPE_OUTDIGIT3_MB,
+ _NL_CTYPE_OUTDIGIT4_MB,
+ _NL_CTYPE_OUTDIGIT5_MB,
+ _NL_CTYPE_OUTDIGIT6_MB,
+ _NL_CTYPE_OUTDIGIT7_MB,
+ _NL_CTYPE_OUTDIGIT8_MB,
+ _NL_CTYPE_OUTDIGIT9_MB,
+ _NL_CTYPE_OUTDIGIT0_WC,
+ _NL_CTYPE_OUTDIGIT1_WC,
+ _NL_CTYPE_OUTDIGIT2_WC,
+ _NL_CTYPE_OUTDIGIT3_WC,
+ _NL_CTYPE_OUTDIGIT4_WC,
+ _NL_CTYPE_OUTDIGIT5_WC,
+ _NL_CTYPE_OUTDIGIT6_WC,
+ _NL_CTYPE_OUTDIGIT7_WC,
+ _NL_CTYPE_OUTDIGIT8_WC,
+ _NL_CTYPE_OUTDIGIT9_WC,
+ _NL_CTYPE_TRANSLIT_TAB_SIZE,
+ _NL_CTYPE_TRANSLIT_FROM_IDX,
+ _NL_CTYPE_TRANSLIT_FROM_TBL,
+ _NL_CTYPE_TRANSLIT_TO_IDX,
+ _NL_CTYPE_TRANSLIT_TO_TBL,
+ _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN,
+ _NL_CTYPE_TRANSLIT_DEFAULT_MISSING,
+ _NL_CTYPE_TRANSLIT_IGNORE_LEN,
+ _NL_CTYPE_TRANSLIT_IGNORE,
+ _NL_CTYPE_MAP_TO_NONASCII,
+ _NL_CTYPE_NONASCII_CASE,
+ _NL_CTYPE_EXTRA_MAP_1,
+ _NL_CTYPE_EXTRA_MAP_2,
+ _NL_CTYPE_EXTRA_MAP_3,
+ _NL_CTYPE_EXTRA_MAP_4,
+ _NL_CTYPE_EXTRA_MAP_5,
+ _NL_CTYPE_EXTRA_MAP_6,
+ _NL_CTYPE_EXTRA_MAP_7,
+ _NL_CTYPE_EXTRA_MAP_8,
+ _NL_CTYPE_EXTRA_MAP_9,
+ _NL_CTYPE_EXTRA_MAP_10,
+ _NL_CTYPE_EXTRA_MAP_11,
+ _NL_CTYPE_EXTRA_MAP_12,
+ _NL_CTYPE_EXTRA_MAP_13,
+ _NL_CTYPE_EXTRA_MAP_14,
+ _NL_NUM_LC_CTYPE,
+
+ __INT_CURR_SYMBOL = (((4) << 16) | (0)),
+ __CURRENCY_SYMBOL,
+ __MON_DECIMAL_POINT,
+ __MON_THOUSANDS_SEP,
+ __MON_GROUPING,
+ __POSITIVE_SIGN,
+ __NEGATIVE_SIGN,
+ __INT_FRAC_DIGITS,
+ __FRAC_DIGITS,
+ __P_CS_PRECEDES,
+ __P_SEP_BY_SPACE,
+ __N_CS_PRECEDES,
+ __N_SEP_BY_SPACE,
+ __P_SIGN_POSN,
+ __N_SIGN_POSN,
+ _NL_MONETARY_CRNCYSTR,
+
+ __INT_P_CS_PRECEDES,
+ __INT_P_SEP_BY_SPACE,
+ __INT_N_CS_PRECEDES,
+ __INT_N_SEP_BY_SPACE,
+ __INT_P_SIGN_POSN,
+ __INT_N_SIGN_POSN,
+ _NL_MONETARY_DUO_INT_CURR_SYMBOL,
+ _NL_MONETARY_DUO_CURRENCY_SYMBOL,
+ _NL_MONETARY_DUO_INT_FRAC_DIGITS,
+ _NL_MONETARY_DUO_FRAC_DIGITS,
+ _NL_MONETARY_DUO_P_CS_PRECEDES,
+ _NL_MONETARY_DUO_P_SEP_BY_SPACE,
+ _NL_MONETARY_DUO_N_CS_PRECEDES,
+ _NL_MONETARY_DUO_N_SEP_BY_SPACE,
+ _NL_MONETARY_DUO_INT_P_CS_PRECEDES,
+ _NL_MONETARY_DUO_INT_P_SEP_BY_SPACE,
+ _NL_MONETARY_DUO_INT_N_CS_PRECEDES,
+ _NL_MONETARY_DUO_INT_N_SEP_BY_SPACE,
+ _NL_MONETARY_DUO_P_SIGN_POSN,
+ _NL_MONETARY_DUO_N_SIGN_POSN,
+ _NL_MONETARY_DUO_INT_P_SIGN_POSN,
+ _NL_MONETARY_DUO_INT_N_SIGN_POSN,
+ _NL_MONETARY_UNO_VALID_FROM,
+ _NL_MONETARY_UNO_VALID_TO,
+ _NL_MONETARY_DUO_VALID_FROM,
+ _NL_MONETARY_DUO_VALID_TO,
+ _NL_MONETARY_CONVERSION_RATE,
+ _NL_MONETARY_DECIMAL_POINT_WC,
+ _NL_MONETARY_THOUSANDS_SEP_WC,
+ _NL_MONETARY_CODESET,
+ _NL_NUM_LC_MONETARY,
+ __DECIMAL_POINT = (((1) << 16) | (0)),
+ RADIXCHAR = __DECIMAL_POINT,
+
+ __THOUSANDS_SEP,
+ THOUSEP = __THOUSANDS_SEP,
+
+ __GROUPING,
+ _NL_NUMERIC_DECIMAL_POINT_WC,
+ _NL_NUMERIC_THOUSANDS_SEP_WC,
+ _NL_NUMERIC_CODESET,
+ _NL_NUM_LC_NUMERIC,
+
+ __YESEXPR = (((5) << 16) | (0)),
+
+ __NOEXPR,
+
+ __YESSTR,
+ __NOSTR,
+ _NL_MESSAGES_CODESET,
+ _NL_NUM_LC_MESSAGES,
+
+ _NL_PAPER_HEIGHT = (((7) << 16) | (0)),
+ _NL_PAPER_WIDTH,
+ _NL_PAPER_CODESET,
+ _NL_NUM_LC_PAPER,
+
+ _NL_NAME_NAME_FMT = (((8) << 16) | (0)),
+ _NL_NAME_NAME_GEN,
+ _NL_NAME_NAME_MR,
+ _NL_NAME_NAME_MRS,
+ _NL_NAME_NAME_MISS,
+ _NL_NAME_NAME_MS,
+ _NL_NAME_CODESET,
+ _NL_NUM_LC_NAME,
+
+ _NL_ADDRESS_POSTAL_FMT = (((9) << 16) | (0)),
+ _NL_ADDRESS_COUNTRY_NAME,
+ _NL_ADDRESS_COUNTRY_POST,
+ _NL_ADDRESS_COUNTRY_AB2,
+ _NL_ADDRESS_COUNTRY_AB3,
+ _NL_ADDRESS_COUNTRY_CAR,
+ _NL_ADDRESS_COUNTRY_NUM,
+ _NL_ADDRESS_COUNTRY_ISBN,
+ _NL_ADDRESS_LANG_NAME,
+ _NL_ADDRESS_LANG_AB,
+ _NL_ADDRESS_LANG_TERM,
+ _NL_ADDRESS_LANG_LIB,
+ _NL_ADDRESS_CODESET,
+ _NL_NUM_LC_ADDRESS,
+
+ _NL_TELEPHONE_TEL_INT_FMT = (((10) << 16) | (0)),
+ _NL_TELEPHONE_TEL_DOM_FMT,
+ _NL_TELEPHONE_INT_SELECT,
+ _NL_TELEPHONE_INT_PREFIX,
+ _NL_TELEPHONE_CODESET,
+ _NL_NUM_LC_TELEPHONE,
+
+ _NL_MEASUREMENT_MEASUREMENT = (((11) << 16) | (0)),
+ _NL_MEASUREMENT_CODESET,
+ _NL_NUM_LC_MEASUREMENT,
+
+ _NL_IDENTIFICATION_TITLE = (((12) << 16) | (0)),
+ _NL_IDENTIFICATION_SOURCE,
+ _NL_IDENTIFICATION_ADDRESS,
+ _NL_IDENTIFICATION_CONTACT,
+ _NL_IDENTIFICATION_EMAIL,
+ _NL_IDENTIFICATION_TEL,
+ _NL_IDENTIFICATION_FAX,
+ _NL_IDENTIFICATION_LANGUAGE,
+ _NL_IDENTIFICATION_TERRITORY,
+ _NL_IDENTIFICATION_AUDIENCE,
+ _NL_IDENTIFICATION_APPLICATION,
+ _NL_IDENTIFICATION_ABBREVIATION,
+ _NL_IDENTIFICATION_REVISION,
+ _NL_IDENTIFICATION_DATE,
+ _NL_IDENTIFICATION_CATEGORY,
+ _NL_IDENTIFICATION_CODESET,
+ _NL_NUM_LC_IDENTIFICATION,
+ _NL_NUM
+};
+
+typedef const char *THOUSANDS_SEP_T;
+typedef unsigned int size_t;
+enum { WORK_BUFFER_SIZE = 1000 / sizeof (char) };
+
+enum __printf_buffer_mode
+ {
+ __printf_buffer_mode_failed,
+ __printf_buffer_mode_sprintf,
+ __printf_buffer_mode_snprintf,
+ __printf_buffer_mode_sprintf_chk,
+ __printf_buffer_mode_to_file,
+ __printf_buffer_mode_asprintf,
+ __printf_buffer_mode_dprintf,
+ __printf_buffer_mode_strfmon,
+ __printf_buffer_mode_fp,
+ __printf_buffer_mode_fp_to_wide,
+ __printf_buffer_mode_fphex_to_wide,
+ __printf_buffer_mode_obstack,
+};
+
+struct __locale_data
+{
+ const char *name;
+ const char *filedata;
+ off_t filesize;
+ enum
+ {
+ ld_malloced,
+ ld_mapped,
+ ld_archive
+ } alloc;
+ void *private;
+
+ unsigned int usage_count;
+
+ int use_translit;
+
+ unsigned int nstrings;
+ union locale_data_value
+ {
+ const uint32_t *wstr;
+ const char *string;
+ unsigned int word;
+ }
+ values [];
+};
+
+struct __printf_buffer
+{
+ char *write_base;
+ char *write_ptr;
+ char *write_end;
+ uint64_t written;
+
+ enum __printf_buffer_mode mode;
+};
+
+
+void __printf_fphex_l_buffer (struct __printf_buffer *, locale_t,
+ const struct printf_info *,
+ const void *const *) __attribute__ ((visibility ("hidden")));
+
+void __printf_fp_l_buffer (struct __printf_buffer *, locale_t,
+ const struct printf_info *,
+ const void *const *) __attribute__ ((visibility ("hidden")));
+
+extern __thread locale_t __libc_tsd_LOCALE __attribute__ ((tls_model ("initial-exec")));
+
+static inline void
+__printf_fp_spec (struct __printf_buffer *target,
+ const struct printf_info *info, const void *const *args)
+{
+ if (info->spec == 'a' || info->spec == 'A')
+ __printf_fphex_l_buffer (target, ((__libc_tsd_LOCALE)), info, args);
+ else
+ __printf_fp_l_buffer (target, ((__libc_tsd_LOCALE)), info, args);
+}
+
+union printf_arg
+ {
+ wchar_t pa_wchar;
+ int pa_int;
+ long int pa_long_int;
+ long long int pa_long_long_int;
+ unsigned int pa_u_int;
+ unsigned long int pa_u_long_int;
+ unsigned long long int pa_u_long_long_int;
+ double pa_double;
+ long double pa_long_double;
+
+ const char *pa_string;
+ const wchar_t *pa_wstring;
+ void *pa_pointer;
+ void *pa_user;
+};
+
+
+typedef void printf_va_arg_function (void *__mem, va_list *__ap);
+
+struct grouping_iterator
+{
+ unsigned int remaining_in_current_group;
+ unsigned int remaining;
+ const char *groupings;
+ unsigned int non_repeating_groups;
+ unsigned int separators;
+};
+
+typedef struct
+{
+ int __count;
+ union
+ {
+ unsigned int __wch;
+ char __wchb[4];
+ } __value;
+} mbstate_t;
+
+struct printf_modifier_record;
+extern struct printf_modifier_record **__printf_modifier_table __attribute__ ((visibility ("hidden")));
+extern size_t __wcrtomb (char *__restrict __s, wchar_t __wc, mbstate_t *__restrict __ps) __attribute__ ((visibility ("hidden")));
+extern __thread locale_t __libc_tsd_LOCALE __attribute__ ((tls_model ("initial-exec")));
+extern printf_va_arg_function **__printf_va_arg_table __attribute__ ((visibility ("hidden")));
+
+typedef int printf_function (FILE *__stream, const struct printf_info *__info, const void *const *__args);
+
+extern __thread int __libc_errno __attribute__ ((tls_model ("initial-exec")));
+
+extern printf_function **__printf_function_table __attribute__ ((visibility ("hidden")));
+
+extern char *__strchrnul (const char *__s, int __c) __attribute__ ((__pure__));
+
+extern __thread struct __locale_data *const *_nl_current_LC_NUMERIC __attribute__ ((visibility ("hidden"))) __attribute__ ((tls_model ("initial-exec")));
+
+extern __inline __attribute__ ((__always_inline__)) const unsigned char *
+__find_specmb (const unsigned char *format)
+{
+ return (const unsigned char *) __strchrnul ((const char *) format, '%');
+}
+
+static void outstring_converted_wide_string (struct __printf_buffer *target,
+ const wchar_t *src, int prec, int width, _Bool left) {};
+
+extern void __printf_buffer_write (struct __printf_buffer *buf, const char *s,
+ size_t count) __attribute__ ((visibility ("hidden")));
+
+static inline int __attribute__ ((__warn_unused_result__))
+__printf_buffer_has_failed (struct __printf_buffer *buf)
+{
+ return buf->mode == __printf_buffer_mode_failed;
+}
+
+static inline void
+__printf_buffer_mark_failed (struct __printf_buffer *buf)
+{
+ buf->mode = __printf_buffer_mode_failed;
+}
+
+void __printf_buffer_putc_1 (struct __printf_buffer *buf, char ch)
+ __attribute__ ((visibility ("hidden")));
+
+extern char *_itoa (unsigned long long int value, char *buflim,
+ unsigned int base, int upper_case) __attribute__ ((visibility ("hidden")));
+
+extern char *_itoa_word (unsigned long int value, char *buflim,
+ unsigned int base,
+ int upper_case) __attribute__ ((visibility ("hidden")));
+
+_Bool __grouping_iterator_init (struct grouping_iterator *it,
+ int category, locale_t loc,
+ unsigned int digits) __attribute__ ((visibility ("hidden")));
+
+_Bool __grouping_iterator_init_none (struct grouping_iterator *it, unsigned int digits)
+ __attribute__ ((visibility ("hidden")));
+
+int __translated_number_width (locale_t loc, const char *first, const char *last)
+ __attribute__ ((visibility ("hidden")));
+
+static inline void
+__printf_buffer_putc (struct __printf_buffer *buf, char ch)
+{
+ if (buf->write_ptr != buf->write_end)
+ *buf->write_ptr++ = ch;
+ else
+ __printf_buffer_putc_1 (buf, ch);
+}
+
+void __printf_buffer_pad_1 (struct __printf_buffer *buf,
+ char ch, size_t count) __attribute__ ((visibility ("hidden")));
+
+static void group_number (struct __printf_buffer *buf,
+ struct grouping_iterator *iter,
+ char *from, char *to, THOUSANDS_SEP_T thousands_sep, _Bool i18n) {};
+
+extern void __libc_fatal (const char *__message) __attribute__ ((__noreturn__));
+int __printf_buffer_done (struct __printf_buffer *buf) __attribute__ ((visibility ("hidden")));
+extern const char *__get_errname (int) __attribute__ ((visibility ("hidden")));
+extern char *__strerror_r (int __errnum, char *__buf, size_t __buflen);
+
+static inline void
+__printf_buffer_pad (struct __printf_buffer *buf, char ch, ssize_t count)
+{
+ if (count > 0)
+ __printf_buffer_pad_1 (buf, ch, count);
+}
+
+static const uint8_t jump_table[] =
+ {
+ 1, 0, 0, 4,
+ 0, 14, 0, 6,
+ 0, 0, 7, 2,
+ 0, 3, 9, 0,
+ 5, 8, 8, 8,
+ 8, 8, 8, 8,
+ 8, 8, 0, 0,
+ 0, 0, 0, 0,
+ 0, 26, 30, 25,
+ 0, 19, 19, 19,
+ 0, 29, 0, 0,
+ 12, 0, 0, 0,
+ 0, 0, 0, 21,
+ 0, 0, 0, 0,
+ 18, 0, 13, 0,
+ 0, 0, 0, 0,
+ 0, 26, 30, 20,
+ 15, 19, 19, 19,
+ 10, 15, 28, 0,
+ 11, 24, 23, 17,
+ 22, 12, 0, 21,
+ 27, 16, 0, 31,
+ 18, 0, 13
+ };
+
+static void printf_positional (struct __printf_buffer *buf,
+ const char *format, int readonly_format,
+ va_list ap, va_list *ap_savep,
+ int nspecs_done, const unsigned char *lead_str_end,
+ char *work_buffer, int save_errno,
+ const char *grouping,
+ THOUSANDS_SEP_T thousands_sep,
+ unsigned int mode_flags){};
+
+void
+__printf_buffer (struct __printf_buffer *buf, const char *format,
+ va_list ap, unsigned int mode_flags)
+{
+
+ THOUSANDS_SEP_T thousands_sep = 0;
+
+
+ const char *grouping;
+
+
+ const unsigned char *f;
+
+
+ const unsigned char *lead_str_end;
+
+
+ const unsigned char *end_of_spec;
+
+
+ char work_buffer[WORK_BUFFER_SIZE];
+ char *workend;
+
+
+ va_list ap_save;
+
+
+ int nspecs_done;
+
+
+ int save_errno = __libc_errno;
+
+
+
+ int readonly_format = 0;
+
+
+ grouping = (const char *) -1;
+
+ __builtin_va_copy( ap_save, ap);
+
+ nspecs_done = 0;
+ f = lead_str_end = __find_specmb ((const unsigned char *) format);
+
+ __printf_buffer_write (buf, format, lead_str_end - (const unsigned char *) format);
+ if (__printf_buffer_has_failed (buf))
+ return;
+
+ if (*f == '\0')
+ return;
+
+
+ if (__builtin_expect ((__printf_function_table !=
+ ((void *)0)
+ || __printf_modifier_table !=
+ ((void *)0)
+ || __printf_va_arg_table !=
+ ((void *)0)
+ ), 0))
+ goto do_positional;
+
+ do
+ {
+ static const void *const step0_jumps[32] = { &&do_form_unknown, &&do_flag_space, &&do_flag_plus, &&do_flag_minus, &&do_flag_hash, &&do_flag_zero, &&do_flag_quote, &&do_width_asterics, &&do_width, &&do_precision, &&do_mod_half, &&do_mod_long, &&do_mod_longlong, &&do_mod_size_t, &&do_form_percent, &&do_form_integer, &&do_form_unsigned, &&do_form_octal, &&do_form_hexa, &&do_form_float, &&do_form_character, &&do_form_string, &&do_form_pointer, &&do_form_number, &&do_form_strerror, &&do_form_wcharacter, &&do_form_floathex, &&do_mod_ptrdiff_t, &&do_mod_intmax_t, &&do_flag_i18n, &&do_form_binary, &&do_mod_bitwidth, }; static const void *const step1_jumps[32] = { &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_precision, &&do_mod_half, &&do_mod_long, &&do_mod_longlong, &&do_mod_size_t, &&do_form_percent, &&do_form_integer, &&do_form_unsigned, &&do_form_octal, &&do_form_hexa, &&do_form_float, &&do_form_character, &&do_form_string, &&do_form_pointer, &&do_form_number, &&do_form_strerror, &&do_form_wcharacter, &&do_form_floathex, &&do_mod_ptrdiff_t, &&do_mod_intmax_t, &&do_form_unknown, &&do_form_binary, &&do_mod_bitwidth, }; static const void *const step2_jumps[32] = { &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_mod_half, &&do_mod_long, &&do_mod_longlong, &&do_mod_size_t, &&do_form_percent, &&do_form_integer, &&do_form_unsigned, &&do_form_octal, &&do_form_hexa, &&do_form_float, &&do_form_character, &&do_form_string, &&do_form_pointer, &&do_form_number, &&do_form_strerror, &&do_form_wcharacter, &&do_form_floathex, &&do_mod_ptrdiff_t, &&do_mod_intmax_t, &&do_form_unknown, &&do_form_binary, &&do_mod_bitwidth, }; static const void *const step3a_jumps[32] = { &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_mod_halfhalf, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_percent, &&do_form_integer, &&do_form_unsigned, &&do_form_octal, &&do_form_hexa, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_number, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_binary, &&do_form_unknown, }; static const void *const step3b_jumps[32] = { &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_mod_longlong, &&do_form_unknown, &&do_form_unknown, &&do_form_percent, &&do_form_integer, &&do_form_unsigned, &&do_form_octal, &&do_form_hexa, &&do_form_float, &&do_form_character, &&do_form_string, &&do_form_pointer, &&do_form_number, &&do_form_strerror, &&do_form_wcharacter, &&do_form_floathex, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_binary, &&do_form_unknown, };
+ static const void *const step4_jumps[32] = { &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_percent, &&do_form_integer, &&do_form_unsigned, &&do_form_octal, &&do_form_hexa, &&do_form_float, &&do_form_character, &&do_form_string, &&do_form_pointer, &&do_form_number, &&do_form_strerror, &&do_form_wcharacter, &&do_form_floathex, &&do_form_unknown, &&do_form_unknown, &&do_form_unknown, &&do_form_binary, &&do_form_unknown, };
+
+ int is_negative;
+ union
+ {
+ unsigned long long int longlong;
+ unsigned long int word;
+ } number;
+ int base;
+ union printf_arg the_arg;
+ char *string;
+ int alt = 0;
+ int space = 0;
+ int left = 0;
+ int showsign = 0;
+ int group = 0;
+
+
+ int is_long_double __attribute__ ((unused)) = 0;
+ int is_short = 0;
+ int is_long = 0;
+ int is_char = 0;
+ int width = 0;
+ int prec = -1;
+
+
+ int use_outdigits = 0;
+ unsigned char pad = ' ';
+ char spec;
+
+ workend = work_buffer + WORK_BUFFER_SIZE;
+
+
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_flag_space:
+ space = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_flag_plus:
+ showsign = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_flag_minus:
+ left = 1;
+ pad = ' ';
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_flag_hash:
+ alt = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_flag_zero:
+ if (!left)
+ pad = '0';
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_flag_quote:
+ group = 1;
+
+ if (grouping == (const char *) -1)
+ {
+
+
+
+
+ thousands_sep = ((*_nl_current_LC_NUMERIC)->values[((int) (__THOUSANDS_SEP) & 0xffff)].string);
+
+
+ grouping = ((*_nl_current_LC_NUMERIC)->values[((int) (__GROUPING) & 0xffff)].string);
+ if (*grouping == '\0' || *grouping ==
+
+ (0x7f * 2 + 1)
+
+
+
+
+
+ || *thousands_sep == '\0'
+
+ )
+ grouping =
+
+ ((void *)0)
+
+ ;
+ }
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+ do_flag_i18n:
+ use_outdigits = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step0_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_width_asterics:
+ {
+ const unsigned char *tmp;
+
+ tmp = ++f;
+ if (((unsigned int) ((*tmp) - '0') < 10))
+ {
+ int pos = read_int (&tmp);
+
+ if (pos == -1)
+ {
+ (__libc_errno = (
+
+ 75
+
+ ));
+ __printf_buffer_mark_failed (buf);
+ goto all_done;
+ }
+
+ if (pos && *tmp == '$')
+
+ goto do_positional;
+ }
+ width =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ int
+
+ )
+
+ ;
+
+
+ if (width < 0)
+ {
+ width = -width;
+ pad = ' ';
+ left = 1;
+ }
+ }
+ do { const void *ptr; spec = (*f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step1_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_width:
+ width = read_int (&f);
+
+ if (__builtin_expect ((width == -1), 0))
+ {
+ (__libc_errno = (
+
+ 75
+
+ ));
+ __printf_buffer_mark_failed (buf);
+ goto all_done;
+ }
+
+ if (*f == '$')
+
+ goto do_positional;
+ do { const void *ptr; spec = (*f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step1_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+ do_precision:
+ ++f;
+ if (*f == '*')
+ {
+ const unsigned char *tmp;
+
+ tmp = ++f;
+ if (((unsigned int) ((*tmp) - '0') < 10))
+ {
+ int pos = read_int (&tmp);
+
+ if (pos == -1)
+ {
+ (__libc_errno = (
+
+ 75
+
+ ));
+ __printf_buffer_mark_failed (buf);
+ goto all_done;
+ }
+
+ if (pos && *tmp == '$')
+
+ goto do_positional;
+ }
+ prec =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ int
+
+ )
+
+ ;
+
+
+ if (prec < 0)
+ prec = -1;
+ }
+ else if (((unsigned int) ((*f) - '0') < 10))
+ {
+ prec = read_int (&f);
+
+
+
+ if (prec == -1)
+ {
+ (__libc_errno = (
+
+ 75
+
+ ));
+ __printf_buffer_mark_failed (buf);
+ goto all_done;
+ }
+ }
+ else
+ prec = 0;
+ do { const void *ptr; spec = (*f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step2_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_mod_half:
+ is_short = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step3a_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_mod_halfhalf:
+ is_short = 0;
+ is_char = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step4_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_mod_long:
+ is_long = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step3b_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+
+ do_mod_longlong:
+ is_long_double = 1;
+ is_long = 1;
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step4_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+ do_mod_size_t:
+ is_long_double = sizeof (size_t) > sizeof (unsigned long int);
+ is_long = sizeof (size_t) > sizeof (unsigned int);
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step4_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+ do_mod_ptrdiff_t:
+ is_long_double = sizeof (ptrdiff_t) > sizeof (unsigned long int);
+ is_long = sizeof (ptrdiff_t) > sizeof (unsigned int);
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step4_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+ do_mod_intmax_t:
+ is_long_double = sizeof (intmax_t) > sizeof (unsigned long int);
+ is_long = sizeof (intmax_t) > sizeof (unsigned int);
+ do { const void *ptr; spec = (*++f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step4_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ do_mod_bitwidth:
+ ++f;
+
+
+ _Bool
+
+ is_fast =
+
+ 0
+
+ ;
+ if (*f == 'f')
+ {
+ ++f;
+ is_fast =
+
+ 1
+
+ ;
+ }
+ int bitwidth = 0;
+ if (((unsigned int) ((*f) - '0') < 10))
+ bitwidth = read_int (&f);
+ if (is_fast)
+ switch (bitwidth)
+ {
+ case 8:
+ bitwidth = 8;
+ break;
+ case 16:
+ bitwidth = 32;
+ break;
+ case 32:
+ bitwidth = 32;
+ break;
+ case 64:
+ bitwidth = 64;
+ break;
+ }
+ switch (bitwidth)
+ {
+ case 8:
+ is_char = 1;
+ break;
+ case 16:
+ is_short = 1;
+ break;
+ case 32:
+ break;
+ case 64:
+ is_long_double = 1;
+ is_long = 1;
+ break;
+ default:
+
+ (__libc_errno = (
+
+ 22
+
+ ));
+ __printf_buffer_mark_failed (buf);
+ goto all_done;
+ }
+ do { const void *ptr; spec = (*f); ptr = ((spec) < ' ' || (spec) > 'z') ? &&do_form_unknown : step4_jumps[(jump_table[(int) (spec) - ' '])]; goto *ptr; } while (0);
+
+
+ while (1)
+ {
+
+
+
+{
+
+
+do_form_percent:
+
+ __printf_buffer_putc (buf, '%');
+ break;
+
+do_form_integer:
+
+ base = 10;
+
+ if (is_long_double)
+ {
+ long long int signed_number =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ long long int
+
+ )
+
+ ;
+ is_negative = signed_number < 0;
+ number.longlong = is_negative ? (- signed_number) : signed_number;
+
+ goto do_longlong_number;
+ }
+ else
+ {
+ long int signed_number;
+ if (0)
+ signed_number =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ long int
+
+ )
+
+ ;
+ else if (is_char)
+ signed_number = (signed char)
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ unsigned int
+
+ )
+
+ ;
+ else if (!is_short)
+ signed_number =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ int
+
+ )
+
+ ;
+ else
+ signed_number = (short int)
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ unsigned int
+
+ )
+
+ ;
+
+ is_negative = signed_number < 0;
+ number.word = is_negative ? (- signed_number) : signed_number;
+
+ goto do_number;
+ }
+
+
+do_form_unsigned:
+
+ base = 10;
+ goto do_unsigned_number;
+
+
+do_form_octal:
+
+ base = 8;
+ goto do_unsigned_number;
+
+
+do_form_hexa:
+
+ base = 16;
+ goto do_unsigned_number;
+
+
+do_form_binary:
+
+ base = 2;
+ goto do_unsigned_number;
+
+
+do_unsigned_number:
+
+
+
+ is_negative = 0;
+ showsign = 0;
+ space = 0;
+
+ if (is_long_double)
+ {
+ number.longlong = __builtin_va_arg( ap , unsigned long long int) ;
+
+ do_longlong_number:
+ if (prec < 0)
+
+ prec = 1;
+ else
+
+
+ pad = ' ';
+
+
+
+
+ if (prec == 0 && number.longlong == 0)
+ {
+ string = workend;
+ if (base == 8 && alt)
+ *--string = '0';
+ }
+ else
+
+ string = _itoa (number.longlong, workend, base, spec == 'X');
+
+ number.word = number.longlong != 0;
+ }
+ else
+ {
+ if (0)
+ number.word =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ unsigned long int
+
+ )
+
+ ;
+ else if (is_char)
+ number.word = (unsigned char)
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ unsigned int
+
+ )
+
+ ;
+ else if (!is_short)
+ number.word =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ unsigned int
+
+ )
+
+ ;
+ else
+ number.word = (unsigned short int)
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ unsigned int
+
+ )
+
+ ;
+
+ do_number:
+ if (prec < 0)
+
+ prec = 1;
+ else
+
+
+ pad = ' ';
+
+
+
+
+ if (prec == 0 && number.word == 0)
+ {
+ string = workend;
+ if (base == 8 && alt)
+ *--string = '0';
+ }
+ else
+
+ string = _itoa_word (number.word, workend, base,
+ spec == 'X');
+ }
+
+
+ struct grouping_iterator iter;
+
+
+ _Bool
+
+ number_slow_path = group || (use_outdigits && base == 10);
+ if (group)
+ __grouping_iterator_init (&iter, 1, ((__libc_tsd_LOCALE)),
+ workend - string);
+ else if (use_outdigits && base == 10)
+ __grouping_iterator_init_none (&iter, workend - string);
+
+ int number_length;
+
+ if (use_outdigits && base == 10)
+ number_length = __translated_number_width (((__libc_tsd_LOCALE)),
+ string, workend);
+ else
+ number_length = workend - string;
+ if (group)
+ number_length += iter.separators * strlen (thousands_sep);
+
+
+
+ _Bool
+
+ octal_marker = (prec <= number_length && number.word != 0
+ && alt && base == 8);
+
+
+
+
+
+
+
+ unsigned int prec_inc = (((0)>(prec - (workend - string)))?(0):(prec - (workend - string)));
+
+ if (!left)
+ {
+ width -= number_length + prec_inc;
+
+ if (number.word != 0 && alt && (base == 16 || base == 2))
+
+ width -= 2;
+
+ if (octal_marker)
+ --width;
+
+ if (is_negative || showsign || space)
+ --width;
+
+ if (pad == ' ')
+ {
+ __printf_buffer_pad (buf, ' ', width);
+ width = 0;
+ }
+
+ if (is_negative)
+ __printf_buffer_putc (buf, '-');
+ else if (showsign)
+ __printf_buffer_putc (buf, '+');
+ else if (space)
+ __printf_buffer_putc (buf, ' ');
+
+ if (number.word != 0 && alt && (base == 16 || base == 2))
+ {
+ __printf_buffer_putc (buf, '0');
+ __printf_buffer_putc (buf, spec);
+ }
+
+ width += prec_inc;
+ __printf_buffer_pad (buf, '0', width);
+
+ if (octal_marker)
+ __printf_buffer_putc (buf, '0');
+
+ if (number_slow_path)
+ group_number (buf, &iter, string, workend, thousands_sep,
+ use_outdigits && base == 10);
+ else
+ __printf_buffer_write (buf, string, workend - string);
+
+ break;
+ }
+ else
+ {
+
+
+ if (is_negative)
+ {
+ __printf_buffer_putc (buf, '-');
+ --width;
+ }
+ else if (showsign)
+ {
+ __printf_buffer_putc (buf, '+');
+ --width;
+ }
+ else if (space)
+ {
+ __printf_buffer_putc (buf, ' ');
+ --width;
+ }
+
+ if (number.word != 0 && alt && (base == 16 || base == 2))
+ {
+ __printf_buffer_putc (buf, '0');
+ __printf_buffer_putc (buf, spec);
+ width -= 2;
+ }
+
+ if (octal_marker)
+ --width;
+
+
+
+
+
+ width -= number_length + prec_inc;
+
+ __printf_buffer_pad (buf, '0', prec_inc);
+
+ if (octal_marker)
+ __printf_buffer_putc (buf, '0');
+
+ if (number_slow_path)
+ group_number (buf, &iter, string, workend, thousands_sep,
+ use_outdigits && base == 10);
+ else
+ __printf_buffer_write (buf, string, workend - string);
+
+ __printf_buffer_pad (buf, ' ', width);
+ break;
+ }
+
+do_form_pointer:
+
+ {
+ const void *ptr =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ void *
+
+ )
+
+ ;
+ if (ptr !=
+
+ ((void *)0)
+
+ )
+ {
+
+ base = 16;
+ number.word = (unsigned long int) ptr;
+ is_negative = 0;
+ alt = 1;
+ group = 0;
+ spec = 'x';
+ goto do_number;
+ }
+ else
+ {
+
+ string = (char *) "(nil)";
+
+ if (prec < 5)
+ prec = 5;
+
+ is_long = sizeof (char) > 1;
+ goto do_print_string;
+ }
+ }
+
+
+do_form_number:
+ if ((mode_flags & 0x0002) != 0)
+ {
+ if (! readonly_format)
+ {
+ extern int __readonly_area (const void *, size_t)
+ __attribute__ ((visibility ("hidden")));
+ readonly_format
+ = __readonly_area (format, ((strlen (format) + 1)
+ * sizeof (char)));
+ }
+ if (readonly_format < 0)
+ __libc_fatal ("*** %n in writable segment detected ***\n");
+ }
+
+ void *ptrptr =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ void *
+
+ )
+
+ ;
+ unsigned int written = __printf_buffer_done (buf);
+ if (is_long_double)
+ *(long long int *) ptrptr = written;
+ else if (0)
+ *(long int *) ptrptr = written;
+ else if (is_char)
+ *(char *) ptrptr = written;
+ else if (!is_short)
+ *(int *) ptrptr = written;
+ else
+ *(short int *) ptrptr = written;
+ break;
+
+do_form_strerror:
+
+ if (alt)
+ string = (char *) __get_errname (save_errno);
+ else
+ string = (char *) __strerror_r (save_errno, (char *) work_buffer,
+ WORK_BUFFER_SIZE * sizeof (char));
+ if (string ==
+
+ ((void *)0)
+
+ )
+ {
+
+ base = 10;
+ is_negative = save_errno < 0;
+ number.word = save_errno;
+ if (is_negative)
+ number.word = -number.word;
+ goto do_number;
+ }
+ else
+ {
+ is_long = 0;
+ goto do_print_string;
+ }
+
+do_form_character:
+
+ if (is_long)
+ goto do_form_wcharacter;
+ --width;
+ if (!left)
+ __printf_buffer_pad (buf, ' ', width);
+
+
+
+
+ __printf_buffer_putc (buf, (unsigned char)
+
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ int
+
+ )
+
+ );
+
+ if (left)
+ __printf_buffer_pad (buf, ' ', width);
+ break;
+
+do_form_string:
+ {
+ size_t len;
+
+
+
+
+
+
+ string = (char *)
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ const char *
+
+ )
+
+ ;
+
+
+ do_print_string:
+
+ if (string ==
+
+ ((void *)0)
+
+ )
+ {
+
+ if (prec == -1 || prec >= (int) (sizeof (null) / sizeof ((null)[0]) + 0 * sizeof (struct { _Static_assert (!__builtin_types_compatible_p (__typeof (null), __typeof (&(null)[0])), "argument must be an array"); })) - 1)
+ {
+ string = (char *) null;
+ len = (sizeof (null) / sizeof ((null)[0]) + 0 * sizeof (struct { _Static_assert (!__builtin_types_compatible_p (__typeof (null), __typeof (&(null)[0])), "argument must be an array"); })) - 1;
+ }
+ else
+ {
+ string = (char *) L"";
+ len = 0;
+ }
+ }
+ else if (!is_long && spec != 'S')
+ {
+
+
+
+
+
+
+ if (prec != -1)
+
+
+ len = __strnlen (string, prec);
+ else
+ len = strlen (string);
+
+ }
+ else
+ {
+
+ outstring_converted_wide_string (buf, (const wchar_t *) string,
+ prec, width, left);
+
+ break;
+
+ }
+
+ if ((width -= len) < 0)
+ {
+ __printf_buffer_write (buf, string, len);
+ break;
+ }
+
+ if (!left)
+ __printf_buffer_pad (buf, ' ', width);
+ __printf_buffer_write (buf, string, len);
+ if (left)
+ __printf_buffer_pad (buf, ' ', width);
+ }
+ break;
+
+do_form_wcharacter:
+ {
+
+ char wcbuf[16];
+ mbstate_t mbstate;
+ size_t len;
+
+ memset (&mbstate, '\0', sizeof (mbstate_t));
+ len = __wcrtomb (wcbuf, __builtin_va_arg( ap , wchar_t) , &mbstate);
+ if (len == (size_t) -1)
+ {
+
+ __printf_buffer_mark_failed (buf);
+ goto all_done;
+ }
+ width -= len;
+ if (!left)
+ __printf_buffer_pad (buf, ' ', width);
+ __printf_buffer_write (buf, wcbuf, len);
+ if (left)
+ __printf_buffer_pad (buf, ' ', width);
+ }
+ break;
+
+}
+
+
+ do_form_float:
+ do_form_floathex:
+ {
+ if (__builtin_expect (((mode_flags & 0x0001) != 0), 0))
+ is_long_double = 0;
+
+ struct printf_info info =
+ {
+ .prec = prec,
+ .width = width,
+ .spec = spec,
+ .is_long_double = is_long_double,
+ .is_short = is_short,
+ .is_long = is_long,
+ .alt = alt,
+ .space = space,
+ .left = left,
+ .showsign = showsign,
+ .group = group,
+ .pad = pad,
+ .extra = 0,
+ .i18n = use_outdigits,
+ .wide = sizeof (char) != 1,
+ .is_binary128 = 0
+ };
+
+ do { info.is_binary128 = 0; if (is_long_double) the_arg.pa_long_double =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ long double
+
+ )
+
+ ; else the_arg.pa_double =
+
+ __builtin_va_arg(
+
+ ap
+
+ ,
+
+ double
+
+ )
+
+ ; } while (0);;
+ const void *ptr = &the_arg;
+
+ __printf_fp_spec (buf, &info, &ptr);
+ }
+ break;
+
+ do_form_unknown:
+ if (spec == '\0')
+ {
+
+ (__libc_errno = ( 22));
+ __printf_buffer_mark_failed (buf);
+ goto all_done;
+ }
+
+
+
+ goto do_positional;
+ }
+
+
+ ++nspecs_done;
+
+
+
+
+
+ f = __find_specmb ((end_of_spec = ++f));
+
+
+
+ __printf_buffer_write (buf, (const char *) end_of_spec,
+ f - end_of_spec);
+ }
+ while (*f != '\0' && !__printf_buffer_has_failed (buf));
+
+ all_done:
+
+
+
+ return;
+
+
+do_positional:
+ printf_positional (buf, format, readonly_format, ap, &ap_save,
+ nspecs_done, lead_str_end, work_buffer,
+ save_errno, grouping, thousands_sep, mode_flags);
+}
+
+/* { dg-final { scan-assembler-times {vsetivli\tzero,\s*4,\s*e8,\s*mf4,\s*t[au],\s*m[au]} 2 } } */
--
2.36.3
next reply other threads:[~2024-01-25 12:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 12:33 Juzhe-Zhong [this message]
2024-01-25 13:40 ` Kito Cheng
2024-01-25 16:18 ` Robin Dapp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240125123349.981882-1-juzhe.zhong@rivai.ai \
--to=juzhe.zhong@rivai.ai \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=kito.cheng@gmail.com \
--cc=kito.cheng@sifive.com \
--cc=rdapp.gcc@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).