+ test_mant_dig_comp = ''
+ if (narrowing
+ and comb_type not in narrow_args):
+ # The expected argument type is the first in
+ # narrow_args that can represent all the values of
+ # comb_type (which, for the supported cases, means the
+ # first with mant_dig at least as large as that for
+ # comb_type, provided this isn't the case of an IBM
+ # long double argument with binary128 type from
+ # narrow_args).
+ narrow_extra_conds = []
+ test_mant_dig_list = ['#undef NARROW_MANT_DIG\n#if 0\n']
+ for t in narrow_args:
+ t_cond = '(%s && %s && %s <= %s && %s)' % (
+ narrow_args_cond, t.condition, mant_dig, t.mant_dig,
+ Type.can_combine_types(this_args + [t]))
+ narrow_extra_conds.append(t_cond)
+ test_mant_dig_list.append('#elif %s\n'
+ '#define NARROW_MANT_DIG %s\n'
+ % (t_cond, t.mant_dig))
+ test_mant_dig_list.append('#endif\n')
+ test_mant_dig_comp = ''.join(test_mant_dig_list)
+ all_conds.append('(%s)' % ' || '.join(narrow_extra_conds))
+ # A special case where this logic isn't correct is
+ # where comb_type is the internal long_double_Float64
+ # or long_double_Float64x, which will be detected as
+ # not in narrow_args even if the actual type chosen in
+ # a particular configuration would have been in
+ # narrow_args, so check for that case and handle it
+ # appropriately. In particular, if long double has
+ # the same format as double and there are long double
+ # and _Float64 arguments, and the macro returns
+ # _Float32x, the function called should be one for
+ # _Float64 arguments, not one for _Float64x arguments
+ # that would arise from this logic.
+ if comb_type.real_type.name == 'long_double_Float64':
+ comb_type_1 = Type.long_double_type
+ comb_type_2 = Type.float64_type
+ comb_type_is_2_cond = 'LDBL_MANT_DIG <= FLT64_MANT_DIG'
+ elif comb_type.real_type.name == 'long_double_Float64x':
+ comb_type_1 = Type.long_double_type
+ comb_type_2 = Type.float64x_type
+ comb_type_is_2_cond = 'LDBL_MANT_DIG < FLT64X_MANT_DIG'
+ else:
+ comb_type_1 = None
+ comb_type_2 = None
+ if comb_type_1 is None:
+ mant_dig = 'NARROW_MANT_DIG'
+ else:
+ mant_dig = ''
+ if comb_type_1 in narrow_args:
+ mant_dig += '!(%s) ? %s : ' % (comb_type_is_2_cond,
+ comb_type_1.mant_dig)
+ if comb_type_2 in narrow_args:
+ mant_dig += '%s ? %s : ' % (comb_type_is_2_cond,
+ comb_type_2.mant_dig)
+ mant_dig += 'NARROW_MANT_DIG'
+ if narrow_mant_dig != 0:
+ narrow_mant_dig = mant_dig