https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119241
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Using real.cc: 1) to build a REAL_CST with target _Float128 type from string can be done: REAL_VALUE_TYPE r; real_from_string3 (&r, buf, TYPE_MODE (float128_type_node)); tree ret = build_real (float128_type_node, r); 2) to build REAL_CST with zero: tree ret = build_real (float128_type_node, dconst0); (there is also dconst1, dconst2, dconstm0, dconstm1, dconsthalf, dconstinf and dconstminf for 1.0, 2.0, -0.0, -1.0, 0.5, +inf, -inf) 3) to convert a REAL_CST to string, e.g. REAL_VALUE_TYPE r = TREE_REAL_CST (node); char string[100]; if (REAL_VALUE_ISINF (d)) strcpy (string, REAL_VALUE_NEGATIVE (d) ? "-Inf" : "Inf"); else if (REAL_VALUE_ISNAN (d)) strcpy (string, "NaN"); else real_to_decimal_for_mode (string, &d, sizeof (string), 0, 1, TYPE_MODE (float128_type_node)); (note, real_to_decimal_for_mode prints Inf/NaN some way on its own as well, this is just to show that if you want different spelling etc., there is an easy way). 4) to perform some arithmetics on REAL_CST, e.g. tree ret = const_binop (PLUS_EXPR, node1, node2); where node1 and node2 are REAL_CST; you can also use real_arithmetic directly, inexact = real_arithmetic (&value, code, &d1, &d2); real_convert (&result, TYPE_MODE (float128_type_mode), &value); (see const_binop in gcc/fold-const.cc for some details, note it will punt on some folding e.g. if -frounding-math option is used, so if it is something that should be done regardless, either that option needs to be temporarily turned off for the call or real_arithmetic used directly) 5) to convert a wide_int (including e.g. FIXED_WIDE_INT(128) from PR119242), e.g. real_from_integer (&r, TYPE_MODE (float128_type_node), some_wide_int, SIGNED); (or UNSIGNED)