OpenCores
URL https://opencores.org/ocsvn/zipcpu/zipcpu/trunk

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [sw/] [gcc-zippatch.patch] - Blame information for rev 192

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 102 dgisselq
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/config.sub gcc-5.3.0-zip/config.sub
2
--- gcc-5.3.0-original/config.sub       2015-01-02 04:30:21.000000000 -0500
3
+++ gcc-5.3.0-zip/config.sub    2016-01-30 12:27:56.023073747 -0500
4
@@ -316,7 +316,7 @@
5
        | visium \
6
        | we32k \
7
        | x86 | xc16x | xstormy16 | xtensa \
8
-       | z8k | z80)
9
+       | z8k | z80 | zip)
10
                basic_machine=$basic_machine-unknown
11
                ;;
12
        c54x)
13
@@ -1547,6 +1547,9 @@
14
 # system, and we'll never get to this point.
15
 
16
 case $basic_machine in
17
+       zip-*)
18
+               os=-elf
19
+               ;;
20
        score-*)
21
                os=-elf
22
                ;;
23
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/configure gcc-5.3.0-zip/configure
24
--- gcc-5.3.0-original/configure        2015-05-03 13:29:57.000000000 -0400
25
+++ gcc-5.3.0-zip/configure     2016-01-30 16:19:48.264867231 -0500
26
@@ -3927,6 +3927,8 @@
27
   vax-*-*)
28
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
29
     ;;
30
+  zip*)
31
+    noconfigdirs="$noconfigdirs target-libffi target-boehm-gc gdb gprof"
32
 esac
33
 
34
 # If we aren't building newlib, then don't build libgloss, since libgloss
35
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/configure.ac gcc-5.3.0-zip/configure.ac
36
--- gcc-5.3.0-original/configure.ac     2015-05-03 13:29:57.000000000 -0400
37
+++ gcc-5.3.0-zip/configure.ac  2016-02-12 10:47:23.847194843 -0500
38
@@ -1274,6 +1274,10 @@
39
   vax-*-*)
40
     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
41
     ;;
42
+  zip*)
43
+    noconfigdirs="$noconfigdirs target-libffi target-boehm-gc gdb gprof"
44
+    unsupported_languages="$unsupported_languages fortran java"
45
+    ;;
46
 esac
47
 
48
 # If we aren't building newlib, then don't build libgloss, since libgloss
49 117 dgisselq
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/cfgexpand.c gcc-5.3.0-zip/gcc/cfgexpand.c
50
--- gcc-5.3.0-original/gcc/cfgexpand.c  2015-07-23 06:39:26.000000000 -0400
51
+++ gcc-5.3.0-zip/gcc/cfgexpand.c       2016-04-01 06:40:17.288326711 -0400
52
@@ -108,6 +108,14 @@
53
 #include "tree-chkp.h"
54
 #include "rtl-chkp.h"
55
 
56
+#ifdef DO_ZIP_DEBUGS
57
+#include <stdio.h>
58
+#define ZIP_DEBUG_LINE(STR,RTX) do{fprintf(stderr,"%s:%d/%s\n",__FILE__,__LINE__,STR); zip_debug_rtx(RTX);} while(0)
59
+extern void    zip_debug_rtx(const_rtx);
60
+#else
61
+#define        ZIP_DEBUG_LINE(STR,RTX)
62
+#endif
63
+
64
 /* Some systems use __main in a way incompatible with its use in gcc, in these
65
    cases use the macros NAME__MAIN to give a quoted symbol and SYMBOL__MAIN to
66
    give the same symbol without quotes for an alternative entry point.  You
67 111 dgisselq
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/cgraphbuild.c gcc-5.3.0-zip/gcc/cgraphbuild.c
68
--- gcc-5.3.0-original/gcc/cgraphbuild.c        2015-01-09 15:18:42.000000000 -0500
69
+++ gcc-5.3.0-zip/gcc/cgraphbuild.c     2016-03-24 22:13:24.815287808 -0400
70
@@ -62,6 +62,13 @@
71
 #include "ipa-prop.h"
72
 #include "ipa-inline.h"
73
 
74
+#ifdef DO_ZIP_DEBUGS
75
+extern void zip_debug_rtx(const_rtx);
76
+#define        ZIP_DEBUG_LINE(STR,RTX) do { fprintf(stderr, "%s:%d/%s\n", __FILE__,__LINE__,STR); zip_debug_rtx(RTX); } while(0)
77
+#else
78
+#define        ZIP_DEBUG_LINE(STR,RTX)
79
+#endif
80
+
81
 /* Context of record_reference.  */
82
 struct record_reference_ctx
83
 {
84 102 dgisselq
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/common/config/zip/zip-common.c gcc-5.3.0-zip/gcc/common/config/zip/zip-common.c
85
--- gcc-5.3.0-original/gcc/common/config/zip/zip-common.c       1969-12-31 19:00:00.000000000 -0500
86
+++ gcc-5.3.0-zip/gcc/common/config/zip/zip-common.c    2016-02-14 00:54:31.821055716 -0500
87
@@ -0,0 +1,52 @@
88
+////////////////////////////////////////////////////////////////////////////////
89
+//
90
+// Filename:   common/config/zip/zip-common.c
91
+//
92
+// Project:    Zip CPU backend for the GNU Compiler Collection
93
+//
94
+// Purpose:    To eliminate the frame register automatically.
95
+//
96
+// Creator:    Dan Gisselquist, Ph.D.
97
+//             Gisselquist Technology, LLC
98
+//
99
+////////////////////////////////////////////////////////////////////////////////
100
+//
101
+// Copyright (C) 2016, Gisselquist Technology, LLC
102
+//
103
+// This program is free software (firmware): you can redistribute it and/or
104
+// modify it under the terms of  the GNU General Public License as published
105
+// by the Free Software Foundation, either version 3 of the License, or (at
106
+// your option) any later version.
107
+//
108
+// This program is distributed in the hope that it will be useful, but WITHOUT
109
+// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
110
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
111
+// for more details.
112
+//
113
+// You should have received a copy of the GNU General Public License along
114
+// with this program.  (It's in the $(ROOT)/doc directory, run make with no
115
+// target there if the PDF file isn't present.)  If not, see
116
+// <http://www.gnu.org/licenses/> for a copy.
117
+//
118
+// License:    GPL, v3, as defined and found on www.gnu.org,
119
+//             http://www.gnu.org/licenses/gpl.html
120
+//
121
+//
122
+////////////////////////////////////////////////////////////////////////////////
123
+#include "config.h"
124
+#include "system.h"
125
+#include "coretypes.h"
126
+#include "tm.h"
127
+#include "common/common-target.h"
128
+#include "common/common-target-def.h"
129
+
130
+static const struct default_options zip_option_optimization_table[] =
131
+  {
132
+    { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },
133
+    { OPT_LEVELS_NONE, 0, NULL, 0 }
134
+  };
135
+
136
+#undef TARGET_OPTION_OPTIMIZATION_TABLE
137
+#define        TARGET_OPTION_OPTIMIZATION_TABLE        zip_option_optimization_table
138
+
139
+struct gcc_targetm_common      targetm_common = TARGETM_COMMON_INITIALIZER;
140
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/aarch64/aarch64-linux.h gcc-5.3.0-zip/gcc/config/aarch64/aarch64-linux.h
141 192 dgisselq
--- gcc-5.3.0-original/gcc/config/aarch64/aarch64-linux.h       2016-11-03 13:52:45.187664099 -0400
142 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/aarch64/aarch64-linux.h    2015-07-24 12:00:26.000000000 -0400
143
@@ -21,7 +21,7 @@
144
 #ifndef GCC_AARCH64_LINUX_H
145
 #define GCC_AARCH64_LINUX_H
146
 
147
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
148
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
149
 
150
 #undef  ASAN_CC1_SPEC
151
 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
152
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/alpha/linux-elf.h gcc-5.3.0-zip/gcc/config/alpha/linux-elf.h
153 192 dgisselq
--- gcc-5.3.0-original/gcc/config/alpha/linux-elf.h     2016-11-03 13:52:45.203663997 -0400
154 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/alpha/linux-elf.h  2015-01-05 07:33:28.000000000 -0500
155
@@ -23,8 +23,8 @@
156
 #define EXTRA_SPECS \
157
 { "elf_dynamic_linker", ELF_DYNAMIC_LINKER },
158
 
159
-#define GLIBC_DYNAMIC_LINKER   "/tools/lib/ld-linux.so.2"
160
-#define UCLIBC_DYNAMIC_LINKER "/tools/lib/ld-uClibc.so.0"
161
+#define GLIBC_DYNAMIC_LINKER   "/lib/ld-linux.so.2"
162
+#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
163
 #if DEFAULT_LIBC == LIBC_UCLIBC
164
 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
165
 #elif DEFAULT_LIBC == LIBC_GLIBC
166
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/arm/linux-eabi.h gcc-5.3.0-zip/gcc/config/arm/linux-eabi.h
167 192 dgisselq
--- gcc-5.3.0-original/gcc/config/arm/linux-eabi.h      2016-11-03 13:52:45.203663997 -0400
168 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/arm/linux-eabi.h   2015-01-05 07:33:28.000000000 -0500
169
@@ -68,8 +68,8 @@
170
    GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI.  */
171
 
172
 #undef  GLIBC_DYNAMIC_LINKER
173
-#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/tools/lib/ld-linux.so.3"
174
-#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/tools/lib/ld-linux-armhf.so.3"
175
+#define GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "/lib/ld-linux.so.3"
176
+#define GLIBC_DYNAMIC_LINKER_HARD_FLOAT "/lib/ld-linux-armhf.so.3"
177
 #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
178
 
179
 #define GLIBC_DYNAMIC_LINKER \
180
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/arm/linux-elf.h gcc-5.3.0-zip/gcc/config/arm/linux-elf.h
181 192 dgisselq
--- gcc-5.3.0-original/gcc/config/arm/linux-elf.h       2016-11-03 13:52:45.203663997 -0400
182 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/arm/linux-elf.h    2015-06-23 05:26:54.000000000 -0400
183
@@ -62,7 +62,7 @@
184
 
185
 #define LIBGCC_SPEC "%{mfloat-abi=soft*:-lfloat} -lgcc"
186
 
187
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld-linux.so.2"
188
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
189
 
190
 #define LINUX_TARGET_LINK_SPEC  "%{h*} \
191
    %{static:-Bstatic} \
192
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/bfin/linux.h gcc-5.3.0-zip/gcc/config/bfin/linux.h
193 192 dgisselq
--- gcc-5.3.0-original/gcc/config/bfin/linux.h  2016-11-03 13:52:45.203663997 -0400
194 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/bfin/linux.h       2015-01-05 07:33:28.000000000 -0500
195
@@ -45,7 +45,7 @@
196
   %{shared:-G -Bdynamic} \
197
   %{!shared: %{!static: \
198
    %{rdynamic:-export-dynamic} \
199
-   -dynamic-linker /tools/lib/ld-uClibc.so.0} \
200
+   -dynamic-linker /lib/ld-uClibc.so.0} \
201
    %{static}} -init __init -fini __fini"
202
 
203
 #undef TARGET_SUPPORTS_SYNC_CALLS
204
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/cris/linux.h gcc-5.3.0-zip/gcc/config/cris/linux.h
205 192 dgisselq
--- gcc-5.3.0-original/gcc/config/cris/linux.h  2016-11-03 13:52:45.203663997 -0400
206 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/cris/linux.h       2015-01-05 07:33:28.000000000 -0500
207
@@ -102,7 +102,7 @@
208
 #undef CRIS_DEFAULT_CPU_VERSION
209
 #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_NG
210
 
211
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
212
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
213
 
214
 #undef CRIS_LINK_SUBTARGET_SPEC
215
 #define CRIS_LINK_SUBTARGET_SPEC \
216
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/freebsd-spec.h gcc-5.3.0-zip/gcc/config/freebsd-spec.h
217 192 dgisselq
--- gcc-5.3.0-original/gcc/config/freebsd-spec.h        2016-11-03 13:52:45.203663997 -0400
218 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/freebsd-spec.h     2015-06-25 13:53:14.000000000 -0400
219
@@ -129,9 +129,9 @@
220
 #endif
221
 
222
 #if FBSD_MAJOR < 6
223
-#define FBSD_DYNAMIC_LINKER "/tools/libexec/ld-elf.so.1"
224
+#define FBSD_DYNAMIC_LINKER "/usr/libexec/ld-elf.so.1"
225
 #else
226
-#define FBSD_DYNAMIC_LINKER "/tools/libexec/ld-elf.so.1"
227
+#define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1"
228
 #endif
229
 
230
 /* NOTE: The freebsd-spec.h header is included also for various
231
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/frv/linux.h gcc-5.3.0-zip/gcc/config/frv/linux.h
232 192 dgisselq
--- gcc-5.3.0-original/gcc/config/frv/linux.h   2016-11-03 13:52:45.203663997 -0400
233 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/frv/linux.h        2015-01-05 07:33:28.000000000 -0500
234
@@ -34,7 +34,7 @@
235
 #define ENDFILE_SPEC \
236
   "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s"
237
 
238
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
239
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
240
 
241
 #undef LINK_SPEC
242
 #define LINK_SPEC "\
243
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/i386/gnu.h gcc-5.3.0-zip/gcc/config/i386/gnu.h
244 192 dgisselq
--- gcc-5.3.0-original/gcc/config/i386/gnu.h    2016-11-03 13:52:45.203663997 -0400
245 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/i386/gnu.h 2015-01-05 07:33:28.000000000 -0500
246
@@ -22,7 +22,7 @@
247
 #define GNU_USER_LINK_EMULATION "elf_i386"
248
 
249
 #undef GNU_USER_DYNAMIC_LINKER
250
-#define GNU_USER_DYNAMIC_LINKER "/tools/lib/ld.so"
251
+#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so"
252
 
253
 #undef STARTFILE_SPEC
254
 #if defined HAVE_LD_PIE
255
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/i386/kfreebsd-gnu64.h gcc-5.3.0-zip/gcc/config/i386/kfreebsd-gnu64.h
256 192 dgisselq
--- gcc-5.3.0-original/gcc/config/i386/kfreebsd-gnu64.h 2016-11-03 13:52:45.203663997 -0400
257 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/i386/kfreebsd-gnu64.h      2015-01-05 07:33:28.000000000 -0500
258
@@ -22,6 +22,6 @@
259
 #define GNU_USER_LINK_EMULATION64 "elf_x86_64_fbsd"
260
 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64_fbsd"
261
 
262
-#define GLIBC_DYNAMIC_LINKER32 "/tools/lib/ld.so.1"
263
-#define GLIBC_DYNAMIC_LINKER64 "/tools/lib/ld-kfreebsd-x86-64.so.1"
264
-#define GLIBC_DYNAMIC_LINKERX32 "/tools/lib/ld-kfreebsd-x32.so.1"
265
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
266
+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-kfreebsd-x86-64.so.1"
267
+#define GLIBC_DYNAMIC_LINKERX32 "/lib/ld-kfreebsd-x32.so.1"
268
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/i386/kfreebsd-gnu.h gcc-5.3.0-zip/gcc/config/i386/kfreebsd-gnu.h
269 192 dgisselq
--- gcc-5.3.0-original/gcc/config/i386/kfreebsd-gnu.h   2016-11-03 13:52:45.203663997 -0400
270 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/i386/kfreebsd-gnu.h        2015-01-05 07:33:28.000000000 -0500
271
@@ -19,4 +19,4 @@
272
 <http://www.gnu.org/licenses/>.  */
273
 
274
 #define GNU_USER_LINK_EMULATION "elf_i386_fbsd"
275
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
276
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
277
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/i386/linux64.h gcc-5.3.0-zip/gcc/config/i386/linux64.h
278 192 dgisselq
--- gcc-5.3.0-original/gcc/config/i386/linux64.h        2016-11-03 13:52:45.203663997 -0400
279 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/i386/linux64.h     2015-01-05 07:33:28.000000000 -0500
280
@@ -27,6 +27,6 @@
281
 #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
282
 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
283
 
284
-#define GLIBC_DYNAMIC_LINKER32 "/tools/lib/ld-linux.so.2"
285
-#define GLIBC_DYNAMIC_LINKER64 "/tools/lib64/ld-linux-x86-64.so.2"
286
-#define GLIBC_DYNAMIC_LINKERX32 "/tools/libx32/ld-linux-x32.so.2"
287
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
288
+#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
289
+#define GLIBC_DYNAMIC_LINKERX32 "/libx32/ld-linux-x32.so.2"
290
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/i386/linux.h gcc-5.3.0-zip/gcc/config/i386/linux.h
291 192 dgisselq
--- gcc-5.3.0-original/gcc/config/i386/linux.h  2016-11-03 13:52:45.203663997 -0400
292 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/i386/linux.h       2015-01-05 07:33:28.000000000 -0500
293
@@ -20,4 +20,4 @@
294
 <http://www.gnu.org/licenses/>.  */
295
 
296
 #define GNU_USER_LINK_EMULATION "elf_i386"
297
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld-linux.so.2"
298
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
299
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/ia64/linux.h gcc-5.3.0-zip/gcc/config/ia64/linux.h
300 192 dgisselq
--- gcc-5.3.0-original/gcc/config/ia64/linux.h  2016-11-03 13:52:45.203663997 -0400
301 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/ia64/linux.h       2015-01-05 07:33:28.000000000 -0500
302
@@ -55,7 +55,7 @@
303
 /* Define this for shared library support because it isn't in the main
304
    linux.h file.  */
305
 
306
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld-linux-ia64.so.2"
307
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
308
 
309
 #undef LINK_SPEC
310
 #define LINK_SPEC "\
311
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/knetbsd-gnu.h gcc-5.3.0-zip/gcc/config/knetbsd-gnu.h
312 192 dgisselq
--- gcc-5.3.0-original/gcc/config/knetbsd-gnu.h 2016-11-03 13:52:45.203663997 -0400
313 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/knetbsd-gnu.h      2015-01-05 07:33:28.000000000 -0500
314
@@ -32,4 +32,4 @@
315
 
316
 
317
 #undef GNU_USER_DYNAMIC_LINKER
318
-#define GNU_USER_DYNAMIC_LINKER "/tools/lib/ld.so.1"
319
+#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
320
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/kopensolaris-gnu.h gcc-5.3.0-zip/gcc/config/kopensolaris-gnu.h
321 192 dgisselq
--- gcc-5.3.0-original/gcc/config/kopensolaris-gnu.h    2016-11-03 13:52:45.203663997 -0400
322 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/kopensolaris-gnu.h 2015-01-05 07:33:28.000000000 -0500
323
@@ -31,5 +31,4 @@
324
   while (0)
325
 
326
 #undef GNU_USER_DYNAMIC_LINKER
327
-#define GNU_USER_DYNAMIC_LINKER "/tools/lib/ld.so.1"
328
-
329
+#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
330
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/linux.h gcc-5.3.0-zip/gcc/config/linux.h
331 192 dgisselq
--- gcc-5.3.0-original/gcc/config/linux.h       2016-11-03 13:52:45.203663997 -0400
332 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/linux.h    2015-01-05 07:33:28.000000000 -0500
333
@@ -73,10 +73,10 @@
334
    GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
335
    GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
336
    supporting both 32-bit and 64-bit compilation.  */
337
-#define UCLIBC_DYNAMIC_LINKER "/tools/lib/ld-uClibc.so.0"
338
-#define UCLIBC_DYNAMIC_LINKER32 "/tools/lib/ld-uClibc.so.0"
339
-#define UCLIBC_DYNAMIC_LINKER64 "/tools/lib/ld64-uClibc.so.0"
340
-#define UCLIBC_DYNAMIC_LINKERX32 "/tools/lib/ldx32-uClibc.so.0"
341
+#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
342
+#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
343
+#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
344
+#define UCLIBC_DYNAMIC_LINKERX32 "/lib/ldx32-uClibc.so.0"
345
 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
346
 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
347
 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
348
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/lm32/uclinux-elf.h gcc-5.3.0-zip/gcc/config/lm32/uclinux-elf.h
349 192 dgisselq
--- gcc-5.3.0-original/gcc/config/lm32/uclinux-elf.h    2016-11-03 13:52:45.203663997 -0400
350 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/lm32/uclinux-elf.h 2015-01-05 07:33:28.000000000 -0500
351
@@ -67,7 +67,7 @@
352
    %{shared:-shared} \
353
    %{symbolic:-Bsymbolic} \
354
    %{rdynamic:-export-dynamic} \
355
-   -dynamic-linker /tools/lib/ld-linux.so.2"
356
+   -dynamic-linker /lib/ld-linux.so.2"
357
 
358
 #define TARGET_OS_CPP_BUILTINS() GNU_USER_TARGET_OS_CPP_BUILTINS()
359
 
360
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/m68k/linux.h gcc-5.3.0-zip/gcc/config/m68k/linux.h
361 192 dgisselq
--- gcc-5.3.0-original/gcc/config/m68k/linux.h  2016-11-03 13:52:45.203663997 -0400
362 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/m68k/linux.h       2015-01-05 07:33:28.000000000 -0500
363
@@ -71,7 +71,7 @@
364
    When the -shared link option is used a final link is not being
365
    done.  */
366
 
367
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
368
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
369
 
370
 #undef LINK_SPEC
371
 #define LINK_SPEC "-m m68kelf %{shared} \
372
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/microblaze/linux.h gcc-5.3.0-zip/gcc/config/microblaze/linux.h
373 192 dgisselq
--- gcc-5.3.0-original/gcc/config/microblaze/linux.h    2016-11-03 13:52:45.203663997 -0400
374 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/microblaze/linux.h 2015-05-28 10:08:19.000000000 -0400
375
@@ -28,7 +28,7 @@
376
 #undef TLS_NEEDS_GOT
377
 #define TLS_NEEDS_GOT 1
378
 
379
-#define DYNAMIC_LINKER "/tools/lib/ld.so.1"
380
+#define DYNAMIC_LINKER "/lib/ld.so.1"
381
 #undef  SUBTARGET_EXTRA_SPECS
382
 #define SUBTARGET_EXTRA_SPECS \
383
   { "dynamic_linker", DYNAMIC_LINKER }
384
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/mips/linux.h gcc-5.3.0-zip/gcc/config/mips/linux.h
385 192 dgisselq
--- gcc-5.3.0-original/gcc/config/mips/linux.h  2016-11-03 13:52:45.203663997 -0400
386 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/mips/linux.h       2015-01-05 07:33:28.000000000 -0500
387
@@ -22,20 +22,20 @@
388
 #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
389
 
390
 #define GLIBC_DYNAMIC_LINKER32 \
391
-  "%{mnan=2008:/tools/lib/ld-linux-mipsn8.so.1;:/tools/lib/ld.so.1}"
392
+  "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
393
 #define GLIBC_DYNAMIC_LINKER64 \
394
-  "%{mnan=2008:/tools/lib64/ld-linux-mipsn8.so.1;:/tools/lib64/ld.so.1}"
395
+  "%{mnan=2008:/lib64/ld-linux-mipsn8.so.1;:/lib64/ld.so.1}"
396
 #define GLIBC_DYNAMIC_LINKERN32 \
397
-  "%{mnan=2008:/tools/lib32/ld-linux-mipsn8.so.1;:/tools/lib32/ld.so.1}"
398
+  "%{mnan=2008:/lib32/ld-linux-mipsn8.so.1;:/lib32/ld.so.1}"
399
 
400
 #undef UCLIBC_DYNAMIC_LINKER32
401
 #define UCLIBC_DYNAMIC_LINKER32 \
402
-  "%{mnan=2008:/tools/lib/ld-uClibc-mipsn8.so.0;:/tools/lib/ld-uClibc.so.0}"
403
+  "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
404
 #undef UCLIBC_DYNAMIC_LINKER64
405
 #define UCLIBC_DYNAMIC_LINKER64 \
406
-  "%{mnan=2008:/tools/lib/ld64-uClibc-mipsn8.so.0;:/tools/lib/ld64-uClibc.so.0}"
407
+  "%{mnan=2008:/lib/ld64-uClibc-mipsn8.so.0;:/lib/ld64-uClibc.so.0}"
408
 #define UCLIBC_DYNAMIC_LINKERN32 \
409
-  "%{mnan=2008:/tools/lib32/ld-uClibc-mipsn8.so.0;:/tools/lib32/ld-uClibc.so.0}"
410
+  "%{mnan=2008:/lib32/ld-uClibc-mipsn8.so.0;:/lib32/ld-uClibc.so.0}"
411
 
412
 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
413
 #define GNU_USER_DYNAMIC_LINKERN32 \
414
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/mn10300/linux.h gcc-5.3.0-zip/gcc/config/mn10300/linux.h
415 192 dgisselq
--- gcc-5.3.0-original/gcc/config/mn10300/linux.h       2016-11-03 13:52:45.203663997 -0400
416 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/mn10300/linux.h    2015-01-05 07:33:28.000000000 -0500
417
@@ -32,7 +32,7 @@
418
 #undef  ASM_SPEC
419
 #define ASM_SPEC ""
420
 
421
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
422
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
423
 
424
 #undef  LINK_SPEC
425
 #define LINK_SPEC "%{mrelax:--relax} %{shared:-shared} \
426
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/pa/pa-linux.h gcc-5.3.0-zip/gcc/config/pa/pa-linux.h
427 192 dgisselq
--- gcc-5.3.0-original/gcc/config/pa/pa-linux.h 2016-11-03 13:52:45.203663997 -0400
428 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/pa/pa-linux.h      2015-09-24 20:04:26.000000000 -0400
429
@@ -37,7 +37,7 @@
430
 /* Define this for shared library support because it isn't in the main
431
    linux.h file.  */
432
 
433
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
434
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
435
 
436
 #undef LINK_SPEC
437
 #define LINK_SPEC "\
438
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/rs6000/linux64.h gcc-5.3.0-zip/gcc/config/rs6000/linux64.h
439 192 dgisselq
--- gcc-5.3.0-original/gcc/config/rs6000/linux64.h      2016-11-03 13:52:45.203663997 -0400
440 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/rs6000/linux64.h   2015-03-09 19:18:57.000000000 -0400
441
@@ -357,14 +357,14 @@
442
 #undef LINK_OS_DEFAULT_SPEC
443
 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
444
 
445
-#define GLIBC_DYNAMIC_LINKER32 "/tools/lib/ld.so.1"
446
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
447
 #ifdef LINUX64_DEFAULT_ABI_ELFv2
448
-#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:/tools/lib64/ld64.so.1;:/tools/lib64/ld64.so.2}"
449
+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv1:/lib64/ld64.so.1;:/lib64/ld64.so.2}"
450
 #else
451
-#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:/tools/lib64/ld64.so.2;:/tools/lib64/ld64.so.1}"
452
+#define GLIBC_DYNAMIC_LINKER64 "%{mabi=elfv2:/lib64/ld64.so.2;:/lib64/ld64.so.1}"
453
 #endif
454
-#define UCLIBC_DYNAMIC_LINKER32 "/tools/lib/ld-uClibc.so.0"
455
-#define UCLIBC_DYNAMIC_LINKER64 "/tools/lib/ld64-uClibc.so.0"
456
+#define UCLIBC_DYNAMIC_LINKER32 "/lib/ld-uClibc.so.0"
457
+#define UCLIBC_DYNAMIC_LINKER64 "/lib/ld64-uClibc.so.0"
458
 #if DEFAULT_LIBC == LIBC_UCLIBC
459
 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
460
 #elif DEFAULT_LIBC == LIBC_GLIBC
461
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/rs6000/sysv4.h gcc-5.3.0-zip/gcc/config/rs6000/sysv4.h
462 192 dgisselq
--- gcc-5.3.0-original/gcc/config/rs6000/sysv4.h        2016-11-03 13:52:45.203663997 -0400
463 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/rs6000/sysv4.h     2015-09-24 09:46:45.000000000 -0400
464
@@ -757,8 +757,8 @@
465
 
466
 #define LINK_START_LINUX_SPEC ""
467
 
468
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
469
-#define UCLIBC_DYNAMIC_LINKER "/tools/lib/ld-uClibc.so.0"
470
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
471
+#define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
472
 #if DEFAULT_LIBC == LIBC_UCLIBC
473
 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
474
 #elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
475
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/s390/linux.h gcc-5.3.0-zip/gcc/config/s390/linux.h
476 192 dgisselq
--- gcc-5.3.0-original/gcc/config/s390/linux.h  2016-11-03 13:52:45.203663997 -0400
477 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/s390/linux.h       2015-05-11 03:14:10.000000000 -0400
478
@@ -60,8 +60,8 @@
479
 #define MULTILIB_DEFAULTS { "m31" }
480
 #endif
481
 
482
-#define GLIBC_DYNAMIC_LINKER32 "/tools/lib/ld.so.1"
483
-#define GLIBC_DYNAMIC_LINKER64 "/tools/lib/ld64.so.1"
484
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
485
+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1"
486
 
487
 #undef  LINK_SPEC
488
 #define LINK_SPEC \
489
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/sh/linux.h gcc-5.3.0-zip/gcc/config/sh/linux.h
490 192 dgisselq
--- gcc-5.3.0-original/gcc/config/sh/linux.h    2016-11-03 13:52:45.203663997 -0400
491 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/sh/linux.h 2015-01-05 07:33:28.000000000 -0500
492
@@ -43,7 +43,7 @@
493
 
494
 #define TARGET_ASM_FILE_END file_end_indicate_exec_stack
495
 
496
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld-linux.so.2"
497
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
498
 
499
 #undef SUBTARGET_LINK_EMUL_SUFFIX
500
 #define SUBTARGET_LINK_EMUL_SUFFIX "_linux"
