2021-08-19 Bill Schmidt <wschm...@linux.ibm.com> gcc/ * config/rs6000/rs6000-builtin-new.def (VEC_INIT_V16QI): Use escape-newline support. (VEC_INIT_V4SI): Likewise. (VEC_INIT_V8HI): Likewise. (PACK_V1TI): Likewise. (DIVDEU): Likewise. (VFIRSTMISMATCHOREOSINDEX_V16QI): Likewise. (VFIRSTMISMATCHOREOSINDEX_V8HI): Likewise. (VFIRSTMISMATCHOREOSINDEX_V4SI): Likewise. (CMPRB2): Likewise. (VSTDCP): Likewise. (VSIEDP): Likewise. (FMAF128_ODD): Likewise. (VSCEQPUO): Likewise. (VSIEQP): Likewise. (VSIEQPF): Likewise. (VSTDCQP): Likewise. (PACK_TD): Likewise. (TABORTDC): Likewise. (TABORTDCI): Likewise. (SE_LXVRBX): Likewise. (SE_LXVRHX): Likewise. (SE_LXVRWX): Likewise. (SE_LXVRDX): Likewise. (VREPLACE_UN_UV2DI): Likewise. (VREPLACE_UN_UV4SI): Likewise. (VREPLACE_UN_V2DI): Likewise. (VREPLACE_ELT_UV2DI): Likewise. (VREPLACE_ELT_V2DI): Likewise. (ZE_LXVRBX): Likewise. (ZE_LXVRHX): Likewise. (ZE_LXVRWX): Likewise. (ZE_LXVRDX): Likewise. (CFUGED): Likewise. (CNTLZDM): Likewise. (CNTTZDM): Likewise. (PDEPD): Likewise. (PEXTD): Likewise. (PMXVBF16GER2): Likewise. (PMXVBF16GER2_INTERNAL): Likewise. (PMXVBF16GER2NN): Likewise. (PMXVBF16GER2NN_INTERNAL): Likewise. (PMXVBF16GER2NP): Likewise. (PMXVBF16GER2NP_INTERNAL): Likewise. (PMXVBF16GER2PN): Likewise. (PMXVBF16GER2PN_INTERNAL): Likewise. (PMXVBF16GER2PP): Likewise. (PMXVBF16GER2PP_INTERNAL): Likewise. (PMXVF16GER2): Likewise. (PMXVF16GER2_INTERNAL): Likewise. (PMXVF16GER2NN): Likewise. (PMXVF16GER2NN_INTERNAL): Likewise. (PMXVF16GER2NP): Likewise. (PMXVF16GER2NP_INTERNAL): Likewise. (PMXVF16GER2PN): Likewise. (PMXVF16GER2PN_INTERNAL): Likewise. (PMXVF16GER2PP): Likewise. (PMXVF16GER2PP_INTERNAL): Likewise. (PMXVF32GER_INTERNAL): Likewise. (PMXVF32GERNN): Likewise. (PMXVF32GERNN_INTERNAL): Likewise. (PMXVF32GERNP): Likewise. (PMXVF32GERNP_INTERNAL): Likewise. (PMXVF32GERPN): Likewise. (PMXVF32GERPN_INTERNAL): Likewise. (PMXVF32GERPP): Likewise. (PMXVF32GERPP_INTERNAL): Likewise. (PMXVF64GER): Likewise. (PMXVF64GER_INTERNAL): Likewise. (PMXVF64GERNN): Likewise. (PMXVF64GERNN_INTERNAL): Likewise. (PMXVF64GERNP): Likewise. (PMXVF64GERNP_INTERNAL): Likewise. (PMXVF64GERPN): Likewise. (PMXVF64GERPN_INTERNAL): Likewise. (PMXVF64GERPP): Likewise. (PMXVF64GERPP_INTERNAL): Likewise. (PMXVI16GER2): Likewise. (PMXVI16GER2_INTERNAL): Likewise. (PMXVI16GER2PP): Likewise. (PMXVI16GER2PP_INTERNAL): Likewise. (PMXVI16GER2S): Likewise. (PMXVI16GER2S_INTERNAL): Likewise. (PMXVI16GER2SPP): Likewise. (PMXVI16GER2SPP_INTERNAL): Likewise. (PMXVI4GER8): Likewise. (PMXVI4GER8_INTERNAL): Likewise. (PMXVI4GER8PP): Likewise. (PMXVI4GER8PP_INTERNAL): Likewise. (PMXVI8GER4): Likewise. (PMXVI8GER4_INTERNAL): Likewise. (PMXVI8GER4PP): Likewise. (PMXVI8GER4PP_INTERNAL): Likewise. (PMXVI8GER4SPP): Likewise. (PMXVI8GER4SPP_INTERNAL): Likewise. * config/rs6000/rs6000-gen-builtins.c (MAXLINES): New macro. (lines): New variable. (lastline): Likewise. (real_line_pos): New function. (diag): Change signature. (bif_diag): Change signature; support escape-newline handling. (ovld_diag): Likewise. (fatal): Move earlier. (consume_whitespace): Adjust diag call. (advance_line): Add escape-newline handling; call fatal. (safe_inc_pos): Adjust diag call. (match_identifier): Likewise. (match_integer): Likewise. (match_to_right_bracket): Call fatal instead of diag; adjust diag call. (match_basetype): Adjust diag calls. (match_bracketed_pair): Likewise. (match_const_restriction): Likewise. (match_type): Likewise. (parse_args): Likewise. (parse_bif_attrs): Likewise. (complete_vector_type): Likewise. (complete_base_type): Likewise. (parse_prototype): Likewise. (parse_bif_entry): Likewise. (parse_bif_stanza): Likewise. (parse_ovld_entry): Likewise. (parse_ovld_stanza): Likewise. (main): Allocate buffers for lines[]. --- gcc/config/rs6000/rs6000-builtin-new.def | 288 +++++++++++++++-------- gcc/config/rs6000/rs6000-gen-builtins.c | 280 +++++++++++++--------- 2 files changed, 358 insertions(+), 210 deletions(-)
diff --git a/gcc/config/rs6000/rs6000-builtin-new.def b/gcc/config/rs6000/rs6000-builtin-new.def index 1966516551e..c22aaf767c7 100644 --- a/gcc/config/rs6000/rs6000-builtin-new.def +++ b/gcc/config/rs6000/rs6000-builtin-new.def @@ -1094,16 +1094,22 @@ const signed short __builtin_vec_ext_v8hi (vss, signed int); VEC_EXT_V8HI nothing {extract} - const vsc __builtin_vec_init_v16qi (signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char, signed char); + const vsc __builtin_vec_init_v16qi (signed char, signed char, signed char, \ + signed char, signed char, signed char, signed char, signed char, \ + signed char, signed char, signed char, signed char, signed char, \ + signed char, signed char, signed char); VEC_INIT_V16QI nothing {init} const vf __builtin_vec_init_v4sf (float, float, float, float); VEC_INIT_V4SF nothing {init} - const vsi __builtin_vec_init_v4si (signed int, signed int, signed int, signed int); + const vsi __builtin_vec_init_v4si (signed int, signed int, signed int, \ + signed int); VEC_INIT_V4SI nothing {init} - const vss __builtin_vec_init_v8hi (signed short, signed short, signed short, signed short, signed short, signed short, signed short, signed short); + const vss __builtin_vec_init_v8hi (signed short, signed short, signed short,\ + signed short, signed short, signed short, signed short, \ + signed short); VEC_INIT_V8HI nothing {init} const vsc __builtin_vec_set_v16qi (vsc, signed char, const int<4>); @@ -2023,7 +2029,8 @@ const unsigned int __builtin_divweu (unsigned int, unsigned int); DIVWEU diveu_si {} - const vsq __builtin_pack_vector_int128 (unsigned long long, unsigned long long); + const vsq __builtin_pack_vector_int128 (unsigned long long, \ + unsigned long long); PACK_V1TI packv1ti {} void __builtin_ppc_speculation_barrier (); @@ -2038,7 +2045,8 @@ const signed long long __builtin_divde (signed long long, signed long long); DIVDE dive_di {} - const unsigned long long __builtin_divdeu (unsigned long long, unsigned long long); + const unsigned long long __builtin_divdeu (unsigned long long, \ + unsigned long long); DIVDEU diveu_di {} @@ -2515,13 +2523,16 @@ const signed int __builtin_altivec_first_mismatch_index_v4si (vsi, vsi); VFIRSTMISMATCHINDEX_V4SI first_mismatch_index_v4si {} - const signed int __builtin_altivec_first_mismatch_or_eos_index_v16qi (vsc, vsc); + const signed int \ + __builtin_altivec_first_mismatch_or_eos_index_v16qi (vsc, vsc); VFIRSTMISMATCHOREOSINDEX_V16QI first_mismatch_or_eos_index_v16qi {} - const signed int __builtin_altivec_first_mismatch_or_eos_index_v8hi (vss, vss); + const signed int \ + __builtin_altivec_first_mismatch_or_eos_index_v8hi (vss, vss); VFIRSTMISMATCHOREOSINDEX_V8HI first_mismatch_or_eos_index_v8hi {} - const signed int __builtin_altivec_first_mismatch_or_eos_index_v4si (vsi, vsi); + const signed int \ + __builtin_altivec_first_mismatch_or_eos_index_v4si (vsi, vsi); VFIRSTMISMATCHOREOSINDEX_V4SI first_mismatch_or_eos_index_v4si {} const vsc __builtin_altivec_vadub (vsc, vsc); @@ -2695,7 +2706,8 @@ const signed int __builtin_scalar_byte_in_range (signed int, signed int); CMPRB cmprb {} - const signed int __builtin_scalar_byte_in_either_range (signed int, signed int); + const signed int \ + __builtin_scalar_byte_in_either_range (signed int, signed int); CMPRB2 cmprb2 {} const vsll __builtin_vsx_extract4b (vsc, const int[0,12]); @@ -2734,10 +2746,12 @@ const signed int __builtin_vsx_scalar_cmp_exp_dp_unordered (double, double); VSCEDPUO xscmpexpdp_unordered {} - const signed int __builtin_vsx_scalar_test_data_class_dp (double, const int<7>); + const signed int \ + __builtin_vsx_scalar_test_data_class_dp (double, const int<7>); VSTDCDP xststdcdp {} - const signed int __builtin_vsx_scalar_test_data_class_sp (float, const int<7>); + const signed int \ + __builtin_vsx_scalar_test_data_class_sp (float, const int<7>); VSTDCSP xststdcsp {} const signed int __builtin_vsx_scalar_test_neg_dp (double); @@ -2835,7 +2849,8 @@ const signed long __builtin_vsx_scalar_extract_sig (double); VSESDP xsxsigdp {} - const double __builtin_vsx_scalar_insert_exp (unsigned long long, unsigned long long); + const double __builtin_vsx_scalar_insert_exp (unsigned long long, \ + unsigned long long); VSIEDP xsiexpdp {} const double __builtin_vsx_scalar_insert_exp_dp (double, unsigned long long); @@ -2853,7 +2868,8 @@ fpmath _Float128 __builtin_divf128_round_to_odd (_Float128, _Float128); DIVF128_ODD divkf3_odd {} - fpmath _Float128 __builtin_fmaf128_round_to_odd (_Float128, _Float128, _Float128); + fpmath _Float128 __builtin_fmaf128_round_to_odd (_Float128, _Float128, \ + _Float128); FMAF128_ODD fmakf4_odd {} fpmath _Float128 __builtin_mulf128_round_to_odd (_Float128, _Float128); @@ -2868,7 +2884,8 @@ const signed int __builtin_vsx_scalar_cmp_exp_qp_lt (_Float128, _Float128); VSCEQPLT xscmpexpqp_lt_kf {} - const signed int __builtin_vsx_scalar_cmp_exp_qp_unordered (_Float128, _Float128); + const signed int \ + __builtin_vsx_scalar_cmp_exp_qp_unordered (_Float128, _Float128); VSCEQPUO xscmpexpqp_unordered_kf {} fpmath _Float128 __builtin_sqrtf128_round_to_odd (_Float128); @@ -2886,13 +2903,16 @@ const signed __int128 __builtin_vsx_scalar_extract_sigq (_Float128); VSESQP xsxsigqp_kf {} - const _Float128 __builtin_vsx_scalar_insert_exp_q (unsigned __int128, unsigned long long); + const _Float128 __builtin_vsx_scalar_insert_exp_q (unsigned __int128, \ + unsigned long long); VSIEQP xsiexpqp_kf {} - const _Float128 __builtin_vsx_scalar_insert_exp_qp (_Float128, unsigned long long); + const _Float128 __builtin_vsx_scalar_insert_exp_qp (_Float128, \ + unsigned long long); VSIEQPF xsiexpqpf_kf {} - const signed int __builtin_vsx_scalar_test_data_class_qp (_Float128, const int<7>); + const signed int __builtin_vsx_scalar_test_data_class_qp (_Float128, \ + const int<7>); VSTDCQP xststdcqp_kf {} const signed int __builtin_vsx_scalar_test_neg_qp (_Float128); @@ -2941,7 +2961,8 @@ const signed long long __builtin_dxexq (_Decimal128); DXEXQ dfp_dxex_td {} - const _Decimal128 __builtin_pack_dec128 (unsigned long long, unsigned long long); + const _Decimal128 __builtin_pack_dec128 (unsigned long long, \ + unsigned long long); PACK_TD packtd {} void __builtin_set_fpscr_drn (const int[0,7]); @@ -3017,10 +3038,12 @@ unsigned int __builtin_tabort (unsigned int); TABORT tabort {htm,htmcr} - unsigned int __builtin_tabortdc (unsigned long long, unsigned long long, unsigned long long); + unsigned int __builtin_tabortdc (unsigned long long, unsigned long long, \ + unsigned long long); TABORTDC tabortdc {htm,htmcr} - unsigned int __builtin_tabortdci (unsigned long long, unsigned long long, unsigned long long); + unsigned int __builtin_tabortdci (unsigned long long, unsigned long long, \ + unsigned long long); TABORTDCI tabortdci {htm,htmcr} unsigned int __builtin_tabortwc (unsigned int, unsigned int, unsigned int); @@ -3115,16 +3138,20 @@ const vui __builtin_altivec_mtvsrwm (unsigned long long); MTVSRWM vec_mtvsr_v4si {} - pure signed __int128 __builtin_altivec_se_lxvrbx (signed long, const signed char *); + pure signed __int128 __builtin_altivec_se_lxvrbx (signed long, \ + const signed char *); SE_LXVRBX vsx_lxvrbx {lxvrse} - pure signed __int128 __builtin_altivec_se_lxvrhx (signed long, const signed short *); + pure signed __int128 __builtin_altivec_se_lxvrhx (signed long, \ + const signed short *); SE_LXVRHX vsx_lxvrhx {lxvrse} - pure signed __int128 __builtin_altivec_se_lxvrwx (signed long, const signed int *); + pure signed __int128 __builtin_altivec_se_lxvrwx (signed long, \ + const signed int *); SE_LXVRWX vsx_lxvrwx {lxvrse} - pure signed __int128 __builtin_altivec_se_lxvrdx (signed long, const signed long long *); + pure signed __int128 __builtin_altivec_se_lxvrdx (signed long, \ + const signed long long *); SE_LXVRDX vsx_lxvrdx {lxvrse} void __builtin_altivec_tr_stxvrbx (vsq, signed long, signed char *); @@ -3358,16 +3385,19 @@ const vull __builtin_altivec_vpextd (vull, vull); VPEXTD vpextd {} - const vull __builtin_altivec_vreplace_un_uv2di (vull, unsigned long long, const int<4>); + const vull __builtin_altivec_vreplace_un_uv2di (vull, unsigned long long, \ + const int<4>); VREPLACE_UN_UV2DI vreplace_un_v2di {} - const vui __builtin_altivec_vreplace_un_uv4si (vui, unsigned int, const int<4>); + const vui __builtin_altivec_vreplace_un_uv4si (vui, unsigned int, \ + const int<4>); VREPLACE_UN_UV4SI vreplace_un_v4si {} const vd __builtin_altivec_vreplace_un_v2df (vd, double, const int<4>); VREPLACE_UN_V2DF vreplace_un_v2df {} - const vsll __builtin_altivec_vreplace_un_v2di (vsll, signed long long, const int<4>); + const vsll __builtin_altivec_vreplace_un_v2di (vsll, signed long long, \ + const int<4>); VREPLACE_UN_V2DI vreplace_un_v2di {} const vf __builtin_altivec_vreplace_un_v4sf (vf, float, const int<4>); @@ -3376,7 +3406,8 @@ const vsi __builtin_altivec_vreplace_un_v4si (vsi, signed int, const int<4>); VREPLACE_UN_V4SI vreplace_un_v4si {} - const vull __builtin_altivec_vreplace_uv2di (vull, unsigned long long, const int<1>); + const vull __builtin_altivec_vreplace_uv2di (vull, unsigned long long, \ + const int<1>); VREPLACE_ELT_UV2DI vreplace_elt_v2di {} const vui __builtin_altivec_vreplace_uv4si (vui, unsigned int, const int<2>); @@ -3385,7 +3416,8 @@ const vd __builtin_altivec_vreplace_v2df (vd, double, const int<1>); VREPLACE_ELT_V2DF vreplace_elt_v2df {} - const vsll __builtin_altivec_vreplace_v2di (vsll, signed long long, const int<1>); + const vsll __builtin_altivec_vreplace_v2di (vsll, signed long long, \ + const int<1>); VREPLACE_ELT_V2DI vreplace_elt_v2di {} const vf __builtin_altivec_vreplace_v4sf (vf, float, const int<2>); @@ -3553,33 +3585,42 @@ const vss __builtin_vsx_xxpermx_v8hi (vss, vss, vuc, const int<3>); XXPERMX_V8HI xxpermx {} - pure unsigned __int128 __builtin_altivec_ze_lxvrbx (signed long, const unsigned char *); + pure unsigned __int128 __builtin_altivec_ze_lxvrbx (signed long, \ + const unsigned char *); ZE_LXVRBX vsx_lxvrbx {lxvrze} - pure unsigned __int128 __builtin_altivec_ze_lxvrhx (signed long, const unsigned short *); + pure unsigned __int128 __builtin_altivec_ze_lxvrhx (signed long, \ + const unsigned short *); ZE_LXVRHX vsx_lxvrhx {lxvrze} - pure unsigned __int128 __builtin_altivec_ze_lxvrwx (signed long, const unsigned int *); + pure unsigned __int128 __builtin_altivec_ze_lxvrwx (signed long, \ + const unsigned int *); ZE_LXVRWX vsx_lxvrwx {lxvrze} - pure unsigned __int128 __builtin_altivec_ze_lxvrdx (signed long, const unsigned long long *); + pure unsigned __int128 \ + __builtin_altivec_ze_lxvrdx (signed long, const unsigned long long *); ZE_LXVRDX vsx_lxvrdx {lxvrze} [power10-64] - const unsigned long long __builtin_cfuged (unsigned long long, unsigned long long); + const unsigned long long __builtin_cfuged (unsigned long long, \ + unsigned long long); CFUGED cfuged {} - const unsigned long long __builtin_cntlzdm (unsigned long long, unsigned long long); + const unsigned long long __builtin_cntlzdm (unsigned long long, \ + unsigned long long); CNTLZDM cntlzdm {} - const unsigned long long __builtin_cnttzdm (unsigned long long, unsigned long long); + const unsigned long long __builtin_cnttzdm (unsigned long long, \ + unsigned long long); CNTTZDM cnttzdm {} - const unsigned long long __builtin_pdepd (unsigned long long, unsigned long long); + const unsigned long long __builtin_pdepd (unsigned long long, \ + unsigned long long); PDEPD pdepd {} - const unsigned long long __builtin_pextd (unsigned long long, unsigned long long); + const unsigned long long __builtin_pextd (unsigned long long, \ + unsigned long long); PEXTD pextd {} @@ -3614,178 +3655,235 @@ vuc __builtin_mma_disassemble_pair_internal (v256, const int<2>); DISASSEMBLE_PAIR_INTERNAL vsx_disassemble_pair {mma} - void __builtin_mma_pmxvbf16ger2 (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvbf16ger2 (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2 nothing {mma,mmaint} - v512 __builtin_mma_pmxvbf16ger2_internal (vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvbf16ger2_internal (vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2_INTERNAL mma_pmxvbf16ger2 {mma} - void __builtin_mma_pmxvbf16ger2nn (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvbf16ger2nn (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2NN nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvbf16ger2nn_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvbf16ger2nn_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2NN_INTERNAL mma_pmxvbf16ger2nn {mma,quad} - void __builtin_mma_pmxvbf16ger2np (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvbf16ger2np (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2NP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvbf16ger2np_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvbf16ger2np_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2NP_INTERNAL mma_pmxvbf16ger2np {mma,quad} - void __builtin_mma_pmxvbf16ger2pn (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvbf16ger2pn (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2PN nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvbf16ger2pn_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvbf16ger2pn_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2PN_INTERNAL mma_pmxvbf16ger2pn {mma,quad} - void __builtin_mma_pmxvbf16ger2pp (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvbf16ger2pp (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2PP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvbf16ger2pp_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvbf16ger2pp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVBF16GER2PP_INTERNAL mma_pmxvbf16ger2pp {mma,quad} - void __builtin_mma_pmxvf16ger2 (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvf16ger2 (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2 nothing {mma,mmaint} - v512 __builtin_mma_pmxvf16ger2_internal (vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf16ger2_internal (vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2_INTERNAL mma_pmxvf16ger2 {mma} - void __builtin_mma_pmxvf16ger2nn (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvf16ger2nn (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2NN nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf16ger2nn_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf16ger2nn_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2NN_INTERNAL mma_pmxvf16ger2nn {mma,quad} - void __builtin_mma_pmxvf16ger2np (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvf16ger2np (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2NP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf16ger2np_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf16ger2np_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2NP_INTERNAL mma_pmxvf16ger2np {mma,quad} - void __builtin_mma_pmxvf16ger2pn (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvf16ger2pn (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2PN nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf16ger2pn_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf16ger2pn_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2PN_INTERNAL mma_pmxvf16ger2pn {mma,quad} - void __builtin_mma_pmxvf16ger2pp (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvf16ger2pp (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2PP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf16ger2pp_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf16ger2pp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVF16GER2PP_INTERNAL mma_pmxvf16ger2pp {mma,quad} void __builtin_mma_pmxvf32ger (v512 *, vuc, vuc, const int<4>, const int<4>); PMXVF32GER nothing {mma,mmaint} - v512 __builtin_mma_pmxvf32ger_internal (vuc, vuc, const int<4>, const int<4>); + v512 __builtin_mma_pmxvf32ger_internal (vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GER_INTERNAL mma_pmxvf32ger {mma} - void __builtin_mma_pmxvf32gernn (v512 *, vuc, vuc, const int<4>, const int<4>); + void __builtin_mma_pmxvf32gernn (v512 *, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERNN nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf32gernn_internal (v512, vuc, vuc, const int<4>, const int<4>); + v512 __builtin_mma_pmxvf32gernn_internal (v512, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERNN_INTERNAL mma_pmxvf32gernn {mma,quad} - void __builtin_mma_pmxvf32gernp (v512 *, vuc, vuc, const int<4>, const int<4>); + void __builtin_mma_pmxvf32gernp (v512 *, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERNP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf32gernp_internal (v512, vuc, vuc, const int<4>, const int<4>); + v512 __builtin_mma_pmxvf32gernp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERNP_INTERNAL mma_pmxvf32gernp {mma,quad} - void __builtin_mma_pmxvf32gerpn (v512 *, vuc, vuc, const int<4>, const int<4>); + void __builtin_mma_pmxvf32gerpn (v512 *, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERPN nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf32gerpn_internal (v512, vuc, vuc, const int<4>, const int<4>); + v512 __builtin_mma_pmxvf32gerpn_internal (v512, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERPN_INTERNAL mma_pmxvf32gerpn {mma,quad} - void __builtin_mma_pmxvf32gerpp (v512 *, vuc, vuc, const int<4>, const int<4>); + void __builtin_mma_pmxvf32gerpp (v512 *, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERPP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvf32gerpp_internal (v512, vuc, vuc, const int<4>, const int<4>); + v512 __builtin_mma_pmxvf32gerpp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>); PMXVF32GERPP_INTERNAL mma_pmxvf32gerpp {mma,quad} - void __builtin_mma_pmxvf64ger (v512 *, v256, vuc, const int<4>, const int<2>); + void __builtin_mma_pmxvf64ger (v512 *, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GER nothing {mma,pair,mmaint} - v512 __builtin_mma_pmxvf64ger_internal (v256, vuc, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf64ger_internal (v256, vuc, const int<4>, \ + const int<2>); PMXVF64GER_INTERNAL mma_pmxvf64ger {mma,pair} - void __builtin_mma_pmxvf64gernn (v512 *, v256, vuc, const int<4>, const int<2>); + void __builtin_mma_pmxvf64gernn (v512 *, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERNN nothing {mma,pair,quad,mmaint} - v512 __builtin_mma_pmxvf64gernn_internal (v512, v256, vuc, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf64gernn_internal (v512, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERNN_INTERNAL mma_pmxvf64gernn {mma,pair,quad} - void __builtin_mma_pmxvf64gernp (v512 *, v256, vuc, const int<4>, const int<2>); + void __builtin_mma_pmxvf64gernp (v512 *, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERNP nothing {mma,pair,quad,mmaint} - v512 __builtin_mma_pmxvf64gernp_internal (v512, v256, vuc, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf64gernp_internal (v512, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERNP_INTERNAL mma_pmxvf64gernp {mma,pair,quad} - void __builtin_mma_pmxvf64gerpn (v512 *, v256, vuc, const int<4>, const int<2>); + void __builtin_mma_pmxvf64gerpn (v512 *, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERPN nothing {mma,pair,quad,mmaint} - v512 __builtin_mma_pmxvf64gerpn_internal (v512, v256, vuc, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf64gerpn_internal (v512, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERPN_INTERNAL mma_pmxvf64gerpn {mma,pair,quad} - void __builtin_mma_pmxvf64gerpp (v512 *, v256, vuc, const int<4>, const int<2>); + void __builtin_mma_pmxvf64gerpp (v512 *, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERPP nothing {mma,pair,quad,mmaint} - v512 __builtin_mma_pmxvf64gerpp_internal (v512, v256, vuc, const int<4>, const int<2>); + v512 __builtin_mma_pmxvf64gerpp_internal (v512, v256, vuc, const int<4>, \ + const int<2>); PMXVF64GERPP_INTERNAL mma_pmxvf64gerpp {mma,pair,quad} - void __builtin_mma_pmxvi16ger2 (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvi16ger2 (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2 nothing {mma,mmaint} - v512 __builtin_mma_pmxvi16ger2_internal (vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvi16ger2_internal (vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2_INTERNAL mma_pmxvi16ger2 {mma} - void __builtin_mma_pmxvi16ger2pp (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvi16ger2pp (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2PP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvi16ger2pp_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvi16ger2pp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2PP_INTERNAL mma_pmxvi16ger2pp {mma,quad} - void __builtin_mma_pmxvi16ger2s (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvi16ger2s (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2S nothing {mma,mmaint} - v512 __builtin_mma_pmxvi16ger2s_internal (vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvi16ger2s_internal (vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2S_INTERNAL mma_pmxvi16ger2s {mma} - void __builtin_mma_pmxvi16ger2spp (v512 *, vuc, vuc, const int<4>, const int<4>, const int<2>); + void __builtin_mma_pmxvi16ger2spp (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2SPP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvi16ger2spp_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<2>); + v512 __builtin_mma_pmxvi16ger2spp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<2>); PMXVI16GER2SPP_INTERNAL mma_pmxvi16ger2spp {mma,quad} - void __builtin_mma_pmxvi4ger8 (v512 *, vuc, vuc, const int<4>, const int<4>, const int<8>); + void __builtin_mma_pmxvi4ger8 (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<8>); PMXVI4GER8 nothing {mma,mmaint} - v512 __builtin_mma_pmxvi4ger8_internal (vuc, vuc, const int<4>, const int<4>, const int<8>); + v512 __builtin_mma_pmxvi4ger8_internal (vuc, vuc, const int<4>, \ + const int<4>, const int<8>); PMXVI4GER8_INTERNAL mma_pmxvi4ger8 {mma} - void __builtin_mma_pmxvi4ger8pp (v512 *, vuc, vuc, const int<4>, const int<4>, const int<4>); + void __builtin_mma_pmxvi4ger8pp (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI4GER8PP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvi4ger8pp_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<4>); + v512 __builtin_mma_pmxvi4ger8pp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI4GER8PP_INTERNAL mma_pmxvi4ger8pp {mma,quad} - void __builtin_mma_pmxvi8ger4 (v512 *, vuc, vuc, const int<4>, const int<4>, const int<4>); + void __builtin_mma_pmxvi8ger4 (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI8GER4 nothing {mma,mmaint} - v512 __builtin_mma_pmxvi8ger4_internal (vuc, vuc, const int<4>, const int<4>, const int<4>); + v512 __builtin_mma_pmxvi8ger4_internal (vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI8GER4_INTERNAL mma_pmxvi8ger4 {mma} - void __builtin_mma_pmxvi8ger4pp (v512 *, vuc, vuc, const int<4>, const int<4>, const int<4>); + void __builtin_mma_pmxvi8ger4pp (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI8GER4PP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvi8ger4pp_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<4>); + v512 __builtin_mma_pmxvi8ger4pp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI8GER4PP_INTERNAL mma_pmxvi8ger4pp {mma,quad} - void __builtin_mma_pmxvi8ger4spp (v512 *, vuc, vuc, const int<4>, const int<4>, const int<4>); + void __builtin_mma_pmxvi8ger4spp (v512 *, vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI8GER4SPP nothing {mma,quad,mmaint} - v512 __builtin_mma_pmxvi8ger4spp_internal (v512, vuc, vuc, const int<4>, const int<4>, const int<4>); + v512 __builtin_mma_pmxvi8ger4spp_internal (v512, vuc, vuc, const int<4>, \ + const int<4>, const int<4>); PMXVI8GER4SPP_INTERNAL mma_pmxvi8ger4spp {mma,quad} void __builtin_mma_xvbf16ger2 (v512 *, vuc, vuc); diff --git a/gcc/config/rs6000/rs6000-gen-builtins.c b/gcc/config/rs6000/rs6000-gen-builtins.c index fdef65fe1d4..3405ff0b7b4 100644 --- a/gcc/config/rs6000/rs6000-gen-builtins.c +++ b/gcc/config/rs6000/rs6000-gen-builtins.c @@ -188,6 +188,15 @@ static char linebuf[LINELEN]; static int line; static int pos; +/* Escape-newline support. For readability, we prefer to allow developers + to use escape-newline to continue long lines to the next one. We + maintain a buffer of "original" lines here, which are concatenated into + linebuf, above, and which can be used to convert the virtual line + position "line / pos" into actual line and position information. */ +#define MAXLINES 4 +static char *lines[MAXLINES]; +static int lastline; + /* Used to determine whether a type can be void (only return types). */ enum void_status { @@ -568,31 +577,61 @@ static typemap type_map[TYPE_MAP_SIZE] = { "vp8hi", "pixel_V8HI" }, }; +/* From a possibly extended line with a virtual position, calculate + the current line and character position. */ +static void +real_line_pos (int diagpos, int *real_line, int *real_pos) +{ + *real_line = line - lastline; + *real_pos = diagpos; + + for (int i = 0; i < MAXLINES && *real_pos > (int) strlen (lines[i]); i++) + { + (*real_line)++; + *real_pos -= strlen (lines[i]) - 2; + } + + /* Convert from zero-base to one-base for printing. */ + (*real_pos)++; +} + /* Pointer to a diagnostic function. */ -static void (*diag) (const char *, ...) - __attribute__ ((format (printf, 1, 2))); +static void (*diag) (int, const char *, ...) + __attribute__ ((format (printf, 2, 3))); /* Custom diagnostics. */ -static void __attribute__ ((format (printf, 1, 2))) -bif_diag (const char * fmt, ...) +static void __attribute__ ((format (printf, 2, 3))) +bif_diag (int diagpos, const char * fmt, ...) { va_list args; - fprintf (stderr, "%s:%d: ", bif_path, line); + int real_line, real_pos; + real_line_pos (diagpos, &real_line, &real_pos); + fprintf (stderr, "%s:%d:%d: ", bif_path, real_line, real_pos); va_start (args, fmt); vfprintf (stderr, fmt, args); va_end (args); } -static void __attribute__ ((format (printf, 1, 2))) -ovld_diag (const char * fmt, ...) +static void __attribute__ ((format (printf, 2, 3))) +ovld_diag (int diagpos, const char * fmt, ...) { va_list args; - fprintf (stderr, "%s:%d: ", ovld_path, line); + int real_line, real_pos; + real_line_pos (diagpos, &real_line, &real_pos); + fprintf (stderr, "%s:%d:%d: ", ovld_path, real_line, real_pos); va_start (args, fmt); vfprintf (stderr, fmt, args); va_end (args); } +/* Produce a fatal error message. */ +static void +fatal (const char *msg) +{ + fprintf (stderr, "FATAL: %s\n", msg); + abort (); +} + /* Pass over whitespace (other than a newline, which terminates the scan). */ static void consume_whitespace (void) @@ -602,7 +641,7 @@ consume_whitespace (void) if (pos >= LINELEN) { - diag ("line length overrun at %d.\n", pos); + diag (pos, "line length overrun.\n"); exit (1); } @@ -620,8 +659,28 @@ advance_line (FILE *file) return 0; line++; size_t len = strlen (linebuf); + + /* Escape-newline processing. */ + lastline = 0; + if (len > 1) + { + strcpy (lines[0], linebuf); + while (linebuf[len - 2] == '\\' + && linebuf[len - 1] == '\n') + { + if (lastline == MAXLINES - 1) + fatal ("number of supported overflow lines exceeded"); + lastline++; + line++; + if (!fgets (lines[lastline], LINELEN, file)) + fatal ("unexpected end of file"); + strcpy (&linebuf[len - 2], lines[lastline]); + len += strlen (lines[lastline]) - 2; + } + } + if (linebuf[len - 1] != '\n') - (*diag) ("line doesn't terminate with newline\n"); + fatal ("line doesn't terminate with newline"); pos = 0; consume_whitespace (); if (linebuf[pos] != '\n' && linebuf[pos] != ';') @@ -634,7 +693,7 @@ safe_inc_pos (void) { if (++pos >= LINELEN) { - (*diag) ("line length overrun.\n"); + diag (pos, "line length overrun.\n"); exit (1); } } @@ -651,7 +710,7 @@ match_identifier (void) if (lastpos >= LINELEN - 1) { - diag ("line length overrun at %d.\n", lastpos); + diag (lastpos, "line length overrun.\n"); exit (1); } @@ -681,7 +740,7 @@ match_integer (void) if (lastpos >= LINELEN - 1) { - diag ("line length overrun at %d.\n", lastpos); + diag (lastpos, "line length overrun.\n"); exit (1); } @@ -705,16 +764,13 @@ match_to_right_bracket (void) while (lastpos < LINELEN - 1 && linebuf[lastpos + 1] != ']') { if (linebuf[lastpos + 1] == '\n') - { - (*diag) ("no ']' found before end of line.\n"); - exit (1); - } + fatal ("no ']' found before end of line.\n"); ++lastpos; } if (lastpos >= LINELEN - 1) { - diag ("line length overrun at %d.\n", lastpos); + diag (lastpos, "line length overrun.\n"); exit (1); } @@ -740,14 +796,6 @@ handle_pointer (typeinfo *typedata) } } -/* Produce a fatal error message. */ -static void -fatal (const char *msg) -{ - fprintf (stderr, "FATAL: %s\n", msg); - abort (); -} - static bif_stanza stanza_name_to_stanza (const char *stanza_name) { @@ -771,7 +819,7 @@ match_basetype (typeinfo *typedata) char *token = match_identifier (); if (!token) { - (*diag) ("missing base type in return type at column %d\n", pos + 1); + diag (pos, "missing base type in return type\n"); return 0; } @@ -825,7 +873,7 @@ match_basetype (typeinfo *typedata) typedata->base = BT_IBM128; else { - (*diag) ("unrecognized base type at column %d\n", oldpos + 1); + diag (oldpos, "unrecognized base type\n"); return 0; } @@ -845,13 +893,13 @@ match_bracketed_pair (typeinfo *typedata, char open, char close, char *x = match_integer (); if (x == NULL) { - (*diag) ("malformed integer at column %d.\n", oldpos + 1); + diag (oldpos, "malformed integer.\n"); return 0; } consume_whitespace (); if (linebuf[pos] != ',') { - (*diag) ("missing comma at column %d.\n", pos + 1); + diag (pos, "missing comma.\n"); return 0; } safe_inc_pos (); @@ -860,7 +908,7 @@ match_bracketed_pair (typeinfo *typedata, char open, char close, char *y = match_integer (); if (y == NULL) { - (*diag) ("malformed integer at column %d.\n", oldpos + 1); + diag (oldpos, "malformed integer.\n"); return 0; } typedata->restr = restr; @@ -870,7 +918,7 @@ match_bracketed_pair (typeinfo *typedata, char open, char close, consume_whitespace (); if (linebuf[pos] != close) { - (*diag) ("malformed restriction at column %d.\n", pos + 1); + diag (pos, "malformed restriction.\n"); return 0; } safe_inc_pos (); @@ -905,7 +953,7 @@ match_const_restriction (typeinfo *typedata) char *x = match_integer (); if (x == NULL) { - (*diag) ("malformed integer at column %d.\n", oldpos + 1); + diag (oldpos, "malformed integer.\n"); return 0; } consume_whitespace (); @@ -918,7 +966,7 @@ match_const_restriction (typeinfo *typedata) } else if (linebuf[pos] != ',') { - (*diag) ("malformed restriction at column %d.\n", pos + 1); + diag (pos, "malformed restriction.\n"); return 0; } safe_inc_pos (); @@ -926,7 +974,7 @@ match_const_restriction (typeinfo *typedata) char *y = match_integer (); if (y == NULL) { - (*diag) ("malformed integer at column %d.\n", oldpos + 1); + diag (oldpos, "malformed integer.\n"); return 0; } typedata->restr = RES_RANGE; @@ -936,7 +984,7 @@ match_const_restriction (typeinfo *typedata) consume_whitespace (); if (linebuf[pos] != '>') { - (*diag) ("malformed restriction at column %d.\n", pos + 1); + diag (pos, "malformed restriction.\n"); return 0; } safe_inc_pos (); @@ -1217,8 +1265,7 @@ match_type (typeinfo *typedata, int voidok) return 1; if (typedata->base != BT_INT) { - (*diag)("'const' at %d requires pointer or integer type", - oldpos + 1); + diag (oldpos, "'const' requires pointer or integer type\n"); return 0; } consume_whitespace (); @@ -1248,7 +1295,7 @@ parse_args (prototype *protoptr) consume_whitespace (); if (linebuf[pos] != '(') { - (*diag) ("missing '(' at column %d.\n", pos + 1); + diag (pos, "missing '('.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -1266,7 +1313,7 @@ parse_args (prototype *protoptr) { if (restr_cnt >= MAXRESTROPNDS) { - (*diag) ("More than two %d operands\n", MAXRESTROPNDS); + diag (pos, "More than two %d operands\n", MAXRESTROPNDS); return PC_PARSEFAIL; } restr_opnd[restr_cnt] = *nargs + 1; @@ -1283,20 +1330,20 @@ parse_args (prototype *protoptr) safe_inc_pos (); else if (linebuf[pos] != ')') { - (*diag) ("arg not followed by ',' or ')' at column %d.\n", - pos + 1); + diag (pos, "arg not followed by ',' or ')'.\n"); return PC_PARSEFAIL; } #ifdef DEBUG - (*diag) ("argument type: isvoid = %d, isconst = %d, isvector = %d, " - "issigned = %d, isunsigned = %d, isbool = %d, ispixel = %d, " - "ispointer = %d, base = %d, restr = %d, val1 = \"%s\", " - "val2 = \"%s\", pos = %d.\n", - argtype->isvoid, argtype->isconst, argtype->isvector, - argtype->issigned, argtype->isunsigned, argtype->isbool, - argtype->ispixel, argtype->ispointer, argtype->base, - argtype->restr, argtype->val1, argtype->val2, pos + 1); + diag (0, + "argument type: isvoid = %d, isconst = %d, isvector = %d, " + "issigned = %d, isunsigned = %d, isbool = %d, ispixel = %d, " + "ispointer = %d, base = %d, restr = %d, val1 = \"%s\", " + "val2 = \"%s\", pos = %d.\n", + argtype->isvoid, argtype->isconst, argtype->isvector, + argtype->issigned, argtype->isunsigned, argtype->isbool, + argtype->ispixel, argtype->ispointer, argtype->base, + argtype->restr, argtype->val1, argtype->val2, pos + 1); #endif } else @@ -1306,7 +1353,7 @@ parse_args (prototype *protoptr) pos = oldpos; if (linebuf[pos] != ')') { - (*diag) ("badly terminated arg list at column %d.\n", pos + 1); + diag (pos, "badly terminated arg list.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -1323,7 +1370,7 @@ parse_bif_attrs (attrinfo *attrptr) consume_whitespace (); if (linebuf[pos] != '{') { - (*diag) ("missing attribute set at column %d.\n", pos + 1); + diag (pos, "missing attribute set.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -1383,7 +1430,7 @@ parse_bif_attrs (attrinfo *attrptr) attrptr->isendian = 1; else { - (*diag) ("unknown attribute at column %d.\n", oldpos + 1); + diag (oldpos, "unknown attribute.\n"); return PC_PARSEFAIL; } @@ -1392,8 +1439,7 @@ parse_bif_attrs (attrinfo *attrptr) safe_inc_pos (); else if (linebuf[pos] != '}') { - (*diag) ("arg not followed by ',' or '}' at column %d.\n", - pos + 1); + diag (pos, "arg not followed by ',' or '}'.\n"); return PC_PARSEFAIL; } } @@ -1402,7 +1448,7 @@ parse_bif_attrs (attrinfo *attrptr) pos = oldpos; if (linebuf[pos] != '}') { - (*diag) ("badly terminated attr set at column %d.\n", pos + 1); + diag (pos, "badly terminated attr set.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -1410,18 +1456,19 @@ parse_bif_attrs (attrinfo *attrptr) } while (attrname); #ifdef DEBUG - (*diag) ("attribute set: init = %d, set = %d, extract = %d, nosoft = %d, " - "ldvec = %d, stvec = %d, reve = %d, pred = %d, htm = %d, " - "htmspr = %d, htmcr = %d, mma = %d, quad = %d, pair = %d, " - "mmaint = %d, no32bit = %d, 32bit = %d, cpu = %d, ldstmask = %d, " - "lxvrse = %d, lxvrze = %d, endian = %d.\n", - attrptr->isinit, attrptr->isset, attrptr->isextract, - attrptr->isnosoft, attrptr->isldvec, attrptr->isstvec, - attrptr->isreve, attrptr->ispred, attrptr->ishtm, attrptr->ishtmspr, - attrptr->ishtmcr, attrptr->ismma, attrptr->isquad, attrptr->ispair, - attrptr->ismmaint, attrptr->isno32bit, attrptr->is32bit, - attrptr->iscpu, attrptr->isldstmask, attrptr->islxvrse, - attrptr->islxvrze, attrptr->isendian); + diag (0, + "attribute set: init = %d, set = %d, extract = %d, nosoft = %d, " + "ldvec = %d, stvec = %d, reve = %d, pred = %d, htm = %d, " + "htmspr = %d, htmcr = %d, mma = %d, quad = %d, pair = %d, " + "mmaint = %d, no32bit = %d, 32bit = %d, cpu = %d, ldstmask = %d, " + "lxvrse = %d, lxvrze = %d, endian = %d.\n", + attrptr->isinit, attrptr->isset, attrptr->isextract, + attrptr->isnosoft, attrptr->isldvec, attrptr->isstvec, + attrptr->isreve, attrptr->ispred, attrptr->ishtm, attrptr->ishtmspr, + attrptr->ishtmcr, attrptr->ismma, attrptr->isquad, attrptr->ispair, + attrptr->ismmaint, attrptr->isno32bit, attrptr->is32bit, + attrptr->iscpu, attrptr->isldstmask, attrptr->islxvrse, + attrptr->islxvrze, attrptr->isendian); #endif return PC_OK; @@ -1483,7 +1530,7 @@ complete_vector_type (typeinfo *typeptr, char *buf, int *bufi) *bufi += 4; break; default: - (*diag) ("unhandled basetype %d.\n", typeptr->base); + diag (pos, "unhandled basetype %d.\n", typeptr->base); exit (1); } } @@ -1543,7 +1590,7 @@ complete_base_type (typeinfo *typeptr, char *buf, int *bufi) memcpy (&buf[*bufi], "if", 2); break; default: - (*diag) ("unhandled basetype %d.\n", typeptr->base); + diag (pos, "unhandled basetype %d.\n", typeptr->base); exit (1); } @@ -1664,20 +1711,20 @@ parse_prototype (prototype *protoptr) int success = match_type (ret_type, VOID_OK); if (!success) { - (*diag) ("missing or badly formed return type at column %d.\n", - oldpos + 1); + diag (oldpos, "missing or badly formed return type.\n"); return PC_PARSEFAIL; } #ifdef DEBUG - (*diag) ("return type: isvoid = %d, isconst = %d, isvector = %d, " - "issigned = %d, isunsigned = %d, isbool = %d, ispixel = %d, " - "ispointer = %d, base = %d, restr = %d, val1 = \"%s\", " - "val2 = \"%s\", pos = %d.\n", - ret_type->isvoid, ret_type->isconst, ret_type->isvector, - ret_type->issigned, ret_type->isunsigned, ret_type->isbool, - ret_type->ispixel, ret_type->ispointer, ret_type->base, - ret_type->restr, ret_type->val1, ret_type->val2, pos + 1); + diag (0, + "return type: isvoid = %d, isconst = %d, isvector = %d, " + "issigned = %d, isunsigned = %d, isbool = %d, ispixel = %d, " + "ispointer = %d, base = %d, restr = %d, val1 = \"%s\", " + "val2 = \"%s\", pos = %d.\n", + ret_type->isvoid, ret_type->isconst, ret_type->isvector, + ret_type->issigned, ret_type->isunsigned, ret_type->isbool, + ret_type->ispixel, ret_type->ispointer, ret_type->base, + ret_type->restr, ret_type->val1, ret_type->val2, pos + 1); #endif /* Get the bif name. */ @@ -1686,12 +1733,12 @@ parse_prototype (prototype *protoptr) *bifname = match_identifier (); if (!*bifname) { - (*diag) ("missing function name at column %d.\n", oldpos + 1); + diag (oldpos, "missing function name.\n"); return PC_PARSEFAIL; } #ifdef DEBUG - (*diag) ("function name is '%s'.\n", *bifname); + diag (0, "function name is '%s'.\n", *bifname); #endif /* Process arguments. */ @@ -1702,14 +1749,14 @@ parse_prototype (prototype *protoptr) consume_whitespace (); if (linebuf[pos] != ';') { - (*diag) ("missing semicolon at column %d.\n", pos + 1); + diag (pos, "missing semicolon.\n"); return PC_PARSEFAIL; } safe_inc_pos (); consume_whitespace (); if (linebuf[pos] != '\n') { - (*diag) ("garbage at end of line at column %d.\n", pos + 1); + diag (pos, "garbage at end of line.\n"); return PC_PARSEFAIL; } @@ -1729,7 +1776,7 @@ parse_bif_entry (void) /* Allocate an entry in the bif table. */ if (num_bifs >= MAXBIFS - 1) { - (*diag) ("too many built-in functions.\n"); + diag (pos, "too many built-in functions.\n"); return PC_PARSEFAIL; } @@ -1742,7 +1789,7 @@ parse_bif_entry (void) char *token = match_identifier (); if (!token) { - (*diag) ("malformed entry at column %d\n", oldpos + 1); + diag (oldpos, "malformed entry.\n"); return PC_PARSEFAIL; } @@ -1769,7 +1816,7 @@ parse_bif_entry (void) /* Now process line 2. First up is the builtin id. */ if (!advance_line (bif_file)) { - (*diag) ("unexpected EOF.\n"); + diag (pos, "unexpected EOF.\n"); return PC_PARSEFAIL; } @@ -1779,19 +1826,18 @@ parse_bif_entry (void) bifs[curr_bif].idname = match_identifier (); if (!bifs[curr_bif].idname) { - (*diag) ("missing builtin id at column %d.\n", pos + 1); + diag (pos, "missing builtin id.\n"); return PC_PARSEFAIL; } #ifdef DEBUG - (*diag) ("ID name is '%s'.\n", bifs[curr_bif].idname); + diag (0, "ID name is '%s'.\n", bifs[curr_bif].idname); #endif /* Save the ID in a lookup structure. */ if (!rbt_insert (&bif_rbt, bifs[curr_bif].idname)) { - (*diag) ("duplicate function ID '%s' at column %d.\n", - bifs[curr_bif].idname, oldpos + 1); + diag (oldpos, "duplicate function ID '%s'.\n", bifs[curr_bif].idname); return PC_PARSEFAIL; } @@ -1804,7 +1850,7 @@ parse_bif_entry (void) if (!rbt_insert (&bifo_rbt, buf)) { - (*diag) ("internal error inserting '%s' in bifo_rbt\n", buf); + diag (pos, "internal error inserting '%s' in bifo_rbt\n", buf); return PC_PARSEFAIL; } @@ -1813,12 +1859,12 @@ parse_bif_entry (void) bifs[curr_bif].patname = match_identifier (); if (!bifs[curr_bif].patname) { - (*diag) ("missing pattern name at column %d.\n", pos + 1); + diag (pos, "missing pattern name.\n"); return PC_PARSEFAIL; } #ifdef DEBUG - (*diag) ("pattern name is '%s'.\n", bifs[curr_bif].patname); + diag (0, "pattern name is '%s'.\n", bifs[curr_bif].patname); #endif /* Process attributes. */ @@ -1836,7 +1882,7 @@ parse_bif_stanza (void) if (linebuf[pos] != '[') { - (*diag) ("ill-formed stanza header at column %d.\n", pos + 1); + diag (pos, "ill-formed stanza header.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -1844,7 +1890,7 @@ parse_bif_stanza (void) const char *stanza_name = match_to_right_bracket (); if (!stanza_name) { - (*diag) ("no expression found in stanza header.\n"); + diag (pos, "no expression found in stanza header.\n"); return PC_PARSEFAIL; } @@ -1852,7 +1898,7 @@ parse_bif_stanza (void) if (linebuf[pos] != ']') { - (*diag) ("ill-formed stanza header at column %d.\n", pos + 1); + diag (pos, "ill-formed stanza header.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -1860,7 +1906,7 @@ parse_bif_stanza (void) consume_whitespace (); if (linebuf[pos] != '\n' && pos != LINELEN - 1) { - (*diag) ("garbage after stanza header.\n"); + diag (pos, "garbage after stanza header.\n"); return PC_PARSEFAIL; } @@ -1927,7 +1973,7 @@ parse_ovld_entry (void) /* Allocate an entry in the overload table. */ if (num_ovlds >= MAXOVLDS - 1) { - (*diag) ("too many overloads.\n"); + diag (pos, "too many overloads.\n"); return PC_PARSEFAIL; } @@ -1948,7 +1994,7 @@ parse_ovld_entry (void) optional overload id. */ if (!advance_line (ovld_file)) { - (*diag) ("unexpected EOF.\n"); + diag (0, "unexpected EOF.\n"); return PC_EOFILE; } @@ -1960,18 +2006,18 @@ parse_ovld_entry (void) ovlds[curr_ovld].ovld_id_name = id; if (!id) { - (*diag) ("missing overload id at column %d.\n", pos + 1); + diag (pos, "missing overload id.\n"); return PC_PARSEFAIL; } #ifdef DEBUG - (*diag) ("ID name is '%s'.\n", id); + diag (pos, "ID name is '%s'.\n", id); #endif /* The builtin id has to match one from the bif file. */ if (!rbt_find (&bif_rbt, id)) { - (*diag) ("builtin ID '%s' not found in bif file.\n", id); + diag (pos, "builtin ID '%s' not found in bif file.\n", id); return PC_PARSEFAIL; } @@ -1989,13 +2035,13 @@ parse_ovld_entry (void) /* Save the overload ID in a lookup structure. */ if (!rbt_insert (&ovld_rbt, id)) { - (*diag) ("duplicate overload ID '%s' at column %d.\n", id, oldpos + 1); + diag (oldpos, "duplicate overload ID '%s'.\n", id); return PC_PARSEFAIL; } if (linebuf[pos] != '\n') { - (*diag) ("garbage at end of line at column %d.\n", pos + 1); + diag (pos, "garbage at end of line.\n"); return PC_PARSEFAIL; } return PC_OK; @@ -2012,7 +2058,7 @@ parse_ovld_stanza (void) if (linebuf[pos] != '[') { - (*diag) ("ill-formed stanza header at column %d.\n", pos + 1); + diag (pos, "ill-formed stanza header.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -2020,7 +2066,7 @@ parse_ovld_stanza (void) char *stanza_name = match_identifier (); if (!stanza_name) { - (*diag) ("no identifier found in stanza header.\n"); + diag (pos, "no identifier found in stanza header.\n"); return PC_PARSEFAIL; } @@ -2028,7 +2074,7 @@ parse_ovld_stanza (void) with subsequent overload entries. */ if (num_ovld_stanzas >= MAXOVLDSTANZAS) { - (*diag) ("too many stanza headers.\n"); + diag (pos, "too many stanza headers.\n"); return PC_PARSEFAIL; } @@ -2039,7 +2085,7 @@ parse_ovld_stanza (void) consume_whitespace (); if (linebuf[pos] != ',') { - (*diag) ("missing comma at column %d.\n", pos + 1); + diag (pos, "missing comma.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -2048,14 +2094,14 @@ parse_ovld_stanza (void) stanza->extern_name = match_identifier (); if (!stanza->extern_name) { - (*diag) ("missing external name at column %d.\n", pos + 1); + diag (pos, "missing external name.\n"); return PC_PARSEFAIL; } consume_whitespace (); if (linebuf[pos] != ',') { - (*diag) ("missing comma at column %d.\n", pos + 1); + diag (pos, "missing comma.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -2064,7 +2110,7 @@ parse_ovld_stanza (void) stanza->intern_name = match_identifier (); if (!stanza->intern_name) { - (*diag) ("missing internal name at column %d.\n", pos + 1); + diag (pos, "missing internal name.\n"); return PC_PARSEFAIL; } @@ -2076,7 +2122,7 @@ parse_ovld_stanza (void) stanza->ifdef = match_identifier (); if (!stanza->ifdef) { - (*diag) ("missing ifdef token at column %d.\n", pos + 1); + diag (pos, "missing ifdef token.\n"); return PC_PARSEFAIL; } consume_whitespace (); @@ -2086,7 +2132,7 @@ parse_ovld_stanza (void) if (linebuf[pos] != ']') { - (*diag) ("ill-formed stanza header at column %d.\n", pos + 1); + diag (pos, "ill-formed stanza header.\n"); return PC_PARSEFAIL; } safe_inc_pos (); @@ -2094,7 +2140,7 @@ parse_ovld_stanza (void) consume_whitespace (); if (linebuf[pos] != '\n' && pos != LINELEN - 1) { - (*diag) ("garbage after stanza header.\n"); + diag (pos, "garbage after stanza header.\n"); return PC_PARSEFAIL; } @@ -2943,6 +2989,10 @@ main (int argc, const char **argv) exit (1); } + /* Allocate some buffers. */ + for (int i = 0; i < MAXLINES; i++) + lines[i] = (char *) malloc (LINELEN); + /* Initialize the balanced trees containing built-in function ids, overload function ids, and function type declaration ids. */ rbt_new (&bif_rbt); -- 2.27.0