Changes for GCC version 3.0 for GNU Pascal 2.1 Before applying these diffs, go to the directory gcc-3.0 and use the command patch -p1 feeding it the following diffs as input. *** gcc-3.0/expr.c.orig Thu May 31 12:23:42 2001 --- gcc-3.0/expr.c Thu May 31 13:12:42 2001 *************** along with GNU CC; see the file COPYING. *** 19,24 **** --- 19,27 ---- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + /* @@ PATCHED FOR GPC @@ */ + #include "config.h" #include "system.h" #include "machmode.h" *************** store_constructor (exp, target, align, c *** 4841,4846 **** --- 4844,4859 ---- domain_min = convert (sizetype, TYPE_MIN_VALUE (domain)); domain_max = convert (sizetype, TYPE_MAX_VALUE (domain)); + + /* Align the set. */ + if (set_alignment) + domain_min = size_binop (MINUS_EXPR, domain_min, + size_binop (TRUNC_MOD_EXPR, domain_min, + size_int (set_alignment))); + bitlength = size_binop (PLUS_EXPR, + size_diffop (domain_max, domain_min), + ssize_int (1)); + bitlength = size_binop (PLUS_EXPR, size_diffop (domain_max, domain_min), ssize_int (1)); *************** store_constructor (exp, target, align, c *** 4853,4859 **** if (GET_MODE (target) != BLKmode || nbits <= 2 * BITS_PER_WORD || (nbytes <= 32 && TREE_CHAIN (elt) != NULL_TREE)) { - unsigned int set_word_size = TYPE_ALIGN (TREE_TYPE (exp)); enum machine_mode mode = mode_for_size (set_word_size, MODE_INT, 1); char *bit_buffer = (char *) alloca (nbits); HOST_WIDE_INT word = 0; --- 4866,4871 ---- *************** store_constructor (exp, target, align, c *** 4866,4872 **** { if (bit_buffer[ibit]) { ! if (BYTES_BIG_ENDIAN) word |= (1 << (set_word_size - 1 - bit_pos)); else word |= 1 << bit_pos; --- 4878,4884 ---- { if (bit_buffer[ibit]) { ! if (set_words_big_endian) word |= (1 << (set_word_size - 1 - bit_pos)); else word |= 1 << bit_pos; *************** store_constructor (exp, target, align, c *** 4983,4988 **** --- 4995,5005 ---- } else #endif + /* The language-specific run time library must provide + a suitable '_setbifts()' function whose action coincides + with the values of 'set_word_size', 'set_alignment', and + 'set_words_big_endian;. */ + emit_library_call (gen_rtx_SYMBOL_REF (Pmode, "__setbits"), LCT_NORMAL, VOIDmode, 4, XEXP (targetx, 0), Pmode, bitlength_rtx, TYPE_MODE (sizetype), *** gcc-3.0/fold-const.c.orig Thu May 31 12:24:39 2001 --- gcc-3.0/fold-const.c Thu May 31 12:41:49 2001 *************** along with GNU CC; see the file COPYING. *** 19,24 **** --- 19,26 ---- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* @@ PATCHED FOR GPC @@ */ + /*@@ This file should be rewritten to use an arbitrary precision @@ representation for "struct tree_int_cst" and "struct tree_real_cst". @@ Perhaps the routines could also be used for bc/dc, and made a lib. *************** int_const_binop (code, arg1, arg2, notru *** 1619,1626 **** } TREE_OVERFLOW (t) ! = ((notrunc ? (!uns || forsize) && overflow ! : force_fit_type (t, (!uns || forsize) && overflow) && ! no_overflow) | TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2)); --- 1621,1627 ---- } TREE_OVERFLOW (t) ! = ((notrunc ? overflow : force_fit_type (t, overflow)) | TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2)); *** gcc-3.0/stor-layout.c.orig Thu May 31 12:26:01 2001 --- gcc-3.0/stor-layout.c Thu May 31 12:42:14 2001 *************** along with GNU CC; see the file COPYING. *** 19,24 **** --- 19,26 ---- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* @@ PATCHED FOR GPC @@ */ + #include "config.h" #include "system.h" *************** unsigned int maximum_field_alignment; *** 50,55 **** --- 52,68 ---- May be overridden by front-ends. */ unsigned int set_alignment = 0; + /* The word size of a bitstring or (power-)set value, in bits. + Must be non-zero. + May be overridden by front-ends. */ + unsigned int set_word_size = BITS_PER_UNIT; + + /* If non-zero, bits in (power-)sets start wth the highest bit. + May be overridden by front-ends. + In order to be backward-compatible, the Chill frontend should + initialize this to BYTES_BIG_ENDIAN. */ + unsigned int set_words_big_endian = 0; + /* Nonzero if all REFERENCE_TYPEs are internal and hence should be allocated in Pmode, not ptr_mode. Set only by internal_reference_types called only by a front end. */ *************** layout_type (type) *** 1480,1494 **** abort(); else { ! #ifndef SET_WORD_SIZE ! #define SET_WORD_SIZE BITS_PER_WORD ! #endif ! unsigned int alignment ! = set_alignment ? set_alignment : SET_WORD_SIZE; ! int size_in_bits ! = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) ! - TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1); ! int rounded_size = ((size_in_bits + alignment - 1) / alignment) * alignment; if (rounded_size > (int) alignment) --- 1493,1510 ---- abort(); else { ! int alignment = set_alignment ? set_alignment : set_word_size; ! int lower_bound = TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))); ! int upper_bound = TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type))); ! int size_in_bits, rounded_size; ! if (set_alignment) ! size_in_bits = upper_bound - (lower_bound / alignment) * alignment + 1; ! else ! size_in_bits ! = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) ! - TREE_INT_CST_LOW (TYPE_MIN_VALUE (TYPE_DOMAIN (type))) + 1); ! ! rounded_size = ((size_in_bits + alignment - 1) / alignment) * alignment; if (rounded_size > (int) alignment) *** gcc-3.0/tree.c.orig Thu May 31 12:37:22 2001 --- gcc-3.0/tree.c Thu May 31 12:42:48 2001 *************** along with GNU CC; see the file COPYING. *** 19,24 **** --- 19,26 ---- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* @@ PATCHED FOR GPC @@ */ + /* This file contains the low level primitives for operating on tree nodes, including allocation, list operations, interning of identifiers, construction of data type nodes and statement nodes, *************** get_set_constructor_bits (init, buffer, *** 4638,4643 **** --- 4640,4649 ---- = tree_low_cst (TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (init))), 0); tree non_const_bits = NULL_TREE; + /* Align the set. */ + if (set_alignment) + domain_min -= domain_min % set_alignment; + for (i = 0; i < bit_size; i++) buffer[i] = 0; *************** get_set_constructor_bytes (init, buffer, *** 4691,4698 **** --- 4697,4708 ---- int wd_size; { int i; + #ifdef GPC + int bit_size = wd_size * BITS_PER_UNIT; + #else /* not GPC */ int set_word_size = BITS_PER_UNIT; int bit_size = wd_size * set_word_size; + #endif /* not GPC */ int bit_pos = 0; unsigned char *bytep = buffer; char *bit_buffer = (char *) alloca (bit_size); *************** get_set_constructor_bytes (init, buffer, *** 4703,4708 **** --- 4713,4730 ---- for (i = 0; i < bit_size; i++) { + #ifdef GPC + if (bit_buffer[i]) + { + int k = bit_pos / BITS_PER_UNIT; + if (WORDS_BIG_ENDIAN) + k = set_word_size / BITS_PER_UNIT - 1 - K; + if (set_words_big_endian) + bytep[k] |= (1 << (BITS_PER_UNIT - 1 - bit_pos % BITS_PER_UNIT)); + else + bytep[k] |= (1 << (bit_pos % BITS_PER_UNIT)); + } + #else /* not GPC */ if (bit_buffer[i]) { if (BYTES_BIG_ENDIAN) *************** get_set_constructor_bytes (init, buffer, *** 4713,4718 **** --- 4735,4741 ---- bit_pos++; if (bit_pos >= set_word_size) bit_pos = 0, bytep++; + #endif /* not GPC */ } return non_const_bits; } *** gcc-3.0/tree.h.orig Thu May 31 12:37:37 2001 --- gcc-3.0/tree.h Thu May 31 13:05:40 2001 *************** along with GNU CC; see the file COPYING. *** 19,24 **** --- 19,26 ---- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* @@ PATCHED FOR GPC @@ */ + #include "machmode.h" #include "version.h" *************** extern unsigned int maximum_field_alignm *** 2236,2241 **** --- 2238,2249 ---- /* If non-zero, the alignment of a bitstring or (power-)set value, in bits. */ extern unsigned int set_alignment; + + /* The word size of a bitstring or (power-)set-value, in bits. */ + extern unsigned int set_word_size; + + /* If non-zero, bits in (power-)sets start with the highest bit. */ + extern unsigned int set_words_big_endian; /* Concatenate two lists (chains of TREE_LIST nodes) X and Y by making the last node in X point to Y. *** gcc-3.0/tree.def.orig Thu May 31 12:38:09 2001 --- gcc-3.0/tree.def Thu May 31 12:43:01 2001 *************** along with GNU CC; see the file COPYING. *** 19,24 **** --- 19,25 ---- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + /* @@ PATCHED FOR GPC @@ */ /* The third argument can be: 'x' for an exceptional code (fits no category). *************** DEFTREECODE (CLEANUP_POINT_EXPR, "cleanu *** 499,505 **** some field in an object of the type contains a value that is used in the computation of another field's offset or size and/or the size of the type. The positions and/or sizes of fields can vary from object ! to object of the same type. Record types with discriminants in Ada or schema types in Pascal are examples of such types. This mechanism is also used to create "fat --- 500,507 ---- some field in an object of the type contains a value that is used in the computation of another field's offset or size and/or the size of the type. The positions and/or sizes of fields can vary from object ! to object of the same type or even for one and the same object within . ! its scope. Record types with discriminants in Ada or schema types in Pascal are examples of such types. This mechanism is also used to create "fat *************** DEFTREECODE (CLEANUP_POINT_EXPR, "cleanu *** 523,529 **** For example, if your type FOO is a RECORD_TYPE with a field BAR, and you need the value of .BAR to calculate TYPE_SIZE (FOO), just substitute above with a PLACEHOLDER_EXPR ! what contains both the expression we wish to evaluate and an expression within which the object may be found. The latter expression is the object itself in the simple case of an Ada record with discriminant, but it can be the array in the case of --- 525,540 ---- For example, if your type FOO is a RECORD_TYPE with a field BAR, and you need the value of .BAR to calculate TYPE_SIZE (FOO), just substitute above with a PLACEHOLDER_EXPR ! whose TREE_TYPE is FOO. Then construct your COMPONENT_REF with ! the PLACEHOLDER_EXPR as the first operand (which has the correct ! type). Later, when the size is needed in the program, the back-end ! will find this PLACEHOLDER_EXPR and generate code to calculate the ! actual size at run-time. In the following, we describe how this ! calculation is done. ! ! When we wish to evaluate a size or offset, we check whether it ! contains a PLACEHOLDER_EXPR. If it does, we construct a ! WITH_RECORDF_EXPR that contains both the expression we wish to evaluate and an expression within which the object may be found. The latter expression is the object itself in the simple case of an Ada record with discriminant, but it can be the array in the case of