Repository navigation
Expand file tree
/
Copy pathacd.descr
More file actions
438 lines (360 loc) · 8.33 KB
/
Copy pathacd.descr
File metadata and controls
438 lines (360 loc) · 8.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# ACD pass description for the ACK compilers.
#
# Pre-set variables.
# PROGRAM - Name the compiler driver is called with.
# ARCH - Default target architecture.
# Library directories search path.
L = /lib /usr/lib
# ACK Compilers support search path.
A = $L $L/ack
# ARCH must be defined.
ifndef ARCH
error "\$ARCH is not predefined"
# Get ARCH from the environment if set.
import ARCH
# Compiler passes.
ACK_CPP = $A/cpp.ansi $CPP_F $PREDEF $NOLINENO
ACK_CEM = $A/em_cemcom.ansi -L $CPP_F $PREDEF \
-Vw${W}.${W}i${W}.${W}p${P}.${W}f4.${W}s2.2l4.${W}d8.${W}
ACK_M2 = $A/em_m2 -I$MOD_INCL -WR \
-Vw${W}.${W}i${W}.${W}p${P}.${W}l4.${W}f4.${W}d8.${W}
ACK_PC = $A/em_pc \
-Vw${W}.${W}i${W}.${W}l4.${W}p${P}.${W}f8.${W}S${W}.${W}
MOD_INCL = $A/m2 +
ACK_DECODE = $A/em_decode
ACK_ENCODE = $A/em_encode
ACK_OPT = $A/em_opt
ACK_EGO = $A/em_ego -P $A/ego -M$EGO_DESCR
EGO_DESCR = $A/ego/${ARCH}descr +
ACK_OPT2 = $A/em_opt2
ACK_CG = $A/$ARCH/cg
ACK_AS = $A/$ARCH/as \-
ACK_LED = $A/em_led -a0:$W -a1:$W -a2:$W -a3:$W
ACK_CV = $A/cv
ASMCONV = /usr/bin/asmconv
AAL = /usr/bin/aal
# Minix predefined symbols.
CPP_F = -D__minix -D__minix3 -D__$ARCH
# Library path.
LIBPATH = $USERLIBPATH $A/$ARCH
# Default output "model".
MODEL = -sep
# Floating point is done in software.
LIBS = -fsoft
# Default optimization level.
OPT_LEVEL = 1
# Call names.
if $PROGRAM = acc
PROGRAM = cc
if $PROGRAM = apc
PROGRAM = pc
if $PROGRAM = am2
PROGRAM = m2
if $PROGRAM = kcc
PROGRAM = cc
# Default transformation target.
stop .out
# Select the runtime environment by option or program name.
arg -.c
if $PROGRAM = cc
ifndef RTSO
RTSO = -.c
LIBS = $LIBS + -.c
# Omit the runtime startoff, but keep the libraries.
arg -.o
RTSO =
arg -.$any
error ".$any: unknown language"
# Select the target architecture.
arg -m$arch
ARCH = $arch
# Preprocessor directives.
arg -D$name
arg -D $name
CPP_F = $CPP_F -D$name
arg -U$name
arg -U $name
CPP_F = $CPP_F -U$name
arg -I$dir
arg -I $dir
CPP_F = $CPP_F -I$dir
ACK_M2 = $ACK_M2 -I$dir
# Debugging.
arg -g # Add debugging info.
ACK_CEM = $ACK_CEM -g
ACK_CG = $ACK_CG -gdb
arg -n # Suppress line numbers.
ACK_M2 = $ACK_M2 -L
ACK_PC = $ACK_PC -L
arg -a # Enable assertions.
arg -A # Enable array bound checks.
ACK_M2 = $ACK_M2 $*
ACK_PC = $ACK_PC $*
# Language checking.
arg -w # No warnings.
ACK_CEM = $ACK_CEM $*
ACK_M2 = $ACK_M2 $*
ACK_PC = $ACK_PC $*
arg -ws # No strict warnings.
ACK_CEM = $ACK_CEM -s
ACK_M2 = $ACK_M2 -wR
arg -wa # No warnings and no strict warnings.
ACK_CEM = $ACK_CEM -a
ACK_M2 = $ACK_M2 -wR
arg -wo # No warnings about old style C.
ACK_CPP = $ACK_CPP -o
ACK_CEM = $ACK_CEM -o
ACK_M2 = $ACK_M2 -wO
arg -3 # Only accept 3rd generation Modula-2.
ACK_M2 = $ACK_M2 $*
arg -_ # Allow underscores in identifiers.
ACK_M2 = $ACK_M2 -U
ACK_PC = $ACK_PC -U
arg -w$any
arg -F
arg -m
# Ignore strange -w flags, and past and present i86 compiler flags.
# Stop suffix.
arg -c
stop .o
arg -c.$stop
stop .$stop
arg -E
stop .E
arg -P
CPP_F = $CPP_F -P
stop .i
arg -S
stop .s
# Optimization.
arg -O
OPT_LEVEL = 1
arg -OS # Optimize for size.
ACK_EGO = $ACK_EGO -S
arg -OT # Optimize for time.
ACK_EGO = $ACK_EGO -T
arg -O$n
numeric $n
OPT_LEVEL = $n
# Library search path.
arg -L$dir
arg -L $dir
USERLIBPATH = $USERLIBPATH $dir/$ARCH $dir
# -llib must be searched in $LIBPATH later.
arg -l$lib
arg -l $lib
$> = $LIBPATH/lib$lib.a
# Software floating point, hardware floating point, or no floating point.
arg -f
arg -fp
arg -fsoft
LIBS = $LIBS + -fsoft
arg -fhard
LIBS = $LIBS - -fsoft
arg -fnone
LIBS = $LIBS + -fnone
# Output model.
arg -com
MODEL = # Common I&D.
arg -sep
arg -i # Separate I&D.
MODEL = -sep
arg -r # Relocatable object (combined .o)
MODEL = -r
# Strip executable.
arg -s
ACK_LED = $ACK_LED -s
# Size of heap+stack.
arg -stack $size
ACK_CV = $ACK_CV -S $size
# Change output file.
arg -o$out
arg -o $out
OUT = $out
# Complain about just -D, -U, -I, ...
arg -D; arg -U; arg -I; arg -L; arg -l; arg -o; arg -stack
error "argument expected after '$*'"
arg -R$pass-$flag # The ACK way of passing options to passes.
arg -Wack-R$pass-$flag # The ACD way.
if $pass = cpp
ACK_CPP = $ACK_CPP -$flag
if $pass = cem
ACK_CEM = $ACK_CEM -$flag
if $pass = m2
ACK_M2 = $ACK_M2 -$flag
if $pass = pc
ACK_PC = $ACK_PC -$flag
if $pass = opt
ACK_OPT = $ACK_OPT -$flag
if $pass = ego
ACK_EGO = $ACK_EGO -$flag
if $pass = opt2
ACK_OPT2 = $ACK_OPT2 -$flag
if $pass = cg
ACK_CG = $ACK_CG -$flag
if $pass = as
ACK_AS = $ACK_AS -$flag
if $pass = led
ACK_LED = $ACK_LED -$flag
arg -Was-$dialect # Default assembly dialect.
ASDIALECT = $dialect
arg -W$any
# Ignore any other -W options.
# Complain about unknown options, don't give them to the loader.
arg -$any
error "$*: unknown option"
# Do the scanning phase early, we need to know the architecture.
scan
# The word and pointer sizes of the target.
if $ARCH = i86
W = 2; P = 2
if $ARCH = i386
W = 4; P = 4
ifndef W
error "$ARCH: unsupported architecture"
# Optimize -O2 or higher?
if (0 1 - $OPT_LEVEL) = (0 1)
ACK_EGO = $ACK_EGO -O$OPT_
8000
LEVEL
ACK_OPT = $ACK_OPT -m0 # Leave multiplication optimization to opt2.
prefer .m .gk
# Tell cem to reverse bitfields on the i386 to be compatible with gcc.
if $ARCH = i386
ACK_CEM = $ACK_CEM -Vr
# Predefined preprocessor flags.
PREDEF = -D_EM_WSIZE=$W -D_EM_PSIZE=$P -D_EM_SSIZE=2 -D_EM_LSIZE=4 \
-D_EM_FSIZE=4 -D_EM_DSIZE=8 -D__ACK__ -D_ACK
# Preprocess C source.
transform .c .i
$ACK_CPP $* > $>
# Preprocess any type of file and send it to standard output or $OUT.
transform "" .E
if $* = "-"
file = # Standard input.
else
file = $*
ifndef OUT
$ACK_CPP $file
else
$ACK_CPP $file > $OUT
# Compile C source to EM-code.
transform .c .k
transform .i .k
$ACK_CEM $* $>
ifndef RTSO
RTSO = -.c
LIBS = $LIBS + -.c
# Compact EM to readable EM.
transform .k .e
transform .m .e
transform .gk .e
transform .g .e
$ACK_DECODE $* > $>
# Readable EM to compact EM.
transform .e .k
ifhash $*
NOLINENO = -P # Encode chokes on cpp line directives.
apply .c .i
unset NOLINENO
$ACK_ENCODE $* > $>
# Peephole optimization.
transform .k .m
$ACK_OPT $* > $>
# Global optimization.
transform .m .gk
$ACK_EGO $* > $>
# Second peephole optimization after global optimization.
transform .gk .g
$ACK_OPT2 $* > $>
# EM-code to target machine assembly.
transform .m .ack.s
transform .g .ack.s
transform .m .s
transform .g .s
if $ARCH = i386
$ACK_CG -F__fp_hook $* > $>
else
$ACK_CG $* > $>
# How to treat plain .s?
ifndef ASDIALECT
transform .s .ack.s
$> = $*
# Assembly to object file.
transform .ack.s .o
ifhash $*
apply .c .i
if $> = $<.o
ifdef OUT
$> = $OUT
$ACK_AS -o $> $*
# Combine object files and libraries to an executable.
combine (.o .a) .out
if $MODEL = ()
model = -b0:0
if $MODEL = (-sep)
model = -b0:0 -b1:0
rtso =
if $RTSO = -.c
rtso = $A/$ARCH/crtso.o
libd = ; libc = ; libfp =
if (-.c - $LIBS) = ()
libd = $A/$ARCH/libd.a
libc = $A/$ARCH/libc.a
if (-fsoft - $LIBS) = ()
libfp = $A/$ARCH/libfp.a
libs = $libd $libc $libfp $A/$ARCH/libe.a
ifndef OUT
OUT = a.out
if (-r - $MODEL) = ()
# Combine to an object file.
$ACK_LED -r -o $OUT $*
else
# Combine to an executable.
mktemp EXE
$ACK_LED $model -o $EXE $rtso $* $libs $A/$ARCH/libend.a
$ACK_CV -x -m$ARCH $EXE $OUT
# Add object files to a library.
combine (.o) .a
if $> = $<.a
ifdef OUT
$> = $OUT
$AAL cr $> $*
# Assembly conversions.
# ACK assembly to ACK Xenix assembly.
transform .ack.s .ncc.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ack ncc $* $>
# ACK assembly to GNU assembly.
transform .ack.s .gnu.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ack gnu $* $>
# ACK Xenix assembly to ACK assembly.
transfo
4C37
rm .ncc.s .ack.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ncc ack $* $>
# ACK Xenix assembly to GNU assembly.
transform .ncc.s .gnu.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH ncc gnu $* $>
# BCC assembly to ACK assembly.
transform .bas.s .ack.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH bas ack $* $>
# BCC assembly to ACK Xenix assembly.
transform .bas.s .ncc.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH bas ncc $* $>
# BCC assembly to GNU assembly.
transform .bas.s .gnu.s
ifhash $*
apply .c .i
$ASMCONV -m$ARCH bas gnu $* $>
#ifdef ASDIALECT
# Treat plain .s as being in the given dialect.
transform .s .$ASDIALECT.s
$> = $*