poly_uint64
streamer_read_poly_uint64 (class lto_input_block *ib)
{
- poly_uint64 res;
- for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
- res.coeffs[i] = streamer_read_uhwi (ib);
- return res;
+ using coeff_type = poly_int_traits<poly_uint64>::coeff_type;
+ return poly_int_read_common<coeff_type> (streamer_read_uhwi, ib);
}
/* Read a poly_int64 from IB. */
poly_int64
streamer_read_poly_int64 (class lto_input_block *ib)
{
- poly_int64 res;
- for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
- res.coeffs[i] = streamer_read_hwi (ib);
- return res;
+ using coeff_type = poly_int_traits<poly_int64>::coeff_type;
+ return poly_int_read_common<coeff_type> (streamer_read_hwi, ib);
}
/* Read gcov_type value from IB. */
#include "cgraph.h"
#include "data-streamer.h"
+/* For offloading -- While streaming-out, host NUM_POLY_INT_COEFFS is
+ stored at beginning of mode_table. While streaming-in, the value is read
+ in host_num_poly_int_coeffs. */
+
+#ifdef ACCEL_COMPILER
+unsigned host_num_poly_int_coeffs = 0;
+#endif
+
/* Pack WORK into BP in a variant of uleb format. */
void
void bp_unpack_real_value (struct bitpack_d *, REAL_VALUE_TYPE *);
unsigned HOST_WIDE_INT bp_unpack_var_len_unsigned (struct bitpack_d *);
HOST_WIDE_INT bp_unpack_var_len_int (struct bitpack_d *);
+extern unsigned host_num_poly_int_coeffs;
/* In data-streamer-out.cc */
void streamer_write_zero (struct output_block *);
return val & mask;
}
+/* Common code for reading poly_int. */
+
+template<typename C, typename F, typename ...Args>
+poly_int<NUM_POLY_INT_COEFFS, C>
+poly_int_read_common (F read_coeff, Args ...args)
+{
+ poly_int<NUM_POLY_INT_COEFFS, C> x;
+ unsigned i;
+
+#ifdef ACCEL_COMPILER
+ /* Ensure that we have streamed-in host_num_poly_int_coeffs. */
+ const unsigned num_poly_int_coeffs = host_num_poly_int_coeffs;
+ gcc_assert (host_num_poly_int_coeffs > 0);
+#else
+ const unsigned num_poly_int_coeffs = NUM_POLY_INT_COEFFS;
+#endif
+
+ if (num_poly_int_coeffs <= NUM_POLY_INT_COEFFS)
+ {
+ for (i = 0; i < num_poly_int_coeffs; i++)
+ x.coeffs[i] = read_coeff (args...);
+ for (; i < NUM_POLY_INT_COEFFS; i++)
+ x.coeffs[i] = 0;
+ }
+ else
+ {
+ for (i = 0; i < NUM_POLY_INT_COEFFS; i++)
+ x.coeffs[i] = read_coeff (args...);
+
+ /* Ensure that degree of poly_int <= accel NUM_POLY_INT_COEFFS. */
+ for (; i < num_poly_int_coeffs; i++)
+ {
+ C val = read_coeff (args...);
+ if (val != 0)
+ fatal_error (input_location,
+ "degree of %<poly_int%> exceeds "
+ "%<NUM_POLY_INT_COEFFS%> (%d)",
+ NUM_POLY_INT_COEFFS);
+ }
+ }
+ return x;
+}
+
/* Unpacks a polynomial value from the bit-packing context BP in which each
coefficient has NBITS bits. */
inline poly_int<NUM_POLY_INT_COEFFS, bitpack_word_t>
bp_unpack_poly_value (struct bitpack_d *bp, unsigned nbits)
{
- poly_int<NUM_POLY_INT_COEFFS, bitpack_word_t> x;
- for (int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
- x.coeffs[i] = bp_unpack_value (bp, nbits);
- return x;
+ return poly_int_read_common<bitpack_word_t> (bp_unpack_value, bp, nbits);
}
header->string_size, vNULL);
bitpack_d bp = streamer_read_bitpack (&ib);
+#ifdef ACCEL_COMPILER
+ host_num_poly_int_coeffs
+ = bp_unpack_value (&bp, MAX_NUM_POLY_INT_COEFFS_BITS);
+#endif
+
unsigned mode_bits = bp_unpack_value (&bp, 5);
unsigned char *table = ggc_cleared_vec_alloc<unsigned char> (1 << mode_bits);
ob = create_output_block (LTO_section_mode_table);
bitpack_d bp = bitpack_create (ob->main_stream);
+ if (lto_stream_offload_p)
+ bp_pack_value (&bp, NUM_POLY_INT_COEFFS, MAX_NUM_POLY_INT_COEFFS_BITS);
+
/* Ensure that for GET_MODE_INNER (m) != m we have
also the inner mode marked. */
for (int i = 0; i < (int) MAX_MACHINE_MODE; i++)
? (void) ((RES).coeffs[I] = VALUE) \
: (void) ((RES).coeffs[I].~C (), new (&(RES).coeffs[I]) C (VALUE)))
+/* Number of bits needed to represent maximum value of
+ NUM_POLY_INT_COEFFS defined by any target. */
+#define MAX_NUM_POLY_INT_COEFFS_BITS 2
+
/* poly_int_full and poly_int_hungry are used internally within poly_int
for delegated initializers. poly_int_full indicates that a parameter
pack has enough elements to initialize every coefficient. poly_int_hungry
lto_input_ts_poly_tree_pointers (class lto_input_block *ib,
class data_in *data_in, tree expr)
{
- for (unsigned int i = 0; i < NUM_POLY_INT_COEFFS; ++i)
- POLY_INT_CST_COEFF (expr, i) = stream_read_tree_ref (ib, data_in);
+#ifdef ACCEL_COMPILER
+ /* Ensure that we have streamed-in host_num_poly_int_coeffs. */
+ const unsigned num_poly_int_coeffs = host_num_poly_int_coeffs;
+ gcc_assert (num_poly_int_coeffs > 0);
+#else
+ const unsigned num_poly_int_coeffs = NUM_POLY_INT_COEFFS;
+#endif
+
+ unsigned i;
+ if (num_poly_int_coeffs <= NUM_POLY_INT_COEFFS)
+ {
+ for (i = 0; i < num_poly_int_coeffs; i++)
+ POLY_INT_CST_COEFF (expr, i) = stream_read_tree_ref (ib, data_in);
+
+ tree coeff_type = TREE_TYPE (POLY_INT_CST_COEFF (expr, 0));
+ for (; i < NUM_POLY_INT_COEFFS; i++)
+ POLY_INT_CST_COEFF (expr, i) = build_zero_cst (coeff_type);
+ }
+ else
+ {
+ for (i = 0; i < NUM_POLY_INT_COEFFS; i++)
+ POLY_INT_CST_COEFF (expr, i) = stream_read_tree_ref (ib, data_in);
+ for (; i < num_poly_int_coeffs; i++)
+ {
+ tree val = stream_read_tree_ref (ib, data_in);
+ if (!integer_zerop (val))
+ fatal_error (input_location,
+ "degree of %<poly_int%> exceeds "
+ "%<NUM_POLY_INT_COEFFS%>");
+ }
+ }
}