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

Subversion Repositories zipcpu

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

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