return c_readstr (TREE_STRING_POINTER (str) + offset, mode, false);
}
+/* Helper function for store_expr storing of RAW_DATA_CST. */
+
+static rtx
+raw_data_cst_read_str (void *data, void *, HOST_WIDE_INT offset,
+ fixed_size_mode mode)
+{
+ tree cst = (tree) data;
+
+ gcc_assert (offset >= 0);
+ if (offset >= RAW_DATA_LENGTH (cst))
+ return const0_rtx;
+
+ if ((unsigned HOST_WIDE_INT) offset + GET_MODE_SIZE (mode)
+ > (unsigned HOST_WIDE_INT) RAW_DATA_LENGTH (cst))
+ {
+ char *p = XALLOCAVEC (char, GET_MODE_SIZE (mode));
+ size_t l = RAW_DATA_LENGTH (cst) - offset;
+ memcpy (p, RAW_DATA_POINTER (cst) + offset, l);
+ memset (p + l, '\0', GET_MODE_SIZE (mode) - l);
+ return c_readstr (p, mode, false);
+ }
+
+ return c_readstr (RAW_DATA_POINTER (cst) + offset, mode, false);
+}
+
/* Generate code for computing expression EXP,
and storing the value into TARGET.
case ARRAY_TYPE:
{
tree value, index;
- unsigned HOST_WIDE_INT i;
+ unsigned HOST_WIDE_INT i, j = 0;
bool need_to_clear;
tree domain;
tree elttype = TREE_TYPE (type);
this_node_count = (tree_to_uhwi (hi_index)
- tree_to_uhwi (lo_index) + 1);
}
+ else if (TREE_CODE (value) == RAW_DATA_CST)
+ this_node_count = RAW_DATA_LENGTH (value);
else
this_node_count = 1;
rtx xtarget = target;
if (cleared && initializer_zerop (value))
- continue;
+ {
+ if (TREE_CODE (value) == RAW_DATA_CST)
+ j += RAW_DATA_LENGTH (value) - 1;
+ continue;
+ }
mode = TYPE_MODE (elttype);
if (mode != BLKmode)
unsigned HOST_WIDE_INT lo, hi, count;
tree offset;
+ gcc_assert (TREE_CODE (value) != RAW_DATA_CST);
+
/* If the range is constant and "small", unroll the loop. */
if (const_bounds_p
&& tree_fits_uhwi_p (lo_index)
{
tree offset;
+ gcc_assert (TREE_CODE (value) != RAW_DATA_CST);
if (index)
offset = fold_build2 (MINUS_EXPR,
TREE_TYPE (index),
index,
TYPE_MIN_VALUE (domain));
else
- offset = size_int (i);
+ offset = size_int (i + j);
offset = size_binop (MULT_EXPR,
fold_convert (sizetype, offset),
bitpos = ((tree_to_uhwi (index) - minelt)
* tree_to_uhwi (TYPE_SIZE (elttype)));
else
- bitpos = (i * tree_to_uhwi (TYPE_SIZE (elttype)));
+ bitpos = ((i + j) * tree_to_uhwi (TYPE_SIZE (elttype)));
if (MEM_P (target) && !MEM_KEEP_ALIAS_SET_P (target)
&& TREE_CODE (type) == ARRAY_TYPE
target = copy_rtx (target);
MEM_KEEP_ALIAS_SET_P (target) = 1;
}
- store_constructor_field (target, bitsize, bitpos, 0,
- bitregion_end, mode, value,
- cleared, get_alias_set (elttype),
- reverse);
+ if (TREE_CODE (value) != RAW_DATA_CST)
+ store_constructor_field (target, bitsize, bitpos, 0,
+ bitregion_end, mode, value,
+ cleared, get_alias_set (elttype),
+ reverse);
+ else
+ {
+ j += RAW_DATA_LENGTH (value) - 1;
+ gcc_assert (known_eq (bitsize, BITS_PER_UNIT));
+ rtx to_rtx = adjust_address (target, mode,
+ bitpos / BITS_PER_UNIT);
+
+ if (to_rtx == target)
+ to_rtx = copy_rtx (to_rtx);
+
+ if (!MEM_KEEP_ALIAS_SET_P (to_rtx)
+ && MEM_ALIAS_SET (to_rtx) != 0)
+ set_mem_alias_set (to_rtx, get_alias_set (elttype));
+
+ if (can_store_by_pieces (RAW_DATA_LENGTH (value),
+ raw_data_cst_read_str,
+ (void *) value,
+ MEM_ALIGN (target), false))
+ {
+ store_by_pieces (target, RAW_DATA_LENGTH (value),
+ raw_data_cst_read_str, (void *) value,
+ MEM_ALIGN (target), false,
+ RETURN_BEGIN);
+ continue;
+ }
+
+ elttype
+ = build_array_type_nelts (TREE_TYPE (value),
+ RAW_DATA_LENGTH (value));
+ tree ctor = build_constructor_single (elttype, NULL_TREE,
+ value);
+ ctor = tree_output_constant_def (ctor);
+ mode = TYPE_MODE (type);
+ store_constructor_field (target,
+ bitsize * RAW_DATA_LENGTH (value),
+ bitpos, 0, bitregion_end, mode,
+ ctor, cleared,
+ get_alias_set (elttype), reverse);
+ }
}
}
break;
--- /dev/null
+struct S { unsigned char s[256]; };
+extern S a;
+struct T { unsigned char t[2048]; };
+extern T c;
+extern const T d[1];
+extern void foo ();
+
+extern const S b[1] {
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
+ 129, 0 }
+};
+extern const T d[1] {
+ { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+ 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
+ 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
+ 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128 }
+};
+
+int
+main ()
+{
+ foo ();
+ for (int i = 0; i < 256; ++i)
+ if (a.s[i] != (i < 129 ? i + 1 : 0))
+ __builtin_abort ();
+ for (int i = 0; i < 2048; ++i)
+ if (c.t[i] != (i < 512 ? (i & 127) + 1 : 0))
+ __builtin_abort ();
+}