501
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/sparc/linux64.h gcc-5.3.0-zip/gcc/config/sparc/linux64.h
502 192 dgisselq
--- gcc-5.3.0-original/gcc/config/sparc/linux64.h       2016-11-03 13:52:45.207663972 -0400
503 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/sparc/linux64.h    2015-01-05 07:33:28.000000000 -0500
504
@@ -84,8 +84,8 @@
505
    When the -shared link option is used a final link is not being
506
    done.  */
507
 
508
-#define GLIBC_DYNAMIC_LINKER32 "/tools/lib/ld-linux.so.2"
509
-#define GLIBC_DYNAMIC_LINKER64 "/tools/lib64/ld-linux.so.2"
510
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld-linux.so.2"
511
+#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux.so.2"
512
 
513
 #ifdef SPARC_BI_ARCH
514
 
515
@@ -193,7 +193,7 @@
516
 #else /* !SPARC_BI_ARCH */
517
 
518
 #undef LINK_SPEC
519
-#define LINK_SPEC "-m elf64_sparc -Y P,%R/tools/lib64 %{shared:-shared} \
520
+#define LINK_SPEC "-m elf64_sparc -Y P,%R/usr/lib64 %{shared:-shared} \
521
   %{!shared: \
522
     %{!static: \
523
       %{rdynamic:-export-dynamic} \
524
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/sparc/linux.h gcc-5.3.0-zip/gcc/config/sparc/linux.h
525 192 dgisselq
--- gcc-5.3.0-original/gcc/config/sparc/linux.h 2016-11-03 13:52:45.207663972 -0400
526 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/sparc/linux.h      2015-01-05 07:33:28.000000000 -0500
527
@@ -83,7 +83,7 @@
528
    When the -shared link option is used a final link is not being
529
    done.  */
530
 
531
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld-linux.so.2"
532
+#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
533
 
534
 #undef  LINK_SPEC
535
 #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
536
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/vax/linux.h gcc-5.3.0-zip/gcc/config/vax/linux.h
537 192 dgisselq
--- gcc-5.3.0-original/gcc/config/vax/linux.h   2016-11-03 13:52:45.207663972 -0400
538 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/vax/linux.h        2015-01-05 07:33:28.000000000 -0500
539
@@ -41,7 +41,7 @@
540
   %{!shared: \
541
     %{!static: \
542
       %{rdynamic:-export-dynamic} \
543
-      -dynamic-linker /tools/lib/ld.so.1} \
544
+      -dynamic-linker /lib/ld.so.1} \
545
     %{static:-static}}"
546
 
547
 #undef  WCHAR_TYPE
548
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/xtensa/linux.h gcc-5.3.0-zip/gcc/config/xtensa/linux.h
549 192 dgisselq
--- gcc-5.3.0-original/gcc/config/xtensa/linux.h        2016-11-03 13:52:45.207663972 -0400
550 102 dgisselq
+++ gcc-5.3.0-zip/gcc/config/xtensa/linux.h     2015-01-05 07:33:28.000000000 -0500
551
@@ -44,7 +44,7 @@
552
   %{mlongcalls:--longcalls} \
553
   %{mno-longcalls:--no-longcalls}"
554
 
555
-#define GLIBC_DYNAMIC_LINKER "/tools/lib/ld.so.1"
556
+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
557
 
558
 #undef LINK_SPEC
559
 #define LINK_SPEC \
560
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/zip/netbsd.h gcc-5.3.0-zip/gcc/config/zip/netbsd.h
561
--- gcc-5.3.0-original/gcc/config/zip/netbsd.h  1969-12-31 19:00:00.000000000 -0500
562
+++ gcc-5.3.0-zip/gcc/config/zip/netbsd.h       2016-01-30 15:04:14.796899050 -0500
563
@@ -0,0 +1,82 @@
564
+////////////////////////////////////////////////////////////////////////////////
565
+//
566
+// Filename:   netbsd.h
567
+//
568
+// Project:    Zip CPU backend for the GNU Compiler Collection
569
+//
570
+// Purpose:
571
+//
572
+// Creator:    Dan Gisselquist, Ph.D.
573
+//             Gisselquist Technology, LLC
574
+//
575
+////////////////////////////////////////////////////////////////////////////////
576
+//
577
+// Copyright (C) 2016, Gisselquist Technology, LLC
578
+//
579
+// This program is free software (firmware): you can redistribute it and/or
580
+// modify it under the terms of  the GNU General Public License as published
581
+// by the Free Software Foundation, either version 3 of the License, or (at
582
+// your option) any later version.
583
+//
584
+// This program is distributed in the hope that it will be useful, but WITHOUT
585
+// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
586
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
587
+// for more details.
588
+//
589
+// You should have received a copy of the GNU General Public License along
590
+// with this program.  (It's in the $(ROOT)/doc directory, run make with no
591
+// target there if the PDF file isn't present.)  If not, see
592
+// <http://www.gnu.org/licenses/> for a copy.
593
+//
594
+// License:    GPL, v3, as defined and found on www.gnu.org,
595
+//             http://www.gnu.org/licenses/gpl.html
596
+//
597
+//
598
+////////////////////////////////////////////////////////////////////////////////
599
+#ifndef        ZIP_NETBSD_H
600
+#define        ZIP_NETBSD_H
601
+
602
+/* Define default target values. */
603
+
604
+#undef MACHINE_TYPE
605
+#define        MACHINE_TYPE    "NetBSD/Zip ELF"
606
+
607
+#undef TARGET_OS_CPP_BUILTINS
608
+#define        TARGET_OS_CPP_BUILTINS()        \
609
+       do { NETBSD_OS_CPP_BUILTINS_ELF();              \
610
+       builtin_define("__ZIPCPU__");                   \
611
+       builtin_assert("cpu=zip");                      \
612
+       builtin_assert("machine=zip");                  \
613
+       } while(0);
614
+
615
+#undef CPP_SPEC
616
+#define        CPP_SPEC        NETBSD_CPP_SPEC
617
+
618
+#undef STARTFILE_SPEC
619
+#define        STARTFILE_SPEC  NETBSD_STARTFILE_SPEC
620
+
621
+#undef ENDFILE_SPEC
622
+#define        ENDFILE_SPEC    NETBSD_ENDFILE_SPEC
623
+
624
+#undef LIB_SPEC
625
+#define        LIB_SPEC        NETBSD_LIB_SPEC
626
+
627
+#undef TARGET_VERSION
628
+#define        TARGET_VERSION  fprintf(stderr, " (%s)", MACHINE_TYPE);
629
+
630
+/* Make gcc agree with <machine/ansi.h> */
631
+
632
+#undef WCHAR_TYPE
633
+#define        WCHAR_TYPE      "int"
634
+
635
+#undef WCHAR_TYPE_SIZE
636
+#define        WCHAR_TYPE_SIZE 32
637
+
638
+#undef WINT_TYPE
639
+#define        WINT_TYPE       "int"
640
+
641
+/* Clean up after the generic Zip/ELF configuration. */
642
+#undef MD_EXEC_PREFIX
643
+#undef MD_STARTFILE_PREFIX
644
+
645
+#endif /* ZIP_NETBSD_H */
646 171 dgisselq
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/zip/notes.txt gcc-5.3.0-zip/gcc/config/zip/notes.txt
647
--- gcc-5.3.0-original/gcc/config/zip/notes.txt 1969-12-31 19:00:00.000000000 -0500
648
+++ gcc-5.3.0-zip/gcc/config/zip/notes.txt      2016-08-17 23:00:25.714139174 -0400
649
@@ -0,0 +1,6 @@
650
+signum:
651
+       CMP       0,%1
652
+       LDILO.GT  1,%1
653
+       LDILO.LT -1,%1
654
+
655
+
656 102 dgisselq
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/zip/t-zip gcc-5.3.0-zip/gcc/config/zip/t-zip
657
--- gcc-5.3.0-original/gcc/config/zip/t-zip     1969-12-31 19:00:00.000000000 -0500
658
+++ gcc-5.3.0-zip/gcc/config/zip/t-zip  2016-02-04 19:00:59.939652587 -0500
659
@@ -0,0 +1,47 @@
660
+################################################################################
661
+##
662
+## Filename:   t-zip
663
+##
664
+## Project:    Zip CPU backend for the GNU Compiler Collection
665
+##
666
+## Purpose:
667
+##
668
+## Creator:    Dan Gisselquist, Ph.D.
669
+##             Gisselquist Technology, LLC
670
+##
671
+################################################################################
672
+##
673
+## Copyright (C) 2016, Gisselquist Technology, LLC
674
+##
675
+## This program is free software (firmware): you can redistribute it and/or
676
+## modify it under the terms of  the GNU General Public License as published
677
+## by the Free Software Foundation, either version 3 of the License, or (at
678
+## your option) any later version.
679
+##
680
+## This program is distributed in the hope that it will be useful, but WITHOUT
681
+## ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
682
+## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
683
+## for more details.
684
+##
685
+## You should have received a copy of the GNU General Public License along
686
+## with this program.  (It's in the $(ROOT)/doc directory, run make with no
687
+## target there if the PDF file isn't present.)  If not, see
688
+## <http://www.gnu.org/licenses/> for a copy.
689
+##
690
+## License:    GPL, v3, as defined and found on www.gnu.org,
691
+##             http://www.gnu.org/licenses/gpl.html
692
+##
693
+##
694
+################################################################################
695
+
696
+FPBIT = fp-bit.c
697
+DPBIT = dp-bit.c
698
+
699
+# dp-bit.c: $(srcdir)/config/fp-bit.c
700
+       # cat $(srcdir)/config/fp-bit.c > dp-bit.c
701
+#
702
+# fp-bit.c: $(srcdir)/config/fp-bit.c
703
+       # echo '#define FLOAT" > fp-bit.c
704
+       # cat $(srcdir)/config/fp-bit.c >> fp-bit.c
705
+
706
+
707
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/zip/zip.c gcc-5.3.0-zip/gcc/config/zip/zip.c
708
--- gcc-5.3.0-original/gcc/config/zip/zip.c     1969-12-31 19:00:00.000000000 -0500
709 192 dgisselq
+++ gcc-5.3.0-zip/gcc/config/zip/zip.c  2016-11-02 10:55:10.906812219 -0400
710 191 dgisselq
@@ -0,0 +1,2291 @@
711 102 dgisselq
+////////////////////////////////////////////////////////////////////////////////
712
+//
713
+// Filename:   zip.c
714
+//
715
+// Project:    Zip CPU backend for the GNU Compiler Collection
716
+//
717
+// Purpose:
718
+//
719
+// Creator:    Dan Gisselquist, Ph.D.
720
+//             Gisselquist Technology, LLC
721
+//
722
+////////////////////////////////////////////////////////////////////////////////
723
+//
724
+// Copyright (C) 2016, Gisselquist Technology, LLC
725
+//
726
+// This program is free software (firmware): you can redistribute it and/or
727
+// modify it under the terms of  the GNU General Public License as published
728
+// by the Free Software Foundation, either version 3 of the License, or (at
729
+// your option) any later version.
730
+//
731
+// This program is distributed in the hope that it will be useful, but WITHOUT
732
+// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
733
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
734
+// for more details.
735
+//
736
+// You should have received a copy of the GNU General Public License along
737
+// with this program.  (It's in the $(ROOT)/doc directory, run make with no
738
+// target there if the PDF file isn't present.)  If not, see
739
+// <http://www.gnu.org/licenses/> for a copy.
740
+//
741
+// License:    GPL, v3, as defined and found on www.gnu.org,
742
+//             http://www.gnu.org/licenses/gpl.html
743
+//
744
+//
745
+////////////////////////////////////////////////////////////////////////////////
746
+#include "config.h"
747
+#include "system.h"
748
+#include "coretypes.h"
749
+#include "tm.h"
750
+#include "rtl.h"
751
+#include "dominance.h"
752
+#include "cfg.h"
753
+#include "cfgrtl.h"
754
+#include "cfganal.h"
755
+#include "lcm.h"
756
+#include "cfgbuild.h"
757
+#include "cfgcleanup.h"
758
+#include "predict.h"
759
+#include "basic-block.h"
760
+#include "df.h"
761
+#include "hashtab.h"
762
+#include "hash-set.h"
763
+#include "machmode.h"
764
+#include "symtab.h"
765
+#include "rtlhash.h"
766
+#include "tree.h"
767
+#include "regs.h"
768
+#include "hard-reg-set.h"
769
+#include "real.h"
770
+#include "insn-config.h"
771
+#include "conditions.h"
772
+#include "output.h"
773
+#include "insn-attr.h"
774
+#include "flags.h"
775
+#include "expr.h"
776
+#include "function.h"
777
+#include "recog.h"
778
+#include "toplev.h"
779
+#include "ggc.h"
780
+#include "builtins.h"
781
+#include "calls.h"
782
+#include "langhooks.h"
783
+#include "optabs.h"
784
+#include "explow.h"
785
+#include "emit-rtl.h"
786 122 dgisselq
+#include "ifcvt.h"
787 102 dgisselq
+
788
+// #include "tmp_p.h"
789
+#include "target.h"
790
+#include "target-def.h"
791
+// #include "tm-constrs.h"
792 122 dgisselq
+#include "tm-preds.h"
793 102 dgisselq
+
794
+#include "diagnostic.h"
795
+// #include "integrate.h"
796
+
797
+// static int  zip_arg_partial_bytes(CUMULATIVE_ARGS *, enum machine_mode, tree, bool);
798
+// static      bool    zip_pass_by_reference(CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool);
799
+static bool    zip_return_in_memory(const_tree, const_tree);
800
+static bool    zip_frame_pointer_required(void);
801
+
802
+static void zip_function_arg_advance(cumulative_args_t ca, enum machine_mode mode,
803
+               const_tree type, bool named);
804
+static rtx zip_function_arg(cumulative_args_t ca, enum machine_mode mode, const_tree type, bool named);
805
+
806
+static void    zip_asm_trampoline_template(FILE *);
807
+static void    zip_trampoline_init(rtx, tree, rtx);
808
+static void    zip_init_builtins(void);
809
+static tree zip_builtin_decl(unsigned, bool);
810
+// static void zip_asm_output_anchor(rtx x);
811
+       void    zip_asm_output_def(FILE *s, const char *n, const char *v);
812
+static rtx     zip_expand_builtin(tree exp, rtx target, rtx subtarget,
813
+                       enum machine_mode tmode, int    ignore);
814
+static bool    zip_scalar_mode_supported_p(enum machine_mode mode);
815
+static bool    zip_libgcc_floating_mode_supported_p(enum machine_mode mode);
816
+static int     zip_address_cost(rtx addr, enum machine_mode mode, addr_space_t as, bool spd);
817
+static bool    zip_mode_dependent_address_p(const_rtx addr, addr_space_t);
818
+static unsigned HOST_WIDE_INT  zip_const_anchor = 0x20000;
819 122 dgisselq
+static          HOST_WIDE_INT  zip_min_opb_imm = -0x20000;
820
+static          HOST_WIDE_INT  zip_max_opb_imm =  0x1ffff;
821 142 dgisselq
+static          HOST_WIDE_INT  zip_min_anchor_offset = -0x2000;
822
+static          HOST_WIDE_INT  zip_max_anchor_offset =  0x1fff;
823 102 dgisselq
+static          HOST_WIDE_INT  zip_min_mov_offset = -0x1000;
824
+static          HOST_WIDE_INT  zip_max_mov_offset =  0x0fff;
825
+static int     zip_sched_issue_rate(void) { return 1; }
826
+static bool    zip_legitimate_address_p(machine_mode, rtx, bool);
827
+static bool    zip_legitimate_move_operand_p(machine_mode, rtx, bool);
828
+       void    zip_debug_rtx_pfx(const char *, const_rtx x);
829
+       void    zip_debug_rtx(const_rtx x);
830
+static void    zip_override_options(void);
831
+static bool    zip_can_eliminate(int from ATTRIBUTE_UNUSED, int to);
832
+static int     zip_memory_move_cost(machine_mode, reg_class_t, bool);
833 111 dgisselq
+static rtx     zip_legitimize_address(rtx x, rtx oldx, machine_mode mode);
834 117 dgisselq
+static bool    zip_cannot_modify_jumps_p(void);
835 122 dgisselq
+#ifdef HAVE_cc0
836
+       void    zip_update_cc_notice(rtx exp, rtx_insn *insn);
837
+#error "We're not supposed to have CC0 anymore"
838
+#else
839
+static bool    zip_fixed_condition_code_regs(unsigned int *a, unsigned int *b);
840
+#endif
841 102 dgisselq
+
842
+
843 103 dgisselq
+#define        ALL_DEBUG_OFF   false
844 102 dgisselq
+#define        ALL_DEBUG_ON    false
845
+
846
+enum ZIP_BUILTIN_ID_CODE {
847
+       ZIP_BUILTIN_RTU,
848
+       ZIP_BUILTIN_HALT,
849
+       ZIP_BUILTIN_IDLE,
850
+       ZIP_BUILTIN_SYSCALL,
851
+       ZIP_BUILTIN_SAVE_CONTEXT,
852
+       ZIP_BUILTIN_RESTORE_CONTEXT,
853
+       ZIP_BUILTIN_BITREV,
854
+       ZIP_BUILTIN_CC,
855 117 dgisselq
+       ZIP_BUILTIN_UCC,
856 171 dgisselq
+       ZIP_BUILTIN_BUSY,
857 102 dgisselq
+       ZIP_BUILTIN_MAX
858
+};
859
+
860
+static GTY (()) tree   zip_builtins[(int)ZIP_BUILTIN_MAX];
861
+static enum insn_code  zip_builtins_icode[(int)ZIP_BUILTIN_MAX];
862
+
863
+
864
+#include "gt-zip.h"
865
+
866
+/* The Global 'targetm' Variable. */
867
+struct gcc_target      targetm = TARGET_INITIALIZER;
868
+
869
+
870
+enum   reg_class zip_reg_class(int);
871
+
872
+#define        LOSE_AND_RETURN(msgid, x)               \
873
+       do {                                    \
874
+               zip_operand_lossage(msgid, x);  \
875
+               return;                         \
876
+       } while(0)
877
+
878
+/* Per-function machine data. */
879
+struct GTY(()) machine_function
880
+{
881
+       /* number of pretented arguments for varargs */
882
+       int     pretend_size;
883
+
884
+       /* Number of bytes saved on the stack for local variables. */
885
+       int     local_vars_size;
886
+
887
+       /* Number of bytes saved on stack for register save area */
888
+       int     saved_reg_size;
889
+       int     save_ret;
890
+
891
+       int     sp_fp_offset;
892
+       bool    fp_needed;
893
+       int     size_for_adjusting_sp;
894
+};
895
+
896
+/* Allocate a chunk of memory for per-function machine-dependent data. */
897
+
898
+static struct machine_function *
899
+zip_init_machine_status(void) {
900
+       return ggc_cleared_alloc<machine_function>();
901
+}
902
+
903
+static void
904
+zip_override_options(void)
905
+{
906
+       init_machine_status = zip_init_machine_status;
907
+}
908
+
909
+enum   reg_class
910
+zip_reg_class(int regno)
911
+{
912
+       if (is_ZIP_GENERAL_REG(regno)) {
913
+               return GENERAL_REGS;
914
+       } else if (is_ZIP_REG(regno)) {
915
+               return ALL_REGS;
916
+       } return NO_REGS;
917
+}
918
+
919
+/* Worker function for TARGET_RETURN_IN_MEMORY. */
920
+static bool
921
+zip_return_in_memory(const_tree type, const_tree fntype ATTRIBUTE_UNUSED) {
922
+       const   HOST_WIDE_INT size = int_size_in_bytes(type);
923
+       return (size == -1)||(size > UNITS_PER_WORD);
924
+}
925
+
926
+/* Emit an error emssage when we're in an asm, and a fatal error for "normal"
927
+ * insn.  Formatted output isn't easily implemented, since we use output operand
928
+ * lossage to output the actual message and handle the categorization of the
929
+ * error.  */
930
+
931
+static void
932
+zip_operand_lossage(const char *msgid, rtx op) {
933
+       fprintf(stderr, "Operand lossage??\n");
934
+       debug_rtx(op);
935
+       zip_debug_rtx(op);
936
+       output_operand_lossage("%s", msgid);
937
+}
938
+
939
+/* The PRINT_OPERAND_ADDRESS worker.   */
940
+void
941
+zip_print_operand_address(FILE *file, rtx x) {
942
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
943
+
944
+       if (dbg) zip_debug_rtx(x);
945
+       switch(GET_CODE(x)) {
946
+               case REG:
947 127 dgisselq
+                       gcc_assert(is_ZIP_REG(REGNO(x)));
948 171 dgisselq
+                       gcc_assert(REGNO(x) < 16);
949 102 dgisselq
+                       fprintf(file, "(%s)", reg_names[REGNO(x)]);
950
+                       break;
951
+               case SYMBOL_REF:
952
+                       fprintf(file, "%s", XSTR(x,0));
953
+                       break;
954
+               case LABEL_REF:
955
+                       x = LABEL_REF_LABEL(x);
956
+               case CODE_LABEL:
957
+                       { char buf[256];
958
+                       ASM_GENERATE_INTERNAL_LABEL(buf, "L", CODE_LABEL_NUMBER(x));
959
+#ifdef ASM_OUTPUT_LABEL_REF
960
+                       ASM_OUTPUT_LABEL_REF(file, buf);
961
+#else
962
+                       assemble_name(file, buf);
963
+#endif
964
+                       }
965
+                       break;
966
+               case PLUS:
967 111 dgisselq
+                       if (!REG_P(XEXP(x, 0))) {
968
+                               fprintf(stderr, "Unsupported address construct\n");
969
+                               zip_debug_rtx(x);
970 102 dgisselq
+                               abort();
971 127 dgisselq
+                       } gcc_assert(is_ZIP_REG(REGNO(XEXP(x,0))));
972 171 dgisselq
+                       gcc_assert(REGNO(XEXP(x,0))<16);
973 127 dgisselq
+                       if (CONST_INT_P(XEXP(x, 1))) {
974 102 dgisselq
+                               if (INTVAL(XEXP(x,1))!=0) {
975
+                                       fprintf(file, "%ld(%s)",
976 135 dgisselq
+                                       (long)INTVAL(XEXP(x, 1)),
977 102 dgisselq
+                                       reg_names[REGNO(XEXP(x, 0))]);
978
+                               } else {
979
+                                       fprintf(file, "(%s)",
980
+                                       reg_names[REGNO(XEXP(x, 0))]);
981
+                               }
982
+                       } else if (GET_CODE(XEXP(x,1)) == SYMBOL_REF) {
983
+                               fprintf(file, "%s(%s)", XSTR(x,0),
984
+                                       reg_names[REGNO(XEXP(x, 0))]);
985
+                       } else if ((GET_CODE(XEXP(x, 1)) == MINUS)
986
+                               && (GET_CODE(XEXP(XEXP(x, 1), 0))==SYMBOL_REF)
987
+                               && (GET_CODE(XEXP(XEXP(x, 1), 1))==SYMBOL_REF)) {
988
+                               fprintf(file, "%s-%s(%s)",
989
+                                       XSTR(XEXP(XEXP(x, 1),0),0),
990
+                                       XSTR(XEXP(XEXP(x, 1),1),0),
991
+                                       reg_names[REGNO(XEXP(x, 0))]);
992
+                       } else
993
+                               fprintf(file, "#INVALID(%s)",
994
+                                       reg_names[REGNO(XEXP(x, 0))]);
995
+                       /*
996
+                       else if (GET_CODE(XEXP(addr, 1)) == LABEL)
997
+                               fprintf(file, "%s(%s)",
998
+                                       GET_CODE(XEXP(addr, 1)),
999
+                                       reg_names[REGNO(GET_CODE(XEXP(addr, 0)))]);
1000
+                       else if ((GET_CODE(XEXP(addr, 1)) == MINUS)
1001
+                               && (GET_CODE(XEXP(GET_CODE(XEXP(addr, 1)), 0))==LABEL)
1002
+                               && (GET_CODE(XEXP(GET_CODE(XEXP(addr, 1)), 1))==LABEL)) {
1003
+                               fprintf(file, "%s-%s(%s)",
1004
+                                       reg_names[REGNO(GET_CODE(XEXP(addr, 0)))]);
1005
+                                       reg_names[REGNO(GET_CODE(XEXP(addr, 0)))]);
1006
+                                       reg_names[REGNO(GET_CODE(XEXP(addr, 0)))]);
1007
+                       }
1008
+                       */
1009
+                       break;
1010
+               // We don't support direct memory addressing within our
1011
+               // instruction set, even though the instructions themselves
1012
+               // would support direct memory addressing of the lower 18 bits
1013
+               // of memory space.
1014
+               case MEM:
1015
+                       if (dbg) zip_debug_rtx(x);
1016
+                       zip_print_operand_address(file, XEXP(x, 0));
1017
+                       break;
1018 111 dgisselq
+               case CONST_INT:
1019 135 dgisselq
+                       fprintf(file, "%ld",(long)INTVAL(x));
1020 111 dgisselq
+                       break;
1021 102 dgisselq
+               default:
1022 111 dgisselq
+                       fprintf(stderr, "Unknown address format\n");
1023
+                       zip_debug_rtx(x);
1024 102 dgisselq
+                       abort(); break;
1025
+                       // output_addr_const(file, x);
1026
+               break;
1027
+       }
1028
+}
1029
+
1030
+/* The PRINT_OPERAND worker. */
1031
+
1032
+void
1033
+zip_print_operand(FILE *file, rtx x, int code)
1034
+{
1035
+       rtx operand = x;
1036
+       int     rgoff = 0;
1037
+
1038
+       // fprintf(file, "Print Operand!\n");
1039
+
1040
+       /* New code entries should just be added to the switch below.  If
1041
+        * handling is finished, just return.  If handling was just a
1042
+        * modification of the operand, the modified operand should be put in
1043
+        * "operand", and then do a break to let default handling
1044
+        * (zero-modifier) output the operand.
1045
+        */
1046
+       switch(code) {
1047
+               case 0:
1048
+                       /* No code, print as usual. */
1049
+                       break;
1050
+               case 'L':
1051
+                       /* Lower of two registers, print one up */
1052
+                       rgoff = 1;
1053
+                       break;
1054
+               case 'R':
1055
+               case 'H':
1056
+                       /* Higher of a register pair, print normal */
1057
+                       break;
1058
+
1059
+               default:
1060
+                       LOSE_AND_RETURN("invalid operand modifier letter", x);
1061
+       }
1062
+
1063
+       /* Print an operand as without a modifier letter. */
1064
+       switch (GET_CODE(operand)) {
1065
+       case REG:
1066
+               if (REGNO(operand)+rgoff >= FIRST_PSEUDO_REGISTER)
1067
+                       internal_error("internal error: bad register: %d", REGNO(operand));
1068
+               fprintf(file, "%s", reg_names[REGNO(operand)+rgoff]);
1069
+               return;
1070
+       case SCRATCH:
1071
+               LOSE_AND_RETURN("Need a scratch register", x);
1072
+               return;
1073
+
1074
+       case CODE_LABEL:
1075
+       case LABEL_REF:
1076
+       case SYMBOL_REF:
1077
+       case PLUS:
1078
+               PRINT_OPERAND_ADDRESS(file, operand);
1079
+               return;
1080
+       case MEM:
1081
+               PRINT_OPERAND_ADDRESS(file, XEXP(operand, 0));
1082
+               return;
1083
+
1084
+       default:
1085
+               /* No need to handle all strange variants, let
1086
+                * output_addr_const do it for us.
1087
+                */
1088
+               if (CONSTANT_P(operand)) {
1089
+                       output_addr_const(file, operand);
1090
+                       return;
1091
+               }
1092
+
1093
+               LOSE_AND_RETURN("unexpected operand", x);
1094
+       }
1095
+}
1096
+
1097
+static bool
1098
+zip_frame_pointer_required(void)
1099
+{
1100
+       // This should really depend upon whether we have variable sized
1101
+       // arguments in our frame or not.  Once this fails, let's look
1102
+       // at what the problem was and then whether or not we can detect
1103
+       // it.
1104
+       //
1105
+       // Use a GCC global to determine our answer
1106 103 dgisselq
+       if (cfun->calls_alloca)
1107
+               return true;
1108 102 dgisselq
+       return (frame_pointer_needed);
1109
+/*
1110
+*/
1111
+}
1112
+
1113
+/* Determine whether or not a register needs to be saved on the stack or not.
1114
+ */
1115
+static bool
1116
+zip_save_reg(int regno) {
1117
+       if (regno == 0)
1118
+               return ((!crtl->is_leaf)
1119
+                       ||((df_regs_ever_live_p(0))&&(!call_used_regs[0])));
1120
+       else if ((regno == zip_GOT)&&(!ZIP_PIC))
1121
+               return  ((df_regs_ever_live_p(regno))
1122
+                               &&(!call_used_regs[regno]));
1123
+       else if (regno == zip_FP)
1124
+               return((zip_frame_pointer_required())||((df_regs_ever_live_p(regno))
1125
+                               &&(!call_used_regs[regno])));
1126
+       else if (regno < zip_FP)
1127
+               return  ((df_regs_ever_live_p(regno))
1128
+                               &&(!call_used_regs[regno]));
1129
+       return false;
1130
+}
1131
+
1132
+/* Compute the size of the local area and the size to be adjusted by the
1133
+ * prologue and epilogue.
1134
+ *
1135
+ * Here's what we are looking at (top is the current, bottom is the last ...)
1136
+ *
1137
+ *     Stack Pointer ->
1138 124 dgisselq
+ *                     Outgoing arguments
1139 102 dgisselq
+ *                     Local variables (could be variable size)
1140
+ *     Frame Pointer ->        (= Stack Pointer + sp_fp_offset)
1141
+ *                     Saved return address, if saved
1142
+ *                     Other Saved registers
1143
+ *                     Saved frame pointer (if used)
1144
+ *                     Saved R12, if used
1145
+ *                     (Stack pointer is not saved)
1146 171 dgisselq
+ *                     (PRETEND-ARGS)
1147 102 dgisselq
+ *     Original stack pointer ->       (= Stack_Pointer +size_for_adjusting_sp)
1148
+ *                     Called arguments (not passed in registers)
1149
+ *                     Return arguments (not R1, args.pretend_args_size)
1150
+ *             (Prior function's stack frame ... )
1151
+ *
1152
+ */
1153
+static void
1154
+zip_compute_frame(void) {
1155
+       int     regno;
1156
+       int     args_size;
1157 124 dgisselq
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
1158 102 dgisselq
+
1159 171 dgisselq
+       if (dbg) fprintf(stderr, "ZIP-COMPUTE-FRAME: %s\n", current_function_name());
1160 102 dgisselq
+       // gcc_assert(crtl);
1161
+       gcc_assert(cfun);
1162
+       gcc_assert(cfun->machine);
1163
+
1164
+       args_size=(ACCUMULATE_OUTGOING_ARGS ? crtl->outgoing_args_size : 0);
1165
+
1166
+       if(crtl->args.pretend_args_size > 0) {
1167
+               args_size += crtl->args.pretend_args_size;
1168 171 dgisselq
+               if (dbg) fprintf(stderr, "%s pretend_args_size : %d\n", current_function_name(),
1169
+                       crtl->args.pretend_args_size);
1170 102 dgisselq
+               cfun->machine->pretend_size = crtl->args.pretend_args_size;
1171
+       }
1172
+
1173
+       cfun->machine->local_vars_size = get_frame_size();
1174
+
1175
+       // Save callee-saved registers.
1176
+       cfun->machine->saved_reg_size = 0;
1177
+       for(regno=0; regno < FIRST_PSEUDO_REGISTER; regno++) {
1178
+               if (zip_save_reg(regno))
1179
+                       cfun->machine->saved_reg_size ++;
1180
+       }
1181
+
1182
+       cfun->machine->fp_needed = (zip_frame_pointer_required());
1183
+
1184
+       if ((cfun->machine->fp_needed)&&
1185
+                       (!df_regs_ever_live_p(zip_FP))) {
1186
+               cfun->machine->saved_reg_size ++;
1187
+       }
1188
+
1189 171 dgisselq
+       cfun->machine->sp_fp_offset = crtl->outgoing_args_size
1190
+                               + cfun->machine->local_vars_size;
1191 102 dgisselq
+       cfun->machine->size_for_adjusting_sp = cfun->machine->local_vars_size
1192
+                       + cfun->machine->saved_reg_size
1193
+                       + args_size;
1194 124 dgisselq
+       if(dbg) {
1195 171 dgisselq
+               fprintf(stderr, "\t---- STACK PTR ----\n");
1196
+               fprintf(stderr, "\tOUTGOIN-SIZE: %d\n",
1197
+                       crtl->outgoing_args_size);
1198 124 dgisselq
+               fprintf(stderr, "\tLOCALS-SIZE : %d\n",
1199
+                       cfun->machine->local_vars_size);
1200 171 dgisselq
+               fprintf(stderr, "\t---- FRAME PTR ----%s\n",
1201
+                       cfun->machine->fp_needed?"":" (Eliminated)");
1202 124 dgisselq
+               fprintf(stderr, "\tREGISTERS   : %d\n",
1203
+                       cfun->machine->saved_reg_size);
1204 171 dgisselq
+               fprintf(stderr, "\tPRETEND SIZE: %d\n",
1205
+                       crtl->args.pretend_args_size);
1206
+               fprintf(stderr, "\t---- ARG PTR (Original SP, should be eliminated) ----\n");
1207
+               fprintf(stderr, "\t----\n");
1208
+               fprintf(stderr, "\tARGS-SIZE   : %d\n", args_size);
1209 124 dgisselq
+               fprintf(stderr, "\tSP_FP_OFFSET: %d\n",
1210
+                       cfun->machine->sp_fp_offset);
1211
+               fprintf(stderr, "\tSP-ADJUSTMNT: %d\n",
1212
+                       cfun->machine->size_for_adjusting_sp);
1213
+       }
1214 102 dgisselq
+}
1215
+
1216
+void
1217
+zip_expand_prologue(void) {
1218
+       rtx     insn;
1219
+
1220
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
1221
+       zip_compute_frame();
1222
+
1223 124 dgisselq
+       if (dbg)  fprintf(stderr, "PROLOGUE: Computing Prologue instructions\n");
1224 127 dgisselq
+       if (dbg)  fprintf(stderr, "PROLOGUE: SP-FP offset is %d\n",
1225
+                       cfun->machine->sp_fp_offset);
1226 102 dgisselq
+       if (cfun->machine->size_for_adjusting_sp != 0) {
1227 138 dgisselq
+               insn = emit_insn(gen_subsi3_reg_clobber(stack_pointer_rtx,
1228 102 dgisselq
+                               stack_pointer_rtx,
1229
+                       gen_int_mode(cfun->machine->size_for_adjusting_sp,
1230
+                               SImode)));
1231
+                       // cfun->machine->sp_fp_offset
1232
+
1233
+               RTX_FRAME_RELATED_P(insn) = 1;
1234
+       }
1235
+
1236
+       {
1237
+               int offset = 0, regno;
1238
+               for(regno=0; regno < FIRST_PSEUDO_REGISTER; regno++) {
1239
+                       if (zip_save_reg(regno)) {
1240 127 dgisselq
+                               if (dbg) fprintf(stderr,
1241
+                                       "PROLOGUE: Saving R%d in %d+%d(SP)\n",
1242
+                                       regno, cfun->machine->sp_fp_offset,
1243
+                                       offset);
1244 124 dgisselq
+                               insn=emit_insn(gen_movsi_sto_off(
1245
+                                       stack_pointer_rtx,
1246
+                                       GEN_INT(cfun->machine->sp_fp_offset
1247
+                                               +offset++),
1248 102 dgisselq
+                                       gen_rtx_REG(SImode, regno)));
1249
+                               RTX_FRAME_RELATED_P(insn) = 1;
1250
+                       }
1251
+               }
1252 103 dgisselq
+               if (dbg)  fprintf(stderr, "%d registers saved%s\n", offset,
1253
+                       (crtl->saves_all_registers)?", should be all of them":", less than all");
1254 102 dgisselq
+       }
1255
+
1256
+       if (cfun->machine->fp_needed) {
1257
+               if (dbg) zip_debug_rtx(stack_pointer_rtx);
1258
+               if (dbg) zip_debug_rtx(frame_pointer_rtx);
1259
+               insn = emit_insn(gen_movsi_reg_off(frame_pointer_rtx,
1260 124 dgisselq
+                               stack_pointer_rtx,
1261
+                               GEN_INT(cfun->machine->sp_fp_offset)));
1262 102 dgisselq
+               RTX_FRAME_RELATED_P(insn) = 1;
1263 103 dgisselq
+               if (dbg)  fprintf(stderr, "sp_fp_offset is %d\n", cfun->machine->sp_fp_offset);
1264 102 dgisselq
+       }
1265
+}
1266
+
1267
+bool
1268
+zip_use_return_insn(void)
1269
+{
1270
+       if ((!reload_completed)||(cfun->machine->fp_needed)
1271
+                       ||(get_frame_size()!=0)) {
1272
+               // If R0 ever gets pushed to the stack, then we cannot
1273
+               // use a master return from anywhere.  We need to clean up the
1274
+               // stack first.
1275
+               if ((!crtl->is_leaf)||((df_regs_ever_live_p(0))
1276
+                                               &&(!call_used_regs[0]))) {
1277
+                       return false;
1278
+               }
1279
+       }
1280
+       zip_compute_frame();
1281
+       return (cfun->machine->size_for_adjusting_sp == 0);
1282
+}
1283
+
1284
+/* As per the notes in M68k.c, quote the function epilogue should not depend
1285
+ * upon the current stack pointer.  It should use the frame poitner only,
1286
+ * if there is a frame pointer.  This is mandatory because of alloca; we also
1287
+ * take advantage of it to omit stack adjustments before returning ...
1288
+ *
1289
+ * Let's see if we can use their approach here.
1290
+ *
1291
+ * We can't.  Consider our choices:
1292
+ *     LOD (FP),R0
1293
+ *     LOD 1(FP),R4
1294
+ *     LOD 2(FP),R5
1295
+ *     LOD 3(FP),R6
1296
+ *     LOD 4(FP),FP
1297
+ *     ... Then what is the stack pointer?
1298
+ * or
1299
+ *     LOD (FP),R0
1300
+ *     LOD 1(FP),R4
1301
+ *     LOD 2(FP),R5
1302
+ *     LOD 3(FP),R6
1303
+ *     MOV FP,SP
1304
+ *     LOD 4(SP),FP
1305
+ *     ... Which suffers unnecessary pipeline stalls, and certainly doesn't
1306
+ *     exploit our pipeline memory function
1307
+ * or
1308
+ *     MOV FP,SP
1309
+ *     LOD (SP),R0
1310
+ *     LOD 1(SP),R4
1311
+ *     LOD 2(SP),R5
1312
+ *     LOD 3(SP),R6
1313
+ *     LOD 4(SP),FP
1314
+ * Which will be our choice.  Note that we do use the stack pointer, eventually.
1315
+ *
1316
+ */
1317
+void
1318
+zip_expand_epilogue(void) {
1319
+       int     regno, offset;
1320
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
1321 138 dgisselq
+       rtx     insn;
1322 102 dgisselq
+
1323
+       zip_compute_frame();
1324
+
1325
+       if (dbg) fprintf(stderr, "EPILOG::\n");
1326
+       if (cfun->machine->fp_needed) {
1327 124 dgisselq
+               // This is done special--if you can't trust the stack pointer
1328
+               // enough so that you must have a frame pointer, then you can't
1329
+               // trust its offset enough to restore from it.  Hence, we start
1330
+               // by moving the frame pointer to the stack pointer to recover
1331
+               // the stack pointer back to a usable value.
1332 102 dgisselq
+               if (dbg) fprintf(stderr, "EPILOG::Moving frame pointer to stack register\n");
1333 138 dgisselq
+               insn = emit_insn(gen_movsi_reg(stack_pointer_rtx, frame_pointer_rtx));
1334
+               RTX_FRAME_RELATED_P(insn) = 1;
1335 102 dgisselq
+       }
1336
+
1337
+       if (cfun->machine->saved_reg_size != 0) {
1338 124 dgisselq
+               if (cfun->machine->fp_needed)
1339
+                       offset = 0;
1340
+               else
1341
+                       offset = cfun->machine->sp_fp_offset;
1342 102 dgisselq
+               if (dbg) fprintf(stderr, "EPILOG::Saved_REG_Size = %d\n", cfun->machine->saved_reg_size);
1343
+               for(regno=0; regno < FIRST_PSEUDO_REGISTER; regno++) {
1344
+                       if (zip_save_reg(regno)) {
1345
+                               if (dbg) fprintf(stderr, "EPILOG::RESTORING R%d\n", regno);
1346 138 dgisselq
+                               rtx reg = gen_rtx_REG(SImode, regno);
1347
+                               insn = emit_insn(gen_movsi_lod_off(
1348
+                                               reg,
1349 124 dgisselq
+                                               stack_pointer_rtx,
1350
+                                               GEN_INT(offset++)));
1351 138 dgisselq
+                               add_reg_note(insn, REG_CFA_RESTORE, reg);
1352
+                               RTX_FRAME_RELATED_P(insn) = 1;
1353 102 dgisselq
+                       }
1354
+               }
1355
+       }
1356
+
1357 124 dgisselq
+       if (cfun->machine->fp_needed) {
1358
+               // Restore the stack pointer back to the original, the
1359
+               // difference being the difference from the frame pointer
1360
+               // to the original stack
1361 138 dgisselq
+               insn = emit_insn(gen_addsi3_reg_clobber(stack_pointer_rtx,
1362
+                       stack_pointer_rtx,
1363 124 dgisselq
+                       GEN_INT(cfun->machine->size_for_adjusting_sp
1364
+                               -cfun->machine->sp_fp_offset)));
1365 138 dgisselq
+               RTX_FRAME_RELATED_P(insn) = 1;
1366 124 dgisselq
+       } else {
1367
+               // else now the difference is between the stack pointer and
1368
+               // the original stack pointer.
1369 102 dgisselq
+               if (dbg) fprintf(stderr, "EPILOG::ADDSI3(StackPtr, %d)\n",
1370
+                               cfun->machine->size_for_adjusting_sp);
1371 138 dgisselq
+               insn = emit_insn(gen_addsi3_reg_clobber(stack_pointer_rtx,
1372
+                       stack_pointer_rtx,
1373 124 dgisselq
+                       GEN_INT(cfun->machine->size_for_adjusting_sp)));
1374 138 dgisselq
+               RTX_FRAME_RELATED_P(insn) = 1;
1375 102 dgisselq
+       }
1376
+       if (dbg) fprintf(stderr, "EPILOG::EMITTING-RETURN\n");
1377
+
1378 138 dgisselq
+       // The return RTX is not allowed to be frame related
1379
+       insn = emit_jump_insn(ret_rtx);
1380
+       // RTX_FRAME_RELATED_P(insn) = 1;
1381 102 dgisselq
+}
1382
+
1383 191 dgisselq
+void
1384
+zip_sibcall_epilogue(void) {
1385
+       int     regno, offset;
1386
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
1387
+       rtx     insn;
1388
+
1389
+       zip_compute_frame();
1390
+
1391
+       if (dbg) fprintf(stderr, "EPILOG::\n");
1392
+       if (cfun->machine->fp_needed) {
1393
+               // This is done special--if you can't trust the stack pointer
1394
+               // enough so that you must have a frame pointer, then you can't
1395
+               // trust its offset enough to restore from it.  Hence, we start
1396
+               // by moving the frame pointer to the stack pointer to recover
1397
+               // the stack pointer back to a usable value.
1398
+               if (dbg) fprintf(stderr, "SIBCALL-EPILOG::Moving frame pointer to stack register\n");
1399
+               insn = emit_insn(gen_movsi_reg(stack_pointer_rtx, frame_pointer_rtx));
1400
+               RTX_FRAME_RELATED_P(insn) = 1;
1401
+       }
1402
+
1403
+       if (cfun->machine->saved_reg_size != 0) {
1404
+               if (cfun->machine->fp_needed)
1405
+                       offset = 0;
1406
+               else
1407
+                       offset = cfun->machine->sp_fp_offset;
1408
+               if (dbg) fprintf(stderr, "SIBCALL-EPILOG::Saved_REG_Size = %d\n", cfun->machine->saved_reg_size);
1409
+               for(regno=0; regno < FIRST_PSEUDO_REGISTER; regno++) {
1410
+                       if (zip_save_reg(regno)) {
1411
+                               if (dbg) fprintf(stderr, "SIBCALL-EPILOG::RESTORING R%d\n", regno);
1412
+                               rtx reg = gen_rtx_REG(SImode, regno);
1413
+                               insn = emit_insn(gen_movsi_lod_off(
1414
+                                               reg,
1415
+                                               stack_pointer_rtx,
1416
+                                               GEN_INT(offset++)));
1417
+                               add_reg_note(insn, REG_CFA_RESTORE, reg);
1418
+                               RTX_FRAME_RELATED_P(insn) = 1;
1419
+                       }
1420
+               }
1421
+       }
1422
+
1423
+       if (cfun->machine->fp_needed) {
1424
+               // Restore the stack pointer back to the original, the
1425
+               // difference being the difference from the frame pointer
1426
+               // to the original stack
1427
+               insn = emit_insn(gen_addsi3_reg_clobber(stack_pointer_rtx,
1428
+                       stack_pointer_rtx,
1429
+                       GEN_INT(cfun->machine->size_for_adjusting_sp
1430
+                               -cfun->machine->sp_fp_offset)));
1431
+               RTX_FRAME_RELATED_P(insn) = 1;
1432
+       } else {
1433
+               // else now the difference is between the stack pointer and
1434
+               // the original stack pointer.
1435
+               if (dbg) fprintf(stderr, "SIBCALL-EPILOG::ADDSI3(StackPtr, %d)\n",
1436
+                               cfun->machine->size_for_adjusting_sp);
1437
+               insn = emit_insn(gen_addsi3_reg_clobber(stack_pointer_rtx,
1438
+                       stack_pointer_rtx,
1439
+                       GEN_INT(cfun->machine->size_for_adjusting_sp)));
1440
+               RTX_FRAME_RELATED_P(insn) = 1;
1441
+       }
1442
+}
1443
+
1444 102 dgisselq
+/* Implement RETURN_ADDR_RTX(COUNT, FRAMEADDR).
1445
+ *
1446
+ * We currently only support calculating the return address for the current
1447
+ * frame.
1448
+ */
1449
+
1450
+/*
1451
+rtx
1452
+zip_return_addr_rtx(int count, rtx frame ATTRIBUTE_UNUSED)
1453
+{
1454
+       if (count)
1455
+               return NULL_RTX;
1456
+
1457
+       zip_compute_frame();
1458
+
1459
+       // saved return address for current function is at fp - 1
1460
+       if (cfun->machine->save_ret)
1461
+               return gen_rtx_MEM(Pmode, plus_constant(frame_pointer_rtx,
1462
+                               -UNITS_PER_WORD));
1463
+       return get_hard_reg_initial_val(Pmode, RETURN_ADDRESS_REGNUM);
1464
+}
1465
+*/
1466
+
1467
+/* Implements the macro INITIAL_ELIMINATION_OFFSET,
1468
+ * return the OFFSET.
1469
+ */
1470
+int
1471
+zip_initial_elimination_offset(int from, int to) {
1472
+       int     ret = 0;
1473
+       zip_compute_frame();
1474
+
1475 171 dgisselq
+/*
1476 102 dgisselq
+       if (((from) == FRAME_POINTER_REGNUM)&&((to) == STACK_POINTER_REGNUM)) {
1477
+               ret = cfun->machine->sp_fp_offset;
1478 117 dgisselq
+       } else if (((from)=ARG_POINTER_REGNUM)&&((to)==STACK_POINTER_REGNUM)) {
1479 171 dgisselq
+               // Since the ARG_POINTER_REGNUM is defined to be identical
1480
+               // to the FRAME_POINTER_REGNUM, this "if" will never ever
1481
+               // get called.
1482 117 dgisselq
+               ret = cfun->machine->sp_fp_offset;
1483 102 dgisselq
+       } else if (((from)=ARG_POINTER_REGNUM)&&((to)==FRAME_POINTER_REGNUM)) {
1484 171 dgisselq
+               // Since we define ARG_POINTER_REGNUM to be FRAME_POINTER_REGNUM
1485
+               // we're asked for the offset between the frame pointer and
1486
+               // itself.  The result had better be zero.
1487
+               //
1488 117 dgisselq
+               ret = 0;
1489 102 dgisselq
+       } else {
1490
+               abort();
1491
+       }
1492 171 dgisselq
+*/
1493 102 dgisselq
+
1494 171 dgisselq
+       // Let's try using an ARG_POINTER != FRAME_POINTER
1495
+       if (((from) == FRAME_POINTER_REGNUM)&&((to) == STACK_POINTER_REGNUM)) {
1496
+               ret = cfun->machine->sp_fp_offset;
1497
+       } else if (((from)=ARG_POINTER_REGNUM)&&((to)==STACK_POINTER_REGNUM)) {
1498
+               // Since the ARG_POINTER_REGNUM is defined to be identical
1499
+               // to the FRAME_POINTER_REGNUM, this "if" will never ever
1500
+               // get called.
1501
+               ret = cfun->machine->size_for_adjusting_sp;
1502
+       } else if (((from)=ARG_POINTER_REGNUM)&&((to)==FRAME_POINTER_REGNUM)) {
1503
+               ret = cfun->machine->size_for_adjusting_sp
1504
+                       - cfun->machine->sp_fp_offset;
1505
+       } else {
1506
+               abort();
1507
+       }
1508
+
1509 102 dgisselq
+       return ret;
1510
+}
1511
+
1512
+/*
1513
+ * Code taken from m68k ...
1514
+ */
1515
+static bool
1516
+zip_can_eliminate(int from, int to)
1517
+{
1518
+       // fprintf(stderr, "CAN_ELIMINATE::QUERYING(%d,%d)\n", from, to);
1519
+       if ((from == zip_FP)&&(to == zip_SP))
1520
+               return !cfun->machine->fp_needed;
1521
+       return true;
1522
+}
1523
+
1524
+/*
1525
+static void
1526
+zip_basic_check(void)
1527
+{
1528
+       gcc_assert(mode_base_align[SImode]==4);
1529
+       if ((BITS_PER_UNIT != 32)
1530
+                       ||(GET_MODE_SIZE(SImode)!=1)
1531
+                       ||(GET_MODE_SIZE(DImode)!=1)
1532
+                       ||(HARD_REGNO_NREGS(0,SImode)!=1)) {
1533
+               printf("SIZEOF(SIMode) == %d\n", GET_MODE_SIZE(SImode));
1534
+               printf("BITS_PER_UNIT  == %d\n", BITS_PER_UNIT);
1535
+               gcc_assert(BITS_PER_UNIT==32);
1536
+               gcc_assert(GET_MODE_SIZE(SImode)==1);
1537
+               gcc_assert(HARD_REGNO_NREGS(0,SImode)==1);
1538
+       }
1539
+}
1540
+*/
1541
+
1542
+#define        zip_basic_check()
1543
+
1544 171 dgisselq
+/* Compute the number of word sized registers needed to hold a function
1545 102 dgisselq
+ * argument of mode INT_MODE and tree type TYPE.
1546
+ */
1547
+int
1548
+zip_num_arg_regs(enum machine_mode mode, const_tree type) {
1549
+       int     size;
1550
+
1551
+       zip_basic_check();
1552
+
1553
+       if (targetm.calls.must_pass_in_stack(mode, type))
1554
+               return 0;
1555
+
1556
+       if ((type)&&(mode == BLKmode))
1557
+               size = int_size_in_bytes(type);
1558
+       else
1559
+               size = GET_MODE_SIZE(mode);
1560
+
1561
+       return (size + UNITS_PER_WORD - 1)/UNITS_PER_WORD;
1562
+}
1563
+
1564
+static void
1565
+zip_function_arg_advance(cumulative_args_t ca, machine_mode mode,
1566
+               const_tree type, bool named ATTRIBUTE_UNUSED) {
1567
+       CUMULATIVE_ARGS *cum;
1568
+       int     nreg;
1569
+
1570
+       zip_basic_check();
1571
+
1572
+       cum = get_cumulative_args(ca);
1573
+       nreg = zip_num_arg_regs(mode, type);
1574
+       if (((*cum)+nreg) > NUM_ARG_REGS)
1575
+               (*cum) = NUM_ARG_REGS;
1576
+       else
1577
+               (*cum) += nreg;
1578
+}
1579
+
1580
+static rtx
1581
+zip_function_arg(cumulative_args_t ca, machine_mode mode,
1582
+               const_tree type ATTRIBUTE_UNUSED, bool named) {
1583
+       CUMULATIVE_ARGS *cum;
1584
+
1585
+       zip_basic_check();
1586
+
1587
+
1588
+       if (!named)
1589
+               return NULL_RTX;
1590
+       //if (targetm.calls.must_pass_in_stack(mode, type))
1591
+               //return NULL_RTX;
1592
+       cum = get_cumulative_args(ca);
1593
+
1594
+       if ((*cum) >= NUM_ARG_REGS)
1595
+               return NULL_RTX;
1596
+       return
1597
+               gen_rtx_REG(mode, (*cum)+1);
1598
+}
1599
+
1600 191 dgisselq
+/* DECL is the declaration of the function being targeted by the call, and EXP
1601
+ * is the CALL_EXPR representing the call.
1602
+ */
1603
+bool   zip_function_ok_for_sibcall(ATTRIBUTE_UNUSED tree decl, tree exp) {
1604
+       // calls.c already checks whether or not the parameter stack space
1605
+       // is identical, so ... let's hope this all works and find out.
1606
+
1607
+       //
1608
+       // Actually, this will fail:  If the sibling uses R5 to pass registers
1609
+       // in and we don't, then there will be no way to restore R5.  This is
1610
+       // true for the current configuration.  It will be true for future
1611
+       // configurations if the sibling ever uses a register that must be
1612
+       // saved as a parameter register.
1613
+       //
1614
+       // We can check this ... if we can count how many registers the
1615
+       // sibling call will use.
1616
+       //
1617
+       CUMULATIVE_ARGS cum_v;
1618
+       cumulative_args_t       cum;
1619
+       tree            parameter;
1620
+       machine_mode    mode;
1621
+       tree            ttype;
1622
+       rtx             parm_rtx;
1623
+       int             i;
1624
+       static const char zip_call_used_register[] = CALL_USED_REGISTERS;
1625
+
1626
+       INIT_CUMULATIVE_ARGS(cum_v, NULL, NULL, 0,0);
1627
+       cum = pack_cumulative_args(&cum_v);
1628
+       for (i=0; i<call_expr_nargs(exp); i++) {
1629
+
1630
+               parameter = CALL_EXPR_ARG(exp, i);
1631
+
1632
+               if ((!parameter) || (TREE_CODE(parameter)==ERROR_MARK))
1633
+                       return true;
1634
+               ttype = TREE_TYPE(parameter);
1635
+               gcc_assert(ttype);
1636
+               mode = ttype->type_common.mode;
1637
+
1638
+               if (pass_by_reference(&cum_v, mode, ttype, true)) {
1639
+                       mode = Pmode;
1640
+                       ttype = build_pointer_type(ttype);
1641
+               }
1642
+
1643
+               parm_rtx = zip_function_arg(cum, mode, ttype, 0);
1644
+               zip_function_arg_advance(cum, mode, ttype, 0);
1645
+               if (!parm_rtx)
1646
+                       continue;
1647
+
1648
+               // If it is a register
1649
+               //      and it is *NOT* a CALL_USED_REGISTER
1650
+               //      then we can't do this.
1651
+               //
1652
+               // Example: func(R1,..R4,R5)
1653
+               //      can be followed by func2(R1,.., up to R5)
1654
+               //      (not supported, though... just to simplify our test
1655
+               //      below)
1656
+               // Example: func(R1,..R4)
1657
+               //      cannot be followed by func2(R1,..,R5)
1658
+               //      We would blow R5 away by our prologue, even if it was
1659
+               //      properly set.
1660
+               // Example: func(R1,..R5)
1661
+               //      can be followed by func2(R1,.., up to R4)
1662
+               //      func2 may save R5 (which doesn't need saving) but that's
1663
+               //              irrelevant
1664
+               // Example: func(R1,..up to R4)
1665
+               //      can be followed by func2(R1,.., up to R4)
1666
+               //
1667
+               if (REG_P(parm_rtx)&&(REGNO(parm_rtx))
1668
+                               &&(REGNO(parm_rtx)<sizeof(zip_call_used_register))
1669
+                               &&(!zip_call_used_register[REGNO(parm_rtx)]))
1670
+                       return false;
1671
+       }
1672
+
1673
+       return true;
1674
+
1675
+       // We also need to check if the return types are the same ... or
1676
+       // will GCC handle that for us?
1677
+}
1678
+
1679 122 dgisselq
+void   zip_canonicalize_comparison(int *code, rtx *op0, rtx *op1,
1680
+               bool preserve_op0)
1681
+{
1682
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
1683 102 dgisselq
+
1684 122 dgisselq
+       if (dbg) fprintf(stderr, "CANONICALIZE ...%s\n", (preserve_op0)?"(Preserve Op0)":"");
1685
+       if (dbg) zip_debug_rtx_pfx("CODE", gen_rtx_fmt_ee((rtx_code)*code, VOIDmode, gen_rtx_REG(CCmode,zip_CC), const0_rtx));
1686
+       if (dbg) zip_debug_rtx_pfx("OP0 ", *op0);
1687
+       if (dbg) zip_debug_rtx_pfx("OP1 ", *op1);
1688
+
1689
+       if ((!preserve_op0)&&((*code == LE)||(*code == GTU)||(*code == GEU))) {
1690
+               rtx tem = *op0;
1691
+               *op0 = *op1;
1692
+               *op1 = tem;
1693
+               *code = (int)swap_condition((enum rtx_code)*code);
1694
+       }
1695
+
1696
+       if ((*code == LE)||(*code == LEU)||(*code == GTU)) {
1697
+               int offset = 1; // (*code == GTU) ? 1 : -1;
1698
+               bool    swap = false;
1699
+
1700
+               if (CONST_INT_P(*op1)) {
1701
+                       *op1 = GEN_INT(INTVAL(*op1)+offset);
1702
+                       swap = true;
1703
+               } else if (REG_P(*op1)) {
1704 138 dgisselq
+                       *op1 = plus_constant(GET_MODE(*op1), *op1, offset, true);
1705 122 dgisselq
+                       swap = true;
1706
+               } else if ((GET_CODE(*op1)==PLUS)&&(CONST_INT_P(XEXP(*op1,1)))){
1707
+                       *op1 = plus_constant(GET_MODE(*op1),XEXP(*op1,0),
1708
+                               INTVAL(XEXP(*op1,1))+offset);
1709
+                       swap = true;
1710
+               } if (swap) {
1711
+                       if (*code == LE)
1712
+                               (*code)= LT;
1713
+                       else if (*code == LEU)
1714
+                               (*code)= LTU;
1715
+                       else // (*code == GTU)
1716
+                               (*code) = GEU;
1717
+               }
1718
+       }
1719
+}
1720
+
1721
+static bool
1722
+zip_fixed_condition_code_regs(unsigned int *a, unsigned int *b) {
1723
+       *a = zip_CC;
1724
+       *b = INVALID_REGNUM;
1725
+       return true;
1726
+}
1727
+
1728
+
1729 102 dgisselq
+/* totally buggy - we can't return pointers to nested functions */
1730
+static void
1731
+zip_asm_trampoline_template(FILE *f) {
1732
+       // Whereas at one time I thought I wouldn't need it, now I know I
1733
+       // need this trampoline function, although it is for a completely
1734
+       // different purpose than the one I was familiar with.
1735 138 dgisselq
+       fprintf(f, "\tbrev\t0,r1\n");
1736
+       fprintf(f, "\tldilo\t0,r1\n");
1737 102 dgisselq
+       fprintf(f, "\tjmp r1\n");
1738
+}
1739
+
1740
+/* Worker function for TARGET_TRAMPOLINE_INIT. */
1741
+static void
1742
+zip_trampoline_init(rtx m_tramp ATTRIBUTE_UNUSED,
1743
+       tree fndecl ATTRIBUTE_UNUSED,
1744
+       rtx chain_value ATTRIBUTE_UNUSED) {
1745
+// #warning "This needs to be filled out"
1746
+       abort();
1747
+}
1748
+
1749
+static tree
1750
+def_builtin(const char *name, enum insn_code icode, enum ZIP_BUILTIN_ID_CODE code,
1751
+       tree type)
1752
+{
1753
+       tree t = add_builtin_function(name,type,code,BUILT_IN_MD, NULL, NULL_TREE);
1754
+       zip_basic_check();
1755
+
1756
+       if(t) {
1757
+               zip_builtins[code] = t;
1758
+               zip_builtins_icode[code] = icode;
1759
+       }
1760
+
1761
+       return t;
1762
+
1763
+}
1764
+
1765
+void   zip_init_builtins(void) {
1766
+       zip_basic_check();
1767
+
1768
+  tree void_ftype_void = build_function_type_list(void_type_node, NULL_TREE);
1769
+#ifdef HAVE_zip_rtu
1770
+  def_builtin("zip_rtu", CODE_FOR_zip_rtu, ZIP_BUILTIN_RTU, void_ftype_void);
1771
+#endif
1772
+#ifdef HAVE_zip_halt
1773
+  def_builtin("zip_halt",  CODE_FOR_zip_halt,  ZIP_BUILTIN_HALT, void_ftype_void);
1774
+#endif
1775 171 dgisselq
+#ifdef HAVE_zip_busy
1776
+  def_builtin("zip_busy",  CODE_FOR_zip_busy,  ZIP_BUILTIN_BUSY, void_ftype_void);
1777
+#endif
1778 102 dgisselq
+#ifdef HAVE_zip_idle
1779
+  def_builtin("zip_idle", CODE_FOR_zip_idle, ZIP_BUILTIN_IDLE, void_ftype_void);
1780
+#endif
1781
+
1782
+#ifdef HAVE_zip_syscall
1783
+// Support int SYSCALL(callID, int a, int b, int c);
1784
+  def_builtin("zip_syscall", CODE_FOR_zip_syscall, ZIP_BUILTIN_SYSCALL,
1785
+                       build_function_type_list(void_type_node, NULL_TREE));
1786
+#endif
1787
+
1788
+#ifdef HAVE_zip_save_context
1789
+  def_builtin("zip_save_context", CODE_FOR_zip_save_context, ZIP_BUILTIN_SAVE_CONTEXT,
1790
+               build_function_type_list(void_type_node, ptr_type_node, 0));
1791
+#endif
1792
+
1793
+#ifdef HAVE_zip_restore_context
1794
+  def_builtin("zip_restore_context", CODE_FOR_zip_restore_context, ZIP_BUILTIN_RESTORE_CONTEXT,
1795
+       build_function_type_list(void_type_node, ptr_type_node, 0));
1796
+#endif
1797
+
1798
+#ifdef HAVE_zip_bitrev
1799
+  def_builtin("zip_bitrev", CODE_FOR_zip_bitrev, ZIP_BUILTIN_BITREV,
1800
+       build_function_type_list(unsigned_type_node, unsigned_type_node,
1801
+               NULL_TREE));
1802
+#endif
1803
+
1804
+#ifdef HAVE_zip_cc
1805
+  def_builtin("zip_cc", CODE_FOR_zip_cc, ZIP_BUILTIN_CC,
1806
+       build_function_type_list(unsigned_type_node, NULL_TREE));
1807
+#endif
1808
+
1809 117 dgisselq
+#ifdef HAVE_zip_ucc
1810
+  def_builtin("zip_ucc", CODE_FOR_zip_ucc, ZIP_BUILTIN_UCC,
1811
+       build_function_type_list(unsigned_type_node, NULL_TREE));
1812
+#endif
1813
+
1814 102 dgisselq
+}
1815
+
1816
+static tree
1817
+zip_builtin_decl(unsigned zip_builtin_code, bool initialize_p ATTRIBUTE_UNUSED)
1818
+{
1819
+  if (zip_builtin_code >= ZIP_BUILTIN_MAX)
1820
+    return error_mark_node;
1821
+
1822
+  return zip_builtins[zip_builtin_code];
1823
+}
1824
+
1825
+static rtx
1826
+zip_expand_builtin(tree exp, rtx target,
1827
+               rtx subtarget ATTRIBUTE_UNUSED,
1828
+               machine_mode tmode ATTRIBUTE_UNUSED,
1829
+               int     ignore ATTRIBUTE_UNUSED) {
1830
+
1831
+       tree    fndecl = TREE_OPERAND(CALL_EXPR_FN(exp), 0);
1832
+       bool    nonvoid = (TREE_TYPE(TREE_TYPE(fndecl)) != void_type_node);
1833
+       enum    ZIP_BUILTIN_ID_CODE code=(enum ZIP_BUILTIN_ID_CODE)DECL_FUNCTION_CODE(fndecl);
1834
+       enum    insn_code icode = zip_builtins_icode[code];
1835
+       rtx     pat, op[5];
1836
+       call_expr_arg_iterator  iter;
1837
+       tree    arg;
1838
+
1839
+       if ((code == ZIP_BUILTIN_SAVE_CONTEXT)
1840
+                       ||(code == ZIP_BUILTIN_RESTORE_CONTEXT)) {
1841
+               arg = first_call_expr_arg(exp, &iter);
1842
+               if (arg == error_mark_node)
1843
+                       return NULL_RTX;
1844
+               op[0] = expand_normal(arg);
1845
+               if (GET_CODE(op[0]) != REG)
1846
+                       op[0] = force_reg(Pmode, op[0]);
1847
+               pat = GEN_FCN(icode)(op[0]);
1848
+       } else if (code == ZIP_BUILTIN_BITREV) {
1849
+               arg = first_call_expr_arg(exp, &iter);
1850
+               if (arg == error_mark_node) {
1851
+                       return NULL_RTX;
1852
+               }
1853
+               op[0] = expand_normal(arg);
1854
+               if (!target)
1855
+                       target = gen_reg_rtx(SImode);
1856
+               pat = GEN_FCN(icode)(target, op[0]);
1857 117 dgisselq
+       } else if ((code == ZIP_BUILTIN_CC)||(code == ZIP_BUILTIN_UCC)) {
1858 102 dgisselq
+               if (!target)
1859
+                       target = gen_reg_rtx(SImode);
1860
+               pat = GEN_FCN(icode)(target);
1861
+       } else // RTU, HALT, IDLE
1862
+               pat = GEN_FCN(icode)();
1863
+       if (!pat)
1864
+               return NULL_RTX;
1865
+       emit_insn(pat);
1866
+       return (nonvoid ? target : const0_rtx);
1867
+}
1868
+
1869
+static bool
1870
+zip_scalar_mode_supported_p(enum machine_mode mode) {
1871
+       zip_basic_check();
1872
+
1873
+       return ((mode)==SImode)||((mode)==DImode); // ||((mode)==SFmode);
1874
+}
1875
+
1876
+static bool
1877
+zip_libgcc_floating_mode_supported_p(enum machine_mode mode) {
1878
+       return ((mode)==SFmode)||((mode)==DFmode);
1879
+}
1880
+
1881
+static int
1882
+zip_address_cost(rtx addr ATTRIBUTE_UNUSED,
1883
+       enum machine_mode mode ATTRIBUTE_UNUSED,
1884
+       addr_space_t as ATTRIBUTE_UNUSED, bool spd ATTRIBUTE_UNUSED) {
1885
+       return 1;
1886
+}
1887
+
1888
+static bool
1889
+zip_mode_dependent_address_p(const_rtx addr ATTRIBUTE_UNUSED,
1890
+       addr_space_t as ATTRIBUTE_UNUSED) {
1891
+       return false;
1892
+}
1893
+
1894
+/*
1895
+static void
1896
+zip_asm_output_anchor(rtx x) {
1897
+       printf("ANCHOR: OP(%d)\n", GET_CODE(x));
1898
+}
1899
+*/
1900
+
1901
+static void
1902
+zip_debug_print(const char *pfx, int lvl, const char *str) {
1903
+       int     i;
1904
+       i = lvl;
1905
+       if ((true)||(lvl == 0))
1906
+               fprintf(stderr, "%s", pfx);
1907
+       else
1908
+               i += strlen(pfx);
1909
+       while(i-->0)
1910
+               fprintf(stderr, "  ");
1911
+       fprintf(stderr, "%s\n", str);
1912
+}
1913
+
1914
+static void
1915
+zip_debug_print_m(const char *pfx, int lvl, const char *str, enum machine_mode m) {
1916
+       int     i;
1917
+
1918
+       i = lvl;
1919
+       if ((true)||(lvl == 0))
1920
+               fprintf(stderr, "%s", pfx);
1921
+       else
1922
+               i = lvl+strlen(pfx);
1923
+       while(i-->0)
1924
+               fprintf(stderr, "  ");
1925
+       switch(m) {
1926
+               case VOIDmode:
1927
+                       fprintf(stderr, "%s:V\n", str);
1928
+                       break;
1929
+               case BLKmode:
1930
+                       fprintf(stderr, "%s:BLK\n", str);
1931
+                       break;
1932
+               case BImode:
1933
+                       fprintf(stderr, "%s:BI\n", str);
1934
+                       break;
1935
+#ifdef HAVE_QImode
1936
+               case QImode:
1937
+                       fprintf(stderr, "%s:QI\n", str);
1938
+                       break;
1939
+#endif
1940
+#ifdef HAVE_HImode
1941
+               case HImode:
1942
+                       fprintf(stderr, "%s:HI\n", str);
1943
+                       break;
1944
+#endif
1945
+               case SImode:
1946
+                       fprintf(stderr, "%s:SI\n", str);
1947
+                       break;
1948 122 dgisselq
+               case CCmode:
1949
+                       fprintf(stderr, "%s:CC\n", str);
1950
+                       break;
1951 102 dgisselq
+               case DImode:
1952
+                       fprintf(stderr, "%s:DI\n", str);
1953
+                       break;
1954
+               default:
1955
+                       fprintf(stderr, "%s:?\n", str);
1956
+       }
1957
+}
1958
+
1959
+static void
1960
+zip_debug_rtx_1(const char *pfx, const_rtx x, int lvl) {
1961
+       if (x == NULL_RTX) {
1962
+               zip_debug_print(pfx, lvl, "(NULL-RTX)");
1963
+               return;
1964
+       } else if (GET_CODE(x) > NUM_RTX_CODE) {
1965
+               char    buf[64];
1966
+               sprintf(buf, "(BAD-RTX-CODE %d)", GET_CODE(x));
1967
+               zip_debug_print(pfx, lvl, buf);
1968 117 dgisselq
+               gcc_assert(0 && "Bad RTX Code");
1969 102 dgisselq
+               return;
1970
+       } switch(GET_CODE(x)) { // rtl.def
1971 122 dgisselq
+       case PARALLEL:
1972
+               zip_debug_print(pfx, lvl, "(PARALLEL");
1973
+               for(int j=0; j<XVECLEN(x,0);j++)
1974
+                       zip_debug_rtx_1(pfx, XVECEXP(x,0,j), lvl+1);
1975
+               zip_debug_print(pfx, lvl, ")");
1976
+               debug_rtx(x);
1977
+               break;
1978 102 dgisselq
+       case INT_LIST: zip_debug_print(pfx, lvl, "(INT-LIST"); break;
1979 122 dgisselq
+       case SEQUENCE:
1980
+               zip_debug_print(pfx, lvl, "(SEQUENCE");
1981
+               for(int j=0; j<XVECLEN(x,0);j++)
1982
+                       zip_debug_rtx_1(pfx, XVECEXP(x,0,j), lvl+1);
1983
+               zip_debug_print(pfx, lvl, ")");
1984
+               debug_rtx(x);
1985
+               break;
1986 102 dgisselq
+       case ADDRESS: zip_debug_print(pfx, lvl, "(ADDRESS"); break;
1987
+       case DEBUG_INSN: zip_debug_print(pfx, lvl, "(DEBUG-INSN"); break;
1988
+       case INSN:
1989
+               zip_debug_print(pfx, lvl, "(INSN");
1990
+               /*
1991
+               { const rtx_insn *tmp_rtx;
1992
+               for(tmp_rtx = as_a <const rtx_insn *>(x); tmp_rtx != 0; tmp_rtx = NEXT_INSN(tmp_rtx)) {
1993
+                       zip_debug_rtx_1(tmp_rtx, lvl+1);
1994
+               }}
1995
+               */
1996
+               zip_debug_rtx_1(pfx, PATTERN(x), lvl+1);
1997
+               zip_debug_print(pfx, lvl, ")");
1998 117 dgisselq
+               debug_rtx(x);
1999 102 dgisselq
+               break;
2000
+       case JUMP_INSN: zip_debug_print(pfx, lvl, "(JUMP-INSN");
2001 111 dgisselq
+               zip_debug_rtx_1(pfx, PATTERN(x), lvl+1);
2002
+               zip_debug_print(pfx, lvl, ")");
2003
+               /*
2004 102 dgisselq
+               if (JUMP_LABEL(x)) {
2005 111 dgisselq
+                       if (GET_CODE(JUMP_LABEL(x)) == LABEL_REF) {
2006
+                               char    buf[64];
2007
+                               sprintf(buf, "(LABEL *.L%d))", CODE_LABEL_NUMBER(LABEL_REF_LABEL(JUMP_LABEL(x))));
2008
+                               zip_debug_print(pfx, lvl+1, buf);
2009
+                       } else if (GET_CODE(JUMP_LABEL(x))==CODE_LABEL) {
2010
+                               char    buf[64];
2011
+                               sprintf(buf, "(CODE_LABEL *.L%d))", CODE_LABEL_NUMBER(JUMP_LABEL(x)));
2012
+                               zip_debug_print(pfx, lvl+1, buf);
2013
+                       } else
2014
+                       zip_debug_print(pfx, lvl+1, "(w/Label))");
2015 102 dgisselq
+               } else
2016 111 dgisselq
+                       zip_debug_print(pfx, lvl+1, "(NO label))");
2017
+               debug_rtx(x);
2018
+               */
2019 102 dgisselq
+               break;
2020
+       case CALL:
2021
+               zip_debug_print(pfx, lvl, "(CALL (Adr) (Args)");
2022
+               zip_debug_rtx_1(pfx, XEXP(x,0), lvl+1);
2023
+               zip_debug_rtx_1(pfx, XEXP(x,1), lvl+1);
2024
+               zip_debug_print(pfx, lvl, ")");
2025
+               break;
2026
+       case CALL_INSN: zip_debug_print(pfx, lvl, "(CALL-INSN");
2027
+               debug_rtx(x);
2028
+               break;
2029
+       case BARRIER: zip_debug_print(pfx, lvl, "(BARRIER)"); break;
2030
+       case RETURN: zip_debug_print(pfx, lvl, "(RETURN)"); break;
2031
+       case NOTE:
2032
+               {       char buf[128];
2033
+                       sprintf(buf, "(NOTE %s)", GET_REG_NOTE_NAME(GET_MODE(x)));
2034
+                       zip_debug_print(pfx, lvl, buf);
2035
+               }break;
2036
+       case COND_EXEC: zip_debug_print(pfx, lvl, "(COND_EXEC)");
2037
+               debug_rtx(x);
2038
+               break;
2039
+       case ASM_INPUT: zip_debug_print(pfx, lvl, "(ASM INPUT)"); break;
2040
+       case ASM_OPERANDS: zip_debug_print(pfx, lvl, "(ASM OPERANDS)"); break;
2041
+       case UNSPEC: zip_debug_print(pfx, lvl, "(UNSPEC)"); break;
2042
+       case UNSPEC_VOLATILE: zip_debug_print(pfx, lvl, "(UNSPEC_VOLATILE)"); break;
2043
+       case CODE_LABEL:
2044
+               {
2045 192 dgisselq
+                       char    buf[128];
2046 111 dgisselq
+                       sprintf(buf, "(CODE_LABEL *.L%d)", CODE_LABEL_NUMBER(x));
2047 102 dgisselq
+                       zip_debug_print_m(pfx, lvl, buf, GET_MODE(x));
2048
+               } break;
2049
+       case SET:
2050
+               zip_debug_print_m(pfx, lvl, "(SET", GET_MODE(x));
2051 117 dgisselq
+               zip_debug_rtx_1(pfx, SET_DEST(x),lvl+1);
2052
+               zip_debug_rtx_1(pfx, SET_SRC(x),lvl+1);
2053 102 dgisselq
+               zip_debug_print(pfx, lvl, ")");
2054 117 dgisselq
+               debug_rtx(x);
2055 102 dgisselq
+               break;
2056 122 dgisselq
+       case REG: {
2057 127 dgisselq
+               char buf[25], mstr[4];
2058
+               mstr[0] = '\0';
2059
+               if (GET_MODE(x) == SImode)
2060
+                       strcpy(mstr, ":SI");
2061
+               else if (GET_MODE(x) == DImode)
2062
+                       strcpy(mstr, ":DI");
2063
+               else if (GET_MODE(x) == VOIDmode)
2064
+                       strcpy(mstr, ":V");
2065 102 dgisselq
+               if (REGNO(x) == zip_PC)
2066 127 dgisselq
+                       sprintf(buf, "(PC%s)", mstr);
2067 102 dgisselq
+               else if (REGNO(x) == zip_CC)
2068 127 dgisselq
+                       sprintf(buf, "(CC%s)", mstr);
2069 102 dgisselq
+               else if (REGNO(x) == zip_SP)
2070 127 dgisselq
+                       sprintf(buf, "(SP%s)", mstr);
2071 102 dgisselq
+               else if (REGNO(x) == zip_FP)
2072 127 dgisselq
+                       sprintf(buf, "(REG%s FP)", mstr);
2073 102 dgisselq
+               else if (REGNO(x) == zip_GOT)
2074 127 dgisselq
+                       sprintf(buf, "(REG%s GBL)", mstr);
2075 102 dgisselq
+               else if (FUNCTION_VALUE_REGNO_P(REGNO(x)))
2076 127 dgisselq
+                       sprintf(buf, "(REG%s RTN-VL)", mstr);
2077 102 dgisselq
+               else if (REGNO(x) == RETURN_ADDRESS_REGNUM)
2078 127 dgisselq
+                       sprintf(buf, "(REG%s RTN-AD)", mstr);
2079 122 dgisselq
+               else
2080 127 dgisselq
+                       sprintf(buf, "(REG%s %d)", mstr, REGNO(x));
2081
+               if (mstr[0])
2082
+                       zip_debug_print(pfx, lvl, buf);
2083
+               else
2084
+                       zip_debug_print_m(pfx, lvl, buf, GET_MODE(x));
2085 102 dgisselq
+               } break;
2086
+       case IF_THEN_ELSE: // 51
2087
+               zip_debug_print(pfx, lvl, "(IF-THEN-ELSE");
2088
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2089
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2090
+               zip_debug_rtx_1(pfx, XEXP(x,2),lvl+1);
2091
+               zip_debug_print(pfx, lvl, ")");
2092
+               break;
2093
+       case PC:
2094
+               zip_debug_print(pfx, lvl, "(PC)");
2095
+               break;
2096
+       case CC0:
2097
+               zip_debug_print(pfx, lvl, "(CC0)");
2098
+               break;
2099
+       case COMPARE:
2100 127 dgisselq
+               zip_debug_print_m(pfx, lvl, "(COMPARE", GET_MODE(x));
2101 102 dgisselq
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2102
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2103
+               zip_debug_print(pfx, lvl, ")");
2104
+               break;
2105 111 dgisselq
+       case CONST:
2106
+               zip_debug_print_m(pfx, lvl, "(CONST", GET_MODE(x));
2107
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2108
+               zip_debug_print(pfx, lvl, ")");
2109
+               break;
2110 102 dgisselq
+       case CONST_INT:
2111 192 dgisselq
+               { char buf[128];
2112 102 dgisselq
+               if (GET_MODE(x)==SImode)
2113 135 dgisselq
+                       sprintf(buf, "(CONST_INT:SI %ld)", (long)INTVAL(x));
2114 102 dgisselq
+               else if (GET_MODE(x)==VOIDmode)
2115 135 dgisselq
+                       sprintf(buf, "(CONST_INT:V %ld)", (long)INTVAL(x));
2116 102 dgisselq
+               else
2117 135 dgisselq
+                       sprintf(buf, "(CONST_INT:? %ld)", (long)INTVAL(x));
2118 102 dgisselq
+               zip_debug_print(pfx, lvl, buf);
2119
+               } break;
2120
+       case LABEL_REF:
2121 122 dgisselq
+               { char buf[256];
2122 111 dgisselq
+               sprintf(buf, "(LABEL *.L%d)", CODE_LABEL_NUMBER(LABEL_REF_LABEL(x)));
2123
+               zip_debug_print(pfx, lvl, buf);
2124
+               }
2125 102 dgisselq
+               break;
2126
+       case SYMBOL_REF:
2127
+               {
2128 192 dgisselq
+                       char buf[128];
2129 102 dgisselq
+                       sprintf(buf, "(SYMBOL: %s)", XSTR(x,0));
2130
+                       // fprintf(file, "%s", XSTR(x,0));
2131
+                       zip_debug_print(pfx, lvl, buf);
2132
+               }
2133
+               break;
2134
+       case MEM:
2135
+               zip_debug_print_m(pfx, lvl, "(MEM", GET_MODE(x));
2136
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2137
+               zip_debug_print(pfx, lvl, ")");
2138
+               break;
2139
+       /*
2140
+       case VALUE:
2141
+               {
2142
+                       char buf[64];
2143
+                       sprintf(buf, "(VALUE: %d)", INTVAL(XEXP,0));
2144
+                       zip_debug_print_m(pfx, lvl, "buf", GET_MODE(x));
2145
+               }
2146
+               break;
2147
+       */
2148
+       case PLUS:
2149
+               zip_debug_print_m(pfx, lvl, "(PLUS", GET_MODE(x));
2150
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2151
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2152
+               zip_debug_print(pfx, lvl, ")");
2153
+               break;
2154
+       case MINUS:
2155
+               zip_debug_print_m(pfx, lvl, "(MINUS", GET_MODE(x));
2156
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2157
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2158
+               zip_debug_print(pfx, lvl, ")");
2159
+               break;
2160
+       case AND:
2161
+               zip_debug_print_m(pfx, lvl, "(AND", GET_MODE(x));
2162
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2163
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2164
+               zip_debug_print(pfx, lvl, ")");
2165
+               break;
2166
+       case IOR:
2167
+               zip_debug_print_m(pfx, lvl, "(OR", GET_MODE(x));
2168
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2169
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2170
+               zip_debug_print(pfx, lvl, ")");
2171
+               break;
2172
+       case XOR:
2173
+               zip_debug_print_m(pfx, lvl, "(XOR", GET_MODE(x));
2174
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2175
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2176
+               zip_debug_print(pfx, lvl, ")");
2177
+               break;
2178
+       case MULT:
2179
+               zip_debug_print_m(pfx, lvl, "(MULT", GET_MODE(x));
2180
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2181
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2182
+               zip_debug_print(pfx, lvl, ")");
2183
+               break;
2184
+       case EQ:        //
2185
+               zip_debug_print_m(pfx, lvl, "(EQ", GET_MODE(x));
2186
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2187
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2188
+               zip_debug_print(pfx, lvl, ")");
2189
+               break;
2190
+       case NE:        //
2191
+               zip_debug_print_m(pfx, lvl, "(NE", GET_MODE(x));
2192
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2193
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2194
+               zip_debug_print(pfx, lvl, ")");
2195
+               break;
2196
+       case GE:        //
2197
+               zip_debug_print_m(pfx, lvl, "(GE", GET_MODE(x));
2198
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2199
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2200
+               zip_debug_print(pfx, lvl, ")");
2201
+               break;
2202
+       case GT:        //
2203
+               zip_debug_print_m(pfx, lvl, "(GT", GET_MODE(x));
2204
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2205
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2206
+               zip_debug_print(pfx, lvl, ")");
2207
+               break;
2208
+       case LE:        //
2209
+               zip_debug_print_m(pfx, lvl, "(LE", GET_MODE(x));
2210
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2211
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2212
+               zip_debug_print(pfx, lvl, ")");
2213
+               break;
2214
+       case LT:        //
2215
+               zip_debug_print_m(pfx, lvl, "(LT", GET_MODE(x));
2216
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2217
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2218
+               zip_debug_print(pfx, lvl, ")");
2219
+               break;
2220
+       case GEU:       //
2221
+               zip_debug_print_m(pfx, lvl, "(GEU", GET_MODE(x));
2222
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2223
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2224
+               zip_debug_print(pfx, lvl, ")");
2225
+               break;
2226
+       case GTU:       //
2227
+               zip_debug_print_m(pfx, lvl, "(GTU", GET_MODE(x));
2228
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2229
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2230
+               zip_debug_print(pfx, lvl, ")");
2231
+               break;
2232
+       case LEU:       //
2233
+               zip_debug_print_m(pfx, lvl, "(LEU", GET_MODE(x));
2234
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2235
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2236
+               zip_debug_print(pfx, lvl, ")");
2237
+               break;
2238
+       case LTU:       //
2239
+               zip_debug_print_m(pfx, lvl, "(LTU", GET_MODE(x));
2240
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2241
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2242
+               zip_debug_print(pfx, lvl, ")");
2243
+               break;
2244
+       case SCRATCH:   //
2245
+               zip_debug_print_m(pfx, lvl, "(SCRATCH)", GET_MODE(x));
2246
+               break;
2247
+       case SUBREG:
2248
+               { char buf[25];
2249 111 dgisselq
+               if (REG_P(XEXP(x,0))) {
2250
+                       sprintf(buf, "(SUBREG %d/%d)", REGNO(XEXP(x,0)),
2251
+                               SUBREG_BYTE(x));
2252
+                       zip_debug_print(pfx, lvl, buf);
2253
+               } else if (MEM_P(XEXP(x,0))) {
2254
+                       sprintf(buf, "(SUBREG /%d", SUBREG_BYTE(x));
2255
+                       zip_debug_print(pfx, lvl, buf);
2256
+                       zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2257
+                       zip_debug_print(pfx, lvl, ")");
2258
+               } else {
2259
+                       sprintf(buf, "(SUBREG UNK /%d", SUBREG_BYTE(x));
2260
+                       zip_debug_print(pfx, lvl, buf);
2261
+                       zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2262
+                       zip_debug_print(pfx, lvl, ")");
2263
+               }}
2264
+               break;
2265 127 dgisselq
+       case ASHIFT:
2266
+               zip_debug_print_m(pfx, lvl, "(ASHIFT", GET_MODE(x));
2267
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2268
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2269
+               zip_debug_print(pfx, lvl, ")");
2270
+               break;
2271
+       case ASHIFTRT:
2272
+               zip_debug_print_m(pfx, lvl, "(ASHIFTRT", GET_MODE(x));
2273
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2274
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2275
+               zip_debug_print(pfx, lvl, ")");
2276
+               break;
2277
+       case LSHIFTRT:
2278
+               zip_debug_print_m(pfx, lvl, "(LSHIFTRT", GET_MODE(x));
2279
+               zip_debug_rtx_1(pfx, XEXP(x,0),lvl+1);
2280
+               zip_debug_rtx_1(pfx, XEXP(x,1),lvl+1);
2281
+               zip_debug_print(pfx, lvl, ")");
2282
+               break;
2283 102 dgisselq
+       default:
2284 111 dgisselq
+               { char buf[128];
2285 102 dgisselq
+               sprintf(buf, "(? = %d) -- calling DEBUG-RTX", GET_CODE(x));
2286
+               zip_debug_print(pfx, lvl, buf);
2287
+               debug_rtx(x);
2288
+               } break;
2289
+       }
2290
+}
2291
+
2292
+void
2293
+zip_debug_rtx_pfx(const char *pfx, const_rtx x) {
2294
+       zip_debug_rtx_1(pfx, x, 0);
2295
+}
2296
+
2297
+void
2298
+zip_debug_rtx(const_rtx x) {
2299
+       zip_debug_rtx_pfx("", x);
2300
+}
2301
+
2302
+void
2303 142 dgisselq
+zip_debug_ccode(int ccode) {
2304
+       switch(ccode) {
2305
+       case    EQ: fprintf(stderr, "EQ"); break;
2306
+       case    NE: fprintf(stderr, "NE"); break;
2307
+       case    GT: fprintf(stderr, "GT"); break;
2308
+       case    GE: fprintf(stderr, "GE"); break;
2309
+       case    LT: fprintf(stderr, "LT"); break;
2310
+       case    LE: fprintf(stderr, "LE"); break;
2311
+       case    GTU: fprintf(stderr, "GTU"); break;
2312
+       case    GEU: fprintf(stderr, "GEU"); break;
2313
+       case    LTU: fprintf(stderr, "LTU"); break;
2314
+       case    LEU: fprintf(stderr, "LEU"); break;
2315
+       default:
2316
+               fprintf(stderr, "%d", ccode); break;
2317
+       }
2318
+}
2319
+
2320
+void
2321 102 dgisselq
+zip_debug_insn(rtx_insn *insn ATTRIBUTE_UNUSED) {
2322
+}
2323
+
2324
+void
2325
+zip_debug_bb(basic_block bb) {
2326
+       rtx_insn        *insn;
2327
+
2328
+       fprintf(stderr, "************ BASIC-BLOCK ***************\n");
2329
+       FOR_BB_INSNS(bb, insn)
2330
+       {
2331
+               zip_debug_rtx(insn);
2332
+       }
2333
+}
2334
+
2335
+
2336
+static bool
2337 122 dgisselq
+zip_legitimate_opb(rtx x, bool strict)
2338 102 dgisselq
+{
2339 103 dgisselq
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2340 102 dgisselq
+
2341 111 dgisselq
+       if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB\n");
2342 102 dgisselq
+       if (dbg) zip_debug_rtx_pfx("Test: ", x);
2343
+
2344
+       if (NULL_RTX == x)
2345
+               return false;
2346 122 dgisselq
+       else if ((GET_MODE(x) != SImode)&&(GET_MODE(x) != VOIDmode)) {
2347
+               if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> Mode failure\n");
2348 102 dgisselq
+               return false;
2349 122 dgisselq
+       } else if ((strict)&&(REG_P(x))) {
2350
+               if (REGNO(x)<zip_CC) {
2351
+                       if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> (Reg)\n");
2352
+                       return true;
2353
+               } else return false;
2354
+       } else if (register_operand(x, GET_MODE(x))) {
2355
+               // This also handles subregs
2356
+               if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> (Reg)\n");
2357
+               return true;
2358 111 dgisselq
+       } else if ((CONST_INT_P(x))
2359
+               &&(INTVAL(x) >= zip_min_opb_imm)
2360
+               &&(INTVAL(x) <= zip_max_opb_imm)) {
2361 136 dgisselq
+               if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> YES! (Const) %ld <= %ld <= %ld\n", (long)zip_min_opb_imm, (long)INTVAL(x), (long)zip_max_opb_imm);
2362 111 dgisselq
+               return true;
2363 122 dgisselq
+       // } else if ((GET_CODE(x) == LABEL_REF)||(GET_CODE(x)==CODE_LABEL)) {
2364
+               // return true;
2365 102 dgisselq
+       } else if (GET_CODE(x) == PLUS) {
2366
+               // Is it a valid register?
2367 122 dgisselq
+               if ((!strict)&&(!register_operand((rtx)XEXP((rtx)x,0), GET_MODE(x)))) {
2368 111 dgisselq
+                       if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> No (No reg in +%s)\n",
2369 102 dgisselq
+                       (GET_CODE(XEXP(x,1))==REG)?", reg in op[1]":"");
2370
+                       return false;
2371 122 dgisselq
+               } else if ((strict)&&((!REG_P(XEXP(x,0)))||(REGNO(XEXP(x,0))>=zip_CC))) {
2372 102 dgisselq
+                       return false;
2373
+               } if ((GET_CODE(XEXP(x, 1)) == CONST_INT)
2374
+                       &&(INTVAL(XEXP(x, 1)) <= zip_max_anchor_offset)
2375
+                       &&(INTVAL(XEXP(x, 1)) >= zip_min_anchor_offset)) {
2376 111 dgisselq
+                       if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> YES! (reg+int)\n");
2377 103 dgisselq
+                       // if((INTVAL(XEXP(x,1))<0)&&(REGNO(XEXP(x,0))==zip_SP))
2378
+                               // gcc_unreachable();
2379 102 dgisselq
+                       return true;
2380
+               } if ((GET_CODE(XEXP(x, 1)) == LABEL_REF)
2381 122 dgisselq
+                       ||(GET_CODE(XEXP(x, 1)) == CODE_LABEL)
2382 102 dgisselq
+                       ||(GET_CODE(XEXP(x, 1)) == SYMBOL_REF)) {
2383
+                       // While we can technically support this, the problem
2384
+                       // is that the symbol address could be anywhere, and we
2385
+                       // have no way of recovering if it's outside of our
2386
+                       // 14 allowable bits.
2387 111 dgisselq
+                       if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> No. (reg+lbl)\n");
2388 102 dgisselq
+                       return false;
2389
+               }
2390
+       }
2391
+
2392 111 dgisselq
+       if (dbg) fprintf(stderr, "ZIP-LEGITIMATE-OPB -> No\n");
2393 102 dgisselq
+       if (dbg) zip_debug_rtx(x);
2394
+       return false;
2395
+}
2396
+
2397
+static bool
2398
+zip_legitimate_move_operand_p(machine_mode mode ATTRIBUTE_UNUSED, rtx x, bool strict) {
2399
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2400
+
2401
+       if (dbg) fprintf(stderr, "ZIP-VALID-MOVE-OPERAND\n");
2402
+       if (dbg) zip_debug_rtx_pfx("VMov?: ", x);
2403
+
2404 122 dgisselq
+       if (!zip_legitimate_opb(x, strict))
2405 102 dgisselq
+               return false;
2406 122 dgisselq
+       else if ((GET_CODE(x)==PLUS)&&(CONST_INT_P(XEXP(x,1)))) {
2407
+               if ((INTVAL(XEXP(x, 1)) > zip_max_mov_offset)
2408
+                       ||(INTVAL(XEXP(x, 1)) < zip_min_mov_offset)) {
2409 135 dgisselq
+                       if (dbg) fprintf(stderr, "ZIP-VALID-MOVE-OPERAND -> NO! (reg+int), int out of bounds: %ld\n", (long)INTVAL(XEXP(x,1)));
2410 102 dgisselq
+                       return false;
2411
+               }
2412
+       }
2413
+
2414 122 dgisselq
+       if (dbg) fprintf(stderr, "ZIP-VALID-MOVE-OPERAND -> Yes\n");
2415 102 dgisselq
+       if (dbg) zip_debug_rtx(x);
2416 122 dgisselq
+       return true;
2417 102 dgisselq
+}
2418
+
2419
+int
2420
+zip_pd_mov_operand(rtx op)
2421
+{
2422
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2423
+
2424
+       if (dbg) fprintf(stderr, "ZIP-VALID-MOV(predicate) for OPERAND\n");
2425
+       return zip_legitimate_move_operand_p(VOIDmode, op, !can_create_pseudo_p());
2426
+}
2427
+
2428
+int
2429 111 dgisselq
+zip_pd_mvimm_operand(rtx op)
2430
+{
2431
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2432
+
2433
+       if (dbg) fprintf(stderr, "ZIP-VALID-MVIMM(predicate) for OPERAND\n");
2434
+       if (!CONST_INT_P(op))
2435
+               return false;
2436
+       if (INTVAL(op) > zip_max_mov_offset)
2437
+               return false;
2438
+       if (INTVAL(op) < zip_min_mov_offset)
2439
+               return false;
2440
+       return true;
2441
+}
2442
+
2443
+int
2444
+zip_pd_imm_operand(rtx op)
2445
+{
2446
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2447
+
2448
+       if (dbg) fprintf(stderr, "ZIP-VALID-IMM(predicate) for OPERAND\n");
2449
+       if (!CONST_INT_P(op))
2450
+               return false;
2451
+       if (INTVAL(op) > zip_max_anchor_offset)
2452
+               return false;
2453
+       if (INTVAL(op) < zip_min_anchor_offset)
2454
+               return false;
2455
+       return true;
2456
+}
2457
+
2458
+int
2459 102 dgisselq
+zip_address_operand(rtx op)
2460
+{
2461
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2462
+
2463
+       if (dbg) fprintf(stderr, "ZIP-ADDRESS for OPERAND\n");
2464 111 dgisselq
+       if ((REG_P(op))&&(REGNO(op)==zip_CC))
2465
+               return false;
2466
+       else if ((GET_CODE(op) == PLUS)&&(REG_P(XEXP(op,0)))
2467
+                       &&(REGNO(XEXP(op,0))==zip_CC))
2468
+               return false;
2469
+       else
2470
+               return zip_legitimate_opb(op, !can_create_pseudo_p());
2471 102 dgisselq
+}
2472
+
2473
+int
2474 111 dgisselq
+zip_pd_opb_operand(rtx op)
2475 102 dgisselq
+{
2476
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2477
+
2478 111 dgisselq
+       if (dbg) fprintf(stderr, "ZIP-OPB(predicate) for OPERAND\n");
2479 122 dgisselq
+       return zip_legitimate_opb(op, false); //, !can_create_pseudo_p());
2480 102 dgisselq
+}
2481
+
2482
+int
2483
+zip_ct_address_operand(rtx op)
2484
+{
2485
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2486
+
2487
+       if (dbg) fprintf(stderr, "ZIP-ADDRESS(constraint) for OPERAND\n");
2488 111 dgisselq
+       return zip_legitimate_opb(op, !can_create_pseudo_p());
2489 102 dgisselq
+}
2490
+
2491
+int
2492
+zip_const_address_operand(rtx x) {
2493
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2494
+
2495
+       if (dbg) fprintf(stderr, "is ZIP-CONST-ADDRESS?\n");
2496
+       if (dbg) zip_debug_rtx(x);
2497 127 dgisselq
+       if ((GET_MODE(x) != SImode)&&(GET_MODE(x) != VOIDmode)) {
2498
+               fprintf(stderr, "is ZIP-CONST-ADDRESS? -> NO, BAD MODE\n");
2499 102 dgisselq
+               return false;
2500 127 dgisselq
+       }
2501 102 dgisselq
+       if ((GET_CODE(x) == LABEL_REF)
2502
+                       ||(GET_CODE(x) == CODE_LABEL)
2503
+                       ||(GET_CODE(x) == SYMBOL_REF)) {
2504 127 dgisselq
+               if (dbg) fprintf(stderr, "is ZIP-CONST-ADDRESS? -> YES! (LBL)\n");
2505 102 dgisselq
+               return true;
2506
+       } else if (CONST_INT_P(x)) {
2507 127 dgisselq
+               if (dbg) fprintf(stderr, "is ZIP-CONST-ADDRESS? -> YES! (INT)\n");
2508 102 dgisselq
+               return true;
2509
+       } else if (GET_CODE(x) == PLUS) {
2510
+               if (dbg) fprintf(stderr, "is ZIP-CONST-ADDRESS(PLUS)\n");
2511
+               return ((zip_const_address_operand(XEXP(x,0)))
2512
+                       &&(CONST_INT_P(XEXP(x,1))));
2513
+       } else if (GET_CODE(x) == MINUS) {
2514
+               if (dbg) fprintf(stderr, "is ZIP-CONST-ADDRESS(MINUS)\n");
2515
+               return ((zip_const_address_operand(XEXP(x,0)))
2516
+                       &&(zip_const_address_operand(XEXP(x,1))));
2517
+       }
2518
+
2519
+       if (dbg) fprintf(stderr, "is ZIP-CONST-ADDRESS? -> No\n");
2520
+       if (dbg) zip_debug_rtx(x);
2521
+       return false;
2522
+}
2523
+
2524
+int
2525
+zip_ct_const_address_operand(rtx x) {
2526
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2527
+
2528
+       if (dbg) fprintf(stderr, "ZIP-CONST-ADDRESS(constraint)\n");
2529
+       return zip_const_address_operand(x);
2530
+}
2531
+
2532
+int
2533
+zip_pd_const_address_operand(rtx x) {
2534
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2535
+
2536
+       if (dbg) fprintf(stderr, "ZIP-CONST-ADDRESS(predicate)\n");
2537
+       return zip_const_address_operand(x);
2538
+}
2539
+
2540
+
2541
+static bool
2542
+zip_legitimate_address_p(machine_mode mode ATTRIBUTE_UNUSED, rtx x, bool strict)
2543
+{
2544
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2545
+
2546
+       if (dbg) fprintf(stderr, "Zip-LEGITIMATE-ADDRESS-P\n");
2547
+       if (dbg) zip_debug_rtx(x);
2548
+
2549
+       // Only insist the register be a valid register if strict is true
2550 111 dgisselq
+       if (zip_legitimate_opb(x, strict))
2551 102 dgisselq
+               return true;
2552 111 dgisselq
+       // else if (zip_const_address_operand(x))
2553
+               // return true;
2554 102 dgisselq
+
2555
+       return false;
2556
+}
2557
+
2558 111 dgisselq
+static rtx
2559
+zip_legitimize_address(rtx x, rtx oldx ATTRIBUTE_UNUSED, machine_mode mode ATTRIBUTE_UNUSED) {
2560
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2561
+
2562
+       if (dbg) zip_debug_rtx_pfx("LEGITIMIZE: ", x);
2563
+       if (zip_legitimate_address_p(mode, x, !can_create_pseudo_p()))
2564
+               return x;
2565
+
2566
+       if (GET_CODE(x)==PLUS) {
2567
+               if (!REG_P(XEXP(x,0)))
2568
+                       XEXP(x,0) = force_reg(GET_MODE(x),XEXP(x,0));
2569
+               if ((!zip_legitimate_address_p(mode, x, !can_create_pseudo_p()))
2570
+                       &&(!CONST_INT_P(XEXP(x,1))))
2571
+                       x = force_reg(GET_MODE(x),x);
2572
+       } else if (MEM_P(x))
2573
+               x = force_reg(GET_MODE(x),x);
2574
+
2575
+       if (dbg) zip_debug_rtx_pfx("LEGITIMATE: ", x);
2576
+       return x;
2577
+}
2578
+
2579 102 dgisselq
+void
2580
+zip_asm_output_def(FILE *stream, const char *name, const char *value)
2581
+{
2582
+       assemble_name(stream, name);
2583
+       fprintf(stream, "\t.equ ");
2584
+       assemble_name(stream, value);
2585
+       fputc('\n', stream);
2586
+}
2587
+
2588 111 dgisselq
+#define        USE_SUBREG
2589
+#ifdef USE_SUBREG
2590
+#define        SREG_P(RTX) ((SUBREG_P(RTX))&&(REG_P(XEXP(RTX,0))))
2591
+#define        SMEM_P(RTX) ((SUBREG_P(RTX))&&(MEM_P(XEXP(RTX,0))))
2592
+#else
2593
+#define        SREG_P(RTX)     false
2594
+#define        SMEM_P(RTX)     false
2595
+#endif
2596 102 dgisselq
+
2597
+const char *zip_set_zero_or_one(rtx condition, rtx dst) {
2598 103 dgisselq
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2599 102 dgisselq
+       if (dbg) fprintf(stderr, "ZIP::SET-ZERO-OR-ONE\n");
2600
+       if (dbg) zip_debug_rtx_pfx("CND", condition);
2601
+       if (dbg) zip_debug_rtx_pfx("REG", dst);
2602
+       switch(GET_CODE(condition)) {
2603
+       case EQ:        return "LDI\t0,%0\n\tLDILO.Z\t1,%0";
2604
+       case NE:        return "LDI\t0,%0\n\tLDILO.NZ\t1,%0";
2605
+       case LT:        return "LDI\t0,%0\n\tLDILO.LT\t1,%0";
2606
+       case GT:        return "LDI\t0,%0\n\tLDILO.GT\t1,%0";
2607
+       case LE:        return "LDI\t1,%0\n\tLDILO.GT\t0,%0";
2608
+       case GE:        return "LDI\t0,%0\n\tLDILO.GE\t1,%0";
2609
+       case LTU:       return "LDI\t0,%0\n\tLDILO.C\t1,%0";
2610
+       case GTU:       return "LDI\t1,%0\n\tLDILO.C\t0,%0\n\tLDILO.Z\t0,%0";
2611
+       case LEU:       return "LDI\t0,%0\n\tLDILO.C\t1,%0\n\tLDILO.Z\t1,%0";
2612
+       case GEU:       return "LDI\t1,%0\n\tLDILO.C\t0,%0";
2613
+       default:
2614
+               zip_debug_rtx(condition);
2615
+               internal_error("CSTORE Unsupported condition");
2616
+               return NULL;
2617
+       }
2618
+}
2619
+
2620 127 dgisselq
+/*
2621 102 dgisselq
+const char *zip_binary_movsicc(rtx_code condition, const char *op, const int opno) {
2622
+       static char     result[64] = "";
2623
+       switch(condition) {
2624
+               //
2625
+               // Result already exists in the iffalse register
2626
+               // Can't change it.  Therefore, on the
2627
+               // condition ... move true register to the
2628
+               // destination
2629
+               //
2630
+               case EQ:        sprintf(result, "%s.Z\t%%%d,%%0", op, opno); break;
2631
+               case NE:        sprintf(result, "%s.NZ\t%%%d,%%0", op, opno); break;
2632
+               case LT:        sprintf(result, "%s.LT\t%%%d,%%0", op, opno); break;
2633
+               case GT:        sprintf(result, "%s.GT\t%%%d,%%0", op, opno); break;
2634
+               // .LE doesn't exist on Zip CPU--turn this into two instructions
2635
+               case LE:        sprintf(result, "%s.LT\t%%%d,%%0\n\t%s.Z\t%%%d,%%0", op, opno, op, opno); break;
2636
+               case GE:        sprintf(result, "%s.GE\t%%%d,%%0", op, opno); break;
2637
+               case LTU:       sprintf(result, "%s.C\t%%%d,%%0", op, opno); break;
2638
+               //
2639
+               // .GTU doesn't exist on the Zip CPU either. We also note that
2640
+               // .C will never be set on an equal condition.  Therefore, we
2641
+               // turn this into a XOR.NZ 2,CC, which will set the .C condition
2642
+               // as long as .Z wasn't true.  We then undo this when we're
2643
+               // done.  This is possible since none of these instructions
2644
+               // (LDI/MOV/Lod conditional, nor Xor conditional) will ever set
2645
+               // the condition codes.
2646
+               //
2647
+               // This is obviously not very optimal.  Avoid this by all means
2648
+               // if you can
2649
+               case GTU:       sprintf(result, "XOR.NZ\t2,CC\n%s.C\t%%%d,%%0\n\tXOR.NZ\t2,CC", op, opno); break;
2650
+               // .LEU doesn't exist on Zip CPU either--turn this into another
2651
+               // two instructions
2652
+               case LEU:       sprintf(result, "%s.C\t%%%d,%%0\n\t%s.Z\t%%%d,%%0", op, opno, op, opno); break;
2653
+               //
2654
+               // .GEU doesn't exist on Zip CPU.  Implementing it her is
2655
+               // painful.  We can change the condition codes to make it so,
2656
+               // but the instruction requires the condition codes not be
2657
+               // changed.  Hence, we must change them back if we do so.
2658
+               //
2659
+               // .C will be set on less than but not equal.  Hence !.C will
2660
+               // be true on greater than or equal.
2661
+               case GEU:       sprintf(result, "XOR\t2,CC\n%s.C\t%%%d,%%0\n\tXOR\t2,CC", op, opno); break;
2662
+               default:
2663
+                       internal_error("MOVSICC(BINARY) Unsupported condition");
2664
+                       return NULL;
2665
+       } return result;
2666
+}
2667 127 dgisselq
+*/
2668 102 dgisselq
+
2669 127 dgisselq
+bool
2670
+zip_supported_condition(int c) {
2671
+       switch(c) {
2672
+       case NE: case LT: case EQ: case GT: case GE: case LTU:
2673
+               return true;
2674
+               break;
2675
+       default:
2676
+               break;
2677
+       } return false;
2678 102 dgisselq
+}
2679
+
2680 127 dgisselq
+bool
2681
+zip_signed_comparison(int c) {
2682
+       switch(c) {
2683
+       case NE: case LT: case EQ: case GT: case GE:
2684
+               return true;
2685
+       default:
2686
+               break;
2687
+       } return false;
2688
+}
2689
+
2690 142 dgisselq
+bool
2691 127 dgisselq
+zip_expand_movsicc(rtx dst, rtx condition, rtx iftrue, rtx iffalse) {
2692 142 dgisselq
+       rtx_insn *insn;
2693 103 dgisselq
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2694 102 dgisselq
+       if (dbg) fprintf(stderr, "ZIP::MOVSICC\n");
2695
+       if (dbg) zip_debug_rtx_pfx("DST", dst);
2696
+       if (dbg) zip_debug_rtx_pfx("CND", condition);
2697
+       if (dbg) zip_debug_rtx_pfx("TRU", iftrue);
2698
+       if (dbg) zip_debug_rtx_pfx("FAL", iffalse);
2699 127 dgisselq
+
2700
+       // Start with the condition
2701
+       rtx     cmpa = XEXP(condition,0), cmpb=XEXP(condition,1);
2702
+       enum rtx_code   cmpcode = GET_CODE(condition);
2703
+
2704 142 dgisselq
+       // Want to always do the false expression, and only sometimes the
2705
+       // true expression.  If, however, the false is a constant and the
2706
+       // true and destination are the same thing, this doesn't work.
2707
+       if (rtx_equal_p(dst, iftrue)) {
2708
+               // If the true value is the same as the destination already,
2709
+               // then swap so we only do the condition on true
2710
+               rtx tem = iffalse;
2711
+               iffalse = iftrue;
2712
+               iftrue  = tem;
2713
+               cmpcode = reverse_condition(cmpcode);
2714
+       }
2715
+
2716 127 dgisselq
+       //; Do we need to swap or adjust the condition?
2717
+       if (zip_supported_condition((int)cmpcode)) {
2718
+               // Keep everything as is
2719 142 dgisselq
+               if (dbg) fprintf(stderr, "ZIP::MOVSICC -- Condition is supported\n");
2720 127 dgisselq
+       } else if ((zip_supported_condition(reverse_condition(cmpcode)))
2721 142 dgisselq
+                       &&(!MEM_P(iffalse))
2722
+                       &&(!rtx_equal_p(dst,iffalse))) {
2723 127 dgisselq
+               rtx tem = iffalse;
2724
+               iffalse = iftrue;
2725
+               iftrue = tem;
2726
+
2727
+               cmpcode = reverse_condition(cmpcode);
2728
+       } else if ((zip_supported_condition((int)swap_condition(cmpcode)))
2729
+               &&((REG_P(cmpb))||(can_create_pseudo_p()))) {
2730
+               rtx tem = cmpa;
2731
+               cmpa = cmpb;
2732
+               cmpa = tem;
2733
+               cmpcode = swap_condition(cmpcode);
2734
+
2735
+               if ((GET_CODE(cmpa)==PLUS)&&(zip_signed_comparison((int)cmpcode))
2736
+                       &&(REG_P(XEXP(cmpa,0)))
2737
+                       &&(CONST_INT_P(XEXP(cmpa,1)))
2738
+                       &&(abs(INTVAL(XEXP(cmpa,1)))<(1<<17))) {
2739
+
2740
+                       // If we were doing CMP x(Rb),Ra
2741
+                       // and we just changed it to CMP Ra,x(Rb)
2742
+                       // adjust it to CMP -x(Ra),Rb
2743
+                       cmpb = plus_constant(SImode, cmpb, -INTVAL(XEXP(cmpa,1)));
2744
+                       cmpa = XEXP(cmpa,0);
2745
+               } else if (!REG_P(cmpa)) {
2746
+                       // Otherwise, if we had anything else in Rb other than
2747
+                       // a register ... such as a constant, then load it into
2748
+                       // a register before comparing it.  So
2749
+                       //      CMP x,Ra
2750
+                       // became
2751
+                       //      CMP Ra,x
2752
+                       // now becomes
2753
+                       //      LDI x,Rt
2754
+                       //      CMP Ra,Rt
2755
+                       // (We already tested for can_create_pseudo_p() above..)
2756
+                       tem = gen_reg_rtx(SImode);
2757
+                       emit_move_insn(tem, cmpa);
2758
+                       cmpa = tem;
2759 102 dgisselq
+               }
2760 127 dgisselq
+       } else {
2761
+               // Here's our last chance.
2762
+               // This will adjust for less than equal types of stuff
2763
+               int     cod = (int)cmpcode;
2764
+               zip_canonicalize_comparison(&cod, &cmpa, &cmpb, false);
2765
+               cmpcode = (enum rtx_code)cod;
2766 102 dgisselq
+       }
2767
+
2768 142 dgisselq
+       if (dbg) fprintf(stderr, "ZIP::MOVSICC -- Post-Modes\n");
2769
+       if (dbg) zip_debug_rtx_pfx("DST-P: ", dst);
2770
+       if (dbg) zip_debug_rtx_pfx("CND-P: ", condition);
2771
+       if (dbg) zip_debug_rtx_pfx("TRU-P: ", iftrue);
2772
+       if (dbg) zip_debug_rtx_pfx("FAL-P: ", iffalse);
2773
+
2774
+       if (!zip_supported_condition((int)cmpcode)) {
2775
+               if (dbg) {
2776
+               fprintf(stderr, "ZIP::MOVSICC -- Unsupported condition: ");
2777
+                       zip_debug_ccode(cmpcode);
2778
+                       fprintf(stderr, "\n");
2779
+               }
2780
+               return false;
2781
+       }
2782 127 dgisselq
+       gcc_assert(zip_supported_condition((int)cmpcode));
2783
+
2784
+       //; Always do the default move
2785 142 dgisselq
+       bool    conditionally_do_false = false;
2786
+       conditionally_do_false = (MEM_P(iffalse))
2787
+               &&(!rtx_equal_p(dst,iffalse))
2788
+               &&(zip_supported_condition(reverse_condition(cmpcode)));
2789
+       conditionally_do_false = conditionally_do_false || (rtx_equal_p(dst,iftrue));
2790
+       if ((conditionally_do_false)&&(!zip_supported_condition(reverse_condition(cmpcode)))) {
2791
+               if (dbg) {
2792
+                       fprintf(stderr, "ZIP::MOVSICC -- Cant support the reverse condition: ");
2793
+                       zip_debug_ccode(cmpcode);
2794
+                       fprintf(stderr, "\n");
2795
+               }
2796
+               return false;
2797
+       }
2798 127 dgisselq
+
2799 142 dgisselq
+       if ((!rtx_equal_p(dst, iffalse))&&(!conditionally_do_false)) {
2800
+               if (dbg)
2801
+               fprintf(stderr, "ZIP::MOVSICC -- EMITTING MOVE FALSE->DST\n");
2802
+               insn = emit_move_insn(dst, iffalse);
2803
+               if (dbg) zip_debug_rtx_pfx("BARE-U: ", insn);
2804
+       }
2805
+
2806 127 dgisselq
+       rtx     cc_rtx = gen_rtx_REG(CCmode, zip_CC);
2807
+
2808
+       //; Now let's get our comparison right
2809 142 dgisselq
+       if (dbg) fprintf(stderr, "ZIP::MOVSICC -- EMITTING COMPARISON\n");
2810
+       insn = emit_insn(gen_rtx_SET(VOIDmode, cc_rtx,
2811 127 dgisselq
+               gen_rtx_COMPARE(CCmode, cmpa, cmpb)));
2812 142 dgisselq
+       if (dbg) zip_debug_rtx_pfx("BARE-C: ", insn);
2813 127 dgisselq
+
2814
+       //; Finally, let's load the value on true
2815 142 dgisselq
+       if (!rtx_equal_p(dst, iftrue)) {
2816
+               if (dbg) fprintf(stderr, "ZIP::MOVSICC -- EMITTING BARE\n");
2817
+               insn=emit_insn(gen_movsicc_bare(dst,
2818 127 dgisselq
+                       gen_rtx_fmt_ee(cmpcode, SImode, NULL_RTX, NULL_RTX),
2819
+                       iftrue, dst));
2820 142 dgisselq
+               if (dbg) zip_debug_rtx_pfx("BARE-T: ", insn);
2821
+       }
2822
+
2823
+       if (conditionally_do_false) {
2824
+               gcc_assert(zip_supported_condition(reverse_condition(cmpcode)));
2825
+               insn=emit_insn(gen_movsicc_bare(dst,
2826
+                       gen_rtx_fmt_ee(reverse_condition(cmpcode), SImode,
2827
+                       NULL_RTX, NULL_RTX), iffalse, dst));
2828
+               if (dbg) zip_debug_rtx_pfx("BARE-F: ", insn);
2829
+       }
2830
+
2831
+       // Return true on success
2832
+       return true;
2833 102 dgisselq
+}
2834
+
2835
+const char *zip_addsicc(rtx dst, rtx condition, rtx ifsrc, rtx addv ATTRIBUTE_UNUSED) {
2836
+       // We know upon entry that REG_P(dst) must be true
2837
+       if (!REG_P(dst))
2838
+               internal_error("%s","ADDSICC into something other than register");
2839
+       if ((REG_P(ifsrc))&&(REGNO(dst)==REGNO(ifsrc))) {
2840
+               switch (GET_CODE(condition)) {
2841
+               case EQ: return "ADD.Z\t%3,%0";
2842
+               case NE: return "ADD.NZ\t%3,%0";
2843
+               case LT: return "ADD.LT\t%3,%0";
2844
+               case GT: return "ADD.GT\t%3,%0";
2845
+               case LE: return "ADD.LT\t%3,%0\n\tADD.Z\t%3,%0";
2846
+               case GE: return "ADD.GE\t%3,%0";
2847
+               case LTU: return "ADD.C\t%3,%0";
2848
+               case LEU: return "ADD.C\t%3,%0\n\tADD.Z\t%3,%0";
2849
+               case GEU: return "XOR\t2,CC\n\tADD.C\t%3,%0\n\tXOR\t2,CC";
2850
+               // Can do a GEU comparison, and then undo on the Zero condition
2851
+               case GTU: return "XOR\t2,CC\n\tADD.C\t%3,%0\n\tSUB.Z\t%3,%0\n\tXOR\t2,CC";
2852
+               default:
2853
+                       internal_error("%s", "Zip/No usable addsi expansion");
2854
+                       break;
2855
+               }
2856
+       } else {
2857
+               // MOV A+REG,REG
2858
+               switch (GET_CODE(condition)) {
2859
+               case EQ: return "MOV.Z\t%3+%2,%0";
2860
+               case NE: return "MOV.NZ\t%3+%2,%0";
2861
+               case LT: return "MOV.LT\t%3+%2,%0";
2862
+               case GT: return "MOV.GT\t%3+%2,%0";
2863
+               case LE: return "MOV.LT\t%3+%2,%0\n\tMOV.Z\t%3+%2,%0";
2864
+               case GE: return "MOV.GE\t%3+%2,%0";
2865
+               case LTU: return "MOV.C\t%3+%2,%0";
2866
+               case LEU: return "MOV.C\t%3+%2,%0\n\tMOV.Z\t%3+%2,%0";
2867
+               case GEU: return "XOR\t2,CC\n\tMOV.C\t%3+%2,%0\n\tXOR\t2,CC";
2868
+               // Can do a GEU comparison, and then undo on the Zero condition
2869
+               // EXCEPT: with a move instruction, what's there to undo?  We
2870
+               // just clobbered our register!
2871
+               // case GTU: return "XOR\t2,CC\n\tMOV.C\t%3,%0\n\tSUB.Z\t%3,%0XOR\t2,CC";
2872
+               default:
2873
+                       internal_error("%s", "Zip/No usable addsi(reg,reg) expansion");
2874
+                       break;
2875
+               }
2876
+       }
2877
+
2878
+       return "BREAK";
2879
+}
2880
+
2881 103 dgisselq
+static int     zip_memory_move_cost(machine_mode mode, reg_class_t ATTRIBUTE_UNUSED, bool in ATTRIBUTE_UNUSED) {
2882 102 dgisselq
+       int     rv = 14;
2883
+       if ((mode == DImode)||(mode == DFmode))
2884
+               rv += 2;
2885
+       return rv;
2886
+}
2887
+
2888 103 dgisselq
+// #warning "How do we tell the compiler LDI label is expensive as 2 ops"?
2889 117 dgisselq
+static bool    zip_cannot_modify_jumps_p(void) {
2890
+       // Let's try their suggested approach, keeping us from modifying jumps
2891
+       // after reload.  This should also allow our peephole2 optimizations
2892
+       // to adjust things back to what they need to be if necessary.
2893
+       return (reload_completed || reload_in_progress);
2894
+}
2895 122 dgisselq
+
2896
+rtx_insn       *zip_ifcvt_info;
2897
+
2898
+void
2899
+zip_ifcvt_modify_tests(ce_if_block *ce_info ATTRIBUTE_UNUSED, rtx *true_expr, rtx *false_expr) {
2900
+       const bool      dbg = ((ALL_DEBUG_ON)||(false))&&(!ALL_DEBUG_OFF);
2901
+       if (dbg) fprintf(stderr, "IFCVT-MODIFY-TESTS\n");
2902
+       if (*true_expr) switch(GET_CODE(*true_expr)) {
2903
+               case LE:
2904
+               case GTU:
2905
+               case GEU:
2906
+               case LEU:
2907
+                       if (dbg) fprintf(stderr, "TRUE, missing expr\n");
2908
+                       if (dbg) zip_debug_rtx(*true_expr);
2909
+                       *true_expr = NULL_RTX;
2910
+                       break;
2911
+               default: // LT, GT, GTE, LTU, NE, EQ
2912
+                       break;
2913
+       }
2914
+
2915
+       if (*false_expr) switch(GET_CODE(*false_expr)) {
2916
+               case LE:
2917
+               case GTU:
2918
+               case GEU:
2919
+               case LEU:
2920
+                       if (dbg) fprintf(stderr, "FALSE, missing expr\n");
2921
+                       if (dbg) zip_debug_rtx(*false_expr);
2922
+                       *false_expr = NULL_RTX;
2923
+               default:
2924
+                       break;
2925
+       }
2926
+       if ((dbg)&&((!*true_expr)||(!*false_expr)))
2927
+               fprintf(stderr, "IFCVT-MODIFY-TESTS -- FAIL\n");
2928
+}
2929
+
2930
+void
2931 142 dgisselq
+zip_ifcvt_machdep_init(struct ce_if_block *ceinfo ATTRIBUTE_UNUSED) {
2932 122 dgisselq
+/*
2933 142 dgisselq
+if (!ceinfo->then_bb)
2934
+       return;
2935
+rtx_insn *insn;
2936
+FOR_BB_INSNS(ceinfo->then_bb, insn) {
2937
+       fprintf(stderr, "IFCVT -- INIT\n");
2938
+       zip_debug_rtx_pfx("INIT-BB", insn);
2939 122 dgisselq
+}
2940
+*/
2941
+/*
2942
+       zip_ifcvt_info = NULL;
2943
+       rtx_insn *insn, *ifinsn = NULL;
2944
+       FOR_BB_INSNS(ceinfo->test_bb, insn) {
2945
+               rtx     p;
2946
+               p = single_set(insn);
2947
+               if (!p) continue;
2948
+               if (SET_DEST(p)==pc_rtx) {
2949
+                       ifinsn = insn;
2950
+               }
2951
+               if (!REG_P(SET_DEST(p)))
2952
+                       continue;
2953
+               if (GET_MODE(SET_DEST(p))!=CCmode)
2954
+                       continue;
2955
+               if (REGNO(SET_DEST(p))!=zip_CC)
2956
+                       continue;
2957
+               zip_ifcvt_info = insn;
2958
+       }
2959
+
2960
+       if (zip_ifcvt_info)
2961
+               zip_debug_rtx_pfx("PUTATIVE-CMP",zip_ifcvt_info);
2962
+       if (ifinsn)
2963
+               zip_debug_rtx_pfx("PRIOR-JMP",ifinsn);
2964
+*/
2965
+}
2966
+
2967 142 dgisselq
+void
2968
+zip_ifcvt_modify_insn(struct ce_if_block *ceinfo ATTRIBUTE_UNUSED,
2969
+               rtx pattern ATTRIBUTE_UNUSED,
2970
+               rtx_insn *insn ATTRIBUTE_UNUSED) {
2971
+       // zip_debug_rtx_pfx("MODIFY-INSN: ", insn);
2972
+}
2973
+
2974
+void
2975
+zip_ifcvt_modify_cancel(struct ce_if_block *ceinfo ATTRIBUTE_UNUSED) {
2976
+/*
2977
+       fprintf(stderr, "IFCVT -- CANCEL\n");
2978
+       zip_ifcvt_info = NULL;
2979
+*/
2980
+}
2981
+
2982
+void
2983
+zip_ifcvt_modify_final(struct ce_if_block *ceinfo ATTRIBUTE_UNUSED) {
2984
+/*
2985
+rtx_insn *insn;
2986
+FOR_BB_INSNS(ceinfo->test_bb, insn) {
2987
+       fprintf(stderr, "IFCVT -- FINAL\n");
2988
+       zip_debug_rtx_pfx("FINAL-TEST-BB", insn);
2989
+}
2990
+       zip_ifcvt_info = NULL;
2991
+*/
2992
+}
2993
+
2994
+
2995 127 dgisselq
+int    zip_insn_sets_cc(rtx_insn *insn) {
2996
+       return (get_attr_ccresult(insn)==CCRESULT_SET);
2997
+}
2998
+
2999
+int    zip_is_conditional(rtx_insn *insn) {
3000
+       return (get_attr_conditional(insn)==CONDITIONAL_YES);
3001
+}
3002 102 dgisselq
diff -Naur '--exclude=*.swp' gcc-5.3.0-original/gcc/config/zip/zip.h gcc-5.3.0-zip/gcc/config/zip/zip.h
3003
--- gcc-5.3.0-original/gcc/config/zip/zip.h     1969-12-31 19:00:00.000000000 -0500
3004 191 dgisselq
+++ gcc-5.3.0-zip/gcc/config/zip/zip.h  2016-09-13 13:46:17.890711238 -0400
3005
@@ -0,0 +1,4095 @@
3006 102 dgisselq
+////////////////////////////////////////////////////////////////////////////////
3007
+//
3008
+// Filename:   gcc/config/zip/zip.h
3009
+//
3010
+// Project:    Zip CPU backend for the GNU Compiler Collection
3011
+//
3012
+// Purpose:
3013
+//
3014
+// Creator:    Dan Gisselquist, Ph.D.
3015
+//             Gisselquist Technology, LLC
3016
+//
3017
+////////////////////////////////////////////////////////////////////////////////
3018
+//
3019
+// Copyright (C) 2016, Gisselquist Technology, LLC
3020
+//
3021
+// This program is free software (firmware): you can redistribute it and/or
3022
+// modify it under the terms of  the GNU General Public License as published
3023
+// by the Free Software Foundation, either version 3 of the License, or (at
3024
+// your option) any later version.
3025
+//
3026
+// This program is distributed in the hope that it will be useful, but WITHOUT
3027
+// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
3028
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3029
+// for more details.
3030
+//
3031
+// You should have received a copy of the GNU General Public License along
3032
+// with this program.  (It's in the $(ROOT)/doc directory, run make with no
3033
+// target there if the PDF file isn't present.)  If not, see
3034
+// <http://www.gnu.org/licenses/> for a copy.
3035
+//
3036
+// License:    GPL, v3, as defined and found on www.gnu.org,
3037
+//             http://www.gnu.org/licenses/gpl.html
3038
+//
3039
+//
3040
+////////////////////////////////////////////////////////////////////////////////
3041
+#ifndef        GCC_ZIP_H
3042
+#define        GCC_ZIP_H
3043
+
3044
+
3045
+//
3046
+//
3047 127 dgisselq
+// Zip CPU configuration defines
3048 102 dgisselq
+//
3049
+//
3050
+#define        ZIP_USER        0        // Assume we are in supervisor mode
3051
+#define        ZIP_MULTIPLY    1       // Assume we have multiply instructions
3052
+#define        ZIP_DIVIDE      1       // Assume we have divide instructions
3053
+#define        ZIP_FPU         0        // Assume we have no floating point instructions
3054
+#define        ZIP_PIPELINED   1       // Assume our instructions are pipelined
3055
+#define        ZIP_VLIW        1       // Assume we have the VLIW feature
3056
+#define        ZIP_ATOMIC      ((ZIP_PIPELINED)&&(ZIP_VLIW))
3057
+#define        ZIP_PIC         0        // Attempting to produce PIC code, with GOT
3058
+#define        ZIP_HAS_DI      1
3059 127 dgisselq
+// Should we use the peephole optimizations?
3060
+#define        ZIP_PEEPHOLE    1       // 0 means no peephole optimizations.
3061 138 dgisselq
+// How about the new long multiply instruction set?
3062
+#define        ZIP_LONGMPY     1       // 0 means use the old instruction set
3063 102 dgisselq
+
3064
+// Zip has 16 registers in each user mode.
3065
+//     Register 15 is the program counter (PC)
3066
+//     Register 14 is the condition codes (CC)
3067
+//     Register 13 is the stack pointer   (SP)
3068
+//     Register 12 (may be) the Global Offset Table pointer (GOT)
3069
+//     Register  0 (may be) the return address pointer
3070
+// Registers 16-31 may only be used in supervisor mode.
3071
+#define        is_ZIP_GENERAL_REG(REGNO)       ((REGNO)<13)
3072 171 dgisselq
+#define        is_ZIP_REG(REGNO)               ((REGNO)<33)
3073 102 dgisselq
+
3074 171 dgisselq
+#define        zip_AP_PSEUDO   32
3075 103 dgisselq
+#define        zip_PC          15
3076
+#define        zip_CC          14
3077
+#define        zip_SP          13
3078
+#define        zip_FP          12
3079
+#define        zip_GOT         11
3080 171 dgisselq
+// #define     zip_AP          10      // We're using a PSEUDO REG instead
3081 103 dgisselq
+#define        zip_R1          1
3082
+#define        zip_R0          0
3083 102 dgisselq
+
3084
+#define        ZIP_FIRST_ARG_REGNO     1
3085
+#define        ZIP_LAST_ARG_REGNO      5
3086 111 dgisselq
+#define        NUM_ARG_REGS            (ZIP_LAST_ARG_REGNO-ZIP_FIRST_ARG_REGNO+1)
3087
+#define        MAX_PARM_REGS           (ZIP_LAST_ARG_REGNO-ZIP_FIRST_ARG_REGNO+1)
3088 102 dgisselq
+
3089
+/* The overall framework of an assembler file */
3090
+
3091
+#define        ASM_COMMENT_START       ";"
3092
+#define        ASM_APP_ON              ""
3093
+#define        ASM_APP_OFF             ""
3094
+
3095
+#define        FILE_ASM_OP             "\t.file\n"
3096
+
3097
+/* Output and Generation of Labels */
3098
+#define        GLOBAL_ASM_OP           "\t.global\t"
3099
+
3100
+#undef BITS_PER_UNIT
3101
+#define        BITS_PER_UNIT   (32)
3102
+
3103
+/* Assembler Commands for Alignment */
3104
+#define        ASM_OUTPUT_ALIGN(STREAM,POWER)  \
3105 127 dgisselq
+       { int pwr = POWER; fprintf(STREAM, "\t.p2align %d\n", (pwr<2)?2:pwr); }
3106 102 dgisselq
+
3107
+
3108
+/* A C compound statement to output to stdio stream STREAM the assembler syntax
3109
+ * for an instruction operand X. */
3110
+#define        PRINT_OPERAND(STREAM, X, CODE)  zip_print_operand(STREAM, X, CODE)
3111
+#define        PRINT_OPERAND_ADDRESS(STREAM, X) zip_print_operand_address(STREAM, X)
3112
+
3113
+/* Passing arguments in registers */
3114
+#define        FUNCTION_VALUE_REGNO_P(REGNO)   ((REGNO)==zip_R1)
3115
+
3116
+/* Define how to find the value returned by a function.  VALTYPE is the data
3117
+ * type of the value (as a tree).  If the precise function being called is known
3118
+ * FUNC is its FUNCTION_DECL; otherwise, FUNC is 0. */
3119
+#define        FUNCTION_VALUE(VALTYPE, FUNC) gen_rtx_REG(TYPE_MODE(VALTYPE), zip_R1)
3120
+
3121
+/* Define how to find the value returned by a library function assuming the
3122
+ * value has mode MODE.
3123
+ */
3124
+#define        LIBCALL_VALUE(MODE)     gen_rtx_REG(MODE, zip_R1)
3125
+
3126
+
3127
+/* STACK AND CALLING */
3128
+
3129
+
3130
+/* Define this macro as a C expression that is nonzero for registers that are
3131
+ * used by the epilogue or the return pattern.  The stack and frame pointer
3132
+ * registers are already assumed to be used as needed.
3133
+ */
3134
+#define        EPILOGUE_USES(R)        (R == RETURN_ADDRESS_REGNUM)
3135
+
3136
+
3137
+/* The best alignment to use in cases where we have a choice. */
3138 127 dgisselq
+#define        FASTEST_ALIGNMENT       BITS_PER_WORD
3139 102 dgisselq
+
3140
+/* MAX_FIXED_MODE_SIZE -- An integer expression for the size in bits of the
3141
+ * largest integer machine mode that should actually be used.  All integer
3142
+ * machine modes of this size and smaller can be used for structures and unions
3143
+ * with the appropriate sizes.  If this macro is undefined,
3144
+ * GET_MODE_BITSIZE(DImode) is assumed.
3145
+ *
3146
+ * ZipCPU -- The default looks good enough for us.
3147
+ */
3148
+
3149
+/* Generate Code for Profiling
3150
+ */
3151
+#define        FUNCTION_PROFILER(FILE,LABELNO)         (abort(), 0)
3152
+
3153
+
3154
+/* A C expression which is nonzero if register number NUM is suitable for use
3155
+ * as an index register in operand addresses.
3156
+ */
3157
+#define        REGNO_OK_FOR_INDEX_P(NUM)       0
3158
+
3159
+
3160
+/* A C compound statement with a conditional 'goto LABEL;' executed if X
3161
+ * (an RTX) is a legitimate memory address on the target machine for a memory
3162
+ * operand of mode MODE.
3163
+ */
3164 111 dgisselq
+/* 17.03 Controlling the Compilation Driver, 'gcc' */
3165
+// DRIVER_SELF_SPECS
3166
+// OPTION_DEFAULT_SPECS
3167
+// CPP_SPEC
3168
+// CPLUSPLUS_CPP_SPEC
3169
+// CC1_SPEC
3170
+// CC1PLUS_SPEC
3171
+/* ASM_SPEC ... A C string constant that tells the GCC driver program options
3172
+ * to pass to the assembler.  It can also specify how to translate options you
3173
+ * give to GCC into options for GCC to pass to the assembler.  See the file
3174
+ * 'sun3.h' for an example of this.
3175
+ *
3176
+ * Do not define thismacro if it does not need to do anything.
3177
+ */
3178
+// #undef      ASM_SPEC
3179
+// ASM_FINAL_SPEC
3180
+// ASM_NEEDS_DASH_FOR_PIPED_INPUT
3181
+
3182
+/* LINK_SPEC ... A C string constant that tells the GCC driver program options
3183
+ * to pass to the linker.  It can also specify how to translate options you give
3184
+ * to GCC into options for GCC to pass to the linker.
3185
+ *
3186
+ * Do not define this macro if it does not need to do anything.
3187
+ */
3188
+
3189
+/* LIB_SPEC ... Another C string constant very much like LINK_SPEC.  The
3190
+ * difference between the two is that LIB_SPEC is used at the end of the
3191
+ * command given to the linker.
3192
+ *
3193
+ * If this macro is not defined, a default is provided that loads the standard
3194
+ * C library from the usual place.  See 'gcc.c'.
3195
+ */
3196
+#undef LIB_SPEC
3197
+// #define     LIB_SPEC        "%{!g:-lc} %{g:-lg} -lzip"
3198
+#define        LIB_SPEC        ""
3199
+
3200
+/* LIBGCC_SPEC ... Another C string constant that tells the GCC driver program
3201
+ * hoow and when to place a reference to 'libgcc.a' into the linker command
3202
+ * line.  This constant is placed both before and after the value of LIB_SPEC.
3203
+ *
3204
+ * If this macro is not defined, the GCC driver provides a default that passes
3205
+ * the string '-lgcc' to the linker.
3206
+ */
3207
+#undef LIBGCC_SPEC
3208
+#define        LIBGCC_SPEC     ""
3209
+
3210
+/* REAL_LIBGCC_SPEC ... By default, if ENABLE_SHARED_LIBGCC is defined, the
3211
+ * LIBGCC_SPEC is not directly used by the driver program but is instead
3212
+ * modified to refer to different versions of 'libgcc.a' depending on the
3213
+ * values of the command line flags '-static', '-shared', '-static-libgcc',
3214
+ * and '-shared-libgcc'.  On targets where these modifications are
3215
+ * inappropriate, define REAL_LIBGCC_SPEC instead.  REAL_LIBGCC_SPEC tells the
3216
+ * driver how to place a reference to 'libgcc' on the link command line, but
3217
+ * unlike LIBGCC_SPEC, it is used unmodified.
3218
+ */
3219
+#define        REAL_LIBGCC_SPEC        ""
3220
+
3221
+// USE_LD_AS_NEEDED
3222
+// LINK_EH_SPEC
3223
+
3224
+/* STARTFILE_SPEC ... Another C string constant used much like LINK_SPEC.  The
3225
+ * difference between the two is that STARTFILE_SPEC is used at the very
3226
+ * beginning of the command given to the linker.
3227
+ *
3228
+ * If this macro is not defined, a default is provided that loads the standard
3229
+ * C startup file from the usual place.  See 'gcc.c'
3230
+ */
3231
+#undef STARTFILE_SPEC
3232
+#define        STARTFILE_SPEC  ""
3233
+
3234
+/* ENDFILE_SPEC ... Another C string constant used much like LINK_SPEC.  The
3235
+ * difference between the two is that ENDFILE_SPEC is used at the very end
3236
+ * of the command given to the linker.
3237
+ *
3238
+ * Do not define this macro if it does not do anything.
3239
+ */
3240
+// #undef      ENDFILE_SPEC
3241
+// #define     ENDFILE_SPEC    ""
3242
+
3243
+// THREAD_MODEL_SPEC
3244
+// SYSROOT_SUFFIX_SPEC
3245
+// SYSROOT_HEADERS_SUFFIX_SPEC
3246
+// EXTRA_SPECS
3247
+// LINK_LIBGCC_SPECIAL_1
3248
+// LINK_GCC_C_SEQUENCE_SPEC
3249
+// LINK_COMMAND_SPEC
3250
+// TARGET_ALWAYS_STRIP_DOTDOT
3251
+// MULTILIB_DEFAULTS
3252
+// RELATIVE_PREFIX_NOT_LINKDIR
3253
+// MD_EXEC_PREFIX
3254
+// STANDARD_STARTFILE_PREFIX
3255
+// STANDARD_STARTFILE_PREFIX_1
3256
+// STANDARD_STARTFILE_PREFIX_2
3257
+// MD_STARTFILE_PREFIX
3258
+// MD_STARTFILE_PREFIX_1
3259
+// INIT_ENVIRONMENT
3260
+// LOCAL_INCLUDE_DIR
3261
+#undef LOCAL_INCLUDE_DIR
3262
+
3263
+// NATIVE_SYSTEM_HEADER_COMPONENT
3264
+// INCLUDE_DEFAULTS
3265
+
3266 102 dgisselq
+/* 17.03 Run-time Target Specification */
3267
+
3268
+/* TARGET_CPU_CPP_BUILTINS() ... This function-like macro expands to a block of
3269
+ * code that defines built-in preprocessor macros and assertions for the target
3270
+ * CPU, using the functions builtin_define, builtin_define_std, and
3271
+ * builtin_assert.  When the front end calls this macro it provides a trailing
3272
+ * semicolon, and since it has finished command line option proccessing your
3273
+ * code can use those results freely.
3274
+ *
3275
+ * ZipCPU --- We should probably capture in this macro what capabilities the
3276
+ * command line parameters we've been given indicate that our CPU has.  That
3277
+ * way, code can be adjusted depending upon the CPU's capabilities.
3278
+ */
3279
+#define        TARGET_CPU_CPP_BUILTINS()                       \
3280
+       { builtin_define("__ZIPCPU__");                 \
3281
+       if (ZIP_FPU) builtin_define("__ZIPFPU__");      \
3282
+       if (ZIP_ATOMIC) builtin_define("__ZIPATOMIC__");        \
3283
+       }
3284
+       // If (zip_param_has_fpu)  builtin_define("__ZIPFPU__");
3285
+       // If (zip_param_has_div)  builtin_define("__ZIPDIV__");
3286
+       // If (zip_param_has_mpy)  builtin_define("__ZIPMPY__");
3287
+       // If (zip_param_has_lock) builtin_define("__ZIPLOCK__");
3288
+       // If (zip_param_supervisor) builtin_define("__ZIPUREGS__");
3289
+       // If (we support int64s) builtin_define("___int64_t_defined");
3290
+
3291
+/* TARGET_OS_CPP_BUILTINS() ... Similarly to TARGET_CPU_CPP_BUILTINS but this
3292
+ * macro is optional and is used for the target operating system instead.
3293
+ */
3294
+
3295
+/* Option macros: (we need to define these eventually ... )
3296
+ *
3297
+ *     TARGET_HANDLE_OPTION
3298
+ *     TARGET_HANDLE_C_OPTION
3299
+ *     TARGET_OBJ_CONSTRUCT_STRING_OBJECT
3300
+ *     TARGET_OBJ_DECLARE_UNRESOLVED_CLASS_REFERENCE
3301
+ *     TARGET_OBJ_DECLARE_CLASS_DEFINITION
3302
+ *     TARGET_STRING_OBJECT_REF_TYPE_P
3303
+ *     TARGET_CHECK_STRING_OBJECT_FORMAT_ARG
3304
+ *     TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE(VOID)
3305
+ *     C_COMMON_OVERRIDE_OTPTIONS
3306
+ *     TARGET_OPTION_OPTIMIZATION_TABLE
3307
+ *     TARGET_OPTION_INIT_STRUCT
3308
+ *     TARGET_OPTION_DEFAULT_PARAMS
3309
+ */
3310
+
3311
+/* SWITCHABLE_TARGET
3312
+ *
3313
+ * Zip CPU doesn't need this, so it defaults to zero.  No need to change it
3314
+ * here.
3315
+ */
3316
+
3317
+/* TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P(VOID) ... Returns true if the
3318
+ * target supports IEEE 754 floating-point exceptions and rounding modes, false
3319
+ * otherwise.  This is intended to relate to the float and double types, but not
3320
+ * necessarily "long double".  By default, returns true if the adddf3
3321
+ * instruction pattern is available and false otherwise, on the assumption that
3322
+ * hardware floating point supports exceptions and rounding modes but software
3323
+ * floating point does not.
3324
+ *
3325
+ * ZipCPU floating point is barely going to be functional, I doubt it will
3326
+ * support all of these bells and whistles when full functionality is even
3327
+ * achieved.  Therefore, we won't support these modes.  However, we can't just
3328
+ * set this to zero, so let's come back to this.
3329
+ */
3330
+// #warning "Wrong answer encoded to date"
3331 103 dgisselq
+// #undef      TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P
3332 102 dgisselq
+// #define     TARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P(X) 0
3333
+
3334
+/* 17.04 Defining data structures for per-function information */
3335
+
3336
+/* INIT_EXPANDERS ... Macro called to initialize any target specific
3337
+ * information.  This macro is called once per function, before generation of
3338
+ * any RTL has begun.  The intention is to allow the initialization of the
3339
+ * function pointer init_machine_status.
3340
+ */
3341
+// #warning "I may need to define this to handle function return addresses ..."
3342
+
3343
+/* 17.05 Storage Layout */
3344
+
3345
+/* Storage Layout */
3346
+#define        BITS_BIG_ENDIAN         0        // MSB has highest number
3347
+#define        BYTES_BIG_ENDIAN        1       // 1 if MSB is lowest number
3348
+#define        WORDS_BIG_ENDIAN        1       // 1 if MSW is lowest number
3349
+#define        FLOAT_WORDS_BIG_ENDIAN  1
3350
+#define        BITS_PER_WORD           32
3351
+// #define     MAX_BITS_PER_WORD       // defaults to BITS_PER_WORD
3352
+#define        UNITS_PER_WORD          1       // Storage units in a word, pwr of 2:1-8
3353
+#define        MIN_UNITS_PER_WORD      1       // Default is UNITS_PER_WORD
3354
+/* POINTER_SIZE ... Width of a pointer in bits.  You must specify a value no
3355
+ * wider than the width of Pmode.  If it is not equal to the width of Pmode,
3356
+ * you must define POINTERS_EXTEND_UNSIGNED. If you do not specify a value the
3357
+ * default is BITS_PER_WORD.
3358
+ *
3359
+ * ZipCPU --- All of our pointers are 32-bits, the width of our address bus.
3360
+ */
3361
+#define        POINTER_SIZE            32      // Ptr width in bits
3362
+/* POINTERS_EXTEND_UNSIGNED ... A C expression that determines how pointers
3363
+ * should be extended from ptr_mode to either Pmode or word_mode.  It is greater
3364
+ * than zero if pointers should be zero-extended, zero if they should be sign
3365
+ * extended, and negative if some other conversion is needed.  In the last case,
3366
+ * the extension is done by the target's ptr_extend instruction.
3367
+ *
3368
+ * You need not define this macro if the ptr_mode, Pmode, and word_mode are all
3369
+ * the same width.
3370
+ *
3371
+ * ZipCPU --- While we shouldn't need this, QImode and HImode have the same
3372
+ * number of bits as SImode.  Therefore, one might wish to convert between the
3373
+ * two.  Hence, we specify how we would do that here.
3374
+ */
3375 127 dgisselq
+#define        POINTERS_EXTEND_UNSIGNED        1
3376 102 dgisselq
+
3377
+/* PROMOTE_MODE(m,unsignedp,type) ... A macro to update m and unsignedp when an
3378
+ * object whose type is type and which has he specified mode and signedness is
3379
+ * to be stored in a register.  This macro is only called when type is a scalar
3380
+ * type.
3381
+ *
3382
+ * On most RISC machines, which only have operations that operate on a full
3383
+ * register, define this macro to set m to word_mode if m is an integer mode
3384
+ * narrower than BITS_PER_WORD.  In most cases, only integer modes should be
3385
+ * widened because wider precision floating-point operations are usually more
3386
+ * expensive than their narrower counterparts.
3387
+ *
3388
+ * For most machines, the macro definition does not change unsigndep.  However,
3389
+ * some machines, have instructions that preferentially handle either signed or
3390
+ * unsigned quantities of certain modes.  For example, on the DEC Alpha, 32-bit
3391
+ * loads from memory and 32-bit add instructions sign-extend the result to
3392
+ * 64-bits. On such machines, set unsignedp according to which kind of extension
3393
+ * is more efficient.
3394
+ *
3395
+ * Do not define this macro if it would never modify m.
3396
+ *
3397
+ * ZipCPU --- We need to always (if possible) promote everything to SImode where
3398
+ * we can handle things.  HImode and QImode just don't make sense on this CPU.
3399
+ */
3400
+#define        PROMOTE_MODE(M,U,T)     if ((GET_MODE_CLASS(M)==MODE_INT)&&(GET_MODE_SIZE(M)<2)) (M)=SImode;
3401
+
3402
+// TARGET_PROMOTE_FUNCTION_MODE
3403
+/* PARM_BOUNDARY ... Normal alignment required for function parameters on the
3404
+ * stack, in bits.  All stack parameters receive at least this much alignment
3405
+ * regardless of data type.  On most machines, this is the same as the size of
3406
+ * an integer.
3407
+ */
3408
+#define        PARM_BOUNDARY   32
3409
+
3410
+/* STACK_BOUNDARY ... Define this macro to the minimum alignment enforced by
3411
+ * hardware for the stack pointer on this machine.  The definition is a C
3412
+ * expression for the desired alignment (measured in bits).  This value is used
3413
+ * as a default if PREFERRED_STACK_BOUNDARY is not defined.  On most machines,
3414
+ * this should be the same as PARM_BOUNDARY.
3415
+ */
3416
+#define        STACK_BOUNDARY  PARM_BOUNDARY
3417
+
3418
+/* PREFERRED_STACK_BOUNDARY ... Define this ... */
3419 127 dgisselq
+#define        PREFERRED_STACK_BOUNDARY        STACK_BOUNDARY
3420 102 dgisselq
+
3421 127 dgisselq
+/* INCOMING_STACK_BOUNDARY ... Define this macro if the incoming stack boundary
3422
+ * may be different from PREFERRED_STACK_BOUNDARY.  This macro must evaluate
3423
+ * to a value equal to or larger than STACK_BOUNDARY.
3424 102 dgisselq
+ */
3425 127 dgisselq
+#define        INCOMING_STACK_BOUNDARY STACK_BOUNDARY
3426 102 dgisselq
+
3427
+/* FUNCTION_BOUNDARY ... Alignment required for a function entry point, in bits.
3428
+ */
3429
+#define        FUNCTION_BOUNDARY       32
3430
+
3431
+/* BIGGEST_ALIGNMENT ... Biggest alignment that any data type can require on
3432
+ * this machine, in bits.  Note that this is not the biggest alignment that is
3433
+ * supported, just the biggest alignment that, when violated, may cause a fault.
3434
+ */
3435
+#define BIGGEST_ALIGNMENT      32
3436
+
3437 127 dgisselq
+/* MALLOC_ABI_ALIGNMENT
3438
+ */
3439
+
3440
+/* ATTRIBUTE_ALIGNED_VALUE
3441
+ */
3442
+
3443 102 dgisselq
+/* MINIMUM_ATOMIC_ALIGNMENT ... If defined, the smallest alignment, that can be
3444
+ * given to an object that can be referenced in one operation, without
3445
+ * disturbing any nearby object.  Normally, this is BITS_PER_UNIT, but may be
3446
+ * larger on machines that don't have byte or halfword store operations.
3447
+ */
3448
+#define        MINIMUM_ATOMIC_ALIGNMENT        BITS_PER_UNIT
3449
+
3450 127 dgisselq
+/* BIGGEST_FIELD_ALIGNMENT ... Biggest alignment that any structure or union
3451
+ * field can require on this machine, in bits.  If defined, this overrides
3452
+ * BIGGEST_ALIGNMENT for structure and union fields only, unless the field
3453
+ * alignment has been set by the __attribute__((aligned(n))) construct.
3454
+ */
3455
+#define        BIGGEST_FIELD_ALIGNMENT BITS_PER_UNIT
3456
+
3457
+/* ADJUST_FIELD_ALIGN
3458
+ */
3459
+#define        ADJUST_FIELD_ALIGN(A,B) BITS_PER_WORD
3460
+
3461
+/* MAX_STACK_ALIGNMENT
3462
+ */
3463
+#define        MAX_STACK_ALIGNMENT     BITS_PER_WORD
3464
+
3465
+/* MAX_OFILE_ALIGNMENT
3466
+ */
3467
+
3468
+/* DATA_ALIGNMENT(TYPE, BASIC-ALIGN) ... If defined, a C expression to compute
3469
+ * the alignment for a variable in the static store.  TYPE is the data type, and
3470
+ * BASIC-ALIGN is the alignment that the object would ordinarily have.  The
3471
+ * value of this macro is used instead of that alignment to align the object.
3472
+ *
3473
+ * If this macro is not defined, then BASIC-ALIGN is used.
3474
+ *
3475
+ * ZipCPU -- in hindsight, if this macro is not defined then the compiler is
3476
+ * broken.  So we define it to be our fastest alignment, or 32-bits.
3477
+ */
3478
+#define        DATA_ALIGNMENT(TYPE, ALIGN)     BITS_PER_WORD
3479
+
3480
+
3481
+/* DATA_ABI_ALIGNMENT(TYPE,BASIC-ALIGN)
3482
+ */
3483
+
3484
+/* CONSTANT_ALIGNMENT(CONST, BASIC-ALIGN) ... If defined, a C expression to
3485
+ * compute the alignment given to a constant that is being placed in memory.
3486
+ * CONST is the constant and BASIC-ALIGN is the alignment that the object
3487
+ * would ordinarily have.  The value of this macro is used instead of that
3488
+ * alignment to align the object.
3489
+ *
3490
+ * If this macro is not defined, then BASIC-ALIGN is used.
3491
+ *
3492
+ * ZipCPU -- in hindsiht, if this macro is not defined then the compiler is
3493
+ * broken.  We'll define it as above.
3494
+ *
3495
+ */
3496
+#define        CONSTANT_ALIGNMENT(EXP, ALIGN)  BITS_PER_WORD
3497
+
3498
+/* LOCAL_ALIGNMENT(TYPE,BASIC-ALIGN) ... If defined ...
3499
+ */
3500
+#define        LOCAL_ALIGNMENT(TYP,ALIGN)      BITS_PER_WORD
3501
+
3502
+/* TARGET_VECTOR_ALIGNMENT
3503
+ */
3504
+
3505
+/* STACK_SLOT_ALIGNMENT
3506
+ */
3507
+#define        STACK_SLOT_ALIGNMENT(T,M,B)     BITS_PER_WORD
3508
+
3509
+/* LOCAL_DECL_ALIGNMEN(DECL)
3510
+ */
3511
+#define        LOCAL_DECL_ALIGNMENT(DECL)      BITS_PER_WORD
3512
+
3513
+/* MINIMUM_ALIGNMENT
3514
+ */
3515
+#define        MINIMUM_ALIGNMENT(EXP,MOD,ALIGN)        BITS_PER_WORD
3516
+
3517
+/* EMPTY_FIELD_BOUNDARY
3518
+ * Alignment of field after 'int : 0' in a structure.
3519
+ */
3520
+#define        EMPTY_FIELD_BOUNDARY    BITS_PER_WORD
3521
+
3522
+/* STRUCTURE_SIE_BOUNDARY
3523
+ * ZipCPU -- Every structures size must be a multiple of 32-bits.
3524
+ */
3525
+#define        STRUCTURE_SIZE_BOUNDARY BITS_PER_WORD
3526
+
3527 102 dgisselq
+/* STRICT_ALIGNMENT ... Set this nonzero if move instructions will actually
3528
+ * fail to work when given unaligned data.  If instructions will merely go
3529
+ * slower in that case, define this macro as 0.
3530 125 dgisselq
+ *
3531
+ * ZipCPU -- Since we have defined our smallest addressable unit to be a 32-bit
3532
+ * word (one byte, on our machine), and since reading any amount of 32-bit words
3533
+ * is easy, then there really are no instructions that will ever fail.
3534 102 dgisselq
+ */
3535 125 dgisselq
+#define        STRICT_ALIGNMENT        0
3536 102 dgisselq
+
3537 127 dgisselq
+/* PCC_BITFIELD_TYPE_MATTERS -- define this if you wish to imitate the the way
3538
+ * other C compilers handle alignment of bit-fields and the structures that
3539
+ * contain them.
3540
+ *
3541
+ * The behavior is that the type written for a named bit-field (int, short, or
3542
+ * other integer type) imposes an alignment for the entire structure, as if the
3543
+ * structure really did contain an ordinary field of that type.  In addition,
3544
+ * the bit-field is placed within the structure so that it would fit within
3545
+ * such a field, not crossing a boundary for it.
3546
+ *
3547
+ * Thus, no most machines, a named bit-field whose type is written as int would
3548
+ * not cross a four-byte boundary, and would force four-byte alignment for the
3549
+ * whole structure.  (The alignment used may not be four bytes; it is controlled
3550
+ * by other alignment parameters.)
3551
+ *
3552
+ * An unnamed bit-field will not affect the alignment of the containing
3553
+ * structure.
3554
+ *
3555
+ * If the macro is defined, its definition should be a C expression, a non
3556
+ * zero value for the expression enables this behavior.
3557
+ * Look at the fundamental type that is used for a bit-field and use that to
3558
+ * impose alignment on the enclosing structure.  struct s{int a:8}; should
3559
+ * have the same alignment as 'int', not 'char'.
3560
+ */
3561
+#undef PCC_BITFIELD_TYPE_MATTERS
3562
+#define        PCC_BITFIELD_TYPE_MATTERS       0
3563
+
3564 102 dgisselq
+/* MAX_FIXED_MODE_SIZE ... An integer expression for the size in bits of the
3565
+ * largest integer machine mode that should actually be used.  All integer
3566
+ * machine modes of this size or smaller can be used for structures and unions
3567
+ * with the appropriate sizes.  If this macro is undefined,
3568
+ * GET_MODE_BITSIZE(DImode) is assumed.
3569
+ *
3570
+ * ZipCPU ... Get_MOD_BITSIZE(DImode) will be 64, and this is really not the
3571
+ * size on bits of the largest integer machine mode.  However, that's the case
3572
+ * with most DI implementations: A long is two words, spliced together.  We'd
3573
+ * like to support that eventually, but we need to get there.  Hence, let's use
3574
+ * compile time flag (ZIP_HAS_DI) that we can enable when we're ready.
3575
+ */
3576
+#if (ZIP_HAS_DI != 0)
3577
+#define        MAX_FIXED_MODE_SIZE     64
3578
+#else
3579
+#define        MAX_FIXED_MODE_SIZE     32
3580
+#endif
3581
+
3582
+
3583
+/* 17.06 Layout of Source Language Data Types */
3584
+
3585
+#undef CHAR_TYPE_SIZE
3586
+#undef SHORT_TYPE_SIZE
3587
+#undef INT_TYPE_SIZE
3588
+#undef LONG_TYPE_SIZE
3589
+#undef LONG_LONG_TYPE_SIZE
3590
+//
3591
+#define        CHAR_TYPE_SIZE  32
3592
+#define        SHORT_TYPE_SIZE 32
3593
+#define        INT_TYPE_SIZE   32
3594
+#define        LONG_TYPE_SIZE  32
3595
+#define        LONG_LONG_TYPE_SIZE     64
3596
+// BOOL_TYPE_SIZE defaults to CHAR_TYPE_SIZE
3597
+#undef FLOAT_TYPE_SIZE
3598
+#undef DOUBLE_TYPE_SIZE
3599
+#undef LONG_DOUBLE_TYPE_SIZE
3600
+#define        FLOAT_TYPE_SIZE         32
3601
+#define        DOUBLE_TYPE_SIZE        FLOAT_TYPE_SIZE // Zip CPU doesn't support dbls
3602
+#define        LONG_DOUBLE_TYPE_SIZE   64      // This'll need to be done via emulation
3603
+// SHORT_FRAC_TYPE_SIZE
3604
+// LONG_FFRACT_TYPE_SIZE
3605
+// LONG_LONG_FRACT_TIME_SIZE
3606
+#undef SHORT_ACCUM_TYPE_SIZE
3607
+#undef ACCUM_TYPE_SIZE
3608
+#undef LONG_ACCUM_TYPE_SIZE
3609
+#define        SHORT_ACCUM_TYPE_SIZE   SHORT_TYPE_SIZE
3610
+#define        ACCUM_TYPE_SIZE         INT_TYPE_SIZE
3611
+#define        LONG_ACCUM_TYPE_SIZE    LONG_TYPE_SIZE
3612
+
3613
+/* LIBGCC2_GNU_PREFIX ... This macro corresponds to the TARGET_GNU_PREFIX target
3614
+ * hook and should be defined if that hook is overriden to be true.  It causes
3615
+ * function names in libgcc to be changed to use a __gnu_ prefix for their name
3616
+ * rather than the default __.  A port which uses this macro should also arrange
3617
+ * to use t-gnu-prefix in the libgcc config.host.
3618
+ *
3619
+ * ZipCPU -- I see no reason to define and therefore change this behavior.
3620
+ */
3621
+
3622
+/* TARGET_FLT_EVAL_METHOD ... A C expression for the value for FLT_EVAL_METHOD
3623
+ * in float.h,, assuming, if applicable, that the floating-point control word
3624
+ * is in its default state.  If you do not define this macro the value of
3625
+ * FLT_EVAL_METHOD will be zero.
3626
+ *
3627
+ * ZipCPU --- ???
3628
+ */
3629
+
3630
+/* WIDEST_HARDWARE_FP_SIZE ... A C expression for the size in bits of the widest
3631
+ * floating-point format supported by the hardware.  If you define this macro,
3632
+ * you must specify a value less than or equal to the value of LONG_DOUBLE_...
3633
+ * If you do not define this macro, the value of LONG_DOUBLE_TYPE_SIZE is the
3634
+ * default.
3635
+ *
3636
+ * ZipCPU supports 32-bit IEEE floats--IF THE SUPPORT IS COMPILED IN!  This
3637
+ * really needs to be determined, then, based upon a compile time parameter
3638
+ * where the one compiling the code states whether or not the H/W even has
3639
+ * floating point support.
3640
+ *
3641
+ * For now, we'll assume it does--but once we implement GCC parameters, we'll
3642
+ * need to change this.
3643
+ */
3644
+#undef WIDEST_HARDWARE_FP_SIZE
3645
+// #warning "Definition needs to change if no FPU present"
3646
+#define        WIDEST_HARDWARE_FP_SIZE FLOAT_TYPE_SIZE
3647
+
3648
+/* DEFAULT_SIGNED_CHAR ... An expression whose value is 1 or 0, according to
3649
+ * whether the type char should be signed or unsigned by default.  The user
3650
+ * can always override this default with the options -fsigned-char and
3651
+ * -funsigned-char.
3652
+ *
3653
+ * ZipCPU--let's go with the default behavior.
3654
+ */
3655
+#define        DEFAULT_SIGNED_CHAR     1
3656
+
3657
+/* TARGET_DEFAULT_SHORT_ENUMS(VOID) ... This target hook should return true if
3658 103 dgisselq
+ * the compiler should give an enum type only as many bytes as it takes to
3659 102 dgisselq
+ * represent the range of possible values of that type.  It should return
3660
+ * false if all enum types should be allocated like int.
3661
+ *
3662
+ * The default is to return false.  This is what the ZipCPU needs, so we won't
3663
+ * override it.
3664
+ */
3665
+
3666
+/* SIZE_TYPE ... A C expression for a string describing the name of the data
3667
+ * type to use for size values.  The typedef name size_t is defined using the
3668
+ * contents of the string.
3669
+ *
3670
+ * If you don't define this macro, the default is "long unsigned int".  Since
3671
+ * on the ZipCPU this is a 32-bit number, and all ZipCPU values are 32-bits,
3672
+ * the default seems perfect for us.
3673
+ */
3674
+#define        SIZE_TYPE       "unsigned int"
3675
+
3676
+/* SIZETYPE ... GCC defines internal types () for expressions dealing with size.
3677
+ * This macro is a C expression for a string describing the name of the data
3678
+ * type from which the precision of sizetype is extracted.  The string has the
3679
+ * same restrictions as SIZE_TYPE string.  If you don't define this macro, the
3680
+ * default is SIZE_TYPE --- which seems good enough for us.
3681
+ */
3682
+
3683
+/* PTRDIFF_TYPE ... A C expression for a string describing the name of the data
3684 127 dgisselq
+ * type to use for the result of subtracting two pointers.  The typedef name
3685 102 dgisselq
+ * ptrdiff_t is defined using the contents of the string.  See SIZE_TYPE for
3686
+ * more information.
3687
+ *
3688
+ * The default is "long int" which for the ZipCPU is 32-bits---still good enough
3689
+ * for us.
3690
+ */
3691
+#define        PTRDIFF_TYPE    "int"
3692
+
3693
+/* WCHAR_TYPE ... A C expression for a string describing the name of the data
3694
+ * type to use for wide characters.  The typedef name wchar_t is defined using
3695
+ * the contents of  the string.  If you don't define this macro, the default is
3696
+ * 'int'--good enough for ZipCPU.
3697
+ */
3698
+
3699
+/* WCHAR_TYPE_SIZE ... A C expression for the size in bits of the data type for
3700
+ * wide characters.  This is used in cpp, which cannot make use of WCHAR_TYPE.
3701
+ */
3702
+#undef WCHAR_TYPE_SIZE
3703
+#define        WCHAR_TYPE_SIZE 32
3704
+
3705
+/* WINT_TYPE ... A C expression for a string describing the name of the data
3706
+ * type to use for wide characters passed to printf and returned from getwc.
3707
+ * The typedef name wint_t is defined using the contents of the string.  See
3708
+ *
3709 103 dgisselq
+ * ZipCPU -- If you don't define this macro, the default is "unsigned int"--also
3710
+ * best for us again.
3711 102 dgisselq
+ */
3712
+
3713
+/* INTMAX_TYPE ... A C expression for a string describing the name of the
3714
+ * data type that can represent any value of any standard or extended signed
3715
+ * integer type.  The typedef name intmax_t is defined using the contents of
3716
+ * the string.
3717
+ *
3718
+ * If you don't define this macro, the default is the first of "int", "long int"
3719
+ * or "long long int" that has as much precision as "long long int".
3720
+ */
3721
+
3722
+/* UINTMAX_TYPE ... same as INTMAX_TYPE, but for unsigned
3723
+ */
3724
+
3725
+#undef SIG_ATOMIC_TYPE
3726
+#if (ZIP_ATOMIC != 0)
3727
+#define        SIG_ATOMIC_TYPE "int"
3728
+#else
3729
+#define        SIG_ATOMIC_TYPE NULL    // We have no atomic types, but registers
3730
+#endif
3731
+#undef INT8_TYPE
3732
+#define        INT8_TYPE               NULL    // We have no 8-bit integer type
3733
+#undef INT16_TYPE
3734
+#define        INT16_TYPE              NULL
3735
+#undef INT32_TYPE
3736
+#define        INT32_TYPE              "int"
3737
+#undef UINT8_TYPE
3738
+#define        UINT8_TYPE              NULL
3739
+#undef UINT16_TYPE
3740
+#define        UINT16_TYPE             NULL
3741
+#undef UINT32_TYPE
3742
+#define        UINT32_TYPE             "unsigned int"
3743
+#undef INT_LEAST8_TYPE
3744
+#define        INT_LEAST8_TYPE         "int"
3745
+#undef INT_LEAST16_TYPE
3746
+#define        INT_LEAST16_TYPE        "int"
3747
+#undef INT_LEAST32_TYPE
3748
+#define        INT_LEAST32_TYPE        "int"
3749
+#undef UINT_LEAST8_TYPE
3750
+#define        UINT_LEAST8_TYPE        "unsigned int"
3751
+#undef UINT_LEAST16_TYPE
3752
+#define        UINT_LEAST16_TYPE       "unsigned int"
3753
+#undef UINT_LEAST32_TYPE
3754
+#define        UINT_LEAST32_TYPE       "unsigned int"
3755
+#undef INT_FAST8_TYPE
3756
+#define        INT_FAST8_TYPE          "int"
3757
+#undef INT_FAST16_TYPE
3758
+#define        INT_FAST16_TYPE         "int"
3759
+#undef INT_FAST32_TYPE
3760
+#define        INT_FAST32_TYPE         "int"
3761
+#undef UINT_FAST8_TYPE
3762
+#define        UINT_FAST8_TYPE         "unsigned int"
3763
+#undef UINT_FAST16_TYPE
3764
+#define        UINT_FAST16_TYPE        "unsigned int"
3765
+#undef UINT_FAST32_TYPE
3766
+#define        UINT_FAST32_TYPE        "unsigned int"
3767
+#undef INTPTR_TYPE
3768
+#define        INTPTR_TYPE             "unsigned int"
3769
+#undef UINTPTR_TYPE
3770
+#define        UINTPTR_TYPE            "unsigned int"
3771
+
3772
+#undef INT64_TYPE
3773
+#undef UINT64_TYPE
3774
+#undef INT_LEAST64_TYPE
3775
+#undef UINT_LEAST64_TYPE
3776
+#undef INT_FAST64_TYPE
3777
+#undef UINT_FAST64_TYPE
3778
+
3779
+#if (ZIP_HAS_DI != 0)
3780
+#define        INT64_TYPE              "long int"
3781
+#define        UINT64_TYPE             "long unsigned int"
3782
+#define        INT_LEAST64_TYPE        "long int"
3783
+#define        UINT_LEAST64_TYPE       "long unsigned int"
3784
+#define        INT_FAST64_TYPE         "long int"
3785
+#define        UINT_FAST64_TYPE        "long unsigned int"
3786
+#else
3787
+#define        INT64_TYPE              NULL
3788
+#define        UINT64_TYPE             NULL
3789
+#define        INT_LEAST64_TYPE        NULL
3790
+#define        UINT_LEAST64_TYPE       NULL
3791
+#define        INT_FAST64_TYPE         NULL
3792
+#define        UINT_FAST64_TYPE        NULL
3793
+#endif
3794
+
3795
+#define        TARGET_PTRMEMFUNC_VBI_LOCATION  ptrmemfunc_vbit_in_pfn
3796
+
3797
+
3798
+/* 17.07 Register Usage / Register definitions */
3799
+
3800
+/* FIRST_PSEUDO_REGISTER ... Number of hardware registers known to the compiler.
3801
+ * They receive numbers 0 through FIRST_PSEUDO_REGISTER-1; thus the first
3802
+ * pseudo register's numbrer really is assigned the number
3803
+ * FIRST_PSEUDO_REGISTER.
3804
+ *
3805
+ * ZipCPU---There are 16 registers in the ZipCPU, numbered 0-15 with the CC
3806 171 dgisselq
+ * and PC register being numbered 14 and 15 respectively.  The ZipCPU has
3807
+ * another 16 registers, identical to the first, but user mode registers.  These
3808
+ * are number the same as the first (0-15) in user mode, but numbered (16-31)
3809
+ * in supervisor mode.  In addition, we create a pretend argument pointer
3810
+ * register, zip_AP_PSEUDO, to refer to our arguments.  This final register,
3811
+ * although it gets a valid number, will be eliminated in optimization.
3812 102 dgisselq
+ */
3813 171 dgisselq
+#define        FIRST_PSEUDO_REGISTER   (zip_AP_PSEUDO+1)
3814 102 dgisselq
+
3815
+/* FIXED_REGISTERS ... An initializer that says which registers are used for
3816
+ * fixed purposes all throughout the compiled code and are therefore not
3817
+ * available for general allocation.  These would include the stack pointer, the
3818
+ * frame pointer (except on machines where that can be used as a general
3819
+ * register when no frame pointer is needed), the program counter on machines
3820
+ * where that is considered one of the addressable registers, and any other
3821
+ * numbered register with a standard use.
3822
+ *
3823
+ * This information is expressed as a sequence of numbers, separated by commas,
3824
+ * and surrounded by braces.  The nth number is 1 if register n is fixed, 0
3825
+ * otherwise.
3826
+ *
3827
+ * For the Zip CPU, we have three fixed registers that are not available for
3828
+ * general allocation:
3829
+ *
3830
+ *     SP      The stack pointer
3831
+ *     CC      The condition codes and CPU state register
3832
+ *     PC      The program counter
3833
+ *
3834
+ * Other registers, such as FP (the frame pointer) or GBL (the global offset
3835
+ * table pointer) are registers that we hope will not be so fixed.
3836 171 dgisselq
+ *
3837
+ * Okay, just updated this process.  We now have more registers that are not
3838
+ * available for general allocation:
3839
+ *     uR0-uPC         User registers
3840
+ *     PSEUDO-AP       The pseudo arg pointer
3841 102 dgisselq
+ */
3842 171 dgisselq
+#define        FIXED_REGISTERS         { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1 }
3843 102 dgisselq
+
3844
+/* CALL_USED_REGISTERS ... like FIXED_REGISTERS but has 1 for each register
3845
+ * that is clobbered (in general) by function calls as well as for fixed
3846
+ * registers.  This macro therefore identifies the registers that are not
3847
+ * available for general allocation of values that must live across function
3848
+ * calls.
3849
+ *
3850
+ * If a register has 0 in CALL_USED_REGISTERS, the compiler automatically saves
3851
+ * it on function entry and restores it on function exit, if the register is
3852
+ * used within the function.
3853
+ *
3854
+ * On the Zip CPU, we must save R0 (the return address), and (let's pick) any
3855
+ * register above R5.
3856
+ */
3857 171 dgisselq
+#define        CALL_USED_REGISTERS     { 0,1,1,1, 1,0,0,0, 0,0,0,0, 0,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1,  1 }
3858 102 dgisselq
+
3859
+/* CALL_REALLY_USED_REGISTERS ...  optional macro that, if not defined, defaults
3860
+ * to the value of CALL_USED_REGISTERS.
3861
+ */
3862
+
3863
+/* HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE) ... A C expression that is nonzero
3864
+ * if it is not permissible to store a value of mode MODE in hard register REGNO
3865
+ * across a call without some part of it being clobbbered.  For most machines,
3866
+ * this macro need not be defined.  It is only required for machines that do
3867 103 dgisselq
+ * not preserve the entire contents of a register across a call.
3868 102 dgisselq
+ *
3869 127 dgisselq
+ * ZipCPU--Always preserves the entire contents of those registers that are
3870
+ * preserved across calls, so this shouldnt need to be defined.
3871 102 dgisselq
+ */
3872 127 dgisselq
+// #define     HARD_REGNO_CALL_PART_CLOBBERED(REGNO,MODE)      (REGNO==0)
3873 102 dgisselq
+
3874
+/* TARGET_CONDITIONAL_REGISTER_USAGE(VOID) ... This hook may conditionally
3875
+ * modify five variables fixed_regs, call_used_regs, global_regs, reg_names, and
3876
+ * reg_class_contents, to take into account any dependence of these register
3877
+ * sets on target flags.  The first three of these are of type char[]
3878
+ * (interpreted as Boolean vectors).  global_regs is a const char *[] and
3879
+ * reg_class_contents is a HARD_REG_SET.  Before the macro is called,
3880
+ * fixed_regs, call_used_regs, reg_class_contents, and reg_names have been
3881
+ * initialized from FIXED_REGISTERS, CALL_USED_REGISTERS, REG_CLASS_CONTENTS,
3882
+ * and REGISTER_NAMES, respectively.  global_regs has been cleared, and any
3883
+ * -ffixed-reg, -fcall-used-reg, and -fcall-saved-reg command options have been
3884
+ * applied.
3885
+ *
3886 171 dgisselq
+ * ZipCPU -- I may need to return and define this depending upon how the
3887
+ * GBL register allocation goes.  But for now, we'll leave this at its default
3888 102 dgisselq
+ * value.
3889
+ */
3890
+// #warning "Revisit me after FP and GBL allocation"
3891
+
3892
+/* INCOMING_REGNO(out) ... Define this macro if the target machine has register
3893
+ * windows. ...
3894
+ *
3895
+ * Zip CPU has no register windows.
3896
+ */
3897
+
3898
+/* OUTGOING_REGNO ... same thing.
3899 171 dgisselq
+ * LOCAL_REGNO ... same thing.
3900 102 dgisselq
+ */
3901
+
3902
+/* PC_REGNUM ... If the program counter has a register number, define this as
3903
+ * that register number.  Otherwise do not define it.
3904
+ */
3905
+#define        PC_REGNUM       zip_PC
3906
+
3907
+
3908
+/* REG_ALLOC_ORDER ... If defined, an initializer for a vector of integers,
3909
+ * containing the number of hard registers in the order in which GCC should
3910
+ * prefer to use them (from most preferred to least.
3911
+ *
3912 103 dgisselq
+ * If this macro is not defined, registers are used lowest numbered first (all
3913 102 dgisselq
+ * else being equal).
3914
+ *
3915
+ * Since the default is the ZipCPU desired case, we won't define this here.
3916
+ */
3917
+
3918
+/* ADJUST_REG_ALLOC_ORDER ... on most machines it is not necessary to define
3919
+ * this macro, so we won't either.
3920
+ */
3921
+
3922
+/* HONOR_REG_ALLOC_ORDER ...
3923
+ */
3924
+
3925
+/* HONOR_REG_ALLOC_ORDER ... on most machines it is not necessary to define
3926
+ * this macro, so we won't either.
3927
+ */
3928
+
3929
+/* HARD_REGNO_NREGS(REGNO, MODE) ... A C expression for the number of
3930
+ * consecutive hard registers, starting at register number REGNO, required to
3931
+ * hold a value of mode MODE.
3932
+ *
3933
+ * On a machine where all registers are exactly one word, a suitable definition
3934
+ * is given of ((GET_MODE_SIZE(MODE)+UNITS_PER_WORD-1)/UNITS_PER_WORD.
3935
+ *
3936
+ * On ZipCPU, we might do
3937
+ *     ((((MODE)==DImode)||((MODE)==DFmode))?2:1)
3938
+ * but I think the default (above) code should work as well.  Hence, let's stick
3939
+ * with the default, lest someone try to create larger modes (TImode, OImode,
3940
+ * XImode) and expect us to follow them properly some how.
3941
+ *
3942
+ * Okay, now in hind sight, we know that the default doesn't work for our
3943
+ * architecture, since GET_MODE_SIZE(SImode)=4, not 1.  Thus, let's rearrange
3944
+ * this expression to work in bits rather than in bytes and we'll know more
3945
+ * of what we are doing.
3946
+ */
3947
+#undef HARD_REGNO_NREGS
3948
+#define        HARD_REGNO_NREGS(REGNO, MODE)   ((GET_MODE_SIZE(MODE)+UNITS_PER_WORD-1)\
3949
+               / (UNITS_PER_WORD))
3950
+
3951
+/* HARD_REGNO_NREGS_HAS_PADDING(REGNO,MODE) ... A C expression that is nonzero
3952
+ * if a value of mode MODE, stored in memory, ends with padding that causes it
3953
+ * to take up more space than in registers starting at register number REGNO
3954
+ * (as determined by multiplying GCC's notion of the size of the register when
3955
+ * containing this mode by the number of registers returned by HARD_REGNO_NREGS)
3956
+ * By default this is zero.
3957
+ *
3958
+ * Zip CPU --- The default looks good enough to me.
3959
+ */
3960
+
3961
+/* HARD_REGNO_NREGS_WITH_PADDING(REGNO, MODE)
3962
+ *
3963
+ * ZipCPU ---
3964
+ */
3965
+
3966
+/* REGMODE_NATURAL_SIZE(MODE) -- Define this macro if the natural size of
3967
+ * registers that hold values of mode mode is not the word size.  It is a C
3968
+ * expression that should give the natural size in bytes for the specified mode.
3969
+ * It is used by the register allocator to try to optimize its results.
3970
+ *
3971
+ * ZipCPU ---
3972
+ */
3973
+// #define     REGMODE_NATURAL_SIZE(MODE)      (((MODE)==DImode)?2:1)
3974
+
3975
+/* HARD_REGNO_MODE_OK ... A C expression that is nonzero if it is permissible
3976 103 dgisselq
+ * to store a value of mode MODE in a hard register number REGNO (or in several
3977 102 dgisselq
+ * registers starting with that one).  For a machine where all registers are
3978
+ * equivalent, a suitable definition is '1'.  You need not include code to check
3979
+ * for the numbers of fixed registers, because the allocation mechanism
3980
+ * considered them to be always occupied.
3981
+ *
3982
+ * ZipCPU --- As long as you are already avoiding the fixed registers, the
3983
+ * suitable default definition mentioned above should be sufficient.
3984
+ */
3985
+#undef HARD_REGNO_MODE_OK
3986 103 dgisselq
+#define        HARD_REGNO_MODE_OK(R,M) (R<zip_CC)
3987 102 dgisselq
+
3988
+/* HARD_REGNO_RENAME_OK(FROM,TO) ... A C expression that is nonzero if it is
3989
+ * okay to rename a hard register FROM to another hard register TO.  One common
3990
+ * use of this macro is to prevernt renaming of a register to another register
3991
+ * that is not saved by a prologue in an interrupt handler.  The default is
3992
+ * always nonzero.
3993
+ *
3994
+ * ZipCPU --- The default looks good enough to us.
3995
+ */
3996
+#undef HARD_REGNO_RENAME_OK
3997
+#define        HARD_REGNO_RENAME_OK(FROM,TO)   ((is_ZIP_GENERAL_REG(FROM))&&(is_ZIP_GENERAL_REG(TO)))
3998
+
3999
+
4000
+/* MODES_TIABLE_P(M1, M2) ... A C expression that is nonzero if a value of mode
4001
+ * M1 is accessible in mode M2 without copying.
4002
+ *
4003
+ * ZipCPU --- well, that's true for us (although we support scant few modes) ...
4004
+ * so lets' set to one.
4005
+ */
4006
+#define        MODES_TIEABLE_P(M1,M2)  1
4007
+
4008
+/* TARGET_HARD_REGNO_SCRATCH_OK(REGNO)
4009
+ * This target hook should return true if it is OK to use a hard register
4010
+ * REGNO has a scratch register in peephole2.  One common use of this macro is
4011
+ * to prevent using of a register that is not saved by a prologue in an
4012
+ * interrupt handler.  The default version of this hook always returns true.
4013
+ *
4014
+ * ZipCPU --- the default works for us as well.  If you are in an interrupt
4015
+ * context, you have an entirely new set of registers (the supervisor set), so
4016
+ * this is a non-issue.
4017
+ */
4018
+
4019
+/* AVOID_CCMODE_COPIES ... define this macro if the compiler should avoid
4020
+ * copies to/from CCmode register(s).  You should only define this macro if
4021
+ * support for copying to/from CCmode is incomplete.
4022
+ *
4023
+ * ZipCPU --- CCmode register copies work like any other, so we'll keep with the
4024
+ * default definition.
4025
+ */
4026
+
4027
+/* STACK_REGS ... Define this if the machine has any stack-like registers.
4028
+ *
4029
+ * Zip CPU has no stack-like registers, as their definition is different from
4030
+ * the ZipCPU stack pointer register.
4031
+ */
4032
+
4033 127 dgisselq
+// #define     ZIP_REG_BYTE_SIZE       1
4034 102 dgisselq
+
4035
+/* 17.08 Register Classes */
4036
+
4037
+/* enum reg_class ... An enumerate type that must be defined with all the
4038
+ * register class names as enumerated values.  NO_REGS must be first.  ALL_REGS
4039
+ * must be the last register class, followed by one more enumerated value,
4040
+ * LIM_REG_CLASSES, which is not a register class but rather tells how many
4041
+ * classes there are.
4042
+ *
4043
+ * ZipCPU --- We'll defined register 0-13 as general registers, 14-15 in
4044
+ * all_regs, and go from there.
4045
+ */
4046
+enum   reg_class {
4047
+       NO_REGS, GENERAL_REGS,
4048
+       USER_REGS,
4049
+       ALL_REGS, LIM_REG_CLASSES
4050
+};
4051
+
4052
+/* N_REG_CLASSES ... the number of distinct register classes, defined as follows
4053
+ */
4054
+#define        N_REG_CLASSES   (int)LIM_REG_CLASSES
4055
+
4056
+/* REG_CLASS_NAMES ... An initializer containing the names of the register
4057
+ * classes as C string constants.  These names are used in writing some of the
4058
+ * debugging dumps.
4059
+ */
4060 171 dgisselq
+#define        REG_CLASS_NAMES { "NO_REGS", "GENERAL_REGS", "USER_REGS", "ALL_REGS" }
4061 102 dgisselq
+
4062
+/* REG_CLASS_CONTENTS ... An initializer containing the contents of the register
4063 127 dgisselq
+ * classes, as integers which are bit masks.  The nth integer specifies the
4064 102 dgisselq
+ * contents of class n.  That way the integer mask is interpreted as that
4065
+ * register r is in the class if (mask&(1<<r)) is 1.
4066
+ *
4067 171 dgisselq
+ * When the machine has more than 32 registers, an integer does not suffice.
4068
+ * Then the integers are replaced by sub-initializers, braced groupings
4069
+ * containing several integers.  Each sub-initializer must be suitable as an
4070
+ * initializer for the type HARD_REG_SET which is defined in 'hard-reg-set.h'.
4071
+ * In this situation, the first integer in each subinitializer corresponds to
4072
+ * registers 0-31, the second integer to registers 32-634, and so on.
4073 102 dgisselq
+ *
4074
+ * ZipCPU --- This is straight forward, three register classes, etc.
4075
+ */
4076 171 dgisselq
+#define        REG_CLASS_CONTENTS { { 0x000000000, 0}, {0x00003fff, 0}, {0x0ffff0000, 0}, {0x0ffffffff, 1} }
4077 102 dgisselq
+
4078
+/* REGNO_REG_CLASS ... A C expression whose value is a register class
4079
+ * containing hard register REGNO.  In general there is more than one such
4080
+ * class;  Choose a class which is minimal, meaning that no smaller class also
4081
+ * contains the register.
4082
+ */
4083 171 dgisselq
+#define        REGNO_REG_CLASS(R)      (is_ZIP_REG(R)?(((R)<=13)?GENERAL_REGS:ALL_REGS):NO_REGS)
4084 102 dgisselq
+
4085
+/* BASE_REG_CLASS ... A macro whose definition is the name of the class to which
4086
+ * a valid base register must belong.  A base register is one used in an address
4087
+ * which is the register value plus a displacement.
4088
+ */
4089
+#undef BASE_REG_CLASS
4090
+#define        BASE_REG_CLASS  GENERAL_REGS
4091
+
4092
+/* MODE_BASE_CLASS(MODE) ... This is a variation of the BASE_REG_CLASS macro
4093
+ * which allows the selection of a bse register in a mode dependent manner.  If
4094
+ * mode is VOIDmode then it should return the same value as BASE_REG_CLASS.
4095
+ */
4096
+#undef MODE_BASE_CLASS
4097
+#define        MODE_BASE_CLASS(MODE)   GENERAL_REGS
4098
+
4099
+/* MODE_BASE_REG_REG_CLASS(MODE) ... A C expression whose value is the register
4100
+ * class to which a valid base register must belong in order to be used in a
4101
+ * base plus index register address.  You should define this macro if base plus
4102
+ * index addresses have different requirements than other base register uses.
4103
+ *
4104
+ * Zip CPU does not support the base plus index addressing mode, thus ...
4105
+ */
4106 111 dgisselq
+// #undef      MODE_BASE_REG_REG_CLASS
4107
+// #define     MODE_BASE_REG_REG_CLASS(MODE)   NO_REGS
4108 102 dgisselq
+
4109
+/* INDEX_REG_CLASS ... A macro whose definition is the name of the class to
4110
+ * which a valid index register must belong.  An index register is one used in
4111
+ * an address where its value is either multiplied by a scale factor or added
4112
+ * to another register (as well as added to a displacement).
4113
+ *
4114
+ * ZipCPU -- Has no index registers.
4115
+ */
4116
+#undef INDEX_REG_CLASS
4117
+#define        INDEX_REG_CLASS NO_REGS
4118
+
4119
+/* REGNO_OK_FOR_BASE_P(NUM) ... A C expression which is nonzero if register
4120
+ * number num is suitable for use as a base register in operand addresses.
4121
+ */
4122
+#undef REGNO_OK_FOR_BASE_P
4123 127 dgisselq
+# define REGNO_OK_FOR_BASE_P(NUM)      ((NUM>=FIRST_PSEUDO_REGISTER)||(NUM != zip_CC))
4124 102 dgisselq
+
4125
+/* REGNO_MODE_OK_FOR_BASE_P ... A C expressison that is just like
4126
+ * REGNO_OK_FOR_BASE_P, except that that expression may examine the mode of the
4127 111 dgisselq
+ * memory reference in MODE.  You should define this macro if the mode of the
4128 102 dgisselq
+ * memory reference affects whether a register may be used as a base register.
4129
+ *
4130
+ * ZipCPU --- the mode doesn't affect anything, so we don't define this.
4131
+ */
4132
+
4133
+/* REGNO_MODE_OK_FOR_REG_BASE_P(NUM, MODE) ... base plus index operand
4134
+ * addresses, accessing memory in mode mode.
4135
+ *
4136
+ * Use of this macro is deprecated.
4137
+ */
4138
+
4139 111 dgisselq
+/* REGNO_MODE_CODE_OK_FOR_BASE_P(N,M,AS,OC,IC) ... A C expression which is
4140 102 dgisselq
+ * nonzero if a register number N is suitable for use as a base register in
4141
+ * operand addresses, accessing memory in mode M in address space AS.  This is
4142
+ * similar to REGNO_MODE_OK_FOR_BASE_P, except that the expression may examine
4143
+ * the context in which the register appears in the memory reference.
4144
+ *
4145
+ * ZipCPU---We aren't specific in how we use our registers.
4146
+ */
4147
+#define        REGNO_MODE_CODE_OK_FOR_BASE_P(N,M,AS,OC,IC) REGNO_OK_FOR_BASE_P(N)
4148
+
4149
+/* REGNO_OK_FOR_INDEX_P(REGNO) ... A C expression which is nonzero if register
4150
+ * num is suitable for use as an index register in opernad addressess.  It may
4151
+ * be either a suitable hard register or a pseudo register that has been
4152 111 dgisselq
+ * allocated such as a hard register.
4153 102 dgisselq
+ *
4154
+ * ZipCPU has no index registers, therefore we declare this to be zero.
4155
+ */
4156
+#undef REGNO_OK_FOR_INDEX_P
4157
+#define        REGNO_OK_FOR_INDEX_P(REGNO)     0
4158
+
4159
+/* TARGET_PREFERRED_RENAME_CLASS(RCLASS) ... A target hook that places
4160
+ * additional preference on the register class to use when it is necessary to
4161
+ * rename a register in class RCLASS to another class, or perhaps NO_REGS, if no
4162
+ * preferred register class is found or hook preferred_rename_class is not
4163
+ * implemented.  SOmething returning a more restrictive class makes better code.
4164
+ * For example, on ARM, thumb-2 instructions using LO_REGS may be smaller than
4165
+ * instructions using GENERIC_REGS.  By returning LO_REGS from
4166
+ * preferred_rename_class, code size can be reduced.
4167
+ */
4168
+// #undef TARGET_PREFERRED_RENAME_CLASS
4169
+// #define     TARGET_PREFERRED_RENAME_CLASS(RCLASS)   RCLASS
4170
+
4171
+/* TARGET_PREFERRED_RELOAD_CLASS(X,RC) ... A target hook that places additional
4172
+ * restri tions on the register class to use when it is necessary to copy value
4173
+ * X into a register in class RC.  The value is a register class; rehaps RC, or
4174
+ * perhaps a smaller class.
4175
+ *
4176
+ * The default fversion of this hook always returns value of RC argument, which
4177
+ * sounds quite appropriate for the ZipCPU.
4178
+ */
4179
+
4180
+/* PREFERRED_RELOAD_CLASS(X,CLASS) ... A C expression that places additional
4181
+ * restrictions on the register class to use when it is necessary to copy
4182
+ * value X into a register in class CLASS.  On many machines, the following
4183
+ * definition is safe: PREFERRED_RELOAD_CLASS(X,CLASS) (CLASS)
4184
+ * Sometimes returning a more restrictive class makes better code.  For example,
4185
+ * on the 68k, when x is an integer constant that is in range for a moveq
4186
+ * instruction, the value of this macro is always DATA_REGS as long as CLASS
4187 111 dgisselq
+ * includes the data registers.  Requiring a data register guarantees that a
4188 102 dgisselq
+ * 'moveq' will be used.
4189
+ *
4190
+ * ZipCPU --- you can't load certain values into all members of ALL_REGS.  For
4191
+ * example, loading (sleep and !gie) into the CC register could halt the CPU.
4192
+ * Hence, we only allow loads into the GENERAL_REG class.
4193
+ */
4194
+#define        PREFERRED_RELOAD_CLASS(X, CLASS)        GENERAL_REGS
4195
+
4196
+/* TARGET_PREFERRED_OUTPUT_RELOAD_CLASS(RTX,RCLASS) ... Like TARGET_PREFERRED_..
4197
+ * RELOAD_CLASS, but for output instead of input reloads.
4198
+ *
4199
+ * ZipCPU --- there's gotta be a valid default behaviour for this.
4200
+ */
4201
+
4202
+/* LIMIT_RELOAD_CLASS(MODE, CL) ...
4203
+ *
4204
+ * Don't define this macro unless the target machine has limitations which
4205
+ * require the macro to do something nontrivial.  ZipCPU doesn't, so we won't.
4206
+ */
4207
+
4208
+/* TARGET_SECONDARY_RELOAD
4209
+ * SECONDARY_ ...
4210
+ * Don't think we need these ...
4211
+ */
4212
+
4213
+/* CLASS_MAX_NREGS(CLASS,MODE) ... A C expression for the maximum number of
4214
+ * consecutive registers of class CLASS needed to hold a value of mode MODE.
4215
+ *
4216
+ * This is closely related to the macro HARD_REGNO_NREGS.  In fact, the value
4217
+ * of the macro CLASS_MAX_REGS(CL,M) should be the maximum value of
4218
+ * HARD_REGNO_NREGS(REGNO,MODE) for all REGNO values in the class CLASS.
4219
+ *
4220
+ * This macro helps control the handling of multiple word values in the reload
4221
+ * pass.
4222
+ *
4223
+ * ZipCPU --- We'll just use HARDNO_REGNO_NREGS, since CLASS is independent for
4224
+ * us.  We'll also choose register R0, since ... well, since it simply doesn't
4225
+ * matter.  (HARD_REGNO_NREGS ignores this anyway)
4226
+ */
4227
+#define        CLASS_MAX_NREGS(CLASS, MODE)    HARD_REGNO_NREGS(0,MODE)
4228
+
4229
+/* CANNOT_CHANGE_MODE_CLASS
4230
+ * ???
4231
+ */
4232
+
4233
+/* TARGET_IRA_CHANGE_PSEUDO_ALLOCNO_CLASS
4234
+ */
4235
+
4236
+/* TARRGET_LRA_P
4237
+ * Default looks good.
4238
+ */
4239
+
4240
+/* TARGET_REGISTER_PRIORITY(INT) ... A target hook which returns the register
4241 111 dgisselq
+ * priority number to which the register HARD_REGNO belongs to.  The bigger the
4242 102 dgisselq
+ * number
4243
+ *
4244
+ * The default version of this target hook returns always zero---good enough for
4245
+ * the ZipCPU.
4246
+ */
4247
+
4248
+/* TARGET_REGISTER_USAGE_LEVELING_P(VOID) ... A target hook which returns true
4249
+ * if we need register usage leveling.  That means if a few hard registers are
4250
+ * equally good for the assignment, we choose the least used hard register.  The
4251
+ * register usage leveling may be profitable for some targets.  Don't use usage
4252
+ * leveling for targets with conditional execution or targets with big register
4253
+ * files as it hurts if-conversion and cross-jumping optimizations.  The default
4254
+ * version of this target hook returns always false.
4255
+ *
4256
+ * ZipCPU --- Default is the right answer.
4257
+ */
4258
+
4259
+/* TARGET_DIFFERENT_ADDR_DISPLACEMENT_P ...
4260
+ * Default looks good.
4261
+ */
4262
+
4263
+/* TARGET_CANNOT_SUBSTITUTE_MEM_EQUIV_P ...
4264
+ * Default looks good.
4265
+ */
4266
+
4267
+/* TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT ....
4268
+ */
4269
+
4270
+/* TARGET_SPILL_CLASS
4271
+ *
4272
+ * ZipCPU --- If we were running in supervisor mode only, this might be the
4273
+ * user set of registers.  However, we're not building for that mode (now),
4274
+ * so we'll leave this at the default of NO_REGS.
4275
+ */
4276
+
4277
+/* TARGET_CSTORE_MODE(ICODE) ... Defines the machine mode to use for the
4278
+ * boolean result of conditional store patterns.  The OCIDE argument is the
4279
+ * instruction code for the cstore being performed.  Not defining this hook is
4280
+ * the same as accepting the mode encoded into operand 0 of the cstore expander
4281
+ * patterns.
4282
+ *
4283
+ * ??? ZipCPU --- I don't follow this documentation.  We'll leave this at the
4284
+ * default therefore.
4285
+ */
4286
+
4287
+/* 17.09 Stack Layout and Calling Conventions */
4288
+
4289
+
4290
+/* STACK_GROWS_DOWNWARD ... Define this macro if pushing a word onto the stack
4291
+ * moves the stack pointer to a smaller address, and false otherwise.
4292
+ *
4293
+ * ZipCPU ... well, our stack does grow downward, but it doesn't do so auto-
4294
+ * magically.  We have to move the stack pointer ourselves.  However, since this
4295
+ * is our convention, we'll define it as such.
4296
+ */
4297
+#undef STACK_GROWS_DOWNWARD
4298
+#define        STACK_GROWS_DOWNWARD    1
4299
+
4300
+/* STACK_PUSH_CODE ... This macro defines the operation used when something is
4301
+ * pushed on the stack.  In RTL, a push operation will be
4302
+ * (set (mem( STACK_PUSH_CODE(reg sp))) ...) The choiecs are PRE_DEC, POST_DEC,
4303
+ * PRE_INC, and POST_INC.  Which of these is correct depends on the stack
4304
+ * direction and on whether the stack pointer points to the last item on the
4305
+ * stack or whether it points to the space for the next item on the stack.
4306
+ * The default is PRE_DECC when STACK_GROWS_DOWNWARD is true, which is almost
4307
+ * always right, and PRE_INC otherwise, which is often wrong.
4308
+ *
4309
+ * ZipCPU --- None of these is right, so let's leave this at the default and
4310
+ * see how badly we get mangled.  In particular, ZipCPU doesn't have any of the
4311
+ * PRE_DEC, POST_DEC, PRE_INC, or POST_INC addressing modes used here.
4312
+ */
4313
+
4314
+/* FRAME_GROWS_DOWNWARD ... Define this macro to nonzero if the addresses of
4315
+ * local variable slots are at negative offsets from the frame pointer.
4316
+ *
4317
+ * ZipCPU --- If the frame pointer is defined as the stack pointer upon the
4318 103 dgisselq
+ * start of function execution, and that stack pointer grows downward, then
4319 102 dgisselq
+ * this should be the case as well.
4320
+ */
4321
+#undef FRAME_GROWS_DOWNWARD
4322
+#define        FRAME_GROWS_DOWNWARD    1
4323
+// #define     FRAME_GROWS_DOWNWARD    0        // This was ECO32's value
4324
+
4325
+
4326
+/* ARGS_GROW_DOWNWARD ... Define this macro if successive arguments to a
4327
+ * function occupy decreasing addresses on the stack.
4328
+ *
4329
+ * ZipCPU -- we can leave this up to the compiler's preferred implementation,
4330
+ * it is of no consequence to the hardware.
4331
+ */
4332
+
4333
+/* STARTING_FRAME_OFFSET ... Offset from the frame pointer to the first local
4334
+ * variable slot to be allocated.  If FRAME_GROWS_DOWNWARD, find the next slot's
4335 171 dgisselq
+ * offset by subtracting the first slot's length from STARTING_FRAME_OFFSET.
4336 102 dgisselq
+ * Otherwise it is found by adding the length of the first slot to the value
4337
+ * START_FRAME_OFFSET.
4338
+ *
4339
+ * ZipCPU --- I'm not certain on this, let's come back after we look at how
4340
+ * the code is getting generated.  However, the ECO32 code I am copying from
4341
+ * suggests that 0 is the right value, so we'll use that here.
4342
+ */
4343 171 dgisselq
+// #warning "Re-evaluate me" --- I did.  This still looks good.
4344 102 dgisselq
+#define        STARTING_FRAME_OFFSET   0
4345
+
4346
+/* STACK_ALIGNMENT_NEEDED ... Define to zero to disable final alignment of the
4347
+ * stack during reload.  The nonzero default for this macro is suitable for most
4348
+ * ports.
4349
+ *
4350
+ * ZipCPU --- we'll leave this at the default, although if any alignment code
4351
+ * shows up on the stack we may need to adjust it.
4352
+ */
4353
+
4354
+/* STACK_POINTER_OFFSET ... Offset from the SP register to the first location at
4355
+ * which outgoing arguments are placed.  If not specified, the default value
4356
+ * of zero is used.  This is the proper value for most machines.
4357
+ */
4358
+#define        STACK_POINTER_OFFSET    0
4359
+
4360
+/* FIRST_PARM_OFFSET ... Offset from the argument pointer register to the first
4361
+ * argument's address.  On some machines it may depend on the data type of the
4362 171 dgisselq
+ * function.
4363 102 dgisselq
+ */
4364
+#define        FIRST_PARM_OFFSET(F)    0
4365
+
4366
+/* STACK_DYNAMIC_OFFSET(F) ... Offset from the stack pointer register to an item
4367
+ * dynamically allocated on the stack, e.g., by alloca.  The default value for
4368
+ * this macro is STACK_POINTER_OFFSET plus the length of the outgoing arguments.
4369
+ * The default is correct for most machines, ...
4370
+ *
4371
+ * ZipCPU --- so we'll use it for the ZipCPU.
4372
+ */
4373
+
4374
+/* INITIAL_FRAME_ADDRESS_RTX ... A C expression whose value is RTL representing
4375
+ * the address of the initial stack frame.  This address is passed to
4376
+ * RETURN_ADDR_RTX and DYNAMIC_CHAIN_ADDRESS.  If you don't define this macro,
4377
+ * a reasonable default value will be used.  Define this macro in order to make
4378
+ * frame pointer elimination work in the presence of __builtin_frame_address(C)
4379
+ * and __builtin_return_address(C) for (C) not equal to zero.
4380
+ *
4381
+ * ZipCPU --- Let's try the reasonable default and see what happens.
4382
+ */
4383
+
4384
+/* SETUP_FRAME_ADDRESSES ... A C expression that produces the machine-specific
4385
+ * code to setup the stack so that arbitrary frames can be accessed.  For
4386
+ * example, on the SPARC, we must flush all of the register windows to the stack
4387
+ * before we can access arbitrary stack frames.  You will seldom need to define
4388
+ * this macro.  The default is to do nothing.
4389
+ *
4390
+ * ZipCPU --- which is what we shall do here.
4391
+ */
4392
+
4393
+/* TARGET_BUILTIN_SETJMP_FRAME_VALUE(VOID) ... This target hook should return
4394
+ * an RTX that is used to store the address of the current frame into the
4395
+ * builtin setjmp buffer.  The default value, virtual_stack_vars_rtx, is correct
4396
+ * for most machines.  One reason you may need to define this target hook is if
4397
+ * hard_frame_pointer_rtx is the appropriate value on your machine.
4398
+ *
4399
+ * ZipCPU --- leave this undefined, since the default value should be correct
4400
+ * for "most" machines.
4401
+ */
4402
+
4403
+/* FRAME_ADDR_RTX ... most machines do not need to define it.
4404
+ */
4405
+
4406
+/* RETURN_ADDR_RTX(COUNT,FRAMEADDR) ... A C expression whose value is RTL
4407
+ * representing the value of the return address for the frame COUNT steps up
4408
+ * from the current frame, after the prologue.  FRAMEADDR is the frame pointer
4409
+ * of the COUNT frame, or the frame pointer of the COUNT-1 frame if
4410
+ * RETURN_ADDR_IN_PREVIOUS_FRAME is nonzero.  The value of the expression must
4411
+ * always be the correct address when COUNT is nonzero, but may be NULL_RTX if
4412
+ * there is no way to determine the return address of other frames.
4413
+ *
4414
+ * ZipCPU --- I have no idea how we'd do this, so let's just return NULL_RTX.
4415
+ */
4416
+#undef RETURN_ADDR_RTX
4417
+#define        RETURN_ADDR_RTX(COUNT,FRAMEADDR)        NULL_RTX
4418
+
4419
+/* RETURN_ADDR_IN_PREVIOUS_FRAME ... Define this macro to nonzero value if the
4420
+ * return address of a particular stack frame is accessed from the frame pointer
4421
+ * of the previous stack frame.  The zero default for this macro is suitable
4422
+ * for most ports.
4423
+ *
4424
+ * ZipCPU---Default works here as well.
4425
+ */
4426
+
4427
+/* INCOMING_RETURN_ADDR_RTX ... A C expression whose value is RTL representing
4428
+ * the location of the incoming return address at the beginning of any function,
4429
+ * before the prologue.  This RTL is either a REG, indicating that the return
4430
+ * value is saved in 'REG', or a MEM representing the location in the stack.
4431
+ * If this RTL is a REG, you should define DWARF_RETURN_COLUMN to
4432
+ * DWARF_FRAME_REGNUM(REGNO).
4433
+ *
4434
+ * ZipCPU --- While our incoming return address could theoretically be in any
4435
+ * register, our machine description file is going to place it into register
4436
+ * R0, so that's what we return here.
4437
+ */
4438
+#undef INCOMING_RETURN_ADDR_RTX
4439
+#define        INCOMING_RETURN_ADDR_RTX        gen_rtx_REG(SImode, zip_R0)
4440
+
4441
+
4442
+/* DWARF_ALT_FRAME_RETURN_COLUMN
4443
+ */
4444
+
4445
+/* DWARF_ZERO_REG ... A C exrpession whose value is an integer giving a DWARF2
4446
+ * register number that is considered to always have the value zero.  This
4447
+ * should only be defined if the target has an architected zero register (ZipCPU
4448
+ * does not), and someone decided it was a good idea to use that register number
4449
+ * to terminate the stack backtrace.  New ports should avoid this (so the
4450
+ * ZipCPU port will avoid it as well).
4451
+ *
4452
+ */
4453
+
4454
+/* TARGET_DWARF_HANDLE_FRAME_UNSPEC
4455
+ */
4456
+
4457 171 dgisselq
+/* INCOMING_FRAME_SP_OFFSET ... A C expression whose value is an integer giving
4458
+ * the offset, in bytes, from the value of the stack pointer register to the
4459
+ * top of the stack frame at the beginning of any function, before the prologue.
4460