660 Commits

Author SHA1 Message Date
em
de2af3ce35 Added some xtra output for Henk Schouten's debugger. 1985-02-26 15:05:51 +00:00
cvs2hg
604d707769 fixup commit for branch 'unlabeled-2.17.1' 1985-02-19 13:41:31 +00:00
keie
98761203cb The stacking pattern for ldc C and 4 with highw(c)==0 was incorrect.
The effect was that rand() from libcc/gen always returned
a 0.
1985-02-19 13:41:30 +00:00
bal
9a02e2ede3 p_use->u_ext field deleted from showptable() 1985-02-19 11:16:11 +00:00
bal
7c9dea8bed Dependencies for .m files added. 1985-02-19 11:13:13 +00:00
keie
3a8da23666 Added a default in the ANY case for system type. 1985-02-19 10:31:20 +00:00
keie
5cc658b535 Removed nascom from linked list. 1985-02-18 23:06:13 +00:00
keie
8ecb1b5664 Added link to 6805. 1985-02-18 23:01:05 +00:00
bal
ead7e668ff bug fixed: lifetime of an item was too short; it should also cover
any live/dead message prior to its initial live-message.
1985-02-18 15:14:22 +00:00
keie
eaf62079df The PDP 11 needs -i, Vax'en ignore it. 1985-02-18 12:45:31 +00:00
keie
941ef832f3 Added some comment. 1985-02-18 01:06:58 +00:00
keie
c967f9be34 Made use of apc and acc where assuming results
can be run on own system explicit.
1985-02-18 01:03:51 +00:00
keie
07717c1cb2 Changed "name of system" into "type of system". 1985-02-18 00:12:12 +00:00
keie
54c7ef703d Basic also needs libc.a. 1985-02-17 22:47:40 +00:00
keie
992e62127c Moved retar from ret.s to trp.s.
trp.s needed it and is behind ret.s in the library.
When ret.s is loaded, it calls (via unknown) trp.s so
inclusion in trp.s should work.
1985-02-17 22:31:10 +00:00
keie
36f75c8404 Added a line for
loc loc cuu $1==$1, because write.e contained the line
loc 2
loc 2
ciu
and the cg failed to translate.
1985-02-17 22:03:44 +00:00
keie
1f6fe9a81b Further refinement. 1985-02-17 22:01:03 +00:00
em
8d38f1f8d7 Added .align 2. Prevents end of bss to be odd.
Especially important for malloc, it distinguishes between
odd and even word pointers.
1985-02-17 01:12:36 +00:00
cvs2hg
5e3c3102a6 fixup commit for tag 'dist2' 1985-02-17 00:57:20 +00:00
keie
1ae42c6b70 Added .align 2.
Especially important for malloc.
1985-02-17 00:57:19 +00:00
keie
83f63333d4 *** empty log message *** 1985-02-16 22:09:05 +00:00
keie
51240e1bad *** empty log message *** 1985-02-16 16:48:18 +00:00
em
efb96fa147 Now chooses between Vax and Pdp conversion. 1985-02-16 15:58:34 +00:00
keie
dce1ed2998 The assembler is used for both 2/4 and 4/4. 1985-02-16 15:49:03 +00:00
em
a6bee49d9c *** empty log message *** 1985-02-15 23:13:04 +00:00
em
229e26fa2e 1985-02-15 23:12:16 +00:00
em
5734f92170 Adapted to -DNOFLOAT. 1985-02-15 23:11:30 +00:00
em
83a75598d5 Adapted to NOFLOAT. 1985-02-15 23:10:04 +00:00
em
fc97434c5b *** empty log message *** 1985-02-15 23:00:46 +00:00
em
683c2eecbe *** empty log message *** 1985-02-15 22:53:13 +00:00
em
b1e1945488 Removed one error. 1985-02-15 14:37:35 +00:00
em
cef800df41 Program was adapted with NOFLOAT flag. 1985-02-15 14:23:34 +00:00
em
a28e676920 Added RCS id.
Adapted to use the NOFLOAT cpp flag.
1985-02-15 14:20:04 +00:00
bal
ea3b34d308 Compare group (cmp,cmi,cmu,cms,cmf) added as cheap operators. 1985-02-15 13:18:57 +00:00
em
28b5951129 The cho worked incorrectly, thereby causing the whole test to fail. 1985-02-13 00:41:16 +00:00
em
74736c0bbe Removed the use of float from the test.
Using int's in sqrt gives the same result.
1985-02-12 23:27:23 +00:00
em
2aa95bf38c 1985-02-12 23:07:22 +00:00
em
c05291bb1f A slightly different message. 1985-02-12 23:07:05 +00:00
keie
c8eece7f03 Adfded RCS id. 1985-02-12 14:37:52 +00:00
keie
b7bed39420 As left by Hans v. Staveren. 1985-02-12 14:32:20 +00:00
keie
91f91a4efe *** empty log message *** 1985-02-12 14:20:30 +00:00
keie
a9acfd3fe7 Now using the same em.c as in m68k2/int.
The interpreters are moved from pdp/pdp_int (or some such)
to lib/int22.
1985-02-12 13:11:27 +00:00
keie
aaf560f95a Initial revision 1985-02-12 12:54:44 +00:00
keie
a6b16f9fa1 Initial revision 1985-02-12 12:28:49 +00:00
keie
f9a3465c6f Adapted to run on 4/4 machines. 1985-02-11 14:33:04 +00:00
keie
a55067a1c9 Placed a few dot on e few i's. 1985-02-11 14:32:02 +00:00
keie
8dfed719a0 The default for any machine is without, double length
integer arithmetic and without floating point.
1985-02-11 11:17:35 +00:00
bal
d2031cc751 restructured. 1985-02-11 10:52:49 +00:00
bal
d38149be31 The binaries of the phases of ego are now put in a single directory. 1985-02-11 10:07:47 +00:00
bal
fcd565c4b6 Macros newcflpx and oldcflpx added. 1985-02-11 09:52:11 +00:00
bal
e74811b2bf Include files and declaration of em_flag added. 1985-02-11 09:51:02 +00:00
bal
b318d406e9 Memory allocation/deallocation for extends changed. 1985-02-11 09:48:32 +00:00
keie
a284db06f5 Removed a few typos. 1985-02-08 16:54:34 +00:00
keie
e0e10b71f7 Deleted a line with a statement unknown to this compiler. 1985-02-08 15:41:19 +00:00
keie
5d49bc78d4 Looks more reasonanle now. 1985-02-08 13:21:23 +00:00
keie
c6893215f4 Now calling trace with the current line number as parameter. 1985-02-08 13:18:26 +00:00
keie
ddc05160f2 Improved. 1985-02-08 13:12:51 +00:00
keie
6bd4717ad9 *** empty log message *** 1985-02-07 22:59:50 +00:00
keie
73585dd0ea A list without double entries, for the moment supposing
that trp,etc always gets loaded, so will be there when .dvu needs it.
1985-02-07 22:51:12 +00:00
keie
2c1a71db26 d2 contains the remainder of dvu i.s.o. d3. 1985-02-07 22:26:11 +00:00
keie
b64fbd2430 *** empty log message *** 1985-02-07 22:06:32 +00:00
keie
7415686b36 Initial revision 1985-02-07 17:43:43 +00:00
keie
3526169494 Initial revision 1985-02-07 17:18:06 +00:00
keie
d9098b1255 *** empty log message *** 1985-02-07 15:58:40 +00:00
keie
ce47c6dc76 *** empty log message *** 1985-02-07 15:33:13 +00:00
em
cfbef80934 Added a line about the presence of out.std 1985-02-06 21:31:51 +00:00
em
3de69fcd73 Initial revision 1985-02-06 21:25:27 +00:00
keie
3c95327443 Initial revision 1985-02-06 21:06:03 +00:00
garde
8648657e4b monitor calls open, close and ioctl removed. 1985-02-06 16:56:41 +00:00
garde
e9c60b6bb3 Initial revision 1985-02-06 16:50:52 +00:00
em
6ec08108d7 *** empty log message *** 1985-02-05 14:52:52 +00:00
em
9ed23f00fc Copied from vax2, takes its info on which files
to use in which order from LIST.
1985-02-05 14:52:02 +00:00
em
605bd795e7 This one is made with lorder|tsort. 1985-02-05 14:51:17 +00:00
em
2ba83ebb08 The first one, Duk's order. 1985-02-05 14:50:24 +00:00
em
0161857789 Now fetching sedf from this directory instead of
from the cg source directory.
1985-02-05 11:44:40 +00:00
keie
c833359d74 Placed the include files in {EM_HOME}/h/bc_..... 1985-02-04 22:18:16 +00:00
keie
bf33a4f4ce *** empty log message *** 1985-02-04 14:31:17 +00:00
keie
78cc662c29 *** empty log message *** 1985-02-04 14:26:13 +00:00
keie
569c6fedec Prevent the existence of pem2[24].p to frustate the ln and thus
the whole exercise.
1985-02-04 02:53:18 +00:00
keie
eed6257417 Added an entry "distr" to make tables1.c and tables1.h. 1985-02-03 23:50:51 +00:00
keie
01b13b9130 The creation of the library is now done by the process of creating
the distribution directory.
1985-02-03 23:23:50 +00:00
keie
6a40c131ac Tail_em.s.a is now extracted from the RCS directory by the
distribution making process in em/distr2.
1985-02-03 23:21:24 +00:00
keie
b137cdca9b The effect of the .distr entry is now done by the
mktree process from /usr/em/distr2.
1985-02-03 23:18:06 +00:00
em
785145278b Added libmon to libraries to be translated. 1985-02-02 18:06:37 +00:00
em
6d5181540c *** empty log message *** 1985-02-01 22:12:31 +00:00
garde
d521693526 Many, many improvements made, ususually small ones.
For example: many em-patterns have got alternative code-rules.
1985-02-01 12:51:56 +00:00
keie
c5eaa963e8 Now using ../../proto/libg/Makefile. 1985-02-01 12:38:08 +00:00
keie
86e08fc0b7 To avoid conflict while compiling with acc itself the word
size of the target machine is now defined as TEM_WSIZE.
1985-02-01 12:32:46 +00:00
keie
d0a48dc8e1 Added an entry to create a doc.pr suitable for printing
on a straightforward line printer.
1985-01-31 22:38:00 +00:00
keie
4ec23aa1dc Added a reference to MES 11 in 11.1.4.4 at the non-local goto. 1985-01-31 15:15:20 +00:00
keie
a6c5fba558 1- Zero is deleted as a possible argument to LOI and STI.
Allowing that was an oversight.
2- Message number 10 is reserved for global optimizer output.
3- Message number 11 must be used by GTO destinations.
1985-01-31 15:10:16 +00:00
keie
5dce582bc5 Added a few sentences about the capability of ack to
preprocess Pascal programs and one restriction that imposes
on programs using it.
1985-01-31 14:50:15 +00:00
keie
5024af87a6 Zero is deleted as a possible argument to LOI and STI.
Allowing that was an oversight.
1985-01-31 14:03:56 +00:00
keie
5e33c06a66 Zero is deleted as a possible argument to LOI and STI.
Allowing that was an oversight.
1985-01-31 13:58:09 +00:00
keie
12ab509fe7 1 - Changed incorrect execution line for callc/modc
2 - Added several sources to 'pr' entry, for printing.
1985-01-31 10:53:59 +00:00
bal
60ae999a07 Bugs fixed for the following patterns:
lol loc 255 and 2  (byte order was wrong)
loc x beq , 0 < x < 128  (was 0 < x < 256)
loc x bne (idem).
These bugs were introduced in version 2.2.
1985-01-30 16:34:14 +00:00
bal
4f624f015a register save costs changed: they are now linearly dependent on
the number of registers to be saved (for time).
1985-01-30 15:43:02 +00:00
bal
3bc2ec8825 Entry for LOI changed from CLASS1 to CLASS12. 1985-01-30 14:49:03 +00:00
bal
a3ed92a887 CLASS12 added for the LOI instruction. A "LOI n", n < wordsize,
loads wordsize bytes, not n bytes.
1985-01-30 14:47:49 +00:00
ceriel
149e9e498d Added -DCPM to the flags. 1985-01-30 12:37:10 +00:00
bal
bd01b5a24f Debugging procedure print_allocs now writes to stderr. 1985-01-30 10:52:33 +00:00
bal
cada8b5bb3 bug fixed: assemble_allocs() did generate whole_procedure allocations.
These allocations were initialized with a very low profit. Consequently
account_regsave rejected these allocations.
Solution: repl_allocs() updates the al_profits field of the
whole_procedure allocation.
1985-01-30 10:47:47 +00:00
bal
9eaaede038 bug fixed: oldmap(lmap,llength) was sometimes called when no new map
had to be allocated for the current (data-) unit.
1985-01-28 11:38:06 +00:00
em
cd85c6f2bc Also remove all *.e and *.d files when cleaning up. 1985-01-25 16:19:13 +00:00
keie
e4998f5ad8 Strings in rom are initialized with usage count 9999.
decstr does not touch these at all.
1985-01-25 14:40:51 +00:00
keie
4d93f6d900 Strings in rom are initialized with usage count 9999 i.s.o. 1.
String with that usage count are not touched any way at all.
1985-01-25 14:34:50 +00:00
bal
7284e9d210 Number of address registers decreased from 5 to 4. 1985-01-25 13:24:12 +00:00
keie
690546a7d6 Added an entry called distr.
This make the formatted install.pr to be put on the distribution tape.
1985-01-25 11:28:55 +00:00
keie
fbf86e8a78 The program name is used to set the name
of the file were the contents of data statements are written.
The filename is extracted from the path and the suffix (if present)
is replaced by .d.
1985-01-25 11:04:18 +00:00
keie
0aa95f6015 The parametrs passed to the call to opnchn when initializing are now
correct string descriptors.
Programs with data statements used to crash with TRAP TYPE 11.
1985-01-25 09:57:04 +00:00
keie
a1c05ca061 The non-flag arguments are now passed by position.
The order is :  (bem) input output program-name.
1985-01-25 09:55:28 +00:00
em
e1ba4e407f Removed test18 because it is in essence a busy loop. 1985-01-24 22:34:31 +00:00
em
a6b90c6a7a Added executable files to list of those to cleanup. 1985-01-24 21:27:32 +00:00
em
8f3826e67b Added entry "clean" for cleanup. 1985-01-24 21:25:57 +00:00
keie
9f2092d184 *** empty log message *** 1985-01-24 17:39:54 +00:00
keie
9c9f63e4ca Added ranlib commends. 1985-01-24 16:16:32 +00:00
keie
cddf156153 Some minor changes. 1985-01-24 15:34:23 +00:00
em
80cb295064 Changed the line numbered 19 into a line numbered 190.
This seemed the correct thing to do.
1985-01-24 11:34:12 +00:00
em
a1c27b46db *** empty log message *** 1985-01-24 11:27:36 +00:00
bal
7657fb8d45 bug fixed: the "incr" parameter of sbrk() is a 2-byte integer,
not a 4-byte integer.
1985-01-23 16:31:51 +00:00
bal
8597f736da parameter of fscanf changed from "%d" to "%hd" to read a short. 1985-01-23 16:28:58 +00:00
bal
086642a17e core allocation macros added. 1985-01-23 16:27:47 +00:00
bal
858a1f55e0 ovfl_harmful and arrbound_harmful turned into ints 1985-01-23 16:25:29 +00:00
bal
a8f778fb34 Interface of tmplocal() changed: second parameter is a long now 1985-01-23 16:23:15 +00:00
bal
e7bf924ff7 interface with tmplocal() changed: second parameter is a long now. 1985-01-23 16:18:33 +00:00
bal
81355e7a10 bug fixed in get_instrs(): instr should be an int rather than a Celem_t. 1985-01-23 16:16:49 +00:00
bal
2568996690 bug fixed in last_mnem(): test on nil-pointer.
bug fixed in try_tail(): add line "if(l1==0||l2==0) return FALSE".
1985-01-23 16:13:57 +00:00
bal
fa3e83fbd8 bug fixed in last_line() : assert(l!=0) should be assert(lines!=0). 1985-01-23 16:12:21 +00:00
bal
c64b43ae7e bug fixed in routine get_ca_lines(): test on nil-pointer. 1985-01-23 16:10:43 +00:00
bal
a358b4cf96 init_regcnt renamed initregcnt to avoid name conflict.
bug fixed in routine fits_in(): test on nil-pointer.
routine choose_location(): interface with tmplocal() changed, second
parameter now is a long, so a cast is added.
1985-01-23 16:07:09 +00:00
bal
579935b64e rules for itemtab.h and makeitems added. 1985-01-23 15:50:17 +00:00
bal
ee1a4305f4 clean_items renamed cleanitems to avoid name conflict.
clean_timeset renamed cleantimeset to avoid name conflict.
bugs fixed: calls to fscanf() with a pointer-to-short as argument
should provide a "%hd" instead of "%d".
1985-01-23 15:45:58 +00:00
garde
7b01e4ee6f src1 and src2 extended.
Errors in 'pat loc cmi teq' and 'pat loc cmi tne' recovered.
Second stack-pattern for 'pat zlt' and 'pat zge' added.
Patterns for 'lil loc adi sil', 'lil inc sil', 'lil dec sil'
and 'sil lil' added.
1985-01-22 19:55:11 +00:00
em
d224507a75 User defined trap handling routine is called with calls instruction.
A message is printed if there is no routine at all.
1985-01-22 15:20:19 +00:00
em
c6d9ab97ec Added `movl r3,ap' to restore the argument pointer before returning
vi jmp (r0).
1985-01-22 13:10:35 +00:00
em
1555d8948e Now using opder recommanded by 'lorder'. 1985-01-22 02:17:13 +00:00
keie
2c3c7efe8c Printf does not return a truth value for failure.
These -incorrect- tests were replaced by calls to ferror.
1985-01-21 23:58:07 +00:00
keie
c4daab57eb Added declaration of _newstr. 1985-01-21 23:57:44 +00:00
keie
7f22afeb89 Added correct declaration of salloc, thereby preventing incorrect conversions.
Removed now unnecessary casts from salloc to (char *).
Added a cast to (char *) for the argument of sfree in the second call.
1985-01-21 23:56:10 +00:00
keie
2823430d65 1 - Changed argument from int to unsigned.
2 - The test for a failed malloc is changed from comparison to -1
    to comparison to 0.
1985-01-21 23:54:46 +00:00
keie
1668923508 Tests for EOF returned by stdio routines need the full int width. 1985-01-21 23:53:41 +00:00
keie
3f3a9ed279 Removed casts made superfluous by adding newstr to string.h 1985-01-21 23:53:01 +00:00
keie
092c81b39c Test for EOF returned by stdio routines have to use the full int width. 1985-01-21 23:52:19 +00:00
keie
3b1e068b5d Removed cast made superfluous by added newstr to string.h 1985-01-21 23:51:33 +00:00
keie
14e1e3c768 Added test for outcome of request for more core.
If no more core is available a fatal error message is produced.
1985-01-21 23:48:06 +00:00
em
f4f7d5676a Changed #define's of newlbss of cst_fmt. 1985-01-21 16:40:02 +00:00
em
7b3a4577cc Bug fix: redefined a Local local causing an INTERNAL ERROR from as. 1985-01-21 15:49:22 +00:00
keie
512e225b73 Due to an 8 character identifier length limitation the identifier
"strcompare" is changed into "strcomp".
1985-01-21 14:52:34 +00:00
keie
52249bfb5d Due to an 8 character identifiers limitation calls in EM
the identifier "randomize" was changed into "randomi".
1985-01-21 14:51:29 +00:00
keie
0aded9a4da Due to an 8 character identifiers limitation on EM calls to
"setchannel" were changed into "setchan" and the identifier
"seektable" is replaced by "seektab".
1985-01-21 14:50:12 +00:00
keie
c3df7e864a Changed calls to "setrandom" into calls to "setrand" and
calls to "randomize" inro calls to "randomi" to avoid
problems with routines compiled by C.
1985-01-21 14:48:16 +00:00
keie
c04e2decaf Added a few /*NOSTRICT*/ comments to indicate awareness of lint complaints. 1985-01-21 14:30:55 +00:00
keie
5bdc21e6c7 1 - Changed the defintion of a local 's' into 'Sym' to avoid naming conflict.
2 - Added .integer, .Sptr and .cptr at appropiate places to uses of yylval.
3 - Removed unnecessary casts.
4 - Added a few /*NOSTRICT*/ comments to indicate awareness of lint
    complaints.
1985-01-21 14:26:29 +00:00
keie
858bd446fd 1 - Added comment to indicate awareness of lint complaints.
2 - Added/Removed some casts used with core allocation/deallocation.
1985-01-21 14:23:49 +00:00
keie
9ef0eefc55 Changed the argument of salloc from an int into an unsigned.
Just to shut up lint.
1985-01-21 14:22:07 +00:00
keie
9ced1efe34 Added a declaration of gosublabel. 1985-01-21 14:21:52 +00:00
keie
ac043a42de Added a few comments to indicate awareness of lint complaints. 1985-01-21 14:20:11 +00:00
keie
8d7dbdd802 1 - Removed definition of POINTERSIZE.
2 - Defined void as int, some compilers don't know void.
3 - Added declarations of the routines proclabel, salloc, strcpy, strcat, malloc.
1985-01-21 14:18:47 +00:00
garde
05dbcb9956 case 8 and case 6 deleted in switch of function 'prolog' 1985-01-21 14:17:11 +00:00
keie
d3a42778d0 Now using a union for YYSTYPE and typed (non-)terminals.
Changed values $n(intvalue) to ival in definition of filelist.
Changed one asp,$n(midparms) into several asp,...SIZE in the definition
that uses MIDSYM.
1985-01-21 14:15:06 +00:00
keie
7aa0ac7b9b 1 added lint entry.
2 changed calls to cc into $(CC)
1985-01-21 14:14:22 +00:00
em
dd7341586c To have a file preprocessed, it must start with a # in column o1.
The RCSid is replaced to accomplish this.
1985-01-21 12:56:09 +00:00
em
35b13a69eb Now using correct RCS identification 1985-01-21 12:47:04 +00:00
em
72a885e8a5 Renaming due to 8 character C compiler limit. 1985-01-21 12:37:26 +00:00
em
22d8081884 Used a correct definition of malloc. 1985-01-21 12:35:53 +00:00
em
fd84b38268 Replaced RCSid so that file starts with # in column 0 so it gets preprocessed. 1985-01-21 12:28:59 +00:00
em
7a0d345ca2 Corrected type; forgot closing ". 1985-01-21 12:14:59 +00:00
em
6e192ca1a5 Removed #define IDFIRST because fmt_id() replaces it. 1985-01-21 12:09:44 +00:00
em
24f8685ceb Initial revision 1985-01-18 16:06:21 +00:00
em
8170b48dba Routines are now called with calls instead of jsb. We use ap as argument
pointer register. EM_BSIZE is required to be a constant.
1985-01-18 15:39:07 +00:00
em
ce159743de Changed label generators and added fmt_id(). 1985-01-18 15:36:51 +00:00
em
6143ed2504 Routines are called with calls instead of jsb. EM_BSIZE is required to
be a constant.
1985-01-18 15:33:44 +00:00
duk
1e38cfaf5a Initial revision 1985-01-18 14:30:03 +00:00
bal
ab3a49f087 Initial revision 1985-01-18 09:59:09 +00:00
garde
ecdace453e Initial revision 1985-01-17 14:31:34 +00:00
duk
4aa42e3c2b Initial revision 1985-01-17 14:20:52 +00:00
em
48edb88fe6 Checking in Martin's changes. 1985-01-17 14:10:27 +00:00
keie
f4fe5f16e9 Added some documentation for the interface between C and Pascal.
This was necessary because the format of Pascal and C procedure
pointers differ from now on.
1985-01-17 13:22:49 +00:00
keie
755173396c Added the test program for the C<=>Pascal interface. 1985-01-17 12:43:51 +00:00
keie
2beb7f0ab9 *** empty log message *** 1985-01-17 12:43:04 +00:00
bal
44d3516be2 The EM runtime routines are reentrant now, so the remark about
reentrancy is removed from this file.
1985-01-17 10:39:33 +00:00
bal
ab8f584c8c Bug fixed: a0 is changed by call to _brk, so it should be saved & restored. 1985-01-17 10:33:23 +00:00
keie
d32a6c818d Added RCS id. 1985-01-11 17:03:53 +00:00
keie
589a92b3eb Allows optional second argument.
This is the name of the destination file. The destination directory
is determined by compare.
1985-01-11 16:46:02 +00:00
keie
bf3cd69641 1 - Allows 2 arguments, 1 - name of source in current directory.
2 - name of destination file(!path), default arg 1.
2 - Make the necessary dirctory.
3 - runs ranlib if "ar t ... | grep SYMDEF succeeds.
1985-01-11 16:43:56 +00:00
keie
25e6cb1de9 Added RCS id. 1985-01-11 16:28:30 +00:00
keie
20fc06c5dc The previous fix produced an array in which the values were one off.
This has been fixed.
1985-01-11 13:42:51 +00:00
keie
832ec1a9a7 *** empty log message *** 1985-01-11 13:20:36 +00:00
keie
78bd26211d The recursive call of setp1 initialized elements 0...ASIZE.
This is out of bounds and now altered into 0..ASIZE-1.
1985-01-11 13:17:26 +00:00
keie
b20e6856b6 *** empty log message *** 1985-01-11 13:13:56 +00:00
sater
ff89603e82 RREMOVE section updated. 1985-01-11 09:44:34 +00:00
sater
266e0429ef extra define added to aid in generation of DO_RREMOVE 1985-01-11 09:42:17 +00:00
sater
b29271a7d1 code was added to generate DO_RREMOVE 1985-01-11 09:41:47 +00:00
sater
10188dfba9 code was added to cause generation of DO_RREMOVE in some cases 1985-01-11 09:41:13 +00:00
sater
684e24132a diffs were applied to make default register property at stacking rule
-1 instead of 0.
1985-01-11 09:40:40 +00:00
sater
14ff4bda29 Optional register property in stacking rules must be -1 when absent.
Fixed this.
1985-01-10 16:30:09 +00:00
duk
2118ece784 Maybe some minor changes. 1985-01-10 13:35:39 +00:00
duk
d1870dd6cf Added call to trap signals. 1985-01-10 13:24:36 +00:00
duk
c0f8361e8c Header and section table now allocated statically. 1985-01-10 13:22:04 +00:00
duk
a885e7f981 Inline expansion of index_adjust() and compute_origins().
Section table now allocated statically.
1985-01-10 13:19:47 +00:00
duk
cc778299af Added routine to check signals. 1985-01-10 13:17:22 +00:00
sater
8246648f18 *** empty log message *** 1985-01-08 15:34:54 +00:00
sater
e204e2e7cf Initial revision 1985-01-08 15:28:26 +00:00
keie
f8fc7e5ab4 *** empty log message *** 1985-01-08 13:52:58 +00:00
duk
cef3df332e Added provisions for copying everything after the string area into the
resulting object file. Because this is most likely symbolic debugging
information, these are parametrized by #ifdef SYMDBUG.
1985-01-08 11:54:57 +00:00
keie
ef9e36ad74 *** empty log message *** 1985-01-08 11:48:43 +00:00
sater
b9804696fe *** empty log message *** 1985-01-08 09:59:28 +00:00
keie
78b124fd57 *** empty log message *** 1985-01-07 15:54:38 +00:00
keie
db9b60ff8c *** empty log message *** 1985-01-07 15:43:50 +00:00
keie
fa5eb3feba *** empty log message *** 1985-01-07 14:39:27 +00:00
keie
556a2d039a *** empty log message *** 1985-01-07 14:26:46 +00:00
keie
bfab17b353 *** empty log message *** 1985-01-07 14:15:47 +00:00
keie
9dcce61d84 *** empty log message *** 1985-01-07 13:57:25 +00:00
keie
a52e067a38 15-5-83 EGK
The coercion from rm1 to register contained
                allocate(%[1],GENREG).
                The %[1] here is incorrect and has been removed.
16-5-83         EGK
                The word before the movb was cleared by a xor.
                Now we clear the upper byte after the movb.
                This allows the %[1] to be added to the allocate.
1985-01-07 13:51:36 +00:00
keie
62ae0a54c3 *** empty log message *** 1985-01-07 13:49:31 +00:00
keie
23d1cba365 *** empty log message *** 1985-01-07 13:37:12 +00:00
keie
98df00c0dd *** empty log message *** 1985-01-07 13:08:48 +00:00
sater
c5267505f9 Initial revision 1985-01-04 14:05:25 +00:00
sater
4b109aa39c added entries for cg,ncg and cgg 1985-01-04 14:04:10 +00:00
sater
43e3f84da0 added entry for ncg.doc 1985-01-04 13:57:11 +00:00
sater
2e20f60554 Initial revision 1985-01-04 13:55:07 +00:00
keie
9c626542fc *** empty log message *** 1985-01-01 22:33:43 +00:00
keie
265ed0a7f7 *** empty log message *** 1985-01-01 22:27:02 +00:00
keie
154dfcc797 *** empty log message *** 1985-01-01 22:19:09 +00:00
keie
a097d3ae3c Take precautions against an already existing march. 1985-01-01 21:32:02 +00:00
keie
8ce02c938f *** empty log message *** 1985-01-01 19:56:08 +00:00
keie
4a085a558a *** empty log message *** 1985-01-01 19:42:53 +00:00
keie
adee1f13b0 Initial revision 1985-01-01 19:30:24 +00:00
keie
d68cf0c108 1 - Added void.
2 - Data and function pointers have the same size.
1985-01-01 19:24:34 +00:00
keie
a536e69ff8 Added RCS identification. 1985-01-01 18:35:40 +00:00
keie
aa81915541 *** empty log message *** 1985-01-01 18:34:12 +00:00
bal
5043de261e lay-out enhanced; flags (CFLAGS etc.) inherited from central Makefile;
entry for compiling this phase with ack -O created.
1984-12-21 14:41:47 +00:00
keie
d9ab5ba46a Adapted to new tree structure. 1984-12-21 14:23:10 +00:00
sater
2a0a27f00a Routine was wrong, leaving things on the stack in the one bit case,
the inclusion of slu in this routine was bogus.
It is never called anyway, so slu is taken out.
1984-12-20 15:17:05 +00:00
keie
751f4365a9 1 - Added RCS id.
2 - Used two argument [feature] of install.
1984-12-20 14:26:14 +00:00
keie
12202ff391 See the logfile of mach/m68k2/libem/Makefile. 1984-12-20 14:21:35 +00:00
keie
6c1b88998e The definition if the symbols, end, endbss etc, is moved
from a library to a file. This to avoid 2 libraries in this
directory.
1984-12-20 14:13:48 +00:00
keie
85239ebef6 Added line for m68k interpreters manual. 1984-12-18 17:26:42 +00:00
keie
06fa66f6ff *** empty log message *** 1984-12-18 17:22:29 +00:00
keie
f042bef513 1 - signal did not clear the stack properly.
2 - lseek did not return correct.
1984-12-18 17:12:12 +00:00
keie
ce14d6ad9d Traps now work as documented. 1984-12-18 17:11:35 +00:00
keie
5bf34a7ad2 1 - Human readable profile and count.
2 - Length of last table is now 64.
1984-12-18 17:09:36 +00:00
keie
98b1d72aa4 Profile, count, flow in non-local goto corrected. 1984-12-18 17:08:54 +00:00
keie
1821f0e587 1 - Improved line number updating when returning from library routines.
2 - Line 234, 0xD must be #0x1C, crashed at error handling for
    incorrect return size.
1984-12-18 17:07:23 +00:00
keie
d1a5b58d03 Replaced clr by the faster mov #0, (for d registers). 1984-12-18 17:06:36 +00:00
keie
da191d33c2 1 - Indexed addressing mode gave unwanted sign extends.
They are replaced by additions.
2 - Added pointer checks.
3 - Completed parametrization of addresses of locals.

1984-12-18 17:04:24 +00:00
keie
6100288a2f Finishing profile tables. 1984-12-18 16:59:51 +00:00
keie
8264bfc23f 1 - length of last table
2 - human readable profile and count output.
1984-12-18 16:58:30 +00:00
keie
843cb007e5 Added pointer checks. 1984-12-18 16:58:11 +00:00
keie
c1fcf34d6a Altered 1980 in 1984. 1984-12-18 16:57:56 +00:00
keie
219b6b5b54 Added machines to be sent with the second distribution to the LNTABLES. 1984-12-18 15:28:19 +00:00
keie
7784bcf1a4 The first version, copied from 6800. 1984-12-18 15:13:56 +00:00
keie
6c0814bde7 The first version, copied from 6809. 1984-12-18 15:13:55 +00:00
keie
dfea415aa3 Don't rely on cpp to be in the $PATH, call it from em/lib. 1984-12-18 13:12:30 +00:00
keie
95da5226fb Added Ack distribution Makefile names. 1984-12-18 13:12:03 +00:00
keie
af8ab471e7 Removed the need for as in lib/m68k4.
The as in lib/m68k2 is now used directly.
1984-12-17 17:20:57 +00:00
keie
2dd487db73 *** empty log message *** 1984-12-17 15:52:04 +00:00
keie
db3342e865 Run $RANLIB if the shell variable is set. 1984-12-17 15:50:02 +00:00
sater
3394ae40b3 *** empty log message *** 1984-12-17 15:13:39 +00:00
sater
5b88923783 Changed descr to use recently developed 8080/cg. 1984-12-17 14:36:16 +00:00
keie
7091fd6cbc Added 6500 documentation. 1984-12-17 11:38:36 +00:00
keie
94e17b8685 *** empty log message *** 1984-12-17 11:35:39 +00:00
keie
3935dae9c2 Adapted to new library. 1984-12-17 11:21:11 +00:00
keie
e8c1cfc107 *** empty log message *** 1984-12-17 11:11:37 +00:00
keie
fee4bc3993 Now using LIST. 1984-12-17 11:06:48 +00:00
keie
7b551501a2 *** empty log message *** 1984-12-17 11:03:13 +00:00
keie
827ce2a2ce Added F_DUM(Author of change-- Henry Bal). 1984-12-17 10:45:27 +00:00
keie
f31d74d66d *** empty log message *** 1984-12-17 10:44:08 +00:00
bal
c3e475af74 Initial revision 1984-12-14 15:57:39 +00:00
bal
ed3f76dea7 Initial revision 1984-12-14 15:52:15 +00:00
bal
f946a2d503 Initial revision 1984-12-14 15:41:14 +00:00
keie
b86ce9ae9a Removed entries for pmds. 1984-12-14 13:45:42 +00:00
keie
76715e219a Added Basic library and Revision number. 1984-12-10 15:14:00 +00:00
keie
184f22e538 Added revision number. 1984-12-10 14:57:51 +00:00
keie
957de399cd 1 - Added Basic library.
2 - Added revision number.
1984-12-10 14:41:49 +00:00
keie
fa2714690d Initial revision 1984-12-10 14:41:30 +00:00
keie
ca456f8868 Added Basic library. 1984-12-10 14:29:51 +00:00
keie
fbec4a1d1d Initial revision 1984-12-10 14:28:41 +00:00
bal
af434517be Initial revision 1984-12-10 13:36:12 +00:00
keie
732ec6f76e Removed the definition of the NEEDS variable. 1984-12-10 12:49:56 +00:00
keie
8e05cacf31 *** empty log message *** 1984-12-08 00:50:27 +00:00
keie
4ba9e23bc7 This makefile was copied from ../../m68k2/dl.
The now irrelevant entries are removed.
1984-12-08 00:45:55 +00:00
keie
88d8a9cb71 Comparing shouldn't stop when one compare fails. 1984-12-08 00:40:04 +00:00
keie
972a6a41b8 Added entries for pr and opr. 1984-12-08 00:28:16 +00:00
keie
47fefae471 Adapted to new install + compare, added anties for cmp, clean, opr and pr. 1984-12-08 00:17:39 +00:00
keie
9c2e7adbd6 *** empty log message *** 1984-12-07 17:32:33 +00:00
keie
1ee974b3ec Improved "make pr". 1984-12-07 17:14:43 +00:00
keie
6eadfb8d13 An efficiency change only. 1984-12-07 16:52:09 +00:00
keie
8de2f14ce9 Added cmp entry. 1984-12-07 16:45:26 +00:00
keie
5aa9f95636 This one works, the previous one didn't. 1984-12-07 16:42:59 +00:00
keie
e0e7310024 install now allows a source and destination name. 1984-12-07 16:38:13 +00:00
keie
e5e467b257 Now use prototype makefile from ../../proto. 1984-12-07 15:22:22 +00:00
ceriel
55fa86d7be Removed a reference to a non existing Makefile ( in the lib directory). 1984-12-07 15:21:25 +00:00
bal
a9465eeffc Bug fixed in optimizing two adjacent basic blocks. 1984-12-07 14:19:53 +00:00
keie
0797b57bd0 Changed access path of em h directory. 1984-12-07 14:01:33 +00:00
keie
cb2393abcf Changed access path of en h directory. 1984-12-07 14:01:11 +00:00
keie
4db6d65b08 Initial revision 1984-12-07 13:41:58 +00:00
keie
3879880554 Initial revision 1984-12-07 10:42:27 +00:00
keie
edfc9943ef The path lib/ack is changed into lib/descr.
The name ack, used as a file name was a bit overloaded.
1984-12-06 11:08:40 +00:00
ceriel
6692cbb192 Changed so that the installation process will continue if LLgen
is not present yet.
Also added Makefile to the "make pr" entry.
1984-12-06 10:39:28 +00:00
keie
62f5a16cdf Repaired a few minor bugs. 1984-12-04 21:57:22 +00:00
keie
3b28b7bd26 I hope this version is correct. 1984-12-04 21:48:14 +00:00
keie
1b9d89a7e6 Initial revision 1984-12-04 21:38:13 +00:00
sater
c7404cc041 Initial revision 1984-12-04 15:33:28 +00:00
bal
a4c588562c Initial revision 1984-12-04 15:04:44 +00:00
bal
3e88c1ef02 WORDLENGTH now defined in automatically generated file wordlen.h
Generate this file from makewlen.c
1984-12-04 15:04:01 +00:00
bal
3374980bbc WORDLENGTH now defined in automatically generated file worlen.h 1984-12-04 15:03:22 +00:00
bal
3ba6a9a47a Bug fixed: fill_item() should initialize item->it_desirable to TRUE. 1984-12-04 14:41:20 +00:00
keie
193d318e2f Added tail_m and tail_ln. 1984-12-04 13:31:03 +00:00
bal
dfd575d062 regsave_cost() return void instead of short. 1984-12-04 13:04:27 +00:00
bal
f6e0636553 regsave_cost() returns void instead of short. 1984-12-04 13:03:49 +00:00
keie
a4a757bbad Initial revision 1984-12-03 23:20:13 +00:00
keie
baf63af68c Adapted to use the files in the library directory dedicated to the pmds. 1984-12-03 22:55:26 +00:00
keie
9180900d52 Initial revision 1984-12-03 22:02:45 +00:00
bal
f3aa113380 Comment closer ("*/") added to description of getlines(). 1984-12-03 12:12:37 +00:00
ceriel
e8d88ed790 Increased MAXPATLEN to 8000. 1984-11-30 11:14:18 +00:00
bal
2d40a4fa61 Macros for B_DIST, B_USECNT and B_MARK removed, as these fields are
no longer used.
Declarations of nrinstrs and instrmap marked "extern" to satisfy ack compiler.
1984-11-30 10:52:05 +00:00
bal
0f77c7fb9f Declaration of items[] made static to avoid name conflict with ra_items.c
Core allocation macros added.
1984-11-30 10:50:27 +00:00
bal
83c3f45a29 Declaration of items[] made static to avoid name conflict with ra.c 1984-11-30 10:49:09 +00:00
bal
f84e129361 routines getcall(), get_text() and getcc() move from get.c to this file
routines putactuals(), putcall(), and putcc() move from put.c to this file
get.h, put.h, stdio.h, em_mnem.h and em_pseu.h included
1984-11-30 10:30:22 +00:00
bal
bf86a0f8ef several data structures added (moved from types.h).
core allocation macros added.
1984-11-30 10:28:35 +00:00
bal
e7cbb5780b Declarations for iv and code_info added (moved from types.h).
core allocation macros added.
1984-11-30 10:27:05 +00:00
bal
4a4b1ae156 core allocation macros added 1984-11-30 10:25:21 +00:00
bal
63e97ee535 declaration for sym,num and prc added (moved from types.h) 1984-11-30 10:24:21 +00:00
bal
b8817780f3 ic.h included before ic_lookup.h 1984-11-30 10:23:34 +00:00
bal
530c4d4c63 Lots of procedures removed (turned into macro in alloc.h or
moved to one specific phase).
1984-11-30 10:15:24 +00:00
bal
6a1b482c86 Lots of data structures removed and made local to one specific phase. 1984-11-30 10:14:30 +00:00
bal
d530ba1126 Lots of procedure newxxx() and oldxxx() turned into macros.
Lots of such procedures removed and made local to one specific phase.
1984-11-30 10:12:37 +00:00
bal
bcaecff14d As getbblocks() was moved to cf.c, em_flag.h need no longer
be included.; also, the declaration for em_flag[] was removed.
1984-11-30 10:10:41 +00:00
em
d568a6aca5 The routine salloc crashed on a 2/4 system.
Malloc was nor declared as "char *", but by default as int.
1984-11-30 00:16:29 +00:00
em
77fda75841 I removed the unused integer deftype.
Its name collided with an array in symbols.c.
1984-11-29 17:27:00 +00:00
em
92587276da The definitions of lastline, currline and firstline are made
extern in graph.h. The space reserving declaration is made in
graph.c.
1984-11-29 17:26:44 +00:00
bal
b2dfaa494e -O flag removed 1984-11-29 16:25:08 +00:00
bal
b231200eb7 macros newlvbx and oldlvbx added. 1984-11-29 15:10:11 +00:00
em
4c1ac6ad54 The first line should contain the distribution library name. 1984-11-29 15:03:41 +00:00
bal
d345f87d53 macros newlocal() and oldlocal() moved to alloc.h 1984-11-29 14:40:31 +00:00
em
3ef854719d *** empty log message *** 1984-11-29 14:22:02 +00:00
bal
17cd5516a1 -O flag removed from CFLAGS 1984-11-29 13:33:33 +00:00
bal
a117b57ec9 -O removed from CFLAGS 1984-11-29 13:31:22 +00:00
bal
925f0be202 il_aux.h included (which now contains getcall(),putcall() etc.
routines that were peviously in get.c and put.c).
1984-11-29 11:08:15 +00:00
bal
9ffcf24477 stdio.h included (required by new interface to get.h). 1984-11-29 11:06:23 +00:00
bal
bef1b25962 routines getcall(), get_text() and getcc() move from get.c to this file
routines putactuals(), putcall(), and putcc() move from put.c to this file
get.h, put.h, stdio.h, em_mnem.h and em_pseu.h included
1984-11-29 11:03:19 +00:00
bal
05de05abe7 routine getbblocks (plus its auxiliary routines) moved from get.c
to this file; core allocation macros newcfbx() and oldcfbx() added.
1984-11-29 10:51:16 +00:00
bal
54e3b3db4f newnametable() move from alloc.c to this file,
get_ca_lines moved from get.c to this file,
em_pseu.h and em_mes.h included (needed by get_ca_lines).
1984-11-29 10:31:44 +00:00
bal
21c2208de6 stdio.h included (required by new get.h interface),
macros's newlocal() and oldlocal() added, replacing routines in
alloc.c with same name.
1984-11-29 10:25:21 +00:00
bal
41cd4c15fd getbblocks(), getcall(), getcc() and get_text() removed,
get_ca_lines() removed,
curinp,lastbid,lastlabid exported
getbyte(),getshort(),getoff(),read_line and getlines() exported.
1984-11-29 10:18:53 +00:00
bal
714b50f54b getbblocks() removed (now local to CF phase),
getcall(),getcc() and get_text removed (now local to IL),
get_ca_lines() removed (now local to CA),
current input file "f" renamed "curinp" and exported,
getbyte (macro), getshort() and getoff() exported
read_line() and getlines() exported,
lastbid and lastlabid exported.
1984-11-29 10:15:23 +00:00
bal
2ac28f401c putcall an putcc removed,
curoutp, outbyte,outshort and outoff exported.
1984-11-29 10:11:37 +00:00
bal
ba5ae63e87 putcall and putcc removed (make local to IL phase)
current output file renamed "curoutp" and exported
outbyte, outshort and outoff exported.
1984-11-29 10:09:15 +00:00
bal
2e1928a4eb cleaned up 1984-11-28 09:26:44 +00:00
em
9a02327a2d Installed basic compiler in ACK tree. 1984-11-27 23:59:28 +00:00
em
8c0394eea8 1 - Added RCS identification.
2 - Changed the file name parseparams.c into parsepar.c, the original
    name was too long for RCS under BSD4.1
3 - Adapted to ACK standard Makefile format(cmp,install,...)
4 - Included more dependencies.
1984-11-27 23:53:31 +00:00
em
085069e600 Added basic.doc. 1984-11-27 23:51:07 +00:00
em
e30901a8c4 Added RCS identification. 1984-11-27 23:48:38 +00:00
em
5d2434ce92 *** empty log message *** 1984-11-27 23:46:32 +00:00
em
398a848925 Removed conflict between rcs_id in basic.yacc and lex.c. 1984-11-27 23:41:46 +00:00
em
dee952edfa Now using ACK default tmp directory from em_path.h. 1984-11-27 23:21:41 +00:00
em
1ada89da2a Added RCS identification. 1984-11-27 23:13:28 +00:00
em
02d10bc877 The version of basic copied from Martin Kerstens directory. 1984-11-27 22:23:55 +00:00
em
1046fc1eea The version of basic copied from Martin Kerstens directory. 1984-11-27 22:11:59 +00:00
bal
b5e86c2482 Initial revision 1984-11-27 16:16:36 +00:00
bal
2ab7549af6 cleaned up 1984-11-27 15:52:23 +00:00
bal
85435303c8 stack_change was renamed stack_chg 1984-11-27 15:43:14 +00:00
bal
51eccf208f Initial revision 1984-11-27 15:40:13 +00:00
bal
b27463bccd "ivars" was renamed "ivvars" to avoid name conflict with sr_expr.c 1984-11-27 15:30:34 +00:00
bal
1d613c24af cleaned up 1984-11-27 15:04:04 +00:00
bal
cc22bb4175 cleaned up; dependecies added. 1984-11-27 14:53:00 +00:00
bal
6a084edba7 cleaned up. 1984-11-27 14:25:02 +00:00
bal
e9b3f54f7c cleaned up. use CC. 1984-11-27 14:23:20 +00:00
bal
ee4b1850bb getoff() moved to front (was called before being defined)
declaration char *pseudo[] changed to char *pseudo[5] to suppress warining
1984-11-27 14:21:55 +00:00
bal
49a0e9c414 "cc" replaced by $(CC) 1984-11-27 12:59:18 +00:00
keie
56ba46b2bc Treatment of -R flag is altered.
1 - if recognized by mapflag and not by Ack internally no
    complaint is given.
2 - If recognized by both mapflag and internally:
       -R....-.... : effectuate only mapflag command
       otherwise   : effectuate both.
3 - If not recognized at all, give a warning message and
    pass the flag to the linker.
1984-11-26 17:14:17 +00:00
keie
cf20acf289 This manual page was not included in the first distribution.
This version is hacked from the VU-Pascal distribution.
1984-11-26 15:56:57 +00:00
bal
64ff1da3e4 Initial revision 1984-11-26 15:15:07 +00:00
bal
8e4156532d Initial revision 1984-11-26 15:04:22 +00:00
bal
6e32042c52 Initial revision 1984-11-26 14:51:59 +00:00
bal
e551fa234e Initial revision 1984-11-26 14:35:32 +00:00
bal
15aec67505 Initial revision 1984-11-26 14:14:55 +00:00
bal
03409fb772 Initial revision 1984-11-26 14:07:17 +00:00
bal
7fab127af3 Initial revision 1984-11-26 13:58:05 +00:00
bal
b4b66ce74f Initial revision 1984-11-26 13:43:22 +00:00
sater
fff0d30a9a added documentation for the fmt_id and fmt_ilb macros 1984-11-26 11:09:11 +00:00
sater
2c0619a13a Added support for the fmt_id and fmt_ilb macros 1984-11-26 10:50:46 +00:00
sater
2601187207 In the RREMOVE section of this file, the field e_con of the
expression union was used in stead of e_reg.
Fixed. Checked all other occurrances, are correct.
1984-11-20 16:56:26 +00:00
sater
8d7aa4baad The constant 512 slipped in instead of BUFSIZ.
Changed.
1984-11-20 10:22:12 +00:00
keie
6eaf938a14 Added a check for non-ascii characters in the description files. 1984-11-15 14:24:35 +00:00
ceriel
6d42bab835 Forgotten to close a file. This is corrected. 1984-11-12 18:05:20 +00:00
keie
2cd5f2033e Added rcs identification. 1984-11-08 12:08:31 +00:00
keie
068dee8a06 Added a P for a specification of lal on line 51.
This missing letter caused lal -1 to be mapped on the opcode
for lal 0.
1984-11-08 11:11:31 +00:00
keie
85b1c8b043 Added a check. Minis & shorties need an N or P argument. 1984-11-08 11:09:56 +00:00
bal
a955307239 The routine con_float now generates a dummy floating point constant
and gives a warning, instead of generating a fatal error + abort.
1984-11-06 12:50:21 +00:00
bal
dea117397b Patterns for floating point instruction and for LFR 8 and RET 8 added.
Each such instruction now results in a call to a library routine.
At present, all these routines generate an Illegal EM Instruction trap,
but anyone wishing to implement floating point for the 6502 can
do so without changing the back end table.
1984-11-06 12:47:26 +00:00
em
ac8dee35d0 The line with the user message for failure missed the call to echo. 1984-11-06 10:02:25 +00:00
bal
46a5c99978 make install also make a tail_mon now. 1984-11-05 15:58:11 +00:00
bal
77d2cc5222 arguments for asld changed. several libraries added. 1984-11-05 15:29:48 +00:00
bal
c4dee9c081 program for be is {LIB}/cg instead of {LIB}/be 1984-11-05 15:13:20 +00:00
keie
4a2029781a *** empty log message *** 1984-11-05 15:11:19 +00:00
bal
6cde876c44 em_head renamed head_em; em_tail renamed tail_em
installs tail_em rather than comparing it
1984-11-05 15:06:49 +00:00
em
9adb899d09 Added an example with segment prefixes. 1984-11-05 15:02:32 +00:00
em
8c2dd5a6b5 Adapted to new tree shape for libraries and binaries. 1984-11-05 14:42:17 +00:00
em
73af9ae6cf *** empty log message *** 1984-11-05 12:05:46 +00:00
em
783f95590f *** empty log message *** 1984-11-05 11:55:15 +00:00
keie
d5399de251 The flag -LIB was missing in the call to the shell-procedure
compmodule. Thus the generated libraries could not be effectively
used by our assembler/linker.
1984-11-05 11:37:23 +00:00
bal
b94907a1fa Negation of negative operand with inc/dec added in certain cases.
Don't know effect for sure, author has left.
Added rcsid.
1984-11-02 11:09:46 +00:00
bal
40fcf103bd Initial revision 1984-11-02 10:13:29 +00:00
sater
7f230788d0 Name of error file was wrong, it was the runtime error file instead
of the compile time error file.
1984-11-01 09:30:36 +00:00
ceriel
f0445587cf The input routine used to skip space. This "feature" has been removed
because it is also used to read strings, in which space is significant.
1984-10-31 15:26:09 +00:00
keie
a089216ae7 Adapted to make use of ../../compare and ../../install. 1984-10-26 12:58:15 +00:00
keie
150d744512 Initial revision 1984-10-26 12:54:35 +00:00
keie
e25887d5ca Adapted to make use of ../../compare and ../../install. 1984-10-26 11:48:51 +00:00
keie
c0e66dc8d3 Initial revision 1984-10-26 11:48:13 +00:00
keie
61ab763c07 *** empty log message *** 1984-10-26 11:47:56 +00:00
keie
86f29918c8 Adapted to make use of ../../compare and ../../install. 1984-10-26 11:04:10 +00:00
keie
af335c7be5 *** empty log message *** 1984-10-26 11:01:40 +00:00
keie
2d11c4b2fe Initial revision 1984-10-26 11:00:08 +00:00
ceriel
6fd15f62dc Running makedepend again gave a difference. 1984-10-26 10:31:22 +00:00
ceriel
ca787ba372 removed the "depend" emtry, added a "distr" entry, which should be used
before a distribution is made.
Also added the -DNORCSID flag to the lint-options.
1984-10-26 10:25:55 +00:00
keie
aa65dc9fbd Adapted to use ../../install and ../../compare and hide knowledge
about final destination of libraries.
1984-10-26 10:25:32 +00:00
ceriel
ff47f2ee43 Added a "distr" entry, which will be propagated to the src directory. 1984-10-26 10:24:48 +00:00
keie
5be59d3ade Adapted to make use of ../../compare. 1984-10-26 10:21:18 +00:00
keie
aa74e86069 Adapted to make use of ../../install and ../../compare. 1984-10-26 10:20:29 +00:00
keie
a915561735 Initial revision 1984-10-26 10:20:28 +00:00
keie
9f1edee15f *** empty log message *** 1984-10-26 10:19:56 +00:00
keie
a17a987cb8 *** empty log message *** 1984-10-26 10:12:57 +00:00
keie
db9268bb08 Adapted to use install in ../.. 1984-10-25 14:28:56 +00:00
keie
f064ac567e Now using the compare script in ../.. 1984-10-25 14:28:19 +00:00
keie
17504bb39a Initial revision 1984-10-25 14:28:18 +00:00
keie
ad77d9eb14 *** empty log message *** 1984-10-25 14:24:43 +00:00
keie
558e2166ba Altered the installation procedure.
The libraries etc. are now installed in lib/m68k2 using install in ../..
1984-10-25 14:22:53 +00:00
keie
c71656ab19 Altered to make use of ../../install and ../../compare. 1984-10-25 14:19:58 +00:00
keie
23cf9b8443 Initial revision 1984-10-25 14:19:57 +00:00
keie
44b78ad38d *** empty log message *** 1984-10-25 14:15:27 +00:00
keie
386c0d6e1a Now making use of ../../install and ../../compare. 1984-10-25 14:10:00 +00:00
keie
046ee8050f Adapted to make use of compare in ../.. 1984-10-25 11:40:16 +00:00
keie
1154d87f41 Adapted to make use of install and compare in ../.. 1984-10-25 11:39:39 +00:00
keie
0c16a79a37 *** empty log message *** 1984-10-25 11:39:38 +00:00
keie
f177d69279 Adapted to make use of install and compare in ../.. 1984-10-25 11:27:08 +00:00
keie
a4368ea2d1 *** empty log message *** 1984-10-25 11:25:22 +00:00
keie
675d30712d Removed the definition of LIBDIR, it is superfluous. 1984-10-25 11:16:31 +00:00
keie
209801cac1 Adapted to make use of install and compare in ../.. 1984-10-25 11:16:30 +00:00
keie
9c57272ef9 Initial revision 1984-10-25 11:15:20 +00:00
keie
01f22b3870 Moved the include directory from mach/ibm/include to lib/ibm/include. 1984-10-25 11:00:06 +00:00
keie
6ade85f76e Adapted to use compare in ../.. 1984-10-25 10:46:32 +00:00
keie
0349b620cd Adapted to compare in ../.. 1984-10-25 10:45:22 +00:00
keie
6001a4462e Initial revision 1984-10-25 10:45:21 +00:00
keie
0d853f8c4b *** empty log message *** 1984-10-23 15:29:53 +00:00
keie
e5277be072 Initial revision 1984-10-23 15:29:30 +00:00
keie
cc246efa46 We have only one copy of the script for compare and install now
they are present in ../..
1984-10-23 15:14:17 +00:00
sater
2fe95a276d changed EM_WSIZE to TEM_WSIZE 1984-10-23 15:10:15 +00:00
sater
628d3da626 changed references to EM_?SIZE to TEM_?SIZE 1984-10-23 15:04:24 +00:00
sater
a5c07a52b4 changed EM_WSIZE to TEM_WSIZE 1984-10-23 15:02:03 +00:00
sater
43c97f0d41 added -h and -c flags, to change names of tables.h and tables.c respectively
now also takes an argument instead of stdin.
EM_BSIZE is now compulsory again.
Constants EM_?SIZE are passed on to cg with a T prepended (T for target)
1984-10-23 13:39:15 +00:00
sater
24eeca9474 Changed to use -h flag to cgg and better way of preserving old tables.h
if not changed. Nice huh, Andy?
1984-10-23 13:29:41 +00:00
sater
7eef0e0b59 added rcsid(again). Who took that away? 1984-10-16 13:45:16 +00:00
sater
9d03cb68c7 added code to generate code for ACK assembler.
Works if ACK_ASS is defined.
1984-10-16 13:31:44 +00:00
ceriel
d89d5770b1 Had forgotten to initialise the line number on which a nonterminal
symbol occurred first.
1984-10-12 14:19:34 +00:00
ceriel
f6d9a497eb No changes 1984-10-11 21:35:58 +00:00
ceriel
bac12b0c46 The former version gave a fatal error message at the first undefined
nonterminal. The new version checks all nonterminals
1984-10-11 10:35:01 +00:00
ceriel
e13ebaad9e The routine findpath did not work. It used the same static buffer for
several calls. Now it uses alloc.
1984-10-09 11:43:19 +00:00
em
315806b282 Initial revision 1984-10-09 10:36:29 +00:00
ceriel
43de6c3b78 added "#ifdef NORCSID" 1984-10-09 10:16:33 +00:00
ceriel
0ec009bde2 Added some comments and removed some Lint complaints 1984-10-09 10:13:46 +00:00
ceriel
0f8a2d3a39 Initial revision 1984-10-09 09:47:14 +00:00
ceriel
b5402db333 The routine LLmessage did not insert tokens properly.
This is corrected now.
1984-10-09 09:33:37 +00:00
ceriel
4f5c40c608 Changed RCSid 1984-10-08 17:11:03 +00:00
ceriel
2055a65cae Added RCSid. 1984-10-08 16:21:03 +00:00
ceriel
ed6a7245bd Adapted the libpath routine to use EM_DIR from ../../../h/em_path.h 1984-10-08 15:58:23 +00:00
ceriel
2cd6c03840 Added entry for LLgen. 1984-10-08 15:20:54 +00:00
ceriel
c38d1013cb Initial revision 1984-10-08 15:19:18 +00:00
ceriel
6da013b55a Added entry for LLgen documentation. 1984-10-08 15:00:23 +00:00
ceriel
e3eae54592 Initial revision 1984-10-08 14:51:38 +00:00
ceriel
7cc3184392 Initial revision 1984-10-08 14:24:19 +00:00
ceriel
952ba464cc Initial revision 1984-10-08 14:14:53 +00:00
keie
08b7ec6600 Initial revision 1984-10-08 14:11:42 +00:00
keie
f918aa20fe New installation procedure:
1 - New place for binaries and libraries in the ACK tree.
2 - The ranlib action is moved to ../../install which tries it at
    every action.
1984-10-08 14:09:28 +00:00
bal
54bac1caaf bug fixed: generate "add.l #65536,a1" rather than "lea 65536(a1),a1".
The latter form is only generated for constants that fit in a word.
1984-10-08 12:45:38 +00:00
keie
504da3a54d Altered the test path lib/n_ack into the normal path ACK_PATH. 1984-10-05 15:07:47 +00:00
keie
36cca2b9c7 Added a priority associated with each phase. Paths with the highest
total priority have preference.
1984-10-05 13:34:38 +00:00
keie
6f8a00ee5c 1 - Added some debugging for linker flags.
2 - Setting of NEEDS and RTS is moved to main.c.
3 - Added recognition of -Rphase:[-]number for dynamic priority setting.
1984-10-05 13:31:40 +00:00
keie
ca275f5d22 1 - Most flags used by ack itself are now also passed to the phases
for recognition with mapflag.
2 - A few bugs are removed in connection with argument passing to the
    linker (unrecognized flags and libraries).
3 - The setting of RTS, HEAD and TAIL is done directly after the
    path determination for each file.
1984-10-05 13:28:56 +00:00
keie
150c8164af Removed the defines needed by util/ack/em_pc.c.
These defaults are now provided in lib/ack/fe.
1984-10-04 11:11:30 +00:00
keie
70975146a1 1 - Added RCS identification.
2 - Removed the default for compiler and error file pathname.
    These are now always supplied by the callee.
1984-10-04 11:08:42 +00:00
keie
962cc80686 Corrected a small bug in the pc mapflags. 1984-10-04 10:54:11 +00:00
keie
f6ecbec936 1- Added RCS identification.
2- The pathnames of the Pascal compiler and Compile time-error file
   are now always explicitly passed to em_pc.
1984-10-04 10:47:03 +00:00
keie
8128e3d82d Altered to reflect the changes in em_path.h.
Now dynamically concatenes EM_DIR and error path.
1984-10-04 10:42:13 +00:00
keie
ea86ccd217 Altered the description of EM_HOME in em_path.h to that of
EM_DIR.
1984-10-02 16:24:59 +00:00
sater
045ccfaeba added missing cast at call to regsave, in ms_gto case 1984-10-02 11:17:57 +00:00
sater
a6b69be622 changed definition of myalloc to extern 1984-10-02 10:31:06 +00:00
sater
50d77d903a added external definition for myalloc() 1984-10-02 10:30:44 +00:00
keie
cbf6d06de2 Bug removed: the trailing zero at the end of a growstring was not
explicitly written in doassign(trans.c).
Only luck kept the program together.
1984-10-01 17:42:56 +00:00
keie
bb0ff814f6 Nill pointers are not allowed in CSA descriptors any more. 1984-10-01 16:05:17 +00:00
keie
f80b30bdbb Null pointer are not allowed any more for in-bound indeces in the CSA
table.
1984-10-01 14:54:09 +00:00
keie
7f6105c294 Initial revision 1984-09-25 16:33:15 +00:00
keie
1f59bd7223 Added National semiconductor assembler. 1984-09-25 16:32:45 +00:00
em
8f7669b247 1 - A few minor syntactic changes.
2 - Altered the description of strings as initializers. (sequence of U1's).
1984-09-25 11:06:29 +00:00
keie
f950163854 Made the buffer long enough for the machine state on most machines. 1984-09-24 15:18:20 +00:00
keie
38b8391594 Initial revision 1984-09-24 15:18:07 +00:00
keie
e88fe13466 Initial revision 1984-09-24 14:10:23 +00:00
em
e29ef2395a Compile-time option GLOBAL_OPT defined. If set, the resulting
peephole optimizer will be suitable for optimizing the output of
the global optimizer. In particular, it doesn't change the register
messages.
1984-09-14 10:25:07 +00:00
keie
546bcee023 1 - The prop keyword with is flags is now obsolete. Its function is
taken over by several other keywords: stdin, stdout, prep, optimizer,
    combiner and linker.
2 - The search order is changed. First {EM}/lib/{M}/descr, then
    {EM}/lib/ack/{M}, finally {M}.
1984-09-13 14:40:09 +00:00
keie
a9beb24998 The t_do bits are not set by this module. The t_next entry is used
to see whether the scan for this phase is already done.
t_do is now set in add_inputs(files.c).
1984-09-13 14:35:02 +00:00
keie
96da898a4a 1 - The t_do flags is now set by add_inputs(files.c).
2 - Recognize the fact that it is possible to start a combiner without
    input files.
3 - Removed -d flag. Overflow for -v (>2) now ends up in debug.
    -v may be followed by a number indicating the increment.
1984-09-13 11:07:46 +00:00
keie
a69b503ad0 1 - The outfile entry is only used when the output file must not be thrown
away.
2 - If a combiner has no named input file (only libs+flags) then issue
    a warning message and make up a name.
1984-09-13 11:04:00 +00:00
bal
5fd55904ec pem did not generate a register message for var-parameters of
array- or record type. The routine "treewalk" is modified.
It generates a register message for every var-parameter, even
if it has its noreg-flag set.
1984-09-12 13:21:43 +00:00
bal
195c808f88 unlk a6 added to restr(). 1984-09-11 15:44:14 +00:00
keie
50e3b4fe4a Added ego, basic and callname conventions. 1984-09-10 17:34:04 +00:00
keie
f366afdae1 No comment. 1984-09-10 16:51:02 +00:00
keie
c08fe56b97 Combiners (ego, linkers) now use a list of path's(ack.h) to indicate
their input files.
Unmatched flags are now sent to the linker.
1984-09-10 16:48:57 +00:00
keie
ed3db93f56 1 - A transformation is succesfull when
a - a stopsuffix is indicated and met,
    b - the last transformation is included in the transformation path.
2 - Maintains a 'cash' of best paths for all transformation to be executed.
1984-09-10 16:46:13 +00:00
keie
71dc6af5a8 The input file names of the linker are to be found in a different place. 1984-09-10 16:45:12 +00:00
keie
cfdc2ce05f 1 - added keywords callname and outfile. See manual.
2 - multiple combiners are allowed now.
3 - A different search mechanism is used for finding descriptor files.
1984-09-10 16:42:55 +00:00
keie
845c92825a 1 - callname recognition is moved to rmach.c.
2 - The overall scheme is altered.
	first, all input files are processed until a combining phase is met.
	then, all the combining phases are executed, the resulting files
	are again processed until a combiner (or final) phase is met.
3 - The EM_DIR shell variable can be used to set ack's idea of the EM
    home directory.
1984-09-10 16:37:11 +00:00
keie
3adba1b759 1 - The names of temporary files are now Ack'hex''unique'.'suffix'.
'hex' is the pid of the current invocation of ack in hex.
    'unique' is a tail unique to this invocation.
2 - The outfile field is used to indicate default naming, can be ovrrriden
    by the -o flag.
3 - Added handling for phases with multiple inputs (ego, linker).
1984-09-10 16:33:03 +00:00
keie
ea6c20f5d1 The role of the combiner is -partially- assumed by the linker.
Linker arguments are now part of the transformation structure.
Temp file nameing is changed.
1984-09-10 16:30:47 +00:00
keie
d99b36abf8 Naming of the tempname is changed (see files.c). 1984-09-10 16:29:37 +00:00
keie
93693877be Initial revision 1984-09-03 13:49:40 +00:00
sater
2aa5c6b7d9 Variable nregvars had a name clash with the array nregvar[] in the
file tables.c. That was different in the 8'th character (!"#$%&'()_).
These variables should actually be static.
1984-08-23 17:07:53 +00:00
keie
bbc3cb33cc We do not use the missing " trick anymore.
The root directory of the EM tree is in the name EM_DIR, the
root directory for tempfiles is in TMP_DIR.
All other path's are relative to EM_DIR.
1984-08-23 13:33:11 +00:00
keie
77ebfceac5 The ACK tree on the vax has as default machine 'vax2'. 1984-08-23 13:27:14 +00:00
keie
3d10bd6e59 The missing trailing " trick is now also used for TMP_DIR. 1984-08-23 13:26:44 +00:00
keie
03a31cf3fc The ms_gto is added. This is a trick used to indicate procedures
jumped to with gto.
1984-08-23 13:25:44 +00:00
keie
81267df9ad *** empty log message *** 1984-08-23 13:20:59 +00:00
keie
113cf23e0f Initial revision 1984-08-23 13:18:14 +00:00
keie
3154365fff Initial revision 1984-08-23 13:00:32 +00:00
sater
e006f1ec29 increased MAXNODES in small memory mode 1984-08-23 12:25:24 +00:00
sater
1c36c470db Increased the amount of information passed through error routines
to printf. The routine badassert, running on a 2/4 machine lost it's
last argument on the way.
Anyone know of a better way to solve this problem?
1984-08-17 15:35:28 +00:00
keie
1da13e49e1 Added comment. 1984-08-17 14:57:31 +00:00
keie
f077a39568 Added RCS identification. 1984-08-17 14:44:24 +00:00
sater
6474db065f Revised to include rcsid of pattern file in binary opt 1984-08-16 16:08:39 +00:00
sater
10b16f7c76 enlarged string table in big memory case 1984-08-16 13:34:59 +00:00
sater
1ff6c3236f added patterns to prevent stacking in *p++ cases 1984-08-15 16:05:54 +00:00
sater
19b13e8e4f added patterns to remove some more dup's 1984-08-15 16:04:19 +00:00
sater
e5d1aebbae added patterns for inc/dec/adp of local and external offsetted
This makes the getc() macro from C very efficient, among others
1984-08-15 14:31:54 +00:00
sater
b23de46c3a added patterns to remove as many dup's as possible. 1984-08-15 14:23:42 +00:00
sater
9bdd1abf9a added definition of malloc().
Program crashed on 2/4 machines
1984-08-08 10:54:04 +00:00
sater
6180399964 reworked patterns for autoincrement stores, now that peephole optimizer
rearranged it.
1984-08-07 10:22:49 +00:00
sater
db0822fa37 added patterns for *p++ local and external p
added pattern to remove some badly placed dups
1984-08-03 16:37:15 +00:00
sater
11026ace27 added setcc calls to some incrementing ops
added patterns for indirect local and external increments
added patterns for loe ine and such
1984-08-03 16:33:40 +00:00
sater
76281fa307 removed some superfluous patterns.
Were special cases not needed with the general case.
1984-08-03 13:16:59 +00:00
sater
dbcebe6e4c A move from a nonreg to a reg did not have the effect that all
registers clashing with the destination were erased. Erase added.
1984-08-02 16:31:25 +00:00
keie
8a4d834bc6 The name "unix" is now predefined for preprocessor usage. 1984-08-02 14:13:04 +00:00
sater
925701dc62 When building the parameter list for a pf-call, the line number
for the exchanges war remembered at the wrong time.
This caused:
	foo(3,'string')
to cause an external identifier for the string. Fixed.
1984-07-31 09:39:35 +00:00
keie
385d7ffbd8 String initializer handling is changed.
Strings are now considered to be sequences of xU1's.
No alignment is done before or after the string other than the
alignment done for names and segment type switches.
1984-07-30 14:42:33 +00:00
bal
e1c24cb475 bug fixed: added "fprintf(codefile,""rts\n");" to restr() 1984-07-30 12:47:54 +00:00
bal
964976ff0b bugs fixed (syntax errors, patterns moved to front,
"ldl ldl adp sdl sti" requires DATAREG instead of ANY1 on
fakestack)
1984-07-30 11:16:41 +00:00
bal
4eea24fe69 patterns added to generate autoincrement and to generate
a "move X,d0" instead of a "move X,-(sp)" before storing into X
1984-07-27 16:53:19 +00:00
sater
811bc78f04 added rcsid 1984-07-27 10:28:48 +00:00
sater
b07af506d6 added PR* routines 1984-07-26 13:15:21 +00:00
sater
5e97bff353 Changed procedure prolog to use PR* routines. 1984-07-26 13:05:22 +00:00
keie
c001aa20d7 *** empty log message *** 1984-07-23 11:49:00 +00:00
sater
61da47ea52 removed all calls to blm~ from table
duplicated some patterns for in[lc] to deal with de[lc]
extra rule for adi 2 to deal with source1 cleverly
1984-07-23 11:29:59 +00:00
sater
d6a3a26314 removed blm.s, not used by table anymore 1984-07-20 16:20:54 +00:00
sater
eca6c1f306 edited to make reentrant, no more globals in use 1984-07-20 16:20:28 +00:00
sater
189e577315 added copyright notice 1984-07-20 13:54:36 +00:00
sater
8b9ebd989f added rcsid
adapted to new archive updating style, with LIST and march and all that
1984-07-20 11:32:47 +00:00
sater
182f3ee338 Initial revision 1984-07-20 11:25:31 +00:00
sater
8707eb1715 added rcsid 1984-07-20 11:25:18 +00:00
sater
9935b1fc88 added copyright notice 1984-07-20 11:20:12 +00:00
sater
06249087bd removed copyright notice, wasn't really *written* by us. 1984-07-20 11:07:12 +00:00
sater
5e3c08728c added rcsid 1984-07-20 11:03:31 +00:00
sater
f54556ac0f Initial revision 1984-07-20 10:44:57 +00:00
sater
1a0102783f A sti 8 of a regdef8 token went into panic mode. Fixed. 1984-07-20 10:32:48 +00:00
sater
1e5056bcc0 to check long >= 0 or long < 0 it is enough to test high order word. Added.
anding and oring of long constants is much better now
dvu 2 and rmu 2 by positive constants is now done inline.
1984-07-19 16:50:27 +00:00
sater
96e8152f11 added rcsid 1984-07-19 15:03:30 +00:00
sater
7683ff7d03 Initial revision 1984-07-19 15:01:43 +00:00
sater
309ed81674 Archive made with archiver in environment ASAR if set, arch otherwise 1984-07-19 14:55:12 +00:00
sater
badfdeb5db removed #ifdef UNTESTED around logical instructions without arguments,
seems they were used ( which implicitly means tested ) after all
1984-07-19 14:03:49 +00:00
sater
ea793ccff5 Initial revision 1984-07-19 13:52:18 +00:00
sater
3c037725e9 added rcsid 1984-07-19 13:34:12 +00:00
sater
b28024573a changed name from comparchentry to compmodule 1984-07-19 13:22:36 +00:00
sater
320c575b54 Initial revision 1984-07-19 13:20:15 +00:00
sater
1e806d2a28 old code put back, now register handling is different again
actually old code never was removed, due to a misunderstanding
about comment conventions.
1984-07-19 13:12:03 +00:00
sater
18d72ffde3 makefile adapted to new style archive handling, RCS and all that 1984-07-19 13:11:36 +00:00
sater
53c19368d5 a setl instruction was changed to a setd
setl was just plain wrong
1984-07-19 13:09:53 +00:00
sater
fa6f4b86e3 Initial revision 1984-07-19 12:51:00 +00:00
bal
0f199294ae rcsid added 1984-07-19 11:50:29 +00:00
bal
ff6056a6b6 Initial revision 1984-07-19 11:50:28 +00:00
sater
92c1e38b42 Initial revision 1984-07-19 11:50:18 +00:00
bal
8bbb3ddca7 New implementation of GTO (without register save masks)
several optimizations added
1984-07-19 11:15:28 +00:00
bal
8fef858ce8 New implementation of GTO (without register save masks) 1984-07-19 11:07:15 +00:00
bal
39428d2028 rcsid added
several optimizations added
1984-07-19 11:02:06 +00:00
bal
e5895a2768 rcsid added
clr.w -(sp) generated in prolog if register save mask is 0
1984-07-19 10:57:19 +00:00
bal
250f0df7f7 Initial revision 1984-07-19 10:03:10 +00:00
bal
85c15fca29 Initial revision 1984-07-19 09:37:24 +00:00
sater
3422e2338c added patterns for ldc adi/ldc sbi with zero high order word
added patterns for *--p with p register
added patterns to generate cmpb to compare two bytes.
added patterns to use regvar to index global array
added patterns for lol inl
added patterns for external pointer increment/decrement
1984-07-18 16:47:24 +00:00
sater
e92ac2c6d3 The patterns to change a cii to cuu when dealing with a known positive
quantity was technically wrong. Changed to generate a cui.
1984-07-18 15:54:25 +00:00
sater
35fbddd030 added definition of index, to keep compiler happy 1984-07-18 14:14:46 +00:00
sater
c65b0f7044 removed recursive comments
removed NC with sti rules
added rule to reverse operands of adi 2
added rule to convert loc sbi to loc adi
added loc slu -> loc sli rule
added local++ rule
added rule for asping xsource2
added rule for csb when nothing on stack
1984-07-18 13:39:24 +00:00
sater
84fca60378 added rcsid
changed instruction label format to allow more than 256 procedures
1984-07-18 13:32:11 +00:00
sater
7c5508ddbd changed instruction label format to allow more than 256 procedures 1984-07-18 13:28:01 +00:00
sater
d33e4ac474 added rcsid
converted to recognize and generate new 0%o format
1984-07-18 13:14:18 +00:00
sater
0a4d372056 added patterns for unsigned shifting
added patterns to delay additive operations until after multiplicative,
  this can be useful for some register machines
1984-07-18 11:05:28 +00:00
sater
f98fe503a0 Improved error handling on unterminated strings 1984-07-18 11:04:58 +00:00
sater
4410480e32 added -f flags to all calls to rm 1984-07-16 15:29:48 +00:00
sater
97b50be407 added special patterns for:
1) long compared to constant ( ldc cms 4 zxx )
2) long increments ( ld? ldc adi 4 sd? )
3) autoincrement loads and stores ( lol lol adp stl loi/sti )
1984-07-16 14:39:21 +00:00
keie
f3d3393af3 *** empty log message *** 1984-07-16 09:36:12 +00:00
keie
32f55c5462 Added z8000 assembler manual. 1984-07-16 09:32:22 +00:00
sater
42c556cc1f added missing #endif
added two patterns, big improvement
added patterns for ciu and cui
some cosmetic change
1984-07-13 16:13:56 +00:00
keie
edcf39e999 *** empty log message *** 1984-07-13 15:20:58 +00:00
keie
ac940fe687 Added lines for DECUS cpp manual. 1984-07-13 15:19:19 +00:00
keie
a618660635 The check for a too high offset in a hol is repaired. 1984-07-13 15:03:05 +00:00
keie
965a2fa352 A bug in the exchange was repaired.
Exchanges across pseudo-instructions didn't work properly.
1984-07-13 15:01:23 +00:00
sater
d8238383ca Removed some patterns that have never been tested.
Now if someone uses them he will hear that it doesn't work.
That must be better then giving him code that probably won't work.
All these patterns had to do with things like adf without an argument
and things like that.
1984-07-13 14:55:37 +00:00
sater
f33edd402e Initial revision 1984-07-13 11:25:46 +00:00
sater
a4f3d3c503 Initial revision 1984-07-13 11:12:23 +00:00
sater
d1994a651b changed format of rcsid message 1984-07-12 15:18:13 +00:00
sater
ba79fb2a37 Initial revision 1984-07-12 15:16:23 +00:00
sater
743bbb551f added rcsid 1984-07-12 14:55:49 +00:00
sater
df7b70c37e changed explanation of .base pseudo
added rcsid
1984-07-12 14:55:22 +00:00
sater
58170d17d2 added rcsid
added lines for formatting new manuals
1984-07-12 14:53:30 +00:00
sater
b758fc47aa *** empty log message *** 1984-07-12 14:51:48 +00:00
sater
d608d58ad1 Initial revision 1984-07-12 14:14:54 +00:00
sater
cb1d7f7e96 *** empty log message *** 1984-07-12 14:08:27 +00:00
sater
0ae1957f80 added rcsid 1984-07-12 14:07:14 +00:00
sater
3671970cc5 added rcsid
added compilation of tstgto.p
1984-07-12 14:05:03 +00:00
sater
463090c3a4 Initial revision 1984-07-12 13:50:44 +00:00
keie
e1666e49b0 asprint is removed at cleanup time. 1984-07-12 13:24:02 +00:00
keie
3d2f1d3690 1 - Dump has a parameter.
2 - Dump are enabled.
1984-07-12 13:23:03 +00:00
keie
06a8899eec 1 - A header is treated as an unsigned number.
2 - The low order word of the size in archives is fetched as unsigned.
3 - Sizes are unsigned.
1984-07-12 13:20:48 +00:00
keie
3565805b63 Parameter added to dump preprocessor variable. 1984-07-12 12:58:18 +00:00
keie
207bd9dcf7 1 - Header fetch was changed to unsigned.
2 - Extra parentheses are needed by some compilers.
1984-07-12 12:57:36 +00:00
keie
e2482166f7 Initial revision 1984-07-12 12:48:33 +00:00
sater
af88eafe02 removed REGPATCH define 1984-07-12 11:03:18 +00:00
sater
8f9fb0ad77 added definition of newplb()
removed a tab from some string
1984-07-12 11:02:44 +00:00
sater
8a6604f224 Removed unbalanced quotes in comments, needed for new cpp 1984-07-12 10:50:47 +00:00
sater
6c021a0800 reworked to use ack instead of npc.
made more user-friendly (ha ha)
1984-07-12 10:42:33 +00:00
sater
2eeeba3225 Now lexical analyzer skips lines starting with #
to kill off remnants of some preprocessor.
1984-07-12 10:18:19 +00:00
sater
c79d077c3f added description of newplb macro.
Enlarged an example.
1984-07-12 10:13:56 +00:00
sater
6a1228a5cd The sequence:
lin 100
  cal $foo
  lin 101
used to have it's second lin lni'ed. This is obviously wrong.
A check is now made for procedure calls.
1984-07-12 09:29:49 +00:00
sater
b2d4b9d42d Replaced call to newilb after pro pseudo to call to newplb,
including retrofit for existing mach.h files
1984-07-12 09:26:24 +00:00
sater
60b6d9c00d Increased MAXINSTANCE in big memory model 1984-07-12 09:23:38 +00:00
keie
00a6b2f4c6 Added the entries for instructions with 32-bit arguments. 1984-07-02 16:04:26 +00:00
keie
0a797a2688 1 - added routines to read unsigned 16-bit numbers
2 - cleanup of writing of ABS block, was in error for wordsize>4.
3 - strings are now padded up to a multiple of the wordsize.
4 - the padding algorithm for alignment was in error for wordsize>2.
1984-07-02 16:01:50 +00:00
keie
2e3eb2f103 Not in the initial distribution. 1984-07-02 15:46:59 +00:00
keie
5ce6138a58 Added asprint to list of files to remove with 'clean'. 1984-07-02 15:46:06 +00:00
keie
82d0bd9091 1 - Altered an incorrect dependency for assrl.o
2 - Added asprint
1984-07-02 15:42:37 +00:00
keie
e1466b3e09 Initial revision 1984-07-02 15:35:56 +00:00
sater
51243ce443 Initial revision 1984-07-02 11:26:53 +00:00
sater
c6790d4142 Initial revision 1984-07-02 10:45:13 +00:00
sater
9a91288da9 Added missing .DE macro 1984-06-29 14:51:23 +00:00
sater
79d76cf153 Changed all occurrences of -ms into a macro $(MS) 1984-06-29 14:50:23 +00:00
sater
2a026953ff Initial revision 1984-06-29 14:46:39 +00:00
sater
fb9cd1ed17 Initial revision 1984-06-29 11:29:28 +00:00
sater
3efa053ae7 Initial revision 1984-06-29 11:21:50 +00:00
sater
f5b641009b Initial revision 1984-06-29 11:00:55 +00:00
sater
f3f3069f54 Fixed bug: after BRA instruction was optimized away the variable lastbra
pointed to the instruction following. This could lead to anything,
including bus errors. Lastbra is now reset to 0.
Bug discovered at Philips PMDS by Hans de Vries. The fix is also his.
Actually the function cleaninstr should be rewritten.
1984-06-28 10:40:09 +00:00
sater
ef3aa6fa57 added rcsid 1984-06-26 10:08:37 +00:00
sater
380aa1515e Initial revision 1984-06-26 10:03:31 +00:00
sater
2af94af5c6 Initial revision 1984-06-25 16:22:03 +00:00
sater
af55840493 Initial revision 1984-06-25 11:02:34 +00:00
em
3afc39c1ea The name cpp.new for the alternative C-preprocessor is
no longer needed.
1984-06-21 13:16:26 +00:00
keie
abde37e1fc artificial commit to compensate for changes in 93f3093f2b7e from a CVS
vendor branch
1984-06-21 13:13:10 +00:00
keie
6a279822dc Some ad-hoc stuff for searching in the new tree shape. 1984-06-21 13:13:10 +00:00
em
a8ee954405 Assembler peephole optimizer added. 1984-06-21 13:09:51 +00:00
keie
dc3874ad9d Ack assumed that files resulting from transformations
would not need to be fed through a pre-processor.
This assumption proved false. Ack was altered and allows
use of a pre-processor on files produced by other passes.
1984-06-21 11:29:22 +00:00
keie
c74da38c3d Adapted to use the new backend. 1984-06-21 11:26:10 +00:00
keie
f13d0d6c3e Adapted to the new C preprocessor that does NOT have
ANY default include directories like /usr/include.
1984-06-21 11:25:05 +00:00
keie
0c1ac8e7dd Initial revision 1984-06-21 11:24:08 +00:00
em
580b5f5d7f Added warning about forthcoming shift/reduce conflict 1984-06-21 11:13:28 +00:00
cvs2hg
2019296d74 fixup commit for branch 'unlabeled-1.1.1' 1984-06-21 10:58:00 +00:00
107 changed files with 441 additions and 19383 deletions

View File

@@ -1,44 +0,0 @@
# $Header$
d=../../..
h=$d/h
PEM=$d/lib/pc_pem
PEM_OUT=$d/lib/pc_pem.out
HEAD=$h/em_spec.h $h/em_pseu.h $h/em_mnem.h $h/em_mes.h $h/pc_size.h
LDFLAG=-i
all: pem pem.out
pem.out: pem.m
apc -mint --t -o pem.out pem.m
pem: pem.m
apc $(LDFLAG) -o pem pem.m
# pem.m is system dependent and may NOT be distributed
pem.m: pem.p $(HEAD)
-rm -f pem.m
-if apc -I$h -O -c.m pem.p ; then :; else \
acc -o move move.c ; move ; rm move move.[oskm] ; \
fi
cmp: pem
cmp pem $(PEM)
install: pem
cp pem $(PEM)
distr:
ln pem.p pem22.p ; apc -mpdp -c.m -I$h pem22.p ; rm pem22.p
ln pem.p pem24.p ; apc -mvax2 -c.m -I$h pem24.p ; rm pem24.p
clean:
-rm -f pem pem.out *.[os] *.old
pr:
@pr pem.p
xref:
xref pem.p^pr -h "XREF PEM.P"
opr:
make pr ^ opr

View File

@@ -1,20 +0,0 @@
/* A program to move the file pem??.m to pem.m */
/* Called when "apc pem.p" fails. It is assumed that the binary
file is incorrect in that case and has to be created from the compact
code file.
This program selects the correct compact code file for each combination
of word and pointer size.
It will return an error code if the move failed
*/
main(argc) {
char copy[100] ;
if ( argc!=1 ) {
printf("No arguments allowed\n") ;
exit(1) ;
}
sprintf(copy,"cp pem%d%d.m pem.m", EM_WSIZE, EM_PSIZE) ;
printf("%s\n",copy) ;
return system(copy) ;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,27 +0,0 @@
var w=2
var p=2
var s=2
var l=4
var f=4
var d=8
var NAME=m6500
var M=6500
var LIB=mach/6500/lib/tail_
var RT=mach/6500/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_be
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) -o > (.e:{TAIL}={EM}/{LIB}em)
prop C
end

View File

@@ -1,31 +0,0 @@
var w=2
var i=2
var p=2
var s=2
var l=4
var f=4
var d=8
var NAME=m6809
var M=6809
var LIB=mach/6809/lib/tail_
var RT=mach/6809/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_be
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.c.p:{TAIL}={EM}/{LIB}mon) (.e:{TAIL}={EM}/{LIB}em)
prop C
end

View File

@@ -1,25 +0,0 @@
var w=2
var p=2
var s=2
var l=4
var f=4
var d=4
var M=cpm
var NAME=CPM
var LIB=mach/z80/int/lib/tail_
var RT=mach/z80/int/lib/head_
var SIZE_F=-sm
var INCLUDES=-I{EM}/include
name asld
from .k.m.a
to e.out
program {EM}/lib/em_ass
mapflag -l* LNAME={EM}/{LIB}*
mapflag -+* ASS_F={ASS_F?} -+*
mapflag --* ASS_F={ASS_F?} --*
mapflag -s* SIZE_F=-s*
args {ASS_F?} ({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.c.p:{TAIL}={EM}/{LIB}mon)
prop C
end

View File

@@ -1,60 +0,0 @@
# (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
name cpp
# no from, it's governed by the P property
to .i
program {EM}/lib/cpp
mapflag -I* CPP_F={CPP_F?} -I*
mapflag -U* CPP_F={CPP_F?} -U*
mapflag -D* CPP_F={CPP_F?} -D*
args {CPP_F?} {INCLUDES?} -D{NAME} -DEM_WSIZE={w} -DEM_PSIZE={p} \
-DEM_SSIZE={s} -DEM_LSIZE={l} -DEM_FSIZE={f} -DEM_DSIZE={d} <
prop >P
end
name cem
from .c
to .k
program {EM}/lib/em_cem
mapflag -p CEM_F={CEM_F?} -Xp
mapflag -L CEM_F={CEM_F?} -l
args -Vw{w}i{w}p{p}f{f}s{s}l{l}d{d} {CEM_F?}
prop <>p
rts .c
need .c
end
name pc
from .p
to .k
program {EM}/lib/em_pc
mapflag -p PC_F={PC_F?} -p
mapflag -w PC_F={PC_F?} -w
mapflag -E PC_F={PC_F?} -E
mapflag -e PC_F={PC_F?} -e
mapflag -{*} PC_F={PC_F?} -\{*}
mapflag -L PC_F={PC_F?} -\{l-}
args -Vw{w}p{p}f{d}l{l} {PC_F?} < > {SOURCE}
prop m
rts .p
need .p
end
name encode
from .e
to .k
program {EM}/lib/em_encode
args <
prop >m
end
name opt
from .k
to .m
program {EM}/lib/em_opt
mapflag -LIB OPT_F={OPT_F?} -L
args {OPT_F?} <
prop >O
end
name decode
from .k.m
to .e
program {EM}/lib/em_decode
args <
prop >
end

View File

@@ -1,28 +0,0 @@
var w=1
var p=2
var s=1
var l=2
var f=4
var d=8
var NAME=nascom
var M=z80a
var LIB=mach/z80a/lib/tail_
var RT=mach/z80a/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_be
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) ({RTS}:.c={EM}/{RT}cc) -o > \
(.e:{TAIL}={EM}/{LIB}em.1 {EM}/{LIB}em.2)
prop C
end

View File

@@ -1,27 +0,0 @@
var w=2
var p=2
var s=2
var l=4
var f=4
var d=8
var M=int
var NAME=int22
var LIB=mach/int/lib/tail_
var RT=mach/int/lib/head_
var SIZE_FLAG=-sm
var INCLUDES=-I{EM}/include
name asld
from .k.m.a
to e.out
program {EM}/lib/em_ass
mapflag -l* LNAME={EM}/{LIB}*
mapflag -+* ASS_F={ASS_F?} -+*
mapflag --* ASS_F={ASS_F?} --*
mapflag -s* SIZE_FLAG=-s*
args {SIZE_FLAG} \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) \
(.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.c.p:{TAIL}={EM}/{LIB}mon)
prop C
end

View File

@@ -1,27 +0,0 @@
var w=2
var p=2
var s=2
var l=4
var f=4
var d=8
var NAME=i8080
var M=8080
var LIB=mach/8080/lib/tail_
var RT=mach/8080/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_be
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
args ({RTS}:.c={EM}/{RT}cc) -o > <
prop C
end

View File

@@ -1,32 +0,0 @@
var w=2
var p=2
var s=2
var l=4
var f=4
var d=8
var NAME=i8086
var M=i86
var LIB=mach/i86/lib/tail_
var RT=mach/i86/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_cg
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
mapflag -i IFILE={EM}/{RT}i
args {IFILE?} (.e:{HEAD}={EM}/{RT}em) \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.c.p.e:{TAIL}={EM}/{LIB}alo) (.c.p:{TAIL}={EM}/{LIB}mon) \
(.e:{TAIL}={EM}/{LIB}em)
prop C
end

View File

@@ -1,30 +0,0 @@
var w=2
var p=4
var s=2
var l=4
var f=4
var d=8
var NAME=m68k2
var M=m68k2
var LIB=mach/m68k2/lib/tail_
var RT=mach/m68k2/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_cg
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.e:{TAIL}={EM}/{LIB}em.rt {EM}/{LIB}mon {EM}/{LIB}em.vend)
prop Cm
end

View File

@@ -1,34 +0,0 @@
var w=4
var p=4
var s=2
var l=4
var f=4
var d=8
var NAME=m68k4
var M=m68k4
var LIBDIR=mach/m68k4/lib
var LIB=mach/m68k4/lib/tail_
var RT=mach/m68k4/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_cg
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p.c:{TAIL}={EM}/{LIBDIR}/sys1.s) (.p:{TAIL}={EM}/{LIBDIR}/sys2.s) \
(.c:{TAIL}={EM}/{LIBDIR}/write.s) \
(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.c:{TAIL}={EM}/{LIB}mon {EM}/{LIB}fake) \
(.e:{TAIL}={EM}/{LIB}em.rt {EM}/{LIB}em.vend)
prop Cm
end

View File

@@ -1,38 +0,0 @@
var w=2
var p=2
var s=2
var l=4
var f=4
var d=8
var M=pdp
var NAME=pdp
var LIB=mach/pdp/lib/tail_
var RT=mach/pdp/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_cg
args <
prop >
need .e
end
name as
from .s
to .o
program /bin/as
args - -o > <
prop m
end
name ld
from .o.a
to a.out
program /bin/ld
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) \
(.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.e:{TAIL}={EM}/{LIB}em) (.c.p:{TAIL}=/lib/libc.a)
prop C
end

View File

@@ -1,37 +0,0 @@
var w=4
var p=4
var s=2
var l=4
var f=4
var d=8
var M=vax4
var NAME=vax4
var LIB=mach/vax4/lib/tail_
var RT=mach/vax4/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_cg
args <
prop >
need .e
end
name as
from .s
to .o
program /bin/as
args - -o > <
prop m
end
name ld
from .o.a
to a.out
program /bin/ld
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.e:{TAIL}={EM}/{LIB}em) (.c.p:{TAIL}={EM}/{LIB}mon)
prop C
end

View File

@@ -1,31 +0,0 @@
var w=2
var p=2
var s=2
var l=4
var f=4
var d=8
var NAME=z80
var M=z80
var LIB=mach/z80/lib/tail_
var RT=mach/z80/lib/head_
var INCLUDES=-I{EM}/include
name be
from .m
to .s
program {EM}/lib/{M}_cg
args <
prop >
need .e
end
name asld
from .s.a
to a.out
program {EM}/lib/{M}_as
mapflag -l* LNAME={EM}/{LIB}*
args (.e:{HEAD}={EM}/{RT}em) \
({RTS}:.c={EM}/{RT}cc) ({RTS}:.p={EM}/{RT}pc) -o > < \
(.p:{TAIL}={EM}/{LIB}pc) (.c:{TAIL}={EM}/{LIB}cc.1s {EM}/{LIB}cc.2g) \
(.c.p.e:{TAIL}={EM}/{LIB}alo) (.c.p:{TAIL}={EM}/{LIB}mon) \
(.e:{TAIL}={EM}/{LIB}em.vend)
prop C
end

View File

@@ -1,178 +0,0 @@
# $Header$
PREFLAGS=-I../../../h -I. -DNDEBUG
PFLAGS=
CFLAGS=$(PREFLAGS) $(PFLAGS) -O
LDFLAGS=-i $(PFLAGS)
LINTOPTS=-hbxac
LIBS=../../../lib/em_data.a
CDIR=../../proto/cg
CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
$(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
$(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
$(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\
move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o
all:
make tables.c
make cg
cg: tables.o $(OFILES)
cc $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
tables.o: tables.c
cc -c $(PREFLAGS) -I$(CDIR) tables.c
codegen.o: $(CDIR)/codegen.c
cc -c $(CFLAGS) $(CDIR)/codegen.c
compute.o: $(CDIR)/compute.c
cc -c $(CFLAGS) $(CDIR)/compute.c
equiv.o: $(CDIR)/equiv.c
cc -c $(CFLAGS) $(CDIR)/equiv.c
fillem.o: $(CDIR)/fillem.c
cc -c $(CFLAGS) $(CDIR)/fillem.c
gencode.o: $(CDIR)/gencode.c
cc -c $(CFLAGS) $(CDIR)/gencode.c
glosym.o: $(CDIR)/glosym.c
cc -c $(CFLAGS) $(CDIR)/glosym.c
main.o: $(CDIR)/main.c
cc -c $(CFLAGS) $(CDIR)/main.c
move.o: $(CDIR)/move.c
cc -c $(CFLAGS) $(CDIR)/move.c
nextem.o: $(CDIR)/nextem.c
cc -c $(CFLAGS) $(CDIR)/nextem.c
reg.o: $(CDIR)/reg.c
cc -c $(CFLAGS) $(CDIR)/reg.c
regvar.o: $(CDIR)/regvar.c
cc -c $(CFLAGS) $(CDIR)/regvar.c
salloc.o: $(CDIR)/salloc.c
cc -c $(CFLAGS) $(CDIR)/salloc.c
state.o: $(CDIR)/state.c
cc -c $(CFLAGS) $(CDIR)/state.c
subr.o: $(CDIR)/subr.c
cc -c $(CFLAGS) $(CDIR)/subr.c
var.o: $(CDIR)/var.c
cc -c $(CFLAGS) $(CDIR)/var.c
install: all
../install cg
cmp: all
-../compare cg
tables.c: table
-mv tables.h tables.h.save
../../../lib/cpp -P table | ../../../lib/cgg > debug.out
-if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi
-if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi
lint: $(CFILES)
lint $(LINTOPTS) $(PREFLAGS) $(CFILES)
clean:
rm -f *.o tables.c tables.h debug.out cg tables.h.save
codegen.o: $(CDIR)/assert.h
codegen.o: $(CDIR)/data.h
codegen.o: $(CDIR)/equiv.h
codegen.o: $(CDIR)/extern.h
codegen.o: $(CDIR)/param.h
codegen.o: $(CDIR)/result.h
codegen.o: $(CDIR)/state.h
codegen.o: tables.h
codegen.o: $(CDIR)/types.h
compute.o: $(CDIR)/assert.h
compute.o: $(CDIR)/data.h
compute.o: $(CDIR)/extern.h
compute.o: $(CDIR)/glosym.h
compute.o: $(CDIR)/param.h
compute.o: $(CDIR)/result.h
compute.o: tables.h
compute.o: $(CDIR)/types.h
equiv.o: $(CDIR)/assert.h
equiv.o: $(CDIR)/data.h
equiv.o: $(CDIR)/equiv.h
equiv.o: $(CDIR)/extern.h
equiv.o: $(CDIR)/param.h
equiv.o: $(CDIR)/result.h
equiv.o: tables.h
equiv.o: $(CDIR)/types.h
fillem.o: $(CDIR)/assert.h
fillem.o: $(CDIR)/data.h
fillem.o: $(CDIR)/extern.h
fillem.o: mach.c
fillem.o: mach.h
fillem.o: $(CDIR)/param.h
fillem.o: $(CDIR)/regvar.h
fillem.o: $(CDIR)/result.h
fillem.o: tables.h
fillem.o: $(CDIR)/types.h
gencode.o: $(CDIR)/assert.h
gencode.o: $(CDIR)/data.h
gencode.o: $(CDIR)/extern.h
gencode.o: $(CDIR)/param.h
gencode.o: $(CDIR)/result.h
gencode.o: tables.h
gencode.o: $(CDIR)/types.h
glosym.o: $(CDIR)/glosym.h
glosym.o: $(CDIR)/param.h
glosym.o: tables.h
glosym.o: $(CDIR)/types.h
main.o: $(CDIR)/param.h
move.o: $(CDIR)/assert.h
move.o: $(CDIR)/data.h
move.o: $(CDIR)/extern.h
move.o: $(CDIR)/param.h
move.o: $(CDIR)/result.h
move.o: tables.h
move.o: $(CDIR)/types.h
nextem.o: $(CDIR)/assert.h
nextem.o: $(CDIR)/data.h
nextem.o: $(CDIR)/extern.h
nextem.o: $(CDIR)/param.h
nextem.o: $(CDIR)/result.h
nextem.o: tables.h
nextem.o: $(CDIR)/types.h
reg.o: $(CDIR)/assert.h
reg.o: $(CDIR)/data.h
reg.o: $(CDIR)/extern.h
reg.o: $(CDIR)/param.h
reg.o: $(CDIR)/result.h
reg.o: tables.h
reg.o: $(CDIR)/types.h
regvar.o: $(CDIR)/assert.h
regvar.o: $(CDIR)/data.h
regvar.o: $(CDIR)/extern.h
regvar.o: $(CDIR)/param.h
regvar.o: $(CDIR)/regvar.h
regvar.o: $(CDIR)/result.h
regvar.o: tables.h
regvar.o: $(CDIR)/types.h
salloc.o: $(CDIR)/assert.h
salloc.o: $(CDIR)/data.h
salloc.o: $(CDIR)/extern.h
salloc.o: $(CDIR)/param.h
salloc.o: $(CDIR)/result.h
salloc.o: tables.h
salloc.o: $(CDIR)/types.h
state.o: $(CDIR)/assert.h
state.o: $(CDIR)/data.h
state.o: $(CDIR)/extern.h
state.o: $(CDIR)/param.h
state.o: $(CDIR)/result.h
state.o: $(CDIR)/state.h
state.o: tables.h
state.o: $(CDIR)/types.h
subr.o: $(CDIR)/assert.h
subr.o: $(CDIR)/data.h
subr.o: $(CDIR)/extern.h
subr.o: $(CDIR)/param.h
subr.o: $(CDIR)/result.h
subr.o: tables.h
subr.o: $(CDIR)/types.h
var.o: $(CDIR)/data.h
var.o: $(CDIR)/param.h
var.o: $(CDIR)/result.h
var.o: tables.h
var.o: $(CDIR)/types.h

View File

@@ -1,178 +0,0 @@
# $Header$
PREFLAGS=-I../../../h -I. -DNDEBUG
PFLAGS=
CFLAGS=$(PREFLAGS) $(PFLAGS) -O
LDFLAGS=-i $(PFLAGS)
LINTOPTS=-hbxac
LIBS=../../../lib/em_data.a
CDIR=../../proto/cg
CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
$(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
$(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
$(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\
move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o
all:
make tables.c
make cg
cg: tables.o $(OFILES)
cc $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
tables.o: tables.c
cc -c $(PREFLAGS) -I$(CDIR) tables.c
codegen.o: $(CDIR)/codegen.c
cc -c $(CFLAGS) $(CDIR)/codegen.c
compute.o: $(CDIR)/compute.c
cc -c $(CFLAGS) $(CDIR)/compute.c
equiv.o: $(CDIR)/equiv.c
cc -c $(CFLAGS) $(CDIR)/equiv.c
fillem.o: $(CDIR)/fillem.c
cc -c $(CFLAGS) $(CDIR)/fillem.c
gencode.o: $(CDIR)/gencode.c
cc -c $(CFLAGS) $(CDIR)/gencode.c
glosym.o: $(CDIR)/glosym.c
cc -c $(CFLAGS) $(CDIR)/glosym.c
main.o: $(CDIR)/main.c
cc -c $(CFLAGS) $(CDIR)/main.c
move.o: $(CDIR)/move.c
cc -c $(CFLAGS) $(CDIR)/move.c
nextem.o: $(CDIR)/nextem.c
cc -c $(CFLAGS) $(CDIR)/nextem.c
reg.o: $(CDIR)/reg.c
cc -c $(CFLAGS) $(CDIR)/reg.c
regvar.o: $(CDIR)/regvar.c
cc -c $(CFLAGS) $(CDIR)/regvar.c
salloc.o: $(CDIR)/salloc.c
cc -c $(CFLAGS) $(CDIR)/salloc.c
state.o: $(CDIR)/state.c
cc -c $(CFLAGS) $(CDIR)/state.c
subr.o: $(CDIR)/subr.c
cc -c $(CFLAGS) $(CDIR)/subr.c
var.o: $(CDIR)/var.c
cc -c $(CFLAGS) $(CDIR)/var.c
install: all
../install cg
cmp: all
-../compare cg
tables.c: table
-mv tables.h tables.h.save
../../../lib/cpp -P table | ../../../lib/cgg > debug.out
-if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi
-if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi
lint: $(CFILES)
lint $(LINTOPTS) $(PREFLAGS) $(CFILES)
clean:
rm -f *.o tables.c tables.h debug.out cg tables.h.save
codegen.o: $(CDIR)/assert.h
codegen.o: $(CDIR)/data.h
codegen.o: $(CDIR)/equiv.h
codegen.o: $(CDIR)/extern.h
codegen.o: $(CDIR)/param.h
codegen.o: $(CDIR)/result.h
codegen.o: $(CDIR)/state.h
codegen.o: tables.h
codegen.o: $(CDIR)/types.h
compute.o: $(CDIR)/assert.h
compute.o: $(CDIR)/data.h
compute.o: $(CDIR)/extern.h
compute.o: $(CDIR)/glosym.h
compute.o: $(CDIR)/param.h
compute.o: $(CDIR)/result.h
compute.o: tables.h
compute.o: $(CDIR)/types.h
equiv.o: $(CDIR)/assert.h
equiv.o: $(CDIR)/data.h
equiv.o: $(CDIR)/equiv.h
equiv.o: $(CDIR)/extern.h
equiv.o: $(CDIR)/param.h
equiv.o: $(CDIR)/result.h
equiv.o: tables.h
equiv.o: $(CDIR)/types.h
fillem.o: $(CDIR)/assert.h
fillem.o: $(CDIR)/data.h
fillem.o: $(CDIR)/extern.h
fillem.o: mach.c
fillem.o: mach.h
fillem.o: $(CDIR)/param.h
fillem.o: $(CDIR)/regvar.h
fillem.o: $(CDIR)/result.h
fillem.o: tables.h
fillem.o: $(CDIR)/types.h
gencode.o: $(CDIR)/assert.h
gencode.o: $(CDIR)/data.h
gencode.o: $(CDIR)/extern.h
gencode.o: $(CDIR)/param.h
gencode.o: $(CDIR)/result.h
gencode.o: tables.h
gencode.o: $(CDIR)/types.h
glosym.o: $(CDIR)/glosym.h
glosym.o: $(CDIR)/param.h
glosym.o: tables.h
glosym.o: $(CDIR)/types.h
main.o: $(CDIR)/param.h
move.o: $(CDIR)/assert.h
move.o: $(CDIR)/data.h
move.o: $(CDIR)/extern.h
move.o: $(CDIR)/param.h
move.o: $(CDIR)/result.h
move.o: tables.h
move.o: $(CDIR)/types.h
nextem.o: $(CDIR)/assert.h
nextem.o: $(CDIR)/data.h
nextem.o: $(CDIR)/extern.h
nextem.o: $(CDIR)/param.h
nextem.o: $(CDIR)/result.h
nextem.o: tables.h
nextem.o: $(CDIR)/types.h
reg.o: $(CDIR)/assert.h
reg.o: $(CDIR)/data.h
reg.o: $(CDIR)/extern.h
reg.o: $(CDIR)/param.h
reg.o: $(CDIR)/result.h
reg.o: tables.h
reg.o: $(CDIR)/types.h
regvar.o: $(CDIR)/assert.h
regvar.o: $(CDIR)/data.h
regvar.o: $(CDIR)/extern.h
regvar.o: $(CDIR)/param.h
regvar.o: $(CDIR)/regvar.h
regvar.o: $(CDIR)/result.h
regvar.o: tables.h
regvar.o: $(CDIR)/types.h
salloc.o: $(CDIR)/assert.h
salloc.o: $(CDIR)/data.h
salloc.o: $(CDIR)/extern.h
salloc.o: $(CDIR)/param.h
salloc.o: $(CDIR)/result.h
salloc.o: tables.h
salloc.o: $(CDIR)/types.h
state.o: $(CDIR)/assert.h
state.o: $(CDIR)/data.h
state.o: $(CDIR)/extern.h
state.o: $(CDIR)/param.h
state.o: $(CDIR)/result.h
state.o: $(CDIR)/state.h
state.o: tables.h
state.o: $(CDIR)/types.h
subr.o: $(CDIR)/assert.h
subr.o: $(CDIR)/data.h
subr.o: $(CDIR)/extern.h
subr.o: $(CDIR)/param.h
subr.o: $(CDIR)/result.h
subr.o: tables.h
subr.o: $(CDIR)/types.h
var.o: $(CDIR)/data.h
var.o: $(CDIR)/param.h
var.o: $(CDIR)/result.h
var.o: tables.h
var.o: $(CDIR)/types.h

View File

@@ -1,171 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
/*
* machine dependent back end routines for the PDP-11
*/
#define REGPATCH
con_part(sz,w) register sz; word w; {
while (part_size % sz)
part_size++;
if (part_size == EM_WSIZE)
part_flush();
if (sz == 1) {
w &= 0xFF;
if (part_size)
w <<= 8;
part_word |= w;
} else {
assert(sz == 2);
part_word = w;
}
part_size += sz;
}
con_mult(sz) word sz; {
long l;
if (sz != 4)
fatal("bad icon/ucon size");
l = atol(str);
fprintf(codefile,"\t%o;%o\n",(int)(l>>16),(int)l);
}
con_float() {
double f;
register short *p,i;
if (argval != 4 && argval != 8)
fatal("bad fcon size");
f = atof(str);
p = (short *) &f;
i = *p++;
if (argval == 8) {
fprintf(codefile,"\t%o;%o;",i,*p++);
i = *p++;
}
fprintf(codefile,"\t%o;%o\n",i,*p++);
}
#ifdef REGVARS
char Rstring[10] = "RT";
regscore(off,size,typ,score,totyp) long off; {
if (size != 2)
return(-1);
score -= 1; /* allow for save/restore */
if (off>=0)
score -= 2;
if (typ==reg_pointer)
score *= 17;
else if (typ==reg_loop)
score = 10*score+50; /* Guestimate */
else
score *= 10;
return(score); /* estimated # of words of profit */
}
i_regsave() {
Rstring[2] = 0;
}
f_regsave() {}
regsave(regstr,off,size) char *regstr; long off; {
fprintf(codefile,"/ Local %ld into %s\n",off,regstr);
#ifndef REGPATCH
fprintf(codefile,"mov %s,-(sp)\n",regstr);
#endif
strcat(Rstring,regstr);
if (off>=0)
fprintf(codefile,"mov 0%lo(r5),%s\n",off,regstr);
}
regreturn() {
#ifdef REGPATCH
fprintf(codefile,"jmp eret\n");
#else
fprintf(codefile,"jmp %s\n",Rstring);
#endif
}
#endif
prolog(nlocals) full nlocals; {
#ifdef REGPATCH
fprintf(codefile,"mov r2,-(sp)\nmov r4,-(sp)\n");
#endif
fprintf(codefile,"mov r5,-(sp)\nmov sp,r5\n");
if (nlocals == 0)
return;
if (nlocals == 2)
fprintf(codefile,"tst -(sp)\n");
else
fprintf(codefile,"sub $0%o,sp\n",nlocals);
}
dlbdlb(as,ls) string as,ls; {
if (strlen(as)+strlen(ls)+2<sizeof(labstr)) {
strcat(ls,":");
strcat(ls,as);
} else
fatal("too many consecutive labels");
}
mes(type) word type; {
int argt ;
switch ( (int)type ) {
case ms_ext :
for (;;) {
switch ( argt=getarg(
ptyp(sp_cend)|ptyp(sp_pnam)|sym_ptyp) ) {
case sp_cend :
return ;
default:
strarg(argt) ;
fprintf(codefile,".globl %s\n",argstr) ;
break ;
}
}
default :
while ( getarg(any_ptyp) != sp_cend ) ;
break ;
}
}
char *segname[] = {
".text", /* SEGTXT */
".data", /* SEGCON */
".data", /* SEGROM */
".bss" /* SEGBSS */
};

View File

@@ -1,23 +0,0 @@
/* $Header$ */
#define ex_ap(y) fprintf(codefile,"\t.globl %s\n",y)
#define in_ap(y) /* nothing */
#define newilb(x) fprintf(codefile,"%s:\n",x)
#define newdlb(x) fprintf(codefile,"%s:\n",x)
#define newlbss(l,x) fprintf(codefile,"%s:.=.+0%o\n",l,x);
#define cst_fmt "$0%o"
#define off_fmt "0%o"
#define ilb_fmt "I%02x%x"
#define dlb_fmt "_%d"
#define hol_fmt "hol%d"
#define hol_off "0%o+hol%d"
#define con_cst(x) fprintf(codefile,"0%o\n",x)
#define con_ilb(x) fprintf(codefile,"%s\n",x)
#define con_dlb(x) fprintf(codefile,"%s\n",x)
#define id_first '_'
#define BSS_INIT 0

File diff suppressed because it is too large Load Diff

View File

@@ -1,178 +0,0 @@
# $Header$
PREFLAGS=-I../../../h -I. -DNDEBUG
PFLAGS=
CFLAGS=$(PREFLAGS) $(PFLAGS) -O
LDFLAGS=-i $(PFLAGS)
LINTOPTS=-hbxac
LIBS=../../../lib/em_data.a
CDIR=../../proto/cg
CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
$(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
$(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
$(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\
move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o
all:
make tables.c
make cg
cg: tables.o $(OFILES)
cc $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
tables.o: tables.c
cc -c $(PREFLAGS) -I$(CDIR) tables.c
codegen.o: $(CDIR)/codegen.c
cc -c $(CFLAGS) $(CDIR)/codegen.c
compute.o: $(CDIR)/compute.c
cc -c $(CFLAGS) $(CDIR)/compute.c
equiv.o: $(CDIR)/equiv.c
cc -c $(CFLAGS) $(CDIR)/equiv.c
fillem.o: $(CDIR)/fillem.c
cc -c $(CFLAGS) $(CDIR)/fillem.c
gencode.o: $(CDIR)/gencode.c
cc -c $(CFLAGS) $(CDIR)/gencode.c
glosym.o: $(CDIR)/glosym.c
cc -c $(CFLAGS) $(CDIR)/glosym.c
main.o: $(CDIR)/main.c
cc -c $(CFLAGS) $(CDIR)/main.c
move.o: $(CDIR)/move.c
cc -c $(CFLAGS) $(CDIR)/move.c
nextem.o: $(CDIR)/nextem.c
cc -c $(CFLAGS) $(CDIR)/nextem.c
reg.o: $(CDIR)/reg.c
cc -c $(CFLAGS) $(CDIR)/reg.c
regvar.o: $(CDIR)/regvar.c
cc -c $(CFLAGS) $(CDIR)/regvar.c
salloc.o: $(CDIR)/salloc.c
cc -c $(CFLAGS) $(CDIR)/salloc.c
state.o: $(CDIR)/state.c
cc -c $(CFLAGS) $(CDIR)/state.c
subr.o: $(CDIR)/subr.c
cc -c $(CFLAGS) $(CDIR)/subr.c
var.o: $(CDIR)/var.c
cc -c $(CFLAGS) $(CDIR)/var.c
install: all
../install cg
cmp: all
-../compare cg
tables.c: table
-mv tables.h tables.h.save
../../../lib/cpp -P table | ../../../lib/cgg > debug.out
-if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi
-if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi
lint: $(CFILES)
lint $(LINTOPTS) $(PREFLAGS) $(CFILES)
clean:
rm -f *.o tables.c tables.h debug.out cg tables.h.save
codegen.o: $(CDIR)/assert.h
codegen.o: $(CDIR)/data.h
codegen.o: $(CDIR)/equiv.h
codegen.o: $(CDIR)/extern.h
codegen.o: $(CDIR)/param.h
codegen.o: $(CDIR)/result.h
codegen.o: $(CDIR)/state.h
codegen.o: tables.h
codegen.o: $(CDIR)/types.h
compute.o: $(CDIR)/assert.h
compute.o: $(CDIR)/data.h
compute.o: $(CDIR)/extern.h
compute.o: $(CDIR)/glosym.h
compute.o: $(CDIR)/param.h
compute.o: $(CDIR)/result.h
compute.o: tables.h
compute.o: $(CDIR)/types.h
equiv.o: $(CDIR)/assert.h
equiv.o: $(CDIR)/data.h
equiv.o: $(CDIR)/equiv.h
equiv.o: $(CDIR)/extern.h
equiv.o: $(CDIR)/param.h
equiv.o: $(CDIR)/result.h
equiv.o: tables.h
equiv.o: $(CDIR)/types.h
fillem.o: $(CDIR)/assert.h
fillem.o: $(CDIR)/data.h
fillem.o: $(CDIR)/extern.h
fillem.o: mach.c
fillem.o: mach.h
fillem.o: $(CDIR)/param.h
fillem.o: $(CDIR)/regvar.h
fillem.o: $(CDIR)/result.h
fillem.o: tables.h
fillem.o: $(CDIR)/types.h
gencode.o: $(CDIR)/assert.h
gencode.o: $(CDIR)/data.h
gencode.o: $(CDIR)/extern.h
gencode.o: $(CDIR)/param.h
gencode.o: $(CDIR)/result.h
gencode.o: tables.h
gencode.o: $(CDIR)/types.h
glosym.o: $(CDIR)/glosym.h
glosym.o: $(CDIR)/param.h
glosym.o: tables.h
glosym.o: $(CDIR)/types.h
main.o: $(CDIR)/param.h
move.o: $(CDIR)/assert.h
move.o: $(CDIR)/data.h
move.o: $(CDIR)/extern.h
move.o: $(CDIR)/param.h
move.o: $(CDIR)/result.h
move.o: tables.h
move.o: $(CDIR)/types.h
nextem.o: $(CDIR)/assert.h
nextem.o: $(CDIR)/data.h
nextem.o: $(CDIR)/extern.h
nextem.o: $(CDIR)/param.h
nextem.o: $(CDIR)/result.h
nextem.o: tables.h
nextem.o: $(CDIR)/types.h
reg.o: $(CDIR)/assert.h
reg.o: $(CDIR)/data.h
reg.o: $(CDIR)/extern.h
reg.o: $(CDIR)/param.h
reg.o: $(CDIR)/result.h
reg.o: tables.h
reg.o: $(CDIR)/types.h
regvar.o: $(CDIR)/assert.h
regvar.o: $(CDIR)/data.h
regvar.o: $(CDIR)/extern.h
regvar.o: $(CDIR)/param.h
regvar.o: $(CDIR)/regvar.h
regvar.o: $(CDIR)/result.h
regvar.o: tables.h
regvar.o: $(CDIR)/types.h
salloc.o: $(CDIR)/assert.h
salloc.o: $(CDIR)/data.h
salloc.o: $(CDIR)/extern.h
salloc.o: $(CDIR)/param.h
salloc.o: $(CDIR)/result.h
salloc.o: tables.h
salloc.o: $(CDIR)/types.h
state.o: $(CDIR)/assert.h
state.o: $(CDIR)/data.h
state.o: $(CDIR)/extern.h
state.o: $(CDIR)/param.h
state.o: $(CDIR)/result.h
state.o: $(CDIR)/state.h
state.o: tables.h
state.o: $(CDIR)/types.h
subr.o: $(CDIR)/assert.h
subr.o: $(CDIR)/data.h
subr.o: $(CDIR)/extern.h
subr.o: $(CDIR)/param.h
subr.o: $(CDIR)/result.h
subr.o: tables.h
subr.o: $(CDIR)/types.h
var.o: $(CDIR)/data.h
var.o: $(CDIR)/param.h
var.o: $(CDIR)/result.h
var.o: tables.h
var.o: $(CDIR)/types.h

View File

@@ -1,7 +0,0 @@
/* $Header$ */
#ifndef NDEBUG
#define assert(x) if(!(x)) badassertion("x",__FILE__,__LINE__)
#else
#define assert(x) /* nothing */
#endif

View File

@@ -1,672 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "state.h"
#include "equiv.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#define SHORTCUT /* Stop searching at distance 0 */
#if NREGS >= MAXRULE
#define MAXPOS NREGS
#else
#define MAXPOS MAXRULE
#endif
#define MAXPATTERN 5
#define MAXREPLLEN 5 /* Max length of EM-replacement, should come from boot */
byte startupcode[] = { DO_NEXTEM };
byte *nextem();
unsigned costcalc();
unsigned docoerc();
unsigned stackupto();
string tostring();
#ifdef NDEBUG
#define DEBUG()
#else
#include <stdio.h>
#define DEBUG(string) {if(Debug) fprintf(stderr,"%-*d%s\n",4*level,level,string);}
#endif
#define BROKE() {assert(origcp!=startupcode);DEBUG("BROKE");goto doreturn;}
#define CHKCOST() {if (totalcost>=costlimit) BROKE();}
unsigned codegen(codep,ply,toplevel,costlimit,forced) byte *codep; unsigned costlimit; {
#ifndef NDEBUG
byte *origcp=codep;
static int level=0;
#endif
unsigned totalcost = 0;
byte *bp;
int n;
unsigned mindistance,dist;
register i;
int cindex;
int npos,npos2,pos[MAXPOS],pos2[MAXPOS];
#ifdef STONSTACK
state_t state;
#define SAVEST savestatus(&state)
#define RESTST restorestatus(&state)
#define FREEST /* nothing */
#else
state_p state;
#define SAVEST state=savestatus()
#define RESTST restorestatus(state)
#define FREEST freestatus(state)
#endif
unsigned mincost,t;
int texpno,nodeno;
token_p tp;
tkdef_p tdp;
int tinstno;
struct reginfo *rp,**rpp;
token_t token,mtoken,token2;
int propno;
int exactmatch;
int j;
int decision;
int stringno;
result_t result;
cost_t cost;
int size,lsize,repllen;
int tokexp[MAXPATTERN];
int nregneeded;
token_p regtp[MAXCREG];
c3_p regcp[MAXCREG];
rl_p regls[MAXCREG];
c3_p cp,findcoerc();
int sret;
token_t reptoken[MAXREPLLEN];
int emrepllen,eminstr;
int inscoerc=0;
int stackpad;
struct perm *tup,*ntup,*besttup,*tuples();
#ifndef NDEBUG
level++;
DEBUG("Entering codegen");
#endif
for (;;) {
switch( (*codep++)&037 ) {
default:
assert(FALSE);
/* NOTREACHED */
case DO_NEXTEM:
DEBUG("NEXTEM");
tokpatlen = 0;
nallreg=0;
if (toplevel) {
garbage_collect();
totalcost=0;
} else {
if (--ply <= 0)
goto doreturn;
}
if (stackheight>MAXFSTACK-7)
totalcost += stackupto(&fakestack[6],ply,toplevel);
bp = nextem(toplevel);
if (bp == 0) {
/*
* No pattern found, can be pseudo or error
* in table.
*/
if (toplevel) {
codep--;
DEBUG("pseudo");
dopseudo();
} else
goto doreturn;
} else {
#ifndef NDEBUG
chkregs();
#endif
n = *bp++;
assert(n>0 && n<=MAXRULE);
if (n>1) {
mindistance = MAXINT; npos=0;
for(i=0;i<n;i++) {
getint(cindex,bp);
dist=distance(cindex);
#ifndef NDEBUG
if (Debug)
fprintf(stderr,"distance of pos %d is %u\n",i,dist);
#endif
if (dist<=mindistance) {
if (dist<mindistance) {
#ifdef SHORTCUT
if(dist==0)
goto gotit;
#endif
npos=0;
mindistance = dist;
}
pos[npos++] = cindex;
}
}
assert(mindistance<MAXINT);
if (npos>1) {
/*
* More than 1 tokenpattern is a candidate.
* Decision has to be made by lookahead.
*/
SAVEST;
mincost = costlimit-totalcost+1;
for(i=0;i<npos;i++) {
t=codegen(&coderules[pos[i]],ply,FALSE,mincost,0);
#ifndef NDEBUG
if (Debug)
fprintf(stderr,"mincost %u,cost %u,pos %d\n",mincost,t,i);
#endif
if (t<mincost) {
mincost = t;
cindex = pos[i];
}
RESTST;
}
FREEST;
if (totalcost+mincost>costlimit) {
totalcost += mincost;
BROKE();
}
} else {
cindex = pos[0];
}
} else {
getint(cindex,bp);
}
gotit:
/*
* Now cindex contains the code-index of the best candidate
* so proceed to use it.
*/
codep = &coderules[cindex];
}
break;
case DO_COERC:
DEBUG("COERC");
tokpatlen=1;
inscoerc=1;
break;
case DO_XXMATCH:
DEBUG("XXMATCH");
case DO_XMATCH:
DEBUG("XMATCH");
tokpatlen=(codep[-1]>>5)&07;
for (i=0;i<tokpatlen;i++)
getint(tokexp[i],codep);
tokexp[i]=0;
break; /* match already checked by distance() */
case DO_MATCH:
DEBUG("MATCH");
tokpatlen=(codep[-1]>>5)&07;
for(i=0;i<tokpatlen;i++)
getint(tokexp[i],codep);
tokexp[i] = 0;
tp = &fakestack[stackheight-1];
i=0;
while (i<tokpatlen && tp>=fakestack) {
size=tsize(tp);
while (i<tokpatlen && (lsize=ssize(tokexp[i]))<=size) {
size -= lsize;
i++;
}
if (i<tokpatlen && size!=0) {
totalcost += stackupto(tp,ply,toplevel);
CHKCOST();
break;
}
tp--;
}
tp = &fakestack[stackheight-1];
i=0;
while (i<tokpatlen && tp >= fakestack) {
size = tsize(tp);
lsize= ssize(tokexp[i]);
if (size != lsize) { /* find coercion */
#ifdef MAXSPLIT
sret = split(tp,&tokexp[i],ply,toplevel);
if (sret==0) {
#endif MAXSPLIT
totalcost += stackupto(tp,ply,toplevel);
CHKCOST();
break;
#ifdef MAXSPLIT
}
i += sret;
#endif MAXSPLIT
} else
i += 1;
tp--;
}
nextmatch:
tp = &fakestack[stackheight-1];
i=0; nregneeded = 0;
while (i<tokpatlen && tp>=fakestack) {
if (!match(tp,&machsets[tokexp[i]],0)) {
cp = findcoerc(tp, &machsets[tokexp[i]]);
if (cp==0) {
for (j=0;j<nregneeded;j++)
regtp[j] -= (tp-fakestack+1);
totalcost += stackupto(tp,ply,toplevel);
CHKCOST();
break;
} else {
if (cp->c3_prop==0) {
totalcost+=docoerc(tp,cp,ply,toplevel,0);
CHKCOST();
} else {
assert(nregneeded<MAXCREG);
regtp[nregneeded] = tp;
regcp[nregneeded] = cp;
regls[nregneeded] = curreglist;
nregneeded++;
}
}
}
i++; tp--;
}
if (tokpatlen>stackheight) {
stackpad = tokpatlen-stackheight;
for (j=stackheight-1;j>=0;j--)
fakestack[j+stackpad] = fakestack[j];
for (j=0;j<stackpad;j++)
fakestack[j].t_token=0;
stackheight += stackpad;
for (j=0;j<nregneeded;j++)
regtp[j] += stackpad;
tp = &fakestack[stackpad-1];
while (i<tokpatlen && tp>=fakestack) {
cp = findcoerc((token_p) 0, &machsets[tokexp[i]]);
if (cp==0) {
assert(!toplevel);
for (j=0;j<nregneeded;j++)
myfree(regls[j]);
totalcost=INFINITY;
BROKE();
}
if (cp->c3_prop==0) {
totalcost+=docoerc(tp,cp,ply,toplevel,0);
CHKCOST();
} else {
assert(nregneeded<MAXCREG);
regtp[nregneeded] = tp;
regcp[nregneeded] = cp;
regls[nregneeded] = curreglist;
nregneeded++;
}
i++; tp--;
}
} else
stackpad=0;
assert(i==tokpatlen);
if (nregneeded==0)
break;
SAVEST;
mincost=costlimit-totalcost+1;
tup = tuples(regls,nregneeded);
besttup=0;
for (; tup != 0; tup = ntup) {
ntup = tup->p_next;
for (i=0,t=0;i<nregneeded && t<mincost; i++)
t += docoerc(regtp[i],regcp[i],ply,FALSE,tup->p_rar[i]);
if (t<mincost)
t += codegen(codep,ply,FALSE,mincost-t,0);
if (t<mincost) {
mincost = t;
besttup = tup;
} else
myfree(tup);
RESTST;
}
FREEST;
for (i=0;i<nregneeded;i++)
myfree(regls[i]);
if (totalcost+mincost>costlimit) {
if (besttup)
myfree(besttup);
if (stackpad!=tokpatlen) {
if (stackpad) {
if (costlimit<MAXINT) {
totalcost = costlimit+1;
BROKE();
}
for (i=0;i<stackheight-stackpad;i++)
fakestack[i] = fakestack[i+stackpad];
stackheight -= stackpad;
totalcost += stackupto(&fakestack[stackheight-1],ply,toplevel);
} else
totalcost += stackupto(fakestack,ply,toplevel);
CHKCOST();
goto nextmatch;
}
totalcost += mincost;
BROKE();
}
for (i=0;i<nregneeded;i++)
totalcost += docoerc(regtp[i],regcp[i],ply,toplevel,besttup->p_rar[i]);
myfree(besttup);
break;
case DO_REMOVE:
DEBUG("REMOVE");
if (codep[-1]&32) {
getint(texpno,codep);
getint(nodeno,codep);
} else {
getint(texpno,codep);
nodeno=0;
}
for (tp= &fakestack[stackheight-tokpatlen-1];tp>=&fakestack[0];tp--)
if (match(tp,&machsets[texpno],nodeno)) {
/* investigate possible coercion to register */
totalcost += stackupto(tp,ply,toplevel);
CHKCOST();
break;
}
for (rp=machregs+2;rp<machregs+NREGS;rp++)
if (match(&rp->r_contents,&machsets[texpno],nodeno))
rp->r_contents.t_token=0;
break;
case DO_RREMOVE: /* register remove */
getint(nodeno,codep);
result=compute(&enodes[nodeno]);
assert(result.e_typ==EV_REG);
for (tp= &fakestack[stackheight-tokpatlen-1];tp>=&fakestack[0];tp--)
if (tp->t_token==-1) {
if(tp->t_att[0].ar==result.e_v.e_con)
goto gotone;
} else {
tdp = &tokens[tp->t_token];
for(i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i]==EV_REG &&
tp->t_att[i].ar==result.e_v.e_con)
goto gotone;
}
break;
gotone:
/* investigate possible coercion to register */
totalcost += stackupto(tp,ply,toplevel);
CHKCOST();
break;
case DO_DEALLOCATE:
DEBUG("DEALLOCATE");
getint(tinstno,codep);
instance(tinstno,&token);
if (token.t_token==-1)
chrefcount(token.t_att[0].ar,-1,TRUE);
else {
tdp= &tokens[token.t_token];
for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i]==EV_REG)
chrefcount(token.t_att[i].ar,-1,TRUE);
}
break;
case DO_REALLOCATE:
DEBUG("REALLOCATE");
for(rp=machregs;rp<machregs+NREGS;rp++)
if(rp->r_tcount) {
rp->r_refcount -= rp->r_tcount;
rp->r_tcount = 0;
}
break;
case DO_ALLOCATE:
DEBUG("ALLOCATE");
if (codep[-1]&32) {
getint(propno,codep);
getint(tinstno,codep);
} else {
getint(propno,codep);
tinstno=0;
}
instance(tinstno,&token);
if (!forced) {
do {
npos=exactmatch=0;
for(rpp=reglist[propno];rp= *rpp; rpp++)
if (getrefcount(rp-machregs)==0) {
pos[npos++] = rp-machregs;
if (eqtoken(&rp->r_contents,&token))
exactmatch++;
}
/*
* Now pos[] contains all free registers with desired
* property. If none then some stacking has to take place.
*/
if (npos==0) {
if (stackheight<=tokpatlen) {
if (!toplevel) {
totalcost = INFINITY;
BROKE();
} else {
fatal("No regs available");
}
}
totalcost += stackupto( &fakestack[0],ply,toplevel);
CHKCOST();
}
} while (npos==0);
if (!exactmatch) {
npos2=npos;
for(i=0;i<npos;i++)
pos2[i]=pos[i];
} else {
/*
* Now we are reducing the number of possible registers.
* We take only one equally likely register out of every
* equivalence class as given by set of properties.
*/
mtoken = token;
npos2=0;
for(i=0;i<npos;i++)
if (eqtoken(&machregs[pos[i]].r_contents,&mtoken)) {
pos2[npos2++] = pos[i];
for(j=0;j<npos2-1;j++)
if (eqregclass(pos2[j],pos[i])) {
npos2--;
break;
}
}
}
/*
* Now pos2[] contains all possibilities to try, if more than
* one, lookahead is necessary.
*/
token2.t_token= -1;
for (i=1;i<TOKENSIZE;i++)
token2.t_att[i].aw=0;
if (npos2==1)
decision=pos2[0];
else {
SAVEST;
mincost=costlimit-totalcost+1;
for(j=0;j<npos2;j++) {
chrefcount(pos2[j],1,FALSE);
token2.t_att[0].ar=pos2[j];
allreg[nallreg++] = pos2[j];
if (token.t_token != 0)
t=move(&token,&token2,ply,FALSE,mincost);
else {
t = 0;
erasereg(pos2[j]);
}
if (t<mincost)
t += codegen(codep,ply,FALSE,mincost-t,0);
if (t<mincost) {
mincost=t;
decision=pos2[j];
}
RESTST;
}
FREEST;
if (totalcost+mincost>costlimit) {
totalcost = INFINITY;
BROKE();
}
}
} else {
decision = forced;
if (getrefcount(decision)!=0) {
totalcost = INFINITY;
BROKE();
}
token2.t_token = -1;
}
chrefcount(decision,1,FALSE);
token2.t_att[0].ar=decision;
if (token.t_token != 0) {
totalcost+=move(&token,&token2,ply,toplevel,MAXINT);
CHKCOST();
} else
erasereg(decision);
allreg[nallreg++]=decision;
break;
case DO_LOUTPUT:
DEBUG("LOUTPUT");
getint(stringno,codep);
getint(nodeno,codep);
if (toplevel) {
gencode(codestrings[stringno]);
genexpr(nodeno);
}
break;
case DO_ROUTPUT:
DEBUG("ROUTPUT");
i=((codep[-1]>>5)&07);
do {
getint(stringno,codep);
if (toplevel) {
gencode(codestrings[stringno]);
gennl();
}
} while (i--);
break;
case DO_MOVE:
DEBUG("MOVE");
getint(tinstno,codep);
instance(tinstno,&token);
getint(tinstno,codep);
instance(tinstno,&token2);
totalcost += move(&token,&token2,ply,toplevel,costlimit-totalcost+1);
CHKCOST();
break;
case DO_ERASE:
DEBUG("ERASE");
getint(nodeno,codep);
result=compute(&enodes[nodeno]);
assert(result.e_typ==EV_REG);
erasereg(result.e_v.e_reg);
break;
case DO_TOKREPLACE:
DEBUG("TOKREPLACE");
assert(stackheight>=tokpatlen);
repllen=(codep[-1]>>5)&07;
for(i=0;i<repllen;i++) {
getint(tinstno,codep);
instance(tinstno,&reptoken[i]);
tref(&reptoken[i],1);
}
for(i=0;i<tokpatlen;i++) {
if (!inscoerc)
tref(&fakestack[stackheight-1],-1);
stackheight--;
}
for (i=0;i<repllen;i++) {
assert(stackheight<MAXFSTACK);
fakestack[stackheight++] = reptoken[i];
}
for(i=0;i<nallreg;i++)
chrefcount(allreg[i],-1,FALSE);
break;
case DO_EMREPLACE:
DEBUG("EMREPLACE");
emrepllen=(codep[-1]>>5)&07;
j=emp-emlines;
if (emrepllen>j) {
assert(nemlines+emrepllen-j<MAXEMLINES);
for (i=nemlines;i>=0;i--)
emlines[i+emrepllen-j] = emlines[i];
nemlines += emrepllen-j;
emp += emrepllen-j;
}
emp -= emrepllen;
for (i=0;i<emrepllen;i++) {
getint(eminstr,codep);
getint(nodeno,codep);
emp[i].em_instr = eminstr;
result = compute(&enodes[nodeno]);
switch(result.e_typ) {
default:
assert(FALSE);
case 0:
emp[i].em_optyp = OPNO;
emp[i].em_soper = 0;
break;
case EV_INT:
emp[i].em_optyp = OPINT;
emp[i].em_soper = tostring(result.e_v.e_con);
emp[i].em_u.em_ioper = result.e_v.e_con;
break;
case EV_STR:
emp[i].em_optyp = OPSYMBOL;
emp[i].em_soper = result.e_v.e_str;
break;
}
}
if (!toplevel)
ply += emrepllen;
break;
case DO_COST:
DEBUG("COST");
getint(cost.c_size,codep);
getint(cost.c_time,codep);
totalcost += costcalc(cost);
CHKCOST();
break;
#ifdef REGVARS
case DO_PRETURN:
if (toplevel) {
swtxt();
regreturn(); /* in mach.c */
}
break;
#endif
case DO_RETURN:
DEBUG("RETURN");
assert(origcp!=startupcode);
doreturn:
#ifndef NDEBUG
level--;
#endif
return(totalcost);
}
}
}

View File

@@ -1,364 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "glosym.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#define LLEAF 01
#define LDEF 02
#define RLEAF 04
#define RDEF 010
#define LLDEF LLEAF|LDEF
#define RLDEF RLEAF|RDEF
char opdesc[] = {
0, /* EX_TOKFIELD */
0, /* EX_ARG */
0, /* EX_CON */
0, /* EX_ALLREG */
LLDEF|RLDEF, /* EX_SAMESIGN */
LLDEF|RLDEF, /* EX_SFIT */
LLDEF|RLDEF, /* EX_UFIT */
0, /* EX_ROM */
LLDEF|RLDEF, /* EX_NCPEQ */
LLDEF|RLDEF, /* EX_SCPEQ */
LLDEF|RLDEF, /* EX_RCPEQ */
LLDEF|RLDEF, /* EX_NCPNE */
LLDEF|RLDEF, /* EX_SCPNE */
LLDEF|RLDEF, /* EX_RCPNE */
LLDEF|RLDEF, /* EX_NCPGT */
LLDEF|RLDEF, /* EX_NCPGE */
LLDEF|RLDEF, /* EX_NCPLT */
LLDEF|RLDEF, /* EX_NCPLE */
LLDEF, /* EX_OR2 */
LLDEF, /* EX_AND2 */
LLDEF|RLDEF, /* EX_PLUS */
LLDEF|RLDEF, /* EX_CAT */
LLDEF|RLDEF, /* EX_MINUS */
LLDEF|RLDEF, /* EX_TIMES */
LLDEF|RLDEF, /* EX_DIVIDE */
LLDEF|RLDEF, /* EX_MOD */
LLDEF|RLDEF, /* EX_LSHIFT */
LLDEF|RLDEF, /* EX_RSHIFT */
LLDEF, /* EX_NOT */
LLDEF, /* EX_COMP */
0, /* EX_COST */
0, /* EX_STRING */
LLEAF, /* EX_DEFINED */
0, /* EX_SUBREG */
LLDEF, /* EX_TOSTRING */
LLDEF, /* EX_UMINUS */
0, /* EX_REG */
0, /* EX_LOWW */
0, /* EX_HIGHW */
LLDEF, /* EX_INREG */
LLDEF, /* EX_REGVAR */
};
string salloc(),strcpy(),strcat();
string mycat(s1,s2) string s1,s2; {
register string s;
s=salloc(strlen(s1)+strlen(s2));
strcpy(s,s1);
strcat(s,s2);
return(s);
}
string mystrcpy(s) string s; {
register string r;
r=salloc(strlen(s));
strcpy(r,s);
return(r);
}
char digstr[21][15];
string tostring(n) word n; {
char buf[25];
if (n>=-20 && n<=20 && (n&1)==0) {
if (digstr[(n>>1)+10][0]==0)
sprintf(digstr[(n>>1)+10],WRD_FMT,n);
return(digstr[(n>>1)+10]);
}
sprintf(buf,WRD_FMT,n);
return(mystrcpy(buf));
}
result_t undefres= {EV_UNDEF};
result_t compute(node) node_p node; {
result_t leaf1,leaf2,result;
token_p tp;
int desc;
long mask,tmp;
int i,tmpreg;
glosym_p gp;
desc=opdesc[node->ex_operator];
if (desc&LLEAF) {
leaf1 = compute(&enodes[node->ex_lnode]);
if (desc&LDEF && leaf1.e_typ==EV_UNDEF)
return(undefres);
}
if (desc&RLEAF) {
leaf2 = compute(&enodes[node->ex_rnode]);
if (desc&RDEF && leaf2.e_typ==EV_UNDEF)
return(undefres);
}
result.e_typ=EV_INT;
switch(node->ex_operator) {
default: assert(FALSE);
case EX_TOKFIELD:
if (node->ex_lnode!=0)
tp = &fakestack[stackheight-node->ex_lnode];
else
tp = curtoken;
switch(result.e_typ = tokens[tp->t_token].t_type[node->ex_rnode-1]) {
default:
assert(FALSE);
case EV_INT:
result.e_v.e_con = tp->t_att[node->ex_rnode-1].aw;
break;
case EV_STR:
result.e_v.e_str = tp->t_att[node->ex_rnode-1].as;
break;
case EV_REG:
result.e_v.e_reg = tp->t_att[node->ex_rnode-1].ar;
break;
}
return(result);
case EX_ARG:
return(dollar[node->ex_lnode-1]);
case EX_CON:
result.e_typ = EV_INT;
result.e_v.e_con = ((long) node->ex_rnode << 16) | ((long)node->ex_lnode&0xffff);
return(result);
case EX_REG:
result.e_typ = EV_REG;
result.e_v.e_reg = node->ex_lnode;
return(result);
case EX_ALLREG:
result.e_typ = EV_REG;
result.e_v.e_reg = allreg[node->ex_lnode-1];
#if MAXMEMBERS!=0
if (node->ex_rnode!=0)
result.e_v.e_reg = machregs[result.e_v.e_reg].
r_members[node->ex_rnode-1];
#endif
return(result);
case EX_SAMESIGN:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_typ = EV_INT;
if (leaf1.e_v.e_con>=0)
result.e_v.e_con= leaf2.e_v.e_con>=0;
else
result.e_v.e_con= leaf2.e_v.e_con<0;
return(result);
case EX_SFIT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
mask = 0xFFFFFFFFL;
for (i=0;i<leaf2.e_v.e_con-1;i++)
mask &= ~(1<<i);
tmp = leaf1.e_v.e_con&mask;
result.e_v.e_con = tmp==0||tmp==mask;
return(result);
case EX_UFIT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
mask = 0xFFFFFFFFL;
for (i=0;i<leaf2.e_v.e_con;i++)
mask &= ~(1<<i);
result.e_v.e_con = (leaf1.e_v.e_con&mask)==0;
return(result);
case EX_ROM:
assert(node->ex_rnode>=0 &&node->ex_rnode<MAXROM);
leaf2=dollar[node->ex_lnode];
if (leaf2.e_typ != EV_STR)
return(undefres);
gp = lookglo(leaf2.e_v.e_str);
if (gp == (glosym_p) 0)
return(undefres);
if ((gp->gl_rom[MAXROM]&(1<<node->ex_rnode))==0)
return(undefres);
result.e_v.e_con = gp->gl_rom[node->ex_rnode];
return(result);
case EX_LOWW:
result.e_v.e_con = saveemp[node->ex_lnode].em_u.em_loper&0xFFFF;
return(result);
case EX_HIGHW:
result.e_v.e_con = saveemp[node->ex_lnode].em_u.em_loper>>16;
return(result);
case EX_NCPEQ:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con==leaf2.e_v.e_con;
return(result);
case EX_SCPEQ:
assert(leaf1.e_typ == EV_STR && leaf2.e_typ == EV_STR);
result.e_v.e_con = !strcmp(leaf1.e_v.e_str,leaf2.e_v.e_str);
return(result);
case EX_RCPEQ:
assert(leaf1.e_typ == EV_REG && leaf2.e_typ == EV_REG);
result.e_v.e_con = leaf1.e_v.e_reg==leaf2.e_v.e_reg;
return(result);
case EX_NCPNE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con!=leaf2.e_v.e_con;
return(result);
case EX_SCPNE:
assert(leaf1.e_typ == EV_STR && leaf2.e_typ == EV_STR);
result.e_v.e_con = strcmp(leaf1.e_v.e_str,leaf2.e_v.e_str);
return(result);
case EX_RCPNE:
assert(leaf1.e_typ == EV_REG && leaf2.e_typ == EV_REG);
result.e_v.e_con = leaf1.e_v.e_reg!=leaf2.e_v.e_reg;
return(result);
case EX_NCPGT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con>leaf2.e_v.e_con;
return(result);
case EX_NCPGE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con>=leaf2.e_v.e_con;
return(result);
case EX_NCPLT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con<leaf2.e_v.e_con;
return(result);
case EX_NCPLE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con<=leaf2.e_v.e_con;
return(result);
case EX_OR2:
assert(leaf1.e_typ == EV_INT);
if (leaf1.e_v.e_con==0)
return(compute(&enodes[node->ex_rnode]));
return(leaf1);
case EX_AND2:
assert(leaf1.e_typ == EV_INT);
if (leaf1.e_v.e_con!=0)
return(compute(&enodes[node->ex_rnode]));
return(leaf1);
case EX_PLUS:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con=leaf1.e_v.e_con+leaf2.e_v.e_con;
return(result);
case EX_CAT:
assert(leaf1.e_typ == EV_STR && leaf2.e_typ == EV_STR);
result.e_typ = EV_STR;
result.e_v.e_str = mycat(leaf1.e_v.e_str,leaf2.e_v.e_str);
return(result);
case EX_MINUS:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con - leaf2.e_v.e_con;
return(result);
case EX_TIMES:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con * leaf2.e_v.e_con;
return(result);
case EX_DIVIDE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con / leaf2.e_v.e_con;
return(result);
case EX_MOD:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con % leaf2.e_v.e_con;
return(result);
case EX_LSHIFT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con << leaf2.e_v.e_con;
return(result);
case EX_RSHIFT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con >> leaf2.e_v.e_con;
return(result);
case EX_NOT:
assert(leaf1.e_typ == EV_INT);
result.e_v.e_con = !leaf1.e_v.e_con;
return(result);
case EX_COMP:
assert(leaf1.e_typ == EV_INT);
result.e_v.e_con = ~leaf1.e_v.e_con;
return(result);
case EX_COST:
if (node->ex_rnode==0)
return(compute(&enodes[tokens[node->ex_lnode].t_cost.c_size]));
else
return(compute(&enodes[tokens[node->ex_lnode].t_cost.c_time]));
case EX_STRING:
result.e_typ = EV_STR;
result.e_v.e_str = codestrings[node->ex_lnode];
return(result);
case EX_DEFINED:
result.e_v.e_con=leaf1.e_typ!=EV_UNDEF;
return(result);
case EX_SUBREG:
result.e_typ = EV_REG;
tp= &fakestack[stackheight-node->ex_lnode];
assert(tp->t_token == -1);
tmpreg= tp->t_att[0].ar;
#if MAXMEMBERS!=0
if (node->ex_rnode)
tmpreg=machregs[tmpreg].r_members[node->ex_rnode-1];
#endif
result.e_v.e_reg=tmpreg;
return(result);
case EX_TOSTRING:
assert(leaf1.e_typ == EV_INT);
result.e_typ = EV_STR;
result.e_v.e_str = tostring(leaf1.e_v.e_con);
return(result);
#ifdef REGVARS
case EX_INREG:
assert(leaf1.e_typ == EV_INT);
i = isregvar((long) leaf1.e_v.e_con);
if (i<0)
result.e_v.e_con = 0;
else if (i==0)
result.e_v.e_con = 1;
else
result.e_v.e_con = 2;
return(result);
case EX_REGVAR:
assert(leaf1.e_typ == EV_INT);
i = isregvar((long) leaf1.e_v.e_con);
if (i<=0)
return(undefres);
result.e_typ = EV_REG;
result.e_v.e_reg=i;
return(result);
#endif
case EX_UMINUS:
assert(leaf1.e_typ == EV_INT);
result.e_v.e_con = -leaf1.e_v.e_con;
return(result);
}
}

View File

@@ -1,54 +0,0 @@
/* $Header$ */
typedef struct {
int t_token; /* kind of token, -1 for register */
union {
word aw; /* integer type */
string as; /* string type */
int ar; /* register type */
} t_att[TOKENSIZE];
} token_t,*token_p;
struct reginfo {
int r_repr; /* index in string table */
int r_size; /* size in bytes */
#if MAXMEMBERS!=0
int r_members[MAXMEMBERS]; /* register contained within this reg */
short r_clash[REGSETSIZE]; /* set of clashing registers */
#endif
int r_refcount; /* Times in use */
token_t r_contents; /* Current contents */
int r_tcount; /* Temporary count difference */
};
#if MAXMEMBERS!=0
#define clash(a,b) ((machregs[a].r_clash[(b)>>4]&(1<<((b)&017)))!=0)
#else
#define clash(a,b) ((a)==(b))
#endif
typedef struct {
int t_size; /* size in bytes */
cost_t t_cost; /* cost in bytes and time */
byte t_type[TOKENSIZE]; /* types of attributes, TT_??? */
int t_format; /* index of formatstring */
} tkdef_t,*tkdef_p;
struct emline {
int em_instr;
int em_optyp;
string em_soper;
union {
word em_ioper;
long em_loper;
} em_u;
};
#define OPNO 0
#define OPINT 1
#define OPSYMBOL 2
typedef struct {
int rl_n; /* number in list */
int rl_list[NREGS];
} rl_t,*rl_p;

View File

@@ -1,105 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include "equiv.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
extern string myalloc();
int rar[MAXCREG];
rl_p *lar;
int maxindex;
int regclass[NREGS];
struct perm *perms;
struct perm *
tuples(regls,nregneeded) rl_p *regls; {
int class=0;
register i,j;
/*
* First compute equivalence classes of registers.
*/
for (i=0;i<NREGS;i++) {
regclass[i] = class++;
if (getrefcount(i) == 0) {
for (j=0;j<i;j++) {
if (eqregclass(i,j) &&
eqtoken(&machregs[i].r_contents,
&machregs[j].r_contents)) {
regclass[i] = regclass[j];
break;
}
}
}
}
/*
* Now create tuples through a recursive function
*/
maxindex = nregneeded;
lar = regls;
perms = 0;
permute(0);
return(perms);
}
permute(index) {
register struct perm *pp;
register rl_p rlp;
register i,j;
if (index == maxindex) {
for (pp=perms; pp != 0; pp=pp->p_next) {
for (i=0; i<maxindex; i++)
if (regclass[rar[i]] != regclass[pp->p_rar[i]])
goto diff;
for (i=0; i<maxindex; i++)
for (j=0; j<i; j++)
if (clash(rar[i],rar[j]) !=
clash(pp->p_rar[i],pp->p_rar[j]))
goto diff;
return;
diff: ;
}
pp = (struct perm *) myalloc(sizeof ( *pp ));
pp->p_next = perms;
for (i=0; i<maxindex; i++)
pp->p_rar[i] = rar[i];
perms = pp;
} else {
rlp=lar[index];
for (i=rlp->rl_n-1; i>=0; i--) {
rar[index] = rlp->rl_list[i];
permute(index+1);
}
}
}

View File

@@ -1,8 +0,0 @@
/* $Header$ */
#define MAXCREG 4
struct perm {
struct perm *p_next;
int p_rar[MAXCREG];
};

View File

@@ -1,49 +0,0 @@
/* $Header$ */
extern int maxply; /* amount of lookahead allowed */
extern int stackheight; /* # of tokens on fakestack */
extern token_t fakestack[]; /* fakestack itself */
extern int nallreg; /* number of allocated registers */
extern int allreg[]; /* array of allocated registers */
extern token_p curtoken; /* pointer to current token */
extern result_t dollar[]; /* Values of $1,$2 etc.. */
extern int nemlines; /* # of EM instructions in core */
extern struct emline emlines[]; /* EM instructions itself */
extern struct emline *emp; /* pointer to current instr */
extern struct emline *saveemp; /* pointer to start of pattern */
extern int tokpatlen; /* length of current stackpattern */
extern rl_p curreglist; /* side effect of findcoerc() */
#ifndef NDEBUG
extern int Debug; /* on/off debug printout */
#endif
/*
* Next descriptions are external declarations for tables created
* by bootgram.
* All definitions are to be found in tables.c (Not for humans)
*/
extern byte coderules[]; /* pseudo code for cg itself */
extern char stregclass[]; /* static register class */
extern struct reginfo machregs[]; /* register info */
extern tkdef_t tokens[]; /* token info */
extern node_t enodes[]; /* expression nodes */
extern string codestrings[]; /* table of strings */
extern set_t machsets[]; /* token expression table */
extern inst_t tokeninstances[]; /* token instance description table */
extern move_t moves[]; /* move descriptors */
extern byte pattern[]; /* EM patterns */
extern int pathash[256]; /* Indices into previous */
extern c1_t c1coercs[]; /* coercions type 1 */
#ifdef MAXSPLIT
extern c2_t c2coercs[]; /* coercions type 2 */
#endif MAXSPLIT
extern c3_t c3coercs[]; /* coercions type 3 */
extern struct reginfo **reglist[]; /* lists of registers per property */
#define eqregclass(r1,r2) (stregclass[r1]==stregclass[r2])
#ifdef REGVARS
extern int nregvar[]; /* # of register variables per type */
extern int *rvnumbers[]; /* lists of numbers */
#endif

View File

@@ -1,644 +0,0 @@
#ifndef NORCSID
static char rcsid2[] = "$Header$";
#endif
#include <stdio.h>
#include "assert.h"
#include <em_spec.h>
#include <em_pseu.h>
#include <em_flag.h>
#include <em_ptyp.h>
#include <em_mes.h>
#include "mach.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#ifdef REGVARS
#include "regvar.h"
#include <em_reg.h>
#endif
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
/* segment types for switchseg() */
#define SEGTXT 0
#define SEGCON 1
#define SEGROM 2
#define SEGBSS 3
long con();
#define get8() getc(emfile)
#define MAXSTR 256
FILE *emfile;
extern FILE *codefile;
int nextispseu,savetab1;
int opcode;
int offtyp;
long argval;
int dlbval;
char str[MAXSTR],argstr[32],labstr[32];
int strsiz;
int holno=0;
int procno=0;
int curseg= -1;
int part_size=0;
word part_word=0;
int endofprog=0;
#ifdef REGVARS
int regallowed=0;
#endif
extern char em_flag[];
extern short em_ptyp[];
extern long atol();
extern double atof();
#define sp_cstx sp_cst2
string tostring();
string holstr();
string strarg();
string mystrcpy();
long get32();
in_init(filename) char *filename; {
if ((emfile=freopen(filename,"r",stdin))==NULL)
error("Can't open %s",filename);
if (get16()!=sp_magic)
error("Bad format %s",filename);
}
in_finish() {
}
fillemlines() {
int t,i;
register struct emline *lp;
while ((emlines+nemlines)-emp<MAXEMLINES-5) {
assert(nemlines<MAXEMLINES);
if (nextispseu) {
emlines[nemlines].em_instr=0;
return;
}
lp = &emlines[nemlines++];
switch(t=table1()) {
default:
error("unknown instruction byte");
case sp_ilb1:
case sp_ilb2:
case sp_fpseu:
case sp_dlb1:
case sp_dlb2:
case sp_dnam:
nextispseu=1; savetab1=t;
nemlines--;
lp->em_instr = 0;
return;
case EOF:
nextispseu=1; savetab1=t;
endofprog=1;
nemlines--;
lp->em_instr = 0;
return;
case sp_fmnem:
lp->em_instr = opcode;
break;
}
i=em_flag[lp->em_instr-sp_fmnem] & EM_PAR;
if ( i == PAR_NO ) {
lp->em_optyp = OPNO;
lp->em_soper = 0;
continue;
}
t= em_ptyp[i];
t= getarg(t);
switch(i) {
case PAR_L:
assert(t == sp_cstx);
if (argval >= 0)
argval += EM_BSIZE;
lp->em_optyp = OPINT;
lp->em_u.em_ioper = argval;
lp->em_soper = tostring((word) argval);
continue;
case PAR_G:
if (t != sp_cstx)
break;
lp->em_optyp = OPSYMBOL;
lp->em_soper = holstr((word) argval);
continue;
case PAR_B:
t = sp_ilb2;
break;
case PAR_D:
assert(t == sp_cstx);
lp->em_optyp = OPSYMBOL;
lp->em_soper = strarg(t);
lp->em_u.em_loper = argval;
continue;
}
lp->em_soper = strarg(t);
if (t==sp_cend)
lp->em_optyp = OPNO;
else if (t==sp_cstx) {
lp->em_optyp = OPINT;
lp->em_u.em_ioper = argval;
} else
lp->em_optyp = OPSYMBOL;
}
}
dopseudo() {
register b,t;
register full n;
register long save;
word romcont[MAXROM+1];
int nromwords;
int rombit,rommask;
unsigned dummy,stackupto();
if (nextispseu==0 || nemlines>0)
error("No table entry for %d",emlines[0].em_instr);
nextispseu=0;
switch(savetab1) {
case sp_ilb1:
case sp_ilb2:
swtxt();
dummy = stackupto(&fakestack[stackheight-1],maxply,TRUE);
cleanregs();
strarg(savetab1);
newilb(argstr);
return;
case sp_dlb1:
case sp_dlb2:
case sp_dnam:
strarg(savetab1);
savelab();
return;
case sp_fpseu:
break;
case EOF:
swtxt();
popstr(0);
tstoutput();
exit(0);
default:
error("Unknown opcode %d",savetab1);
}
switch (opcode) {
case ps_hol:
sprintf(labstr,hol_fmt,++holno);
case ps_bss:
getarg(cst_ptyp);
n = (full) argval;
t = getarg(val_ptyp);
save = argval;
getarg(cst_ptyp);
b = (int) argval;
argval = save;
bss(n,t,b);
break;
case ps_con:
switchseg(SEGCON);
dumplab();
con(getarg(val_ptyp));
while ((t = getarg(any_ptyp)) != sp_cend)
con(t);
break;
case ps_rom:
switchseg(SEGROM);
xdumplab();
nromwords=0;
rommask=0;
rombit=1;
t=getarg(val_ptyp);
while (t!=sp_cend) {
if (t==sp_cstx && nromwords<MAXROM) {
romcont[nromwords] = (word) argval;
rommask |= rombit;
}
nromwords++;
rombit <<= 1;
con(t);
t=getarg(any_ptyp);
}
if (rommask != 0) {
romcont[MAXROM]=rommask;
enterglo(labstr,romcont);
}
labstr[0]=0;
break;
case ps_mes:
getarg(ptyp(sp_cst2));
if (argval == ms_emx) {
getarg(ptyp(sp_cst2));
if (argval != EM_WSIZE)
fatal("bad word size");
getarg(ptyp(sp_cst2));
if (argval != EM_PSIZE)
fatal("bad pointer size");
if ( getarg(any_ptyp)!=sp_cend )
fatal("too many parameters");
#ifdef REGVARS
} else if (argval == ms_gto) {
getarg(ptyp(sp_cend));
if (!regallowed)
error("mes 3 not allowed here");
fixregvars(TRUE);
regallowed=0;
} else if (argval == ms_reg) {
long r_off;
int r_size,r_type,r_score;
struct regvar *linkreg();
if (!regallowed)
error("mes 3 not allowed here");
if(getarg(ptyp(sp_cst2)|ptyp(sp_cend)) == sp_cend) {
fixregvars(FALSE);
regallowed=0;
} else {
r_off = argval;
#ifdef EM_BSIZE
if (r_off >= 0)
r_off += EM_BSIZE;
#endif
getarg(ptyp(sp_cst2));
r_size = argval;
getarg(ptyp(sp_cst2));
r_type = argval;
if (r_type<reg_any || r_type>reg_float)
fatal("Bad type in register message");
if(getarg(ptyp(sp_cst2)|ptyp(sp_cend)) == sp_cend)
r_score = 0;
else {
r_score = argval;
if ( getarg(any_ptyp)!=sp_cend )
fatal("too many parameters");
}
tryreg(linkreg(r_off,r_size,r_type,r_score),r_type);
}
#endif
} else
mes((word)argval);
break;
case ps_exa:
strarg(getarg(sym_ptyp));
ex_ap(argstr);
break;
case ps_ina:
strarg(getarg(sym_ptyp));
in_ap(argstr);
break;
case ps_exp:
strarg(getarg(ptyp(sp_pnam)));
ex_ap(argstr);
break;
case ps_inp:
strarg(getarg(ptyp(sp_pnam)));
in_ap(argstr);
break;
case ps_pro:
switchseg(SEGTXT);
procno++;
strarg(getarg(ptyp(sp_pnam)));
newilb(argstr);
getarg(cst_ptyp);
prolog((full)argval);
#ifdef REGVARS
regallowed++;
#endif
break;
case ps_end:
getarg(cst_ptyp | ptyp(sp_cend));
cleanregs();
#ifdef REGVARS
unlinkregs();
#endif
tstoutput();
break;
default:
error("No table entry for %d",savetab1);
}
}
/* ----- input ----- */
int getarg(typset) {
register t,argtyp;
argtyp = t = table2();
if (t == EOF)
fatal("unexpected EOF");
t -= sp_fspec;
t = 1 << t;
if ((typset & t) == 0)
error("bad argument type %d",argtyp);
return(argtyp);
}
int table1() {
register i;
i = get8();
if (i < sp_fmnem+sp_nmnem && i >= sp_fmnem) {
opcode = i;
return(sp_fmnem);
}
if (i < sp_fpseu+sp_npseu && i >= sp_fpseu) {
opcode = i;
return(sp_fpseu);
}
if (i < sp_filb0+sp_nilb0 && i >= sp_filb0) {
argval = i - sp_filb0;
return(sp_ilb2);
}
return(table3(i));
}
int table2() {
register i;
i = get8();
if (i < sp_fcst0+sp_ncst0 && i >= sp_fcst0) {
argval = i - sp_zcst0;
return(sp_cstx);
}
return(table3(i));
}
int table3(i) {
word consiz;
switch(i) {
case sp_ilb1:
argval = get8();
break;
case sp_dlb1:
dlbval = get8();
break;
case sp_dlb2:
dlbval = get16();
break;
case sp_cst2:
i = sp_cstx;
case sp_ilb2:
argval = get16();
break;
case sp_cst4:
i = sp_cstx;
argval = get32();
break;
case sp_dnam:
case sp_pnam:
case sp_scon:
getstring();
break;
case sp_doff:
offtyp = getarg(sym_ptyp);
getarg(cst_ptyp);
break;
case sp_icon:
case sp_ucon:
case sp_fcon:
getarg(cst_ptyp);
consiz = (word) argval;
getstring();
argval = consiz;
break;
}
return(i);
}
int get16() {
register int l_byte, h_byte;
l_byte = get8();
h_byte = get8();
if ( h_byte>=128 ) h_byte -= 256 ;
return l_byte | (h_byte*256) ;
}
long get32() {
register long l;
register int h_byte;
l = get8();
l |= ((unsigned) get8())*256 ;
l |= get8()*256L*256L ;
h_byte = get8() ;
if ( h_byte>=128 ) h_byte -= 256 ;
return l | (h_byte*256L*256*256L) ;
}
getstring() {
register char *p;
register n;
getarg(cst_ptyp);
if (argval < 0 || argval > MAXSTR-1)
fatal("string/identifier too long");
strsiz = n = (int) argval;
p = str;
while (--n >= 0)
*p++ = get8();
*p++ = '\0';
}
char *strarg(t) {
register char *p;
switch (t) {
case sp_ilb1:
case sp_ilb2:
sprintf(argstr,ilb_fmt,procno,(int)argval);
break;
case sp_dlb1:
case sp_dlb2:
sprintf(argstr,dlb_fmt,dlbval);
break;
case sp_cstx:
sprintf(argstr,cst_fmt,(full)argval);
break;
case sp_dnam:
case sp_pnam:
p = argstr;
if (strsiz < 8 || str[0] == id_first)
*p++ = id_first;
sprintf(p,"%.*s",strsiz,str);
break;
case sp_doff:
strarg(offtyp);
for (p = argstr; *p; p++)
;
if (argval >= 0)
*p++ = '+';
sprintf(p,off_fmt,(full)argval);
break;
case sp_cend:
return("");
}
return(mystrcpy(argstr));
}
bss(n,t,b) full n; {
register long s;
if (n % EM_WSIZE)
fatal("bad BSS size");
if (b==0
#ifdef BSS_INIT
|| (t==sp_cstx && argval==BSS_INIT)
#endif BSS_INIT
) {
switchseg(SEGBSS);
newlbss(labstr,n);
labstr[0]=0;
return;
}
switchseg(SEGCON);
dumplab();
while (n > 0)
n -= (s = con(t));
if (s % EM_WSIZE)
fatal("bad BSS initializer");
}
long con(t) {
register i;
strarg(t);
switch (t) {
case sp_ilb1:
case sp_ilb2:
case sp_pnam:
part_flush();
con_ilb(argstr);
return((long)EM_PSIZE);
case sp_dlb1:
case sp_dlb2:
case sp_dnam:
case sp_doff:
part_flush();
con_dlb(argstr);
return((long)EM_PSIZE);
case sp_cstx:
con_part(EM_WSIZE,(word)argval);
return((long)EM_WSIZE);
case sp_scon:
for (i = 0; i < strsiz; i++)
con_part(1,(word) str[i]);
return((long)strsiz);
case sp_icon:
case sp_ucon:
if (argval > EM_WSIZE) {
part_flush();
con_mult((word)argval);
} else {
con_part((int)argval,(word)atol(str));
}
return(argval);
case sp_fcon:
part_flush();
con_float();
return(argval);
}
assert(FALSE);
/* NOTREACHED */
}
extern char *segname[];
swtxt() {
switchseg(SEGTXT);
}
switchseg(s) {
if (s == curseg)
return;
part_flush();
if ((curseg = s) >= 0)
fprintf(codefile,"%s\n",segname[s]);
}
savelab() {
register char *p,*q;
part_flush();
if (labstr[0]) {
dlbdlb(argstr,labstr);
return;
}
p = argstr;
q = labstr;
while (*q++ = *p++)
;
}
dumplab() {
if (labstr[0] == 0)
return;
assert(part_size == 0);
newdlb(labstr);
labstr[0] = 0;
}
xdumplab() {
if (labstr[0] == 0)
return;
assert(part_size == 0);
newdlb(labstr);
}
part_flush() {
/*
* Each new data fragment and each data label starts at
* a new target machine word
*/
if (part_size == 0)
return;
con_cst(part_word);
part_size = 0;
part_word = 0;
}
string holstr(n) word n; {
sprintf(str,hol_off,n,holno);
return(mystrcpy(str));
}
/* ----- machine dependent routines ----- */
#include "mach.c"

View File

@@ -1,194 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include <stdio.h>
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
FILE *codefile;
out_init(filename) char *filename; {
#ifndef NDEBUG
static char stderrbuff[512];
if (Debug) {
codefile = stderr;
if (!isatty(2))
setbuf(stderr,stderrbuff);
} else {
#endif
if (filename == (char *) 0)
codefile = stdout;
else
if ((codefile=freopen(filename,"w",stdout))==NULL)
error("Can't create %s",filename);
#ifndef NDEBUG
}
#endif
}
out_finish() {
#ifndef NDEBUG
if (Debug)
fflush(stderr);
else
#endif
fclose(codefile);
}
tstoutput() {
if (ferror(codefile))
error("Write error on output");
}
gencode(code) register char *code; {
register c;
int tokno,fldno,insno,regno,subno;
register token_p tp;
swtxt();
while ((c= *code++)!=0) switch(c) {
default:
fputc(c,codefile);
break;
case PR_TOK:
tokno = *code++;
tp = &fakestack[stackheight-tokno];
if (tp->t_token==-1)
fprintf(codefile,"%s",codestrings[machregs[tp->t_att[0].ar].r_repr]);
else
prtoken(tp);
break;
case PR_TOKFLD:
tokno = *code++;
fldno = *code++;
tp = &fakestack[stackheight-tokno];
assert(tp->t_token != -1);
switch(tokens[tp->t_token].t_type[fldno-1]) {
default:
assert(FALSE);
case EV_INT:
fprintf(codefile,WRD_FMT,tp->t_att[fldno-1].aw);
break;
case EV_STR:
fprintf(codefile,"%s",tp->t_att[fldno-1].as);
break;
case EV_REG:
assert(tp->t_att[fldno-1].ar>0 && tp->t_att[fldno-1].ar<NREGS);
fprintf(codefile,"%s",codestrings[machregs[tp->t_att[fldno-1].ar].r_repr]);
break;
}
break;
case PR_EMINT:
insno = *code++;
fprintf(codefile,WRD_FMT,dollar[insno-1].e_v.e_con);
break;
case PR_EMSTR:
insno = *code++;
fprintf(codefile,"%s",dollar[insno-1].e_v.e_str);
break;
case PR_ALLREG:
regno = *code++;
subno = (*code++)&0377;
assert(regno>=1 && regno<=nallreg);
regno = allreg[regno-1];
#if MAXMEMBERS!=0
if (subno!=255) {
assert(subno>=1 && subno<=MAXMEMBERS);
regno = machregs[regno].r_members[subno-1];
assert(regno!=0);
}
#endif
fprintf(codefile,"%s",codestrings[machregs[regno].r_repr]);
break;
#if MAXMEMBERS!=0
case PR_SUBREG:
tokno = *code++;
subno = *code++;
tp = &fakestack[stackheight-tokno];
assert(tp->t_token == -1);
fprintf(codefile,"%s",codestrings[machregs[machregs[tp->t_att[0].ar].r_members[subno-1]].r_repr]);
break;
#endif
}
}
genexpr(nodeno) {
result_t result;
result= compute(&enodes[nodeno]);
switch(result.e_typ) {
default: assert(FALSE);
case EV_INT:
fprintf(codefile,WRD_FMT,result.e_v.e_con);
break;
case EV_REG:
fprintf(codefile,"%s", codestrings[machregs[result.e_v.e_reg].r_repr]);
break;
case EV_STR:
fprintf(codefile,"%s",result.e_v.e_str);
break;
}
}
gennl() {
fputc('\n',codefile);
}
prtoken(tp) token_p tp; {
register c;
register char *code;
register tkdef_p tdp;
tdp = &tokens[tp->t_token];
assert(tdp->t_format != -1);
code = codestrings[tdp->t_format];
while ((c = *code++) != 0) {
if (c>=' ' && c<='~')
fputc(c,codefile);
else {
assert(c>0 && c<=TOKENSIZE);
switch(tdp->t_type[c-1]) {
default:
assert(FALSE);
case EV_INT:
fprintf(codefile,WRD_FMT,tp->t_att[c-1].aw);
break;
case EV_STR:
fprintf(codefile,"%s",tp->t_att[c-1].as);
break;
case EV_REG:
fprintf(codefile,"%s",codestrings[machregs[tp->t_att[c-1].ar].r_repr]);
break;
}
}
}
}

View File

@@ -1,52 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "tables.h"
#include "types.h"
#include "glosym.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
extern string myalloc();
glosym_p glolist= (glosym_p) 0;
enterglo(name,romp) string name; word *romp; {
register glosym_p gp;
register i;
gp = (glosym_p) myalloc(sizeof *gp);
gp->gl_next = glolist;
gp->gl_name = (string) myalloc(strlen(name)+1);
strcpy(gp->gl_name,name);
for (i=0;i<=MAXROM;i++)
gp->gl_rom[i] = romp[i];
glolist = gp;
}
glosym_p lookglo(name) string name; {
register glosym_p gp;
for (gp=glolist;gp != (glosym_p) 0; gp=gp->gl_next)
if (strcmp(gp->gl_name,name)==0)
return(gp);
return((glosym_p) 0);
}

View File

@@ -1,9 +0,0 @@
/* $Header$ */
typedef struct glosym {
struct glosym *gl_next;
string gl_name;
word gl_rom[MAXROM+1];
} glosym_t,*glosym_p;
glosym_p lookglo();

View File

@@ -1,84 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
char *progname;
extern char startupcode[];
int maxply=1;
#ifndef NDEBUG
int Debug=0;
#endif
extern int endofprog;
main(argc,argv) char **argv; {
register unsigned n;
extern unsigned cc1,cc2,cc3,cc4;
unsigned ggd();
progname = argv[0];
while (--argc && **++argv == '-') {
switch(argv[0][1]) {
#ifndef NDEBUG
case 'd':
Debug=1; break;
#endif
case 'p':
maxply = atoi(argv[0]+2);
break;
case 'w': /* weight percentage for size */
n=atoi(argv[0]+2);
cc1 *= n;
cc2 *= 50;
cc3 *= (100-n);
cc4 *= 50;
n=ggd(cc1,cc2);
cc1 /= n;
cc2 /= n;
n=ggd(cc3,cc4);
cc3 /= n;
cc4 /= n;
break;
default:
error("Unknown flag %c",argv[0][1]);
}
}
if (argc < 1 || argc > 2)
error("Usage: %s EMfile [ asfile ]",progname);
in_init(argv[0]);
out_init(argv[1]);
codegen(startupcode,maxply,TRUE,MAXINT,0);
in_finish();
if (!endofprog)
error("Bombed out of codegen");
out_finish();
}
unsigned ggd(a,b) register unsigned a,b; {
register unsigned c;
do {
c = a%b; a=b; b=c;
} while (c!=0);
return(a);
}

View File

@@ -1,110 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
unsigned costcalc();
move(tp1,tp2,ply,toplevel,maxcost) token_p tp1,tp2; unsigned maxcost; {
register move_p mp;
register unsigned t;
register struct reginfo *rp;
tkdef_p tdp;
int i;
unsigned codegen();
if (eqtoken(tp1,tp2))
return(0);
if (tp2->t_token == -1) {
if (tp1->t_token == -1) {
if (eqtoken(&machregs[tp1->t_att[0].ar].r_contents,
&machregs[tp2->t_att[0].ar].r_contents) &&
machregs[tp1->t_att[0].ar].r_contents.t_token!=0)
return(0);
if (tp1->t_att[0].ar!=1) { /* COCO reg; tmp kludge */
erasereg(tp2->t_att[0].ar);
machregs[tp2->t_att[0].ar].r_contents =
machregs[tp1->t_att[0].ar].r_contents ;
} else
machregs[tp1->t_att[0].ar].r_contents =
machregs[tp2->t_att[0].ar].r_contents ;
} else {
if (eqtoken(&machregs[tp2->t_att[0].ar].r_contents,tp1))
return(0);
machregs[tp2->t_att[0].ar].r_contents = *tp1;
}
for (rp=machregs;rp<machregs+NREGS;rp++) {
if (rp->r_contents.t_token == 0)
continue;
assert(rp->r_contents.t_token > 0);
tdp = &tokens[rp->r_contents.t_token];
for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i] == EV_REG &&
clash(rp->r_contents.t_att[i].ar,tp2->t_att[0].ar)) {
erasereg(rp-machregs);
break;
}
}
} else if (tp1->t_token == -1) {
if (eqtoken(tp2,&machregs[tp1->t_att[0].ar].r_contents))
return(0);
machregs[tp1->t_att[0].ar].r_contents = *tp2;
}
/*
* If we arrive here the move must really be executed
*/
for (mp=moves;mp<moves+NMOVES;mp++) {
if (!match(tp1,&machsets[mp->m_set1],mp->m_expr1))
continue;
if (match(tp2,&machsets[mp->m_set2],mp->m_expr2))
break;
/*
* Correct move rule is found
*/
}
assert(mp<moves+NMOVES);
/*
* To get correct interpretation of things like %[1]
* in move code we stack tp2 and tp1. This little trick
* saves a lot of testing in other places.
*/
if (mp->m_cindex!=0) {
fakestack[stackheight] = *tp2;
fakestack[stackheight+1] = *tp1;
stackheight += 2;
t = codegen(&coderules[mp->m_cindex],ply,toplevel,maxcost,0);
if (t <= maxcost)
t += costcalc(mp->m_cost);
stackheight -= 2;
} else {
t = 0;
}
return(t);
}

View File

@@ -1,131 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include <em_spec.h>
#include <em_flag.h>
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#ifndef NDEBUG
#include <stdio.h>
extern char em_mnem[][4];
#endif
byte *trypat(bp,len) register byte *bp; {
register patlen,i;
result_t result;
getint(patlen,bp);
if (len == 3) {
if (patlen < 3)
return(0);
} else {
if (patlen != len)
return(0);
}
for(i=0;i<patlen;i++)
if (emp[i].em_instr != (*bp++&BMASK))
return(0);
for (i=0;i<patlen;i++)
if (emp[i].em_optyp==OPNO)
dollar[i].e_typ=EV_UNDEF;
else if ((dollar[i].e_typ=argtyp(emp[i].em_instr))==EV_INT)
dollar[i].e_v.e_con=emp[i].em_u.em_ioper;
else
dollar[i].e_v.e_str=emp[i].em_soper;
getint(i,bp);
if (i!=0) {
result = compute(&enodes[i]);
if (result.e_typ != EV_INT || result.e_v.e_con == 0)
return(0);
}
#ifndef NDEBUG
if (Debug) {
fprintf(stderr,"Matched:");
for (i=0;i<patlen;i++)
fprintf(stderr," %3.3s",em_mnem[emp[i].em_instr-sp_fmnem]);
fprintf(stderr,"\n");
}
#endif
saveemp = emp;
emp += patlen;
return(bp);
}
extern char em_flag[];
argtyp(mn) {
switch(em_flag[mn-sp_fmnem]&EM_PAR) {
case PAR_W:
case PAR_S:
case PAR_Z:
case PAR_O:
case PAR_N:
case PAR_L:
case PAR_F:
case PAR_R:
case PAR_C:
return(EV_INT);
default:
return(EV_STR);
}
}
byte *nextem(toplevel) {
register i;
short hash[3];
register byte *bp;
byte *cp;
int index;
register struct emline *ep;
if (toplevel) {
if (nemlines && emp>emlines) {
nemlines -= emp-emlines;
for (i=0,ep=emlines;i<nemlines;i++)
*ep++ = *emp++;
emp=emlines;
}
fillemlines();
}
hash[0] = emp[0].em_instr;
hash[1] = (hash[0]<<4) ^ emp[1].em_instr;
hash[2] = (hash[1]<<4) ^ emp[2].em_instr;
for (i=2;i>=0;i--) {
index = pathash[hash[i]&BMASK];
while (index != 0) {
bp = &pattern[index];
if ( bp[PO_HASH] == (hash[i]>>8))
if ((cp=trypat(&bp[PO_MATCH],i+1)) != 0)
return(cp);
index = (bp[PO_NEXT]&BMASK) | (bp[PO_NEXT+1]<<8);
}
}
return(0);
}

View File

@@ -1,19 +0,0 @@
/* $Header$ */
#define BMASK 0377
#define BSHIFT 8
#define TRUE 1
#define FALSE 0
#define MAXINT 32767
#define INFINITY (MAXINT+100)
#define MAXROM 3
/*
* Tunable constants
*/
#define MAXEMLINES 20
#define MAXFSTACK 20

View File

@@ -1,175 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
chrefcount(regno,amount,tflag) {
register struct reginfo *rp;
register i;
rp= &machregs[regno];
#if MAXMEMBERS!=0
if (rp->r_members[0]==0) {
#endif
rp->r_refcount += amount;
if (tflag)
rp->r_tcount += amount;
assert(rp->r_refcount >= 0);
#if MAXMEMBERS!=0
} else
for (i=0;i<MAXMEMBERS;i++)
if (rp->r_members[i]!=0)
chrefcount(rp->r_members[i],amount,tflag);
#endif
}
getrefcount(regno) {
register struct reginfo *rp;
register i,maxcount;
rp= &machregs[regno];
#if MAXMEMBERS!=0
if (rp->r_members[0]==0)
#endif
return(rp->r_refcount);
#if MAXMEMBERS!=0
else {
maxcount=0;
for (i=0;i<MAXMEMBERS;i++)
if (rp->r_members[i]!=0)
maxcount=max(maxcount,getrefcount(rp->r_members[i]));
return(maxcount);
}
#endif
}
erasereg(regno) {
register struct reginfo *rp;
#if MAXMEMBERS==0
awayreg(regno);
#else
for (rp=machregs;rp<machregs+NREGS;rp++)
if (rp->r_clash[regno>>4]&(1<<(regno&017)))
awayreg(rp-machregs);
#endif
}
awayreg(regno) {
register struct reginfo *rp;
register tkdef_p tdp;
register i;
rp = &machregs[regno];
rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++)
rp->r_contents.t_att[i].aw = 0;
/* Now erase recursively all registers containing
* something using this one
*/
for (rp=machregs;rp<machregs+NREGS;rp++) {
if (rp->r_contents.t_token == -1) {
if (rp->r_contents.t_att[0].ar == regno)
erasereg(rp-machregs);
} else {
tdp= & tokens[rp->r_contents.t_token];
for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i] == EV_REG &&
rp->r_contents.t_att[i].ar == regno) {
erasereg(rp-machregs);
break;
}
}
}
}
cleanregs() {
register struct reginfo *rp;
register i;
for (rp=machregs;rp<machregs+NREGS;rp++) {
rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++)
rp->r_contents.t_att[i].aw = 0;
}
}
#ifndef NDEBUG
inctcount(regno) {
register struct reginfo *rp;
register i;
rp = &machregs[regno];
#if MAXMEMBERS!=0
if (rp->r_members[0] == 0) {
#endif
rp->r_tcount++;
#if MAXMEMBERS!=0
} else {
for (i=0;i<MAXMEMBERS;i++)
if (rp->r_members[i] != 0)
inctcount(rp->r_members[i]);
}
#endif
}
chkregs() {
register struct reginfo *rp;
register token_p tp;
register tkdef_p tdp;
int i;
for (rp=machregs;rp<machregs+NREGS;rp++) {
assert(rp->r_tcount==0);
}
for (tp=fakestack;tp<fakestack+stackheight;tp++) {
if (tp->t_token == -1)
inctcount(tp->t_att[0].ar);
else {
tdp = &tokens[tp->t_token];
for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i]==EV_REG)
inctcount(tp->t_att[i].ar);
}
}
#ifdef REGVARS
#include <em_reg.h>
for(i=reg_any;i<=reg_float;i++) {
int j;
for(j=0;j<nregvar[i];j++)
inctcount(rvnumbers[i][j]);
}
#endif REGVARS
for (rp=machregs;rp<machregs+NREGS;rp++) {
assert(rp->r_refcount==rp->r_tcount);
rp->r_tcount=0;
}
}
#endif

View File

@@ -1,151 +0,0 @@
#include "assert.h"
#include "param.h"
#include "tables.h"
#ifdef REGVARS
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "regvar.h"
#include <em_reg.h>
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
struct regvar *rvlist;
struct regvar *
linkreg(of,sz,tp,sc) long of; {
struct regvar *rvlp;
rvlp= (struct regvar *) myalloc(sizeof *rvlp);
rvlp->rv_next = rvlist;
rvlist=rvlp;
rvlp->rv_off = of;
rvlp->rv_size = sz;
rvlp->rv_type = tp;
rvlp->rv_score = sc;
rvlp->rv_reg = 0; /* no register assigned yet */
return(rvlp);
}
tryreg(rvlp,typ) struct regvar *rvlp; {
int score;
register i;
struct regassigned *ra;
struct regvar *save;
if (typ != reg_any && nregvar[typ]!=0) {
if (machregs[rvnumbers[typ][0]].r_size!=rvlp->rv_size)
score = -1;
else
score = regscore(rvlp->rv_off,
rvlp->rv_size,
rvlp->rv_type,
rvlp->rv_score,
typ); /* machine dependent */
ra = regassigned[typ];
if (score>ra[nregvar[typ]-1].ra_score) {
save = ra[nregvar[typ]-1].ra_rv;
for (i=nregvar[typ]-1;i>0 && ra[i-1].ra_score<score;i--)
ra[i] = ra[i-1];
ra[i].ra_rv = rvlp;
ra[i].ra_score = score;
if((rvlp=save)==0)
return;
}
}
if (nregvar[reg_any]==0)
return;
if (machregs[rvnumbers[reg_any][0]].r_size!=rvlp->rv_size)
score = -1;
else
score = regscore(rvlp->rv_off,
rvlp->rv_size,
rvlp->rv_type,
rvlp->rv_score,
reg_any); /* machine dependent */
ra = regassigned[reg_any];
if (score>ra[nregvar[reg_any]-1].ra_score) {
for (i=nregvar[reg_any]-1;i>0 && ra[i-1].ra_score<score;i--)
ra[i] = ra[i-1];
ra[i].ra_rv = rvlp;
ra[i].ra_score = score;
}
}
fixregvars(saveall) {
register struct regvar *rv;
register rvtyp,i;
swtxt();
i_regsave(); /* machine dependent initialization */
for (rvtyp=reg_any;rvtyp<=reg_float;rvtyp++) {
for(i=0;i<nregvar[rvtyp];i++)
if (saveall) {
struct reginfo *rp;
rp= &machregs[rvnumbers[rvtyp][i]];
regsave(codestrings[rp->r_repr],-EM_WSIZE,rp->r_size);
} else if(regassigned[rvtyp][i].ra_score>0) {
rv=regassigned[rvtyp][i].ra_rv;
rv->rv_reg=rvnumbers[rvtyp][i];
regsave(codestrings[machregs[rv->rv_reg].r_repr],
rv->rv_off,rv->rv_size);
}
}
f_regsave();
#ifndef EM_BSIZE
for(rv=rvlist;rv!=0;rv=rv->rv_next)
if (rv->rv_off >= 0) rv->rv_off += EM_BSIZE;
#endif
}
isregvar(off) long off; {
register struct regvar *rvlp;
for(rvlp=rvlist;rvlp!=0;rvlp=rvlp->rv_next)
if(rvlp->rv_off == off)
return(rvlp->rv_reg);
return(-1);
}
unlinkregs() {
register struct regvar *rvlp,*t;
register struct regassigned *ra;
int rvtyp,i;
for(rvlp=rvlist;rvlp!=0;rvlp=t) {
t=rvlp->rv_next;
myfree(rvlp);
}
rvlist=0;
for (rvtyp=reg_any;rvtyp<=reg_float;rvtyp++) {
for(i=0;i<nregvar[rvtyp];i++) {
ra= &regassigned[rvtyp][i];
ra->ra_rv = 0;
ra->ra_score = 0;
}
}
}
#endif REGVARS
/* nothing after this */

View File

@@ -1,19 +0,0 @@
/* $Header$ */
struct regvar {
struct regvar *rv_next;
long rv_off;
int rv_size;
int rv_type;
int rv_score;
int rv_reg;
};
struct regassigned {
struct regvar *ra_rv;
int ra_score;
};
extern struct regvar *rvlist;
extern int nregvar[];
extern struct regassigned *regassigned[];

View File

@@ -1,19 +0,0 @@
/* $Header$ */
struct result {
int e_typ; /* EV_INT,EV_REG,EV_STR */
union {
word e_con;
int e_reg;
string e_str;
} e_v; /* value */
};
#define EV_UNDEF 0
#define EV_INT 1
#define EV_REG 2
#define EV_STR 3
typedef struct result result_t;
extern result_t compute();

View File

@@ -1,150 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
/*
* Package for string allocation and garbage collection.
* Call salloc(size) to get room for string.
* Every now and then call garbage_collect() from toplevel.
*/
#define MAXSTAB 500
#define THRESHOLD 200
char *stab[MAXSTAB];
int nstab=0;
string malloc();
string myalloc(size) {
register string p;
p = (string) malloc(size);
if (p==0)
fatal("Out of memory");
return(p);
}
myfree(p) string p; {
free(p);
}
popstr(nnstab) {
register i;
for (i=nnstab;i<nstab;i++)
myfree(stab[i]);
nstab = nnstab;
}
char *salloc(size) {
register char *p;
if (nstab==MAXSTAB)
fatal("String table overflow");
p = myalloc(size+1); /* extra room for terminating zero */
stab[nstab++] = p;
return(p);
}
compar(p1,p2) char **p1,**p2; {
assert(*p1 != *p2);
if (*p1 < *p2)
return(-1);
return(1);
}
garbage_collect() {
register i;
struct emline *emlp;
token_p tp;
tkdef_p tdp;
struct reginfo *rp;
register char **fillp,**scanp;
char used[MAXSTAB]; /* could be bitarray */
if (nstab<THRESHOLD)
return;
qsort(stab,nstab,sizeof (char *),compar);
for (i=0;i<nstab;i++)
used[i]= FALSE;
for(emlp=emlines;emlp<emlines+nemlines;emlp++)
chkstr(emlp->em_soper,used);
for (tp= fakestack;tp<&fakestack[stackheight];tp++) {
if (tp->t_token== -1)
continue;
tdp = &tokens[tp->t_token];
for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i] == EV_STR)
chkstr(tp->t_att[i].as,used);
}
for (rp= machregs; rp<machregs+NREGS; rp++) {
tp = &rp->r_contents;
assert(tp->t_token != -1);
tdp= &tokens[tp->t_token];
for (i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i] == EV_STR)
chkstr(tp->t_att[i].as,used);
}
for (i=0;i<nstab;i++)
if (!used[i]) {
myfree(stab[i]);
stab[i]=0;
}
fillp=stab;
for (scanp=stab;scanp<stab+nstab;scanp++)
if (*scanp != 0)
*fillp++ = *scanp;
nstab = fillp-stab;
}
chkstr(str,used) string str; char used[]; {
register low,middle,high;
low=0; high=nstab-1;
while (high>low) {
middle= (low+high)>>1;
if (str==stab[middle]) {
used[middle]=1;
return;
}
if (str<stab[middle])
high = middle-1;
else
low = middle+1;
}
if (low==high) {
if (str==stab[low]) {
used[low]=1;
}
return;
}
}

View File

@@ -1,104 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "state.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
extern int nstab; /* salloc.c */
#ifndef STONSTACK
extern string myalloc();
state_p stlist=0;
#endif
#ifdef STONSTACK
savestatus(sp) register state_p sp; {
#else
state_p savestatus() {
register state_p sp;
if ((sp=stlist)==0)
sp = (state_p) myalloc( sizeof( *sp ) );
else
stlist=sp->st_next;
#endif
sp->st_sh = stackheight;
bmove((short *)fakestack,(short *)sp->st_fs,stackheight*sizeof(token_t));
sp->st_na = nallreg;
bmove((short *)allreg,(short *)sp->st_ar,nallreg*sizeof(int));
sp->st_ct = curtoken;
bmove((short *)dollar,(short *)sp->st_do,LONGESTPATTERN*sizeof(result_t));
bmove((short *)machregs,(short *)sp->st_mr,NREGS*sizeof(struct reginfo));
sp->st_ne = nemlines;
bmove((short *)emlines,(short *)sp->st_el,nemlines*sizeof(struct emline));
sp->st_em = emp;
sp->st_se = saveemp;
sp->st_tl = tokpatlen;
sp->st_ns = nstab;
#ifndef STONSTACK
return(sp);
#endif
}
restorestatus(sp) register state_p sp; {
stackheight = sp->st_sh;
bmove((short *)sp->st_fs,(short *)fakestack,stackheight*sizeof(token_t));
nallreg = sp->st_na;
bmove((short *)sp->st_ar,(short *)allreg,nallreg*sizeof(int));
curtoken = sp->st_ct;
bmove((short *)sp->st_do,(short *)dollar,LONGESTPATTERN*sizeof(result_t));
bmove((short *)sp->st_mr,(short *)machregs,NREGS*sizeof(struct reginfo));
nemlines = sp->st_ne;
bmove((short *)sp->st_el,(short *)emlines,nemlines*sizeof(struct emline));
emp = sp->st_em;
saveemp = sp->st_se;
tokpatlen = sp->st_tl;
popstr(sp->st_ns);
}
#ifndef STONSTACK
freestatus(sp) state_p sp; {
sp->st_next = stlist;
stlist = sp;
}
#endif
bmove(from,to,nbytes) register short *from,*to; register nbytes; {
if (nbytes<=0)
return;
assert(sizeof(short)==2 && (nbytes&1)==0);
nbytes>>=1;
do
*to++ = *from++;
while (--nbytes);
}

View File

@@ -1,24 +0,0 @@
/* $Header$ */
#define STONSTACK /* if defined state is saved in stackframe */
typedef struct state {
struct state *st_next; /* for linked list */
int st_sh; /* stackheight */
token_t st_fs[MAXFSTACK]; /* fakestack */
int st_na; /* nallreg */
int st_ar[MAXALLREG]; /* allreg[] */
token_p st_ct; /* curtoken */
result_t st_do[LONGESTPATTERN]; /* dollar[] */
struct reginfo st_mr[NREGS]; /* machregs[] */
int st_ne; /* nemlines */
struct emline st_el[MAXEMLINES]; /* emlines[] */
struct emline *st_em; /* emp */
struct emline *st_se; /* saveemp */
int st_tl; /* tokpatlen */
int st_ns; /* nstab */
} state_t,*state_p;
#ifndef STONSTACK
state_p savestatus();
#endif

View File

@@ -1,547 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "assert.h"
#include <stdio.h>
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
#include "extern.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
string myalloc();
unsigned codegen();
match(tp,tep,optexp) register token_p tp; register set_p tep; {
register bitno;
token_p ct;
result_t result;
if (tp->t_token == -1) { /* register frame */
bitno = tp->t_att[0].ar+1;
if (tep->set_val[bitno>>4]&(1<<(bitno&017)))
if (tep->set_val[0]&1 || getrefcount(tp->t_att[0].ar)<=1)
goto oklabel;
return(0);
} else { /* token frame */
bitno = tp->t_token+NREGS+1;
if ((tep->set_val[bitno>>4]&(1<<(bitno&017)))==0)
return(0);
}
oklabel:
if (optexp==0)
return(1);
ct=curtoken;
curtoken=tp;
result=compute(&enodes[optexp]);
curtoken=ct;
return(result.e_v.e_con);
}
instance(instno,token) token_p token; {
inst_p inp;
int i;
token_p tp;
struct reginfo *rp;
int regno;
result_t result;
if (instno==0) {
token->t_token = 0;
for(i=0;i<TOKENSIZE;i++)
token->t_att[i].aw=0;
return;
}
inp= &tokeninstances[instno];
switch(inp->in_which) {
default:
assert(FALSE);
case IN_COPY:
tp= &fakestack[stackheight-inp->in_info[0]];
if (inp->in_info[1]==0) {
*token = *tp;
} else {
token->t_token= -1;
#if MAXMEMBERS!=0
if (tp->t_token == -1) {
rp = &machregs[tp->t_att[0].ar];
token->t_att[0].ar=rp->r_members[inp->in_info[1]-1];
} else {
#endif
assert(tokens[tp->t_token].t_type[inp->in_info[1]-1] == EV_REG);
token->t_att[0].ar=tp->t_att[inp->in_info[1]-1].ar;
#if MAXMEMBERS!=0
}
#endif
}
return;
case IN_RIDENT:
token->t_token= -1;
token->t_att[0].ar= inp->in_info[0];
return;
#ifdef REGVARS
case IN_REGVAR:
result=compute(&enodes[inp->in_info[0]]);
i=isregvar((long)result.e_v.e_con);
assert(i>0);
token->t_token= -1;
token->t_att[0].ar = i;
return;
#endif
case IN_ALLOC:
token->t_token= -1;
regno=allreg[inp->in_info[0]];
#if MAXMEMBERS!=0
if (inp->in_info[1])
regno=machregs[regno].r_members[inp->in_info[1]-1];
#endif
token->t_att[0].ar = regno;
return;
case IN_DESCR:
token->t_token=inp->in_info[0];
for (i=0;i<TOKENSIZE;i++)
if (inp->in_info[i+1]==0) {
assert(tokens[token->t_token].t_type[i]==0);
token->t_att[i].aw=0;
} else {
result=compute(&enodes[inp->in_info[i+1]]);
assert(tokens[token->t_token].t_type[i]==result.e_typ);
if (result.e_typ==EV_INT)
token->t_att[i].aw=result.e_v.e_con;
else if (result.e_typ==EV_STR)
token->t_att[i].as= result.e_v.e_str;
else
token->t_att[i].ar=result.e_v.e_reg;
}
return;
}
}
cinstance(instno,token,tp,regno) token_p token,tp; {
inst_p inp;
int i;
struct reginfo *rp;
result_t result;
int sh; /* saved stackheight */
assert(instno!=0);
inp= &tokeninstances[instno];
switch(inp->in_which) {
default:
assert(FALSE);
case IN_COPY:
assert(inp->in_info[0] == 1);
if (inp->in_info[1]==0) {
*token = *tp;
} else {
token->t_token= -1;
#if MAXMEMBERS!=0
if (tp->t_token == -1) {
rp = &machregs[tp->t_att[0].ar];
token->t_att[0].ar=rp->r_members[inp->in_info[1]-1];
} else {
#endif
assert(tokens[tp->t_token].t_type[inp->in_info[1]-1] == EV_REG);
token->t_att[0].ar=tp->t_att[inp->in_info[1]-1].ar;
#if MAXMEMBERS!=0
}
#endif
}
return;
case IN_RIDENT:
token->t_token= -1;
token->t_att[0].ar= inp->in_info[0];
return;
case IN_ALLOC:
token->t_token= -1;
assert(inp->in_info[0]==0);
#if MAXMEMBERS!=0
if (inp->in_info[1])
regno=machregs[regno].r_members[inp->in_info[1]-1];
#endif
token->t_att[0].ar = regno;
return;
case IN_DESCR:
sh = stackheight;
stackheight = tp - fakestack + 1;
token->t_token=inp->in_info[0];
for (i=0;i<TOKENSIZE;i++)
if (inp->in_info[i+1]==0) {
assert(tokens[token->t_token].t_type[i]==0);
token->t_att[i].aw=0;
} else {
result=compute(&enodes[inp->in_info[i+1]]);
assert(tokens[token->t_token].t_type[i]==result.e_typ);
if (result.e_typ==EV_INT)
token->t_att[i].aw=result.e_v.e_con;
else if (result.e_typ==EV_STR)
token->t_att[i].as= result.e_v.e_str;
else
token->t_att[i].ar=result.e_v.e_reg;
}
stackheight = sh;
return;
}
}
eqtoken(tp1,tp2) token_p tp1,tp2; {
register i;
register tkdef_p tdp;
if (tp1->t_token!=tp2->t_token)
return(0);
if (tp1->t_token==0)
return(1);
if (tp1->t_token==-1) {
if (tp1->t_att[0].ar!=tp2->t_att[0].ar)
return(0);
return(1);
}
tdp = &tokens[tp1->t_token];
for (i=0;i<TOKENSIZE;i++)
switch(tdp->t_type[i]) {
default:
return(1);
case EV_INT:
if (tp1->t_att[i].aw != tp2->t_att[i].aw)
return(0);
break;
case EV_REG:
if (tp1->t_att[i].ar != tp2->t_att[i].ar)
return(0);
break;
case EV_STR:
if (strcmp(tp1->t_att[i].as, tp2->t_att[i].as))
return(0);
break;
}
return(1);
}
distance(cindex) {
register char *bp;
register i;
register token_p tp;
int tokexp,tpl;
int expsize,toksize,exact;
int xsekt=0;
bp = &coderules[cindex];
switch( (*bp)&037 ) {
default:
return(stackheight==0 ? 0 : 100);
case DO_MATCH:
break;
case DO_XXMATCH:
xsekt++;
case DO_XMATCH:
xsekt++;
break;
}
tpl= ((*bp++)>>5)&07;
if (stackheight < tpl) {
if (xsekt)
return(MAXINT);
tpl = stackheight;
} else
if (stackheight != tpl && xsekt==2)
return(MAXINT);
exact=0;
tp= &fakestack[stackheight-1];
for (i=0;i<tpl;i++,tp--) {
getint(tokexp,bp);
if (!match(tp, &machsets[tokexp], 0)) {
if (xsekt)
return(MAXINT);
expsize = ssize(tokexp);
toksize = tsize(tp);
if (expsize>toksize)
return(100);
if (expsize<toksize)
return(99-i);
} else
exact++;
}
if (exact==tpl) {
if (xsekt)
return(0);
return(10-exact);
}
return(20-exact);
}
unsigned costcalc(cost) cost_t cost; {
result_t result1,result2;
extern unsigned cc1,cc2,cc3,cc4;
result1=compute(&enodes[cost.c_size]);
result2=compute(&enodes[cost.c_time]);
assert(result1.e_typ == EV_INT && result2.e_typ == EV_INT);
return(result1.e_v.e_con*cc1/cc2 + result2.e_v.e_con*cc3/cc4);
}
ssize(tokexpno) {
return(machsets[tokexpno].set_size);
}
tsize(tp) register token_p tp; {
if (tp->t_token==-1)
return(machregs[tp->t_att[0].ar].r_size);
return(tokens[tp->t_token].t_size);
}
#ifdef MAXSPLIT
instsize(tinstno,tp) token_p tp; {
inst_p inp;
struct reginfo *rp;
inp = &tokeninstances[tinstno];
switch(inp->in_which) {
default:
assert(FALSE);
case IN_COPY:
assert(inp->in_info[0]==1);
#if MAXMEMBERS!=0
if (inp->in_info[1]==0)
#endif
return(tsize(tp));
#if MAXMEMBERS!=0
else {
assert(tp->t_token == -1);
rp = &machregs[tp->t_att[0].ar];
return(machregs[rp->r_members[inp->in_info[1]-1]].r_size);
}
#endif
case IN_RIDENT:
return(machregs[inp->in_info[0]].r_size);
case IN_ALLOC:
assert(FALSE); /* cannot occur in splitting coercion */
case IN_DESCR:
return(tokens[inp->in_info[0]].t_size);
}
}
#endif MAXSPLIT
tref(tp,amount) register token_p tp; {
register i;
register tkdef_p tdp;
if (tp->t_token==-1)
chrefcount(tp->t_att[0].ar,amount,FALSE);
else {
tdp= &tokens[tp->t_token];
for(i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i]==EV_REG)
chrefcount(tp->t_att[i].ar,amount,FALSE);
}
}
#define MAXSAVE 10
#ifdef MAXSPLIT
split(tp,ip,ply,toplevel) token_p tp; int *ip; {
c2_p cp;
token_t savestack[MAXSAVE];
int ok;
register i;
int diff;
token_p stp;
int tpl;
for (cp=c2coercs;cp< &c2coercs[NC2]; cp++) {
if (!match(tp,&machsets[cp->c2_texpno],0))
continue;
ok=1;
for (i=0; ok && i<cp->c2_nsplit;i++) {
if (ip[i]==0)
goto found;
if (instsize(cp->c2_repl[i],tp) != ssize(ip[i]))
ok=0;
}
goto found;
}
return(0);
found:
assert(stackheight+cp->c2_nsplit-1<MAXFSTACK);
stp = &fakestack[stackheight-1];
diff = stp - tp;
assert(diff<=MAXSAVE);
for (i=1;i<=diff;i++)
savestack[i-1] = tp[i]; /* save top of stack */
stackheight -= diff;
tpl = tokpatlen;
tokpatlen = 1;
codegen(&coderules[cp->c2_codep],ply,toplevel,MAXINT,0);
tokpatlen = tpl;
for (i=0;i<diff;i++) /* restore top of stack */
fakestack[stackheight++] = savestack[i];
return(cp->c2_nsplit);
}
#endif MAXSPLIT
unsigned docoerc(tp,cp,ply,toplevel,forced) token_p tp; c3_p cp; {
token_t savestack[MAXSAVE];
token_p stp;
int i,diff;
unsigned cost;
int tpl; /* saved tokpatlen */
stp = &fakestack[stackheight-1];
diff = stp -tp;
assert(diff<=MAXSAVE);
for (i=1;i<=diff;i++)
savestack[i-1] = tp[i];
stackheight -= diff;
tpl = tokpatlen;
tokpatlen = 1;
cost = codegen(&coderules[cp->c3_codep],ply,toplevel,MAXINT,forced);
tokpatlen = tpl;
for (i=0;i<diff;i++)
fakestack[stackheight++] = savestack[i];
nallreg = 0;
return(cost);
}
unsigned stackupto(limit,ply,toplevel) token_p limit; {
token_t savestack[MAXFSTACK];
token_p stp;
int i,diff;
int tpl; /* saved tokpatlen */
int nareg; /* saved nareg */
int areg[MAXALLREG];
c1_p cp;
register token_p tp;
unsigned totalcost=0;
struct reginfo *rp,**rpp;
for (tp=fakestack;tp<=limit;limit--) {
for (cp=c1coercs;cp< &c1coercs[NC1]; cp++) {
if (match(tp,&machsets[cp->c1_texpno],cp->c1_expr)) {
if (cp->c1_prop>=0) {
for (rpp=reglist[cp->c1_prop];
(rp = *rpp)!=0 &&
getrefcount(rp-machregs)!=0;
rpp++)
;
if (rp==0)
continue;
/* look for other possibility */
}
stp = &fakestack[stackheight-1];
diff = stp -tp;
assert(diff<=MAXFSTACK);
for (i=1;i<=diff;i++)
savestack[i-1] = tp[i];
stackheight -= diff;
tpl = tokpatlen;
tokpatlen = 1;
nareg = nallreg;
for (i=0;i<nareg;i++)
areg[i] = allreg[i];
if (cp->c1_prop>=0) {
nallreg=1; allreg[0] = rp-machregs;
chrefcount(allreg[0],1,FALSE);
} else
nallreg=0;
totalcost+= codegen(&coderules[cp->c1_codep],ply,toplevel,MAXINT,0);
totalcost+= costcalc(cp->c1_cost);
tokpatlen = tpl;
for (i=0;i<diff;i++)
fakestack[stackheight++] = savestack[i];
nallreg=nareg;
for (i=0;i<nareg;i++)
allreg[i] = areg[i];
goto contin;
}
}
assert(FALSE);
contin: ;
}
return(totalcost);
}
c3_p findcoerc(tp,tep) token_p tp; set_p tep; {
register c3_p cp;
token_t rtoken;
register i;
register struct reginfo **rpp;
for (cp=c3coercs;cp< &c3coercs[NC3]; cp++) {
if (tp!=(token_p) 0) {
if (!match(tp,&machsets[cp->c3_texpno],0))
continue;
} else {
if (cp->c3_texpno!=0)
continue;
}
if (cp->c3_prop==0) { /* no reg needed */
cinstance(cp->c3_repl,&rtoken,tp,0);
if (match(&rtoken,tep,0))
return(cp);
} else {
curreglist = (rl_p) myalloc(sizeof (rl_t));
curreglist->rl_n = 0;
for (rpp=reglist[cp->c3_prop];*rpp;rpp++) {
i = *rpp - machregs;
cinstance(cp->c3_repl,&rtoken,tp,i);
if (match(&rtoken,tep,0))
curreglist->rl_list[curreglist->rl_n++] = i;
}
if (curreglist->rl_n != 0)
return(cp);
myfree(curreglist);
}
}
return(0); /* nothing found */
}
error(s,a1,a2,a3,a4) char *s; {
fatal(s,a1,a2,a3,a4);
}
fatal(s,a1,a2,a3,a4) char *s; {
fprintf(stderr,"Error: ");
fprintf(stderr,s,a1,a2,a3,a4);
fprintf(stderr,"\n");
out_finish();
abort();
exit(-1);
}
#ifndef NDEBUG
badassertion(asstr,file,line) char *asstr, *file; {
fatal("Assertion \"%s\" failed %s(%d)",asstr,file,line);
}
#endif
max(a,b) {
return(a>b ? a : b);
}

View File

@@ -1,33 +0,0 @@
/* $Header$ */
#ifndef EM_WSIZE
EM_WSIZE should be defined at this point
#endif
#ifndef EM_PSIZE
EM_PSIZE should be defined at this point
#endif
#if EM_WSIZE>4 || EM_PSIZE>4
Implementation will not be correct unless a long integer
has more then 4 bytes of precision.
#endif
typedef char byte;
typedef char * string;
#if EM_WSIZE>2 || EM_PSIZE>2
#define full long
#else
#define full int
#endif
#if EM_WSIZE>2
#define word long
#ifndef WRD_FMT
#define WRD_FMT "%D"
#endif WRD_FMT
#else
#define word int
#ifndef WRD_FMT
#define WRD_FMT "%d"
#endif WRD_FMT
#endif

View File

@@ -1,41 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "tables.h"
#include "types.h"
#include <cg_pattern.h>
#include "data.h"
#include "result.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
int stackheight = 0;
token_t fakestack[MAXFSTACK];
int nallreg = 0;
int allreg[MAXALLREG];
token_p curtoken = (token_p) 0;
result_t dollar[LONGESTPATTERN];
int nemlines =0;
struct emline emlines[MAXEMLINES];
struct emline *emp=emlines;
struct emline *saveemp;
int tokpatlen;
rl_p curreglist;

View File

@@ -1,178 +0,0 @@
# $Header$
PREFLAGS=-I../../../h -I. -DNDEBUG
PFLAGS=
CFLAGS=$(PREFLAGS) $(PFLAGS) -O
LDFLAGS=-i $(PFLAGS)
LINTOPTS=-hbxac
LIBS=../../../lib/em_data.a
CDIR=../../proto/cg
CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
$(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
$(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
$(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\
move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o
all:
make tables.c
make cg
cg: tables.o $(OFILES)
cc $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
tables.o: tables.c
cc -c $(PREFLAGS) -I$(CDIR) tables.c
codegen.o: $(CDIR)/codegen.c
cc -c $(CFLAGS) $(CDIR)/codegen.c
compute.o: $(CDIR)/compute.c
cc -c $(CFLAGS) $(CDIR)/compute.c
equiv.o: $(CDIR)/equiv.c
cc -c $(CFLAGS) $(CDIR)/equiv.c
fillem.o: $(CDIR)/fillem.c
cc -c $(CFLAGS) $(CDIR)/fillem.c
gencode.o: $(CDIR)/gencode.c
cc -c $(CFLAGS) $(CDIR)/gencode.c
glosym.o: $(CDIR)/glosym.c
cc -c $(CFLAGS) $(CDIR)/glosym.c
main.o: $(CDIR)/main.c
cc -c $(CFLAGS) $(CDIR)/main.c
move.o: $(CDIR)/move.c
cc -c $(CFLAGS) $(CDIR)/move.c
nextem.o: $(CDIR)/nextem.c
cc -c $(CFLAGS) $(CDIR)/nextem.c
reg.o: $(CDIR)/reg.c
cc -c $(CFLAGS) $(CDIR)/reg.c
regvar.o: $(CDIR)/regvar.c
cc -c $(CFLAGS) $(CDIR)/regvar.c
salloc.o: $(CDIR)/salloc.c
cc -c $(CFLAGS) $(CDIR)/salloc.c
state.o: $(CDIR)/state.c
cc -c $(CFLAGS) $(CDIR)/state.c
subr.o: $(CDIR)/subr.c
cc -c $(CFLAGS) $(CDIR)/subr.c
var.o: $(CDIR)/var.c
cc -c $(CFLAGS) $(CDIR)/var.c
install: all
../install cg
cmp: all
-../compare cg
tables.c: table
-mv tables.h tables.h.save
../../../lib/cpp -P table | ../../../lib/cgg > debug.out
-if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi
-if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi
lint: $(CFILES)
lint $(LINTOPTS) $(PREFLAGS) $(CFILES)
clean:
rm -f *.o tables.c tables.h debug.out cg tables.h.save
codegen.o: $(CDIR)/assert.h
codegen.o: $(CDIR)/data.h
codegen.o: $(CDIR)/equiv.h
codegen.o: $(CDIR)/extern.h
codegen.o: $(CDIR)/param.h
codegen.o: $(CDIR)/result.h
codegen.o: $(CDIR)/state.h
codegen.o: tables.h
codegen.o: $(CDIR)/types.h
compute.o: $(CDIR)/assert.h
compute.o: $(CDIR)/data.h
compute.o: $(CDIR)/extern.h
compute.o: $(CDIR)/glosym.h
compute.o: $(CDIR)/param.h
compute.o: $(CDIR)/result.h
compute.o: tables.h
compute.o: $(CDIR)/types.h
equiv.o: $(CDIR)/assert.h
equiv.o: $(CDIR)/data.h
equiv.o: $(CDIR)/equiv.h
equiv.o: $(CDIR)/extern.h
equiv.o: $(CDIR)/param.h
equiv.o: $(CDIR)/result.h
equiv.o: tables.h
equiv.o: $(CDIR)/types.h
fillem.o: $(CDIR)/assert.h
fillem.o: $(CDIR)/data.h
fillem.o: $(CDIR)/extern.h
fillem.o: mach.c
fillem.o: mach.h
fillem.o: $(CDIR)/param.h
fillem.o: $(CDIR)/regvar.h
fillem.o: $(CDIR)/result.h
fillem.o: tables.h
fillem.o: $(CDIR)/types.h
gencode.o: $(CDIR)/assert.h
gencode.o: $(CDIR)/data.h
gencode.o: $(CDIR)/extern.h
gencode.o: $(CDIR)/param.h
gencode.o: $(CDIR)/result.h
gencode.o: tables.h
gencode.o: $(CDIR)/types.h
glosym.o: $(CDIR)/glosym.h
glosym.o: $(CDIR)/param.h
glosym.o: tables.h
glosym.o: $(CDIR)/types.h
main.o: $(CDIR)/param.h
move.o: $(CDIR)/assert.h
move.o: $(CDIR)/data.h
move.o: $(CDIR)/extern.h
move.o: $(CDIR)/param.h
move.o: $(CDIR)/result.h
move.o: tables.h
move.o: $(CDIR)/types.h
nextem.o: $(CDIR)/assert.h
nextem.o: $(CDIR)/data.h
nextem.o: $(CDIR)/extern.h
nextem.o: $(CDIR)/param.h
nextem.o: $(CDIR)/result.h
nextem.o: tables.h
nextem.o: $(CDIR)/types.h
reg.o: $(CDIR)/assert.h
reg.o: $(CDIR)/data.h
reg.o: $(CDIR)/extern.h
reg.o: $(CDIR)/param.h
reg.o: $(CDIR)/result.h
reg.o: tables.h
reg.o: $(CDIR)/types.h
regvar.o: $(CDIR)/assert.h
regvar.o: $(CDIR)/data.h
regvar.o: $(CDIR)/extern.h
regvar.o: $(CDIR)/param.h
regvar.o: $(CDIR)/regvar.h
regvar.o: $(CDIR)/result.h
regvar.o: tables.h
regvar.o: $(CDIR)/types.h
salloc.o: $(CDIR)/assert.h
salloc.o: $(CDIR)/data.h
salloc.o: $(CDIR)/extern.h
salloc.o: $(CDIR)/param.h
salloc.o: $(CDIR)/result.h
salloc.o: tables.h
salloc.o: $(CDIR)/types.h
state.o: $(CDIR)/assert.h
state.o: $(CDIR)/data.h
state.o: $(CDIR)/extern.h
state.o: $(CDIR)/param.h
state.o: $(CDIR)/result.h
state.o: $(CDIR)/state.h
state.o: tables.h
state.o: $(CDIR)/types.h
subr.o: $(CDIR)/assert.h
subr.o: $(CDIR)/data.h
subr.o: $(CDIR)/extern.h
subr.o: $(CDIR)/param.h
subr.o: $(CDIR)/result.h
subr.o: tables.h
subr.o: $(CDIR)/types.h
var.o: $(CDIR)/data.h
var.o: $(CDIR)/param.h
var.o: $(CDIR)/result.h
var.o: tables.h
var.o: $(CDIR)/types.h

View File

@@ -1,178 +0,0 @@
# $Header$
PREFLAGS=-I../../../h -I. -DNDEBUG
PFLAGS=
CFLAGS=$(PREFLAGS) $(PFLAGS) -O
LDFLAGS=-i $(PFLAGS)
LINTOPTS=-hbxac
LIBS=../../../lib/em_data.a
CDIR=../../proto/cg
CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
$(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
$(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
$(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\
move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o
all:
make tables.c
make cg
cg: tables.o $(OFILES)
cc $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
tables.o: tables.c
cc -c $(PREFLAGS) -I$(CDIR) tables.c
codegen.o: $(CDIR)/codegen.c
cc -c $(CFLAGS) $(CDIR)/codegen.c
compute.o: $(CDIR)/compute.c
cc -c $(CFLAGS) $(CDIR)/compute.c
equiv.o: $(CDIR)/equiv.c
cc -c $(CFLAGS) $(CDIR)/equiv.c
fillem.o: $(CDIR)/fillem.c
cc -c $(CFLAGS) $(CDIR)/fillem.c
gencode.o: $(CDIR)/gencode.c
cc -c $(CFLAGS) $(CDIR)/gencode.c
glosym.o: $(CDIR)/glosym.c
cc -c $(CFLAGS) $(CDIR)/glosym.c
main.o: $(CDIR)/main.c
cc -c $(CFLAGS) $(CDIR)/main.c
move.o: $(CDIR)/move.c
cc -c $(CFLAGS) $(CDIR)/move.c
nextem.o: $(CDIR)/nextem.c
cc -c $(CFLAGS) $(CDIR)/nextem.c
reg.o: $(CDIR)/reg.c
cc -c $(CFLAGS) $(CDIR)/reg.c
regvar.o: $(CDIR)/regvar.c
cc -c $(CFLAGS) $(CDIR)/regvar.c
salloc.o: $(CDIR)/salloc.c
cc -c $(CFLAGS) $(CDIR)/salloc.c
state.o: $(CDIR)/state.c
cc -c $(CFLAGS) $(CDIR)/state.c
subr.o: $(CDIR)/subr.c
cc -c $(CFLAGS) $(CDIR)/subr.c
var.o: $(CDIR)/var.c
cc -c $(CFLAGS) $(CDIR)/var.c
install: all
../install cg
cmp: all
-../compare cg
tables.c: table
-mv tables.h tables.h.save
../../../lib/cpp -P table | ../../../lib/cgg > debug.out
-if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi
-if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi
lint: $(CFILES)
lint $(LINTOPTS) $(PREFLAGS) $(CFILES)
clean:
rm -f *.o tables.c tables.h debug.out cg tables.h.save
codegen.o: $(CDIR)/assert.h
codegen.o: $(CDIR)/data.h
codegen.o: $(CDIR)/equiv.h
codegen.o: $(CDIR)/extern.h
codegen.o: $(CDIR)/param.h
codegen.o: $(CDIR)/result.h
codegen.o: $(CDIR)/state.h
codegen.o: tables.h
codegen.o: $(CDIR)/types.h
compute.o: $(CDIR)/assert.h
compute.o: $(CDIR)/data.h
compute.o: $(CDIR)/extern.h
compute.o: $(CDIR)/glosym.h
compute.o: $(CDIR)/param.h
compute.o: $(CDIR)/result.h
compute.o: tables.h
compute.o: $(CDIR)/types.h
equiv.o: $(CDIR)/assert.h
equiv.o: $(CDIR)/data.h
equiv.o: $(CDIR)/equiv.h
equiv.o: $(CDIR)/extern.h
equiv.o: $(CDIR)/param.h
equiv.o: $(CDIR)/result.h
equiv.o: tables.h
equiv.o: $(CDIR)/types.h
fillem.o: $(CDIR)/assert.h
fillem.o: $(CDIR)/data.h
fillem.o: $(CDIR)/extern.h
fillem.o: mach.c
fillem.o: mach.h
fillem.o: $(CDIR)/param.h
fillem.o: $(CDIR)/regvar.h
fillem.o: $(CDIR)/result.h
fillem.o: tables.h
fillem.o: $(CDIR)/types.h
gencode.o: $(CDIR)/assert.h
gencode.o: $(CDIR)/data.h
gencode.o: $(CDIR)/extern.h
gencode.o: $(CDIR)/param.h
gencode.o: $(CDIR)/result.h
gencode.o: tables.h
gencode.o: $(CDIR)/types.h
glosym.o: $(CDIR)/glosym.h
glosym.o: $(CDIR)/param.h
glosym.o: tables.h
glosym.o: $(CDIR)/types.h
main.o: $(CDIR)/param.h
move.o: $(CDIR)/assert.h
move.o: $(CDIR)/data.h
move.o: $(CDIR)/extern.h
move.o: $(CDIR)/param.h
move.o: $(CDIR)/result.h
move.o: tables.h
move.o: $(CDIR)/types.h
nextem.o: $(CDIR)/assert.h
nextem.o: $(CDIR)/data.h
nextem.o: $(CDIR)/extern.h
nextem.o: $(CDIR)/param.h
nextem.o: $(CDIR)/result.h
nextem.o: tables.h
nextem.o: $(CDIR)/types.h
reg.o: $(CDIR)/assert.h
reg.o: $(CDIR)/data.h
reg.o: $(CDIR)/extern.h
reg.o: $(CDIR)/param.h
reg.o: $(CDIR)/result.h
reg.o: tables.h
reg.o: $(CDIR)/types.h
regvar.o: $(CDIR)/assert.h
regvar.o: $(CDIR)/data.h
regvar.o: $(CDIR)/extern.h
regvar.o: $(CDIR)/param.h
regvar.o: $(CDIR)/regvar.h
regvar.o: $(CDIR)/result.h
regvar.o: tables.h
regvar.o: $(CDIR)/types.h
salloc.o: $(CDIR)/assert.h
salloc.o: $(CDIR)/data.h
salloc.o: $(CDIR)/extern.h
salloc.o: $(CDIR)/param.h
salloc.o: $(CDIR)/result.h
salloc.o: tables.h
salloc.o: $(CDIR)/types.h
state.o: $(CDIR)/assert.h
state.o: $(CDIR)/data.h
state.o: $(CDIR)/extern.h
state.o: $(CDIR)/param.h
state.o: $(CDIR)/result.h
state.o: $(CDIR)/state.h
state.o: tables.h
state.o: $(CDIR)/types.h
subr.o: $(CDIR)/assert.h
subr.o: $(CDIR)/data.h
subr.o: $(CDIR)/extern.h
subr.o: $(CDIR)/param.h
subr.o: $(CDIR)/result.h
subr.o: tables.h
subr.o: $(CDIR)/types.h
var.o: $(CDIR)/data.h
var.o: $(CDIR)/param.h
var.o: $(CDIR)/result.h
var.o: tables.h
var.o: $(CDIR)/types.h

View File

@@ -1,178 +0,0 @@
# $Header$
PREFLAGS=-I../../../h -I. -DNDEBUG
PFLAGS=
CFLAGS=$(PREFLAGS) $(PFLAGS) -O
LDFLAGS=-i $(PFLAGS)
LINTOPTS=-hbxac
LIBS=../../../lib/em_data.a
CDIR=../../proto/cg
CFILES=$(CDIR)/codegen.c $(CDIR)/compute.c $(CDIR)/equiv.c $(CDIR)/fillem.c \
$(CDIR)/gencode.c $(CDIR)/glosym.c $(CDIR)/main.c $(CDIR)/move.c \
$(CDIR)/nextem.c $(CDIR)/reg.c $(CDIR)/regvar.c $(CDIR)/salloc.c \
$(CDIR)/state.c $(CDIR)/subr.c $(CDIR)/var.c
OFILES=codegen.o compute.o equiv.o fillem.o gencode.o glosym.o main.o\
move.o nextem.o reg.o regvar.o salloc.o state.o subr.o var.o
all:
make tables.c
make cg
cg: tables.o $(OFILES)
cc $(LDFLAGS) $(OFILES) tables.o $(LIBS) -o cg
tables.o: tables.c
cc -c $(PREFLAGS) -I$(CDIR) tables.c
codegen.o: $(CDIR)/codegen.c
cc -c $(CFLAGS) $(CDIR)/codegen.c
compute.o: $(CDIR)/compute.c
cc -c $(CFLAGS) $(CDIR)/compute.c
equiv.o: $(CDIR)/equiv.c
cc -c $(CFLAGS) $(CDIR)/equiv.c
fillem.o: $(CDIR)/fillem.c
cc -c $(CFLAGS) $(CDIR)/fillem.c
gencode.o: $(CDIR)/gencode.c
cc -c $(CFLAGS) $(CDIR)/gencode.c
glosym.o: $(CDIR)/glosym.c
cc -c $(CFLAGS) $(CDIR)/glosym.c
main.o: $(CDIR)/main.c
cc -c $(CFLAGS) $(CDIR)/main.c
move.o: $(CDIR)/move.c
cc -c $(CFLAGS) $(CDIR)/move.c
nextem.o: $(CDIR)/nextem.c
cc -c $(CFLAGS) $(CDIR)/nextem.c
reg.o: $(CDIR)/reg.c
cc -c $(CFLAGS) $(CDIR)/reg.c
regvar.o: $(CDIR)/regvar.c
cc -c $(CFLAGS) $(CDIR)/regvar.c
salloc.o: $(CDIR)/salloc.c
cc -c $(CFLAGS) $(CDIR)/salloc.c
state.o: $(CDIR)/state.c
cc -c $(CFLAGS) $(CDIR)/state.c
subr.o: $(CDIR)/subr.c
cc -c $(CFLAGS) $(CDIR)/subr.c
var.o: $(CDIR)/var.c
cc -c $(CFLAGS) $(CDIR)/var.c
install: all
../install cg
cmp: all
-../compare cg
tables.c: table
-mv tables.h tables.h.save
../../../lib/cpp -P table | ../../../lib/cgg > debug.out
-if cmp -s tables.h.save tables.h; then mv tables.h.save tables.h; else exit 0; fi
-if cmp -s /dev/null tables.h; then mv tables.h.save tables.h; else exit 0; fi
lint: $(CFILES)
lint $(LINTOPTS) $(PREFLAGS) $(CFILES)
clean:
rm -f *.o tables.c tables.h debug.out cg tables.h.save
codegen.o: $(CDIR)/assert.h
codegen.o: $(CDIR)/data.h
codegen.o: $(CDIR)/equiv.h
codegen.o: $(CDIR)/extern.h
codegen.o: $(CDIR)/param.h
codegen.o: $(CDIR)/result.h
codegen.o: $(CDIR)/state.h
codegen.o: tables.h
codegen.o: $(CDIR)/types.h
compute.o: $(CDIR)/assert.h
compute.o: $(CDIR)/data.h
compute.o: $(CDIR)/extern.h
compute.o: $(CDIR)/glosym.h
compute.o: $(CDIR)/param.h
compute.o: $(CDIR)/result.h
compute.o: tables.h
compute.o: $(CDIR)/types.h
equiv.o: $(CDIR)/assert.h
equiv.o: $(CDIR)/data.h
equiv.o: $(CDIR)/equiv.h
equiv.o: $(CDIR)/extern.h
equiv.o: $(CDIR)/param.h
equiv.o: $(CDIR)/result.h
equiv.o: tables.h
equiv.o: $(CDIR)/types.h
fillem.o: $(CDIR)/assert.h
fillem.o: $(CDIR)/data.h
fillem.o: $(CDIR)/extern.h
fillem.o: mach.c
fillem.o: mach.h
fillem.o: $(CDIR)/param.h
fillem.o: $(CDIR)/regvar.h
fillem.o: $(CDIR)/result.h
fillem.o: tables.h
fillem.o: $(CDIR)/types.h
gencode.o: $(CDIR)/assert.h
gencode.o: $(CDIR)/data.h
gencode.o: $(CDIR)/extern.h
gencode.o: $(CDIR)/param.h
gencode.o: $(CDIR)/result.h
gencode.o: tables.h
gencode.o: $(CDIR)/types.h
glosym.o: $(CDIR)/glosym.h
glosym.o: $(CDIR)/param.h
glosym.o: tables.h
glosym.o: $(CDIR)/types.h
main.o: $(CDIR)/param.h
move.o: $(CDIR)/assert.h
move.o: $(CDIR)/data.h
move.o: $(CDIR)/extern.h
move.o: $(CDIR)/param.h
move.o: $(CDIR)/result.h
move.o: tables.h
move.o: $(CDIR)/types.h
nextem.o: $(CDIR)/assert.h
nextem.o: $(CDIR)/data.h
nextem.o: $(CDIR)/extern.h
nextem.o: $(CDIR)/param.h
nextem.o: $(CDIR)/result.h
nextem.o: tables.h
nextem.o: $(CDIR)/types.h
reg.o: $(CDIR)/assert.h
reg.o: $(CDIR)/data.h
reg.o: $(CDIR)/extern.h
reg.o: $(CDIR)/param.h
reg.o: $(CDIR)/result.h
reg.o: tables.h
reg.o: $(CDIR)/types.h
regvar.o: $(CDIR)/assert.h
regvar.o: $(CDIR)/data.h
regvar.o: $(CDIR)/extern.h
regvar.o: $(CDIR)/param.h
regvar.o: $(CDIR)/regvar.h
regvar.o: $(CDIR)/result.h
regvar.o: tables.h
regvar.o: $(CDIR)/types.h
salloc.o: $(CDIR)/assert.h
salloc.o: $(CDIR)/data.h
salloc.o: $(CDIR)/extern.h
salloc.o: $(CDIR)/param.h
salloc.o: $(CDIR)/result.h
salloc.o: tables.h
salloc.o: $(CDIR)/types.h
state.o: $(CDIR)/assert.h
state.o: $(CDIR)/data.h
state.o: $(CDIR)/extern.h
state.o: $(CDIR)/param.h
state.o: $(CDIR)/result.h
state.o: $(CDIR)/state.h
state.o: tables.h
state.o: $(CDIR)/types.h
subr.o: $(CDIR)/assert.h
subr.o: $(CDIR)/data.h
subr.o: $(CDIR)/extern.h
subr.o: $(CDIR)/param.h
subr.o: $(CDIR)/result.h
subr.o: tables.h
subr.o: $(CDIR)/types.h
var.o: $(CDIR)/data.h
var.o: $(CDIR)/param.h
var.o: $(CDIR)/result.h
var.o: tables.h
var.o: $(CDIR)/types.h

View File

@@ -1,23 +0,0 @@
Makefile
ack.h
data.c
data.h
dmach.c
dmach.h
files.c
grows.c
grows.h
intable.c
list.c
list.h
main.c
malloc.c
mktables.c
pc
rmach.c
run.c
scan.c
svars.c
trans.c
trans.h
util.c

View File

@@ -1,63 +0,0 @@
HFILES=ack.h list.h trans.h data.h dmach.h grows.h
DSRC=list.c data.c main.c scan.c svars.c trans.c util.c rmach.c run.c grows.c\
files.c
ISRC=dmach.c intable.c
OBJ=list.o data.o main.o scan.o svars.o trans.o util.o rmach.o run.o \
dmach.o intable.o grows.o files.o
ACKDIR=../../lib/ack
FE=fe
INTABLES=pdp int
LNTABLES=6500 m68k2 m68k4 6809 8080 acc apc nascom vax2 vax4 z80 i86
CFLAGS=-O -n
BINDIR=../../bin
head: ack
install: ack
cp ack $(BINDIR)/ack
-cd $(BINDIR) ; \
for i in $(INTABLES) $(LNTABLES) ; do ln ack $$i ; done
(cd pc ; make install )
cmp: ack
cmp ack $(BINDIR)/ack
(cd pc ; make cmp )
clean:
-rm -f *.old *.o ack
(cd pc ; make clean )
ack: $(OBJ)
$(CC) -o ack $(CFLAGS) $(OBJ)
grows.o files.o list.o run.o \
data.o main.o scan.o trans.o rmach.o util.o : ack.h list.h
files.o data.o main.o scan.o run.o trans.o rmach.o: trans.h data.h
files.o rmach.o trans.o grows.c : grows.h
rmach.c: dmach.h
files.o main.o rmach.o : ../../h/em_path.h
main.o : ../../h/local.h
malloc.o svars.o: ack.h
dmach.c intable.c: mktables dmach.h
: mktables $(ACKDIR) # $(FE) $(INTABLES)
mktables $(ACKDIR)
mktables: mktables.c
cc -o mktables mktables.c
pr:
@pr Makefile $(HFILES) $(DSRC) $(ACKDIR)/*
@(cd pc ; make pr)
opr:
make pr | opr
lint: $(ISRC)
lint -hbx $(DSRC) $(ISRC)

View File

@@ -1,88 +0,0 @@
/****************************************************************************/
/* User settable options */
/****************************************************************************/
#define FRONTENDS "fe" /* The front-end definitions */
#define ACKNAME "AckXXXXXX" /* Handed to mktemp for temp. files */
/****************************************************************************/
/* Internal mnemonics, should not be tinkered with */
/****************************************************************************/
/* The names of some string variables */
#define HOME "EM"
#define RTS "RTS"
#define NEEDS "NEEDS"
#define HEAD "HEAD"
#define TAIL "TAIL"
#define SRC "SOURCE"
#define LIBVAR "LNAME"
/* Intended for flags, possibly in bit fields */
#define YES 1
#define NO 0
#define MAYBE 2
#define EXTERN extern
#define SUFCHAR '.' /* Start of SUFFIX in file name */
#define SPACE ' '
#define TAB '\t'
#define EQUAL '='
#define S_VAR '{' /* Start of variable */
#define C_VAR '}' /* End of variable */
#define A_VAR '?' /* Variable alternative */
#define BSLASH '\\' /* Backslash */
#define STAR '*' /* STAR */
#define C_IN '<' /* Token specifying input */
#define C_OUT '>' /* Token specifying output */
#define S_EXPR '(' /* Start of expression */
#define C_EXPR ')' /* End of expression */
#define M_EXPR ':' /* Middle of two suffix lists */
#define T_EXPR '=' /* Start of tail */
#define NO_SCAN 0200 /* Bit set in character to defeat recogn. */
typedef struct {
char *p_path; /* points to the full pathname */
int p_keeps:1; /* The string should be thrown when unused */
int p_keep:1; /* The file should be thrown away after use */
} path ;
/* Return values of setpath() */
enum f_path { F_OK, F_NOMATCH, F_NOPATH } ;
/* Library routines */
extern char *index();
extern char *rindex();
extern char *strcpy();
extern char *strcat();
extern char *mktemp();
extern int unlink();
extern int close();
extern int open();
extern int creat();
/* Own routines */
enum f_path setpath();
enum f_path scan_end();
extern int noodstop();
extern char *getvar();
extern char *keeps();
extern char *basename();
extern char *skipblank();
extern char *firstblank();
extern char *getcore();
extern char *changecore();
#define freecore(area) free(area)
/* #define DEBUG 1 /* Allow debugging of Ack */
#ifndef DEBUG
# define debug 0 /* To surprise all these 'if ( debug ) 's */
#else
extern int debug ;
#endif

View File

@@ -1,9 +0,0 @@
#include "ack.h"
#include "list.h"
#include "trans.h"
#undef EXTERN
#define EXTERN
#include "data.h"

View File

@@ -1,43 +0,0 @@
EXTERN char *stopsuffix; /* Suffix to stop at */
EXTERN char *machine; /* The machine id */
EXTERN char *rts; /* The runtime-system id */
EXTERN list_head arguments; /* List of arguments */
EXTERN list_head flags; /* List of flags */
EXTERN list_head c_arguments; /* List of linker arguments */
EXTERN list_head tr_list; /* List of transformations */
EXTERN list_head R_list; /* List of -R flags */
EXTERN list_head head_list; /* List of suffices for headers */
EXTERN list_head tail_list; /* List of suffices for tails */
EXTERN int k_flag; /* Like -k of lint */
EXTERN int g_flag; /* do_run() */
EXTERN int t_flag; /* Preserve intermediate files */
EXTERN int v_flag; /* Verbose */
EXTERN int w_flag; /* Don't print warnings */
EXTERN int nill_flag; /* Don't file names */
EXTERN int Optflag; /* Optimizing */
#ifdef DEBUG
EXTERN int debug; /* Debugging control */
#endif
EXTERN int n_error; /* Number of errors encountered */
EXTERN char *progname; /* The program call name */
EXTERN char *outfile; /* The result file e.g. a.out */
EXTERN char *template; /* The template for temporary file
names */
EXTERN trf *combiner; /* Pointer to the Loader/Linker */
EXTERN trf *cpp_trafo; /* Pointer to C-preprocessor */
EXTERN path in; /* The current input pathname */
EXTERN path out; /* The current output pathname */
EXTERN path orig; /* The original input path */
EXTERN char *p_basename; /* The current basename */
EXTERN char *p_suffix; /* The current input suffix */

View File

@@ -1,15 +0,0 @@
/***************************************************************/
/* */
/* Definition for table that maps a name on an intable index */
/* */
/***************************************************************/
typedef struct {
char *ma_name ; /* The name of the machine */
int ma_index ;
} dmach ;
extern dmach massoc[] ;
extern char intable[] ;

View File

@@ -1,94 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#include "list.h"
#include "trans.h"
#include "grows.h"
#include "data.h"
#include "../../h/em_path.h"
setfiles(phase) register trf *phase ; {
/* Set the out structure according to the in structure,
the transformation and some global data */
growstring pathname ;
register list_elem *elem ;
if ( phase->t_combine ) {
out.p_keep=YES ;
out.p_path=outfile ;
out.p_keeps=NO ;
in.p_path= (char *)0 ;
in.p_keep=YES ;
in.p_keeps=NO ;
} else {
gr_init(&pathname) ;
if ( !phase->t_keep && !t_flag ) {
gr_cat(&pathname,TMP_DIR) ;
gr_cat(&pathname,"/") ;
gr_cat(&pathname,template) ;
out.p_keep=NO ;
} else {
gr_cat(&pathname,p_basename) ;
out.p_keep=YES ;
}
gr_cat(&pathname,phase->t_out) ;
out.p_path= gr_final(&pathname) ;
out.p_keeps= YES ;
}
scanlist( l_first(arguments), elem) {
if ( strcmp(l_content(*elem),out.p_path)==0 ) {
error("attempt to overwrite argument file") ;
return 0 ;
}
}
return 1 ;
}
disc_files() {
if ( in.p_path ) {
if ( !in.p_keep ) {
if ( unlink(in.p_path)!=0 ) {
werror("couldn't unlink %s",in.p_path);
}
}
if ( in.p_keeps ) throws(in.p_path) ;
}
in=out ;
out.p_path= (char *)0 ;
out.p_keeps=NO ;
out.p_keep=NO ;
}
rmtemps() {
/* Called in case of disaster, always remove the current output file!
*/
if ( out.p_path ) {
unlink(out.p_path) ;
if ( out.p_keeps ) throws(out.p_path) ;
out.p_path= (char *)0 ;
out.p_keeps=NO ;
out.p_keep=NO ;
}
if ( !in.p_keep && in.p_path ) {
unlink(in.p_path) ;
if ( in.p_keeps ) throws(in.p_path) ;
in.p_path= (char *)0 ;
out.p_keeps= NO ;
out.p_keep=NO ;
}
}

View File

@@ -1,79 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
/**************************************************************************/
/* */
/* Bookkeeping for growing strings */
/* */
/**************************************************************************/
#include "ack.h"
#include "grows.h"
gr_add(id,c) register growstring *id ; char c ; {
if ( id->gr_size==id->gr_max) {
if ( id->gr_size==0 ) { /* The first time */
id->gr_max= 2*GR_MORE ;
id->gr_string= getcore(id->gr_max) ;
} else {
id->gr_max += GR_MORE ;
id->gr_string= changecore(id->gr_string,id->gr_max ) ;
}
}
*(id->gr_string+id->gr_size++)= c ;
}
gr_cat(id,string) growstring *id ; char *string ; {
register char *ptr ;
#ifdef DEBUG
if ( id->gr_size && *(id->gr_string+id->gr_size-1) ) {
vprint("Non-zero terminated %*s\n",
id->gr_size, id->gr_string ) ;
}
#endif
if ( id->gr_size ) id->gr_size-- ;
ptr=string ;
for (;;) {
gr_add(id,*ptr) ;
if ( *ptr++ ) continue ;
break ;
}
}
gr_throw(id) register growstring *id ; {
/* Throw the string away */
if ( id->gr_max==0 ) return ;
freecore(id->gr_string) ;
id->gr_max=0 ;
id->gr_size=0 ;
}
gr_init(id) growstring *id ; {
id->gr_size=0 ; id->gr_max=0 ;
}
char *gr_final(id) growstring *id ; {
/* Throw away the bookkeeping, adjust the string to its final
length and return a pointer to a string to be get rid of with
throws
*/
register char *retval ;
retval= keeps(gr_start(*id)) ;
gr_throw(id) ;
return retval ;
}

View File

@@ -1,19 +0,0 @@
/* struct used to identify and do bookkeeping for growing strings */
typedef struct {
char *gr_string ; /* Points to start of string */
unsigned gr_size ; /* Current string size */
unsigned gr_max ; /* Maximum string size */
} growstring ;
#define GR_MORE 50 /* Steps to grow */
#define gr_start(id) (id).gr_string /* The start of the string */
/* Routines used */
extern int gr_throw() ; /* To free the core */
extern int gr_add() ; /* To add one character */
extern int gr_cat() ; /* concatenate the contents and the string */
extern int gr_init() ; /* Initialize the bookkeeping */
extern char *gr_final() ; /* Transform to a stable storage string */

View File

@@ -1,73 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#include "list.h"
/* List handling, operations allowed:
adding strings to the list,
throwing away whole lists,
linearize a list.
Routines:
l_add(header,string) Add an element to a list.
header List header, list_head *
string String pointer, char *
the string is NOT copied
l_clear(header) Delete an whole list.
header List header, list_head *
*/
l_add(header,string) list_head *header ; char *string ; {
register list_elem *new;
/* NOSTRICT */
new= (list_elem *)getcore(sizeof *new);
l_content(*new)= string ;
/* NOSTRICT */
l_next(*new)= (list_elem *)0 ;
if ( !header->ca_first ) {
header->ca_first= new ;
} else {
header->ca_last->ca_next= new ;
}
header->ca_last= new ;
}
l_clear(header) list_head *header ; {
register list_elem *old, *next;
for ( old=header->ca_first ; old ; old= next ) {
next= old->ca_next ;
freecore((char *)old) ;
}
header->ca_first= (list_elem *) 0 ;
header->ca_last = (list_elem *) 0 ;
}
l_throw(header) list_head *header ; {
register list_elem *old, *next;
for ( old=header->ca_first ; old ; old= next ) {
throws(l_content(*old)) ;
next= old->ca_next ;
freecore((char *)old) ;
}
header->ca_first= (list_elem *) 0 ;
header->ca_last = (list_elem *) 0 ;
}

View File

@@ -1,23 +0,0 @@
struct ca_elem {
struct ca_elem *ca_next; /* The link */
char *ca_cont; /* The contents */
} ;
struct ca_list {
struct ca_elem *ca_first; /* The head */
struct ca_elem *ca_last; /* The tail */
} ;
typedef struct ca_list list_head ; /* The decl. for headers */
typedef struct ca_elem list_elem ; /* The decl. for elements */
/* Some operations */
/* Access */
#define l_first(header) (header).ca_first
#define l_next(elem) (elem).ca_next
#define l_content(elem) (elem).ca_cont
/* To be used for scanning lists, ptr is the running variable */
#define scanlist(elem,ptr) \
for ( ptr= elem ; ptr; ptr= l_next(*ptr) )

View File

@@ -1,340 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#include "list.h"
#include "trans.h"
#include "../../h/em_path.h"
#include "../../h/local.h"
#include "data.h"
#include <signal.h>
static int sigs[] = { SIGINT, SIGHUP, SIGTERM, 0 } ;
extern char *getenv();
main(argc,argv) char **argv ; {
register list_elem *elem ;
register char *frontend ;
register int *n_sig ;
progname=argv[0];
varinit();
vieuwargs(argc,argv);
if ( (frontend=getenv("ACKFE")) ) {
setlist(frontend) ;
} else {
setlist(FRONTENDS);
}
setlist(machine);
transini();
scanneeds();
template= mktemp(ACKNAME) ;
if ( n_error && !k_flag ) return n_error ;
for ( n_sig=sigs ; *n_sig ; n_sig++ ) {
if ( signal(*n_sig,noodstop)==SIG_IGN ) {
signal(*n_sig,SIG_IGN) ;
}
}
scanlist ( l_first(arguments), elem ) {
if ( !process(l_content(*elem)) && !k_flag ) return 1 ;
}
orig.p_path= (char *)0 ;
if ( !combiner && !stopsuffix ) {
/* Call combiner directly without any transformation */
scanlist(l_first(tr_list),elem) {
if ( t_cont(*elem)->t_combine ) {
combiner= t_cont(*elem) ;
}
}
}
if ( !combiner || n_error ) return n_error ;
if ( !do_combine() ) return 1 ;
if ( g_flag ) {
return do_run();
}
return 0 ;
}
char *srcvar() {
return orig.p_path ;
}
varinit() {
/* initialize the string variables */
setsvar(keeps(HOME),keeps(EM_DIR)) ;
setpvar(keeps(SRC),srcvar) ;
}
/************************* flag processing ***********************/
vieuwargs(argc,argv) char **argv ; {
register char *argp;
register int nextarg ;
register int eaten ;
firstarg(argv[0]) ;
nextarg= 1 ;
while ( nextarg<argc ) {
argp= argv[nextarg] ;
nextarg++ ;
if ( argp[0]!='-' || argp[1]=='l' ) {
/* Not a flag, or a library */
l_add(&arguments,argp) ;
continue ;
}
/* Flags */
eaten=0 ; /* Did not 'eat' tail of flag yet */
switch ( argp[1] ) {
case 'm': if ( machine ) fuerror("Two machines?") ;
machine= &argp[2];
eaten=1 ;
break ;
case 'o': if ( nextarg>=argc ) {
fuerror("-o can't be the last flag") ;
}
if ( outfile ) fuerror("Two results?") ;
outfile= argv[nextarg++] ;
break ;
case 'O': Optflag++ ;
break ;
case 'v': v_flag++ ;
break ;
case 'g': g_flag++ ;
break ;
case 'c': if ( stopsuffix ) fuerror("Two -c flags") ;
stopsuffix= &argp[2]; eaten=1;
if ( *stopsuffix && *stopsuffix!=SUFCHAR ) {
fuerror("-c flag has invalid tail") ;
}
break ;
case 'k': k_flag++ ;
break ;
case 't': t_flag++ ;
break ;
case 'R': do_Rflag(argp); eaten=1;
break ;
case 'r': if ( argp[2]!=SUFCHAR ) {
error("-r must be followed by %c",SUFCHAR) ;
}
keeptail(&argp[2]); eaten=1 ;
break ;
case '.': if ( rts ) fuerror("Two run-time systems?") ;
rts= &argp[1] ; eaten=1;
keephead(rts) ; keeptail(rts) ;
break ;
#ifdef DEBUG
case 'd': debug++ ;
break ;
#endif
case 0 : nill_flag++ ; eaten++ ;
break;
case 'w': { register char *tokeep ;
w_flag++;
tokeep=keeps(argp) ;
*tokeep |= NO_SCAN ;
l_add(&flags,tokeep) ;
}
break ;
default: /* The flag is not recognized,
put it on the list for the sub-processes
*/
#ifdef DEBUG
if ( debug ) {
vprint("Flag %s: phase dependent\n",argp) ;
}
#endif
l_add(&flags,keeps(argp)) ;
eaten=1 ;
}
if ( argp[2] && !eaten ) {
werror("Unexpected characters at end of %s",argp) ;
}
}
if ( !machine && ! (machine=getenv("ACKM")) ) {
#ifdef ACKM
machine= ACKM; /* The default machine */
#else
fuerror("No machine specified") ;
#endif
}
return ;
}
firstarg(argp) register char *argp ; {
register char *name ;
name=rindex(argp,'/') ;
if ( name && *(name+1) ) {
name++ ;
} else {
name= argp ;
}
if ( strcmp(name,"ack")==0 ) return ;
if ( strcmp(name,"acc")==0 || strcmp(name,"cc")==0 ) {
rts= ".c" ; keephead(rts) ; keeptail(rts) ;
return ;
}
if ( strcmp(name,"apc")==0 || strcmp(name,"pc")==0 ) {
rts= ".p" ; keephead(rts) ; keeptail(rts) ;
return ;
}
machine= name;
}
/************************* argument processing ***********************/
process(arg) char *arg ; {
/* Process files & library arguments */
register list_elem *elem ;
register trf *phase ;
int first=YES ;
#ifdef DEBUG
if ( debug ) vprint("Processing %s\n",arg) ;
#endif
if ( arg[0]=='-' ) { l_add(&c_arguments,keeps(arg)) ; return 1 ; }
p_suffix= rindex(arg,SUFCHAR) ;
if ( p_basename ) throws(p_basename) ;
orig.p_keep= YES ; /* Don't throw away the original ! */
orig.p_path= arg ;
p_basename= keeps(basename(arg)) ;
if ( !p_suffix ) { l_add(&c_arguments,keeps(arg)) ; return 1 ; }
/* Try to find a path through the transformations */
switch( setpath() ) {
case F_NOPATH :
error("Incomplete internal specification for %s",arg) ;
l_add(&c_arguments,keeps(arg)) ;
return 1 ;
case F_NOMATCH :
if ( stopsuffix ) werror("Unknown suffix in %s",arg) ;
l_add(&c_arguments,keeps(arg)) ;
return 1 ;
case F_OK :
break ;
}
orig.p_keeps= NO;
in= orig ;
scanlist(l_first(tr_list), elem) {
phase= t_cont(*elem) ;
if ( phase->t_do ) { /* perform this transformation */
if ( first ) {
if ( !nill_flag ) {
printf("%s\n",arg) ;
}
switch ( phase->t_prep ) {
default : if ( !mayprep() ) break ;
case YES: if ( !transform(cpp_trafo) ) {
n_error++ ;
#ifdef DEBUG
vprint("Pre-processor failed\n") ;
#endif
return 0 ;
}
case NO :
break ;
}
}
if ( cpp_trafo && stopsuffix &&
strcmp(cpp_trafo->t_out,stopsuffix)==0 ) {
break ;
}
if ( !transform(phase) ) {
n_error++ ;
#ifdef DEBUG
if ( debug ) {
vprint("phase %s for %s failed\n",
phase->t_name,orig.p_path) ;
}
#endif
return 0 ;
}
first=NO ;
}
}
#ifdef DEBUG
if ( debug ) vprint("Transformation complete for %s\n",orig.p_path) ;
#endif
if ( !in.p_keep ) fatal("attempt to discard the result file") ;
l_add(&c_arguments,keeps(in.p_path));
disc_files() ;
return 1 ;
}
mayprep() {
int file ;
char fc ;
file=open(in.p_path,0);
if ( file<0 ) return 0 ;
if ( read(file,&fc,1)!=1 ) fc=0 ;
close(file) ;
return fc=='#' ;
}
keephead(suffix) char *suffix ; {
l_add(&head_list, suffix) ;
}
keeptail(suffix) char *suffix ; {
l_add(&tail_list, suffix) ;
}
scanneeds() {
register list_elem *elem ;
scanlist(l_first(head_list), elem) { setneeds(l_content(*elem),0) ; }
l_clear(&head_list) ;
scanlist(l_first(tail_list), elem) { setneeds(l_content(*elem),1) ; }
l_clear(&tail_list) ;
}
setneeds(suffix,tail) char *suffix ; {
register list_elem *elem ;
register trf *phase ;
p_suffix= suffix ;
switch ( setpath() ) {
case F_OK :
scanlist( l_first(tr_list), elem ) {
phase = t_cont(*elem) ;
if ( phase->t_do ) {
if ( phase->t_needed ) {
if ( tail )
add_tail(phase->t_needed) ;
else
add_head(phase->t_needed) ;
}
}
}
break ;
case F_NOMATCH :
werror("\"%s\": unrecognized suffix",suffix) ;
break ;
case F_NOPATH :
werror("incomplete internal specification for %s files",
suffix) ;
break ;
}
}

View File

@@ -1,208 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#ifdef DEBUG
#define ASSERT(p) if(!(p))botch("p");else
botch(s)
char *s;
{
printf("malloc/free botched: %s\n",s);
abort();
}
#else
#define ASSERT(p)
#endif
/* avoid break bug */
#ifdef pdp11
#define GRANULE 64
#else
#define GRANULE 0
#endif
/* C storage allocator
* circular first-fit strategy
* works with noncontiguous, but monotonically linked, arena
* each block is preceded by a ptr to the (pointer of)
* the next following block
* blocks are exact number of words long
* aligned to the data type requirements of ALIGN
* pointers to blocks must have BUSY bit 0
* bit in ptr is 1 for busy, 0 for idle
* gaps in arena are merely noted as busy blocks
* last block of arena (pointed to by alloct) is empty and
* has a pointer to first
* idle blocks are coalesced during space search
*
* a different implementation may need to redefine
* ALIGN, NALIGN, BLOCK, BUSY, INT
* where INT is integer type to which a pointer can be cast
*/
#define INT int
#define ALIGN int
#define NALIGN 1
#define WORD sizeof(union store)
#define BLOCK 1024 /* a multiple of WORD*/
#define BUSY 1
#define NULL 0
#define testbusy(p) ((INT)(p)&BUSY)
#define setbusy(p) (union store *)((INT)(p)|BUSY)
#define clearbusy(p) (union store *)((INT)(p)&~BUSY)
union store { union store *ptr;
ALIGN dummy[NALIGN];
int calloc; /*calloc clears an array of integers*/
};
static union store allocs[2]; /*initial arena*/
static union store *allocp; /*search ptr*/
static union store *alloct; /*arena top*/
static union store *allocx; /*for benefit of realloc*/
char *sbrk();
char *
malloc(nbytes)
unsigned nbytes;
{
register union store *p, *q;
register nw;
static temp; /*coroutines assume no auto*/
if(allocs[0].ptr==0) { /*first time*/
allocs[0].ptr = setbusy(&allocs[1]);
allocs[1].ptr = setbusy(&allocs[0]);
alloct = &allocs[1];
allocp = &allocs[0];
}
nw = (nbytes+WORD+WORD-1)/WORD;
ASSERT(allocp>=allocs && allocp<=alloct);
ASSERT(allock());
for(p=allocp; ; ) {
for(temp=0; ; ) {
if(!testbusy(p->ptr)) {
while(!testbusy((q=p->ptr)->ptr)) {
ASSERT(q>p&&q<alloct);
p->ptr = q->ptr;
}
if(q>=p+nw && p+nw>=p)
goto found;
}
q = p;
p = clearbusy(p->ptr);
if(p>q)
ASSERT(p<=alloct);
else if(q!=alloct || p!=allocs) {
ASSERT(q==alloct&&p==allocs);
return(NULL);
} else if(++temp>1)
break;
}
temp = ((nw+BLOCK/WORD)/(BLOCK/WORD))*(BLOCK/WORD);
q = (union store *)sbrk(0);
if(q+temp+GRANULE < q) {
return(NULL);
}
q = (union store *)sbrk(temp*WORD);
if((INT)q == -1) {
return(NULL);
}
ASSERT(q>alloct);
alloct->ptr = q;
if(q!=alloct+1)
alloct->ptr = setbusy(alloct->ptr);
alloct = q->ptr = q+temp-1;
alloct->ptr = setbusy(allocs);
}
found:
allocp = p + nw;
ASSERT(allocp<=alloct);
if(q>allocp) {
allocx = allocp->ptr;
allocp->ptr = p->ptr;
}
p->ptr = setbusy(allocp);
return((char *)(p+1));
}
/* freeing strategy tuned for LIFO allocation
*/
free(ap)
register char *ap;
{
register union store *p = (union store *)ap;
ASSERT(p>clearbusy(allocs[1].ptr)&&p<=alloct);
ASSERT(allock());
allocp = --p;
ASSERT(testbusy(p->ptr));
p->ptr = clearbusy(p->ptr);
ASSERT(p->ptr > allocp && p->ptr <= alloct);
}
/* realloc(p, nbytes) reallocates a block obtained from malloc()
* and freed since last call of malloc()
* to have new size nbytes, and old content
* returns new location, or 0 on failure
*/
char *
realloc(p, nbytes)
register union store *p;
unsigned nbytes;
{
register union store *q;
union store *s, *t;
register unsigned nw;
unsigned onw;
if(testbusy(p[-1].ptr))
free((char *)p);
onw = p[-1].ptr - p;
q = (union store *)malloc(nbytes);
if(q==NULL || q==p)
return((char *)q);
s = p;
t = q;
nw = (nbytes+WORD-1)/WORD;
if(nw<onw)
onw = nw;
while(onw--!=0)
*t++ = *s++;
if(q<p && q+nw>=p)
(q+(q+nw-p))->ptr = allocx;
return((char *)q);
}
#ifdef DEBUG
allock()
{
#ifdef DEBUG
register union store *p;
int x;
x = 0;
for(p= &allocs[0]; clearbusy(p->ptr) > p; p=clearbusy(p->ptr)) {
if(p==allocp)
x++;
}
ASSERT(p==alloct);
return(x==1|p==allocp);
#else
return(1);
#endif
}
#endif

View File

@@ -1,121 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include <stdio.h>
#include <ctype.h>
char *fname = 0 ;
char dname[200] ;
char *tail ;
FILE *intab ;
FILE *dmach ;
int index ;
main(argc,argv) char **argv ; {
register i ;
start(argv[1]) ;
for ( i=2 ; i<argc ; i++ ) {
fname= argv[i] ;
readm() ;
}
stop(argc>2) ;
return 0 ;
}
start(dir) char *dir ; {
tail= dname ;
while ( *dir ) {
*tail++ = *dir ++ ;
}
if ( tail!=dname ) *tail++= '/' ;
index=0 ;
intab= fopen("intable.c","w");
dmach= fopen("dmach.c","w");
if ( intab==NULL || dmach==NULL ) {
fprintf(stderr,"Couln't create output file(s)\n");
exit ( 1) ;
}
fprintf(dmach,"#include \"dmach.h\"\n\ndmach\tmassoc[] = {\n") ;
fprintf(intab,"char intable[] = {\n") ;
}
stop(filled) {
fprintf(dmach,"\t{\"\",\t-1\t}\n} ;\n") ;
if ( !filled ) fprintf(intab,"\t0\n") ;
fprintf(intab,"\n} ;\n") ;
fclose(dmach); fclose(intab) ;
}
FILE *do_open(file) char *file ; {
strcpy(tail,file) ;
return fopen(dname,"r") ;
}
readm() {
register int i ;
register int token ;
register FILE *in ;
in=do_open(fname) ;
if ( in==NULL ) {
fprintf(stderr,"Cannot open %s\n",fname) ;
return ;
}
i=0 ;
fprintf(dmach,"\t{\"%s\",\t%d\t},\n",fname,index) ;
fprintf(intab,"\n/* %s */\n\t",fname) ;
for (;;) {
token=getc(in) ;
index++ ;
if ( ++i == 10 ) {
fprintf(intab,"\n\t") ;
i=0 ;
} else {
fprintf(intab," ") ;
}
if ( !isascii(token) || !(isprint(token) || isspace(token)) ){
if ( token!=EOF ) {
fprintf(stderr,"warning: non-ascii in %s\n",fname) ;
fprintf(intab,"%4d,",token) ;
} else {
fprintf(intab," 0,",token) ;
break ;
}
} else if ( isprint(token) ) {
switch ( token ) {
case '\'': fprintf(intab,"'\\''") ; break ;
case '\\': fprintf(intab,"'\\\\'") ; break ;
default: fprintf(intab," '%c'",token) ; break ;
}
} else switch ( token ) {
case '\n' : fprintf(intab,"'\\n'") ; break ;
case '\t' : fprintf(intab,"'\\t'") ; break ;
case '\r' : fprintf(intab,"'\\r'") ; break ;
case '\f' : fprintf(intab,"'\\f'") ; break ;
case ' ' : fprintf(intab," ' '") ; break ;
default : fprintf(stderr,"warning: unrec. %d\n",
token) ;
fprintf(intab,"%4d",token) ;
break ;
}
fprintf(intab,",") ;
}
fclose(in) ;
}

View File

@@ -1,2 +0,0 @@
Makefile
em_pc.c

View File

@@ -1,25 +0,0 @@
d=../../..
h=$d/h
PC_PATH=$d/lib/em_pc
em_pc: em_pc.c $h/local.h $h/em_path.h
cc -n -o em_pc -O -I$h em_pc.c
cmp: em_pc
cmp em_pc $(PC_PATH)
install: em_pc
cp em_pc $(PC_PATH)
lint:
lint -hpxc -I$h em_pc.c
clean:
rm -f *.o *.old em_pc
opr:
make pr ^ opr
pr:
pr -n em_pc.c

View File

@@ -1,681 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
/*
* put all the pieces of the pascal part of the EM project together
* original author: Johan Stevenson, Vrije Universiteit, Amsterdam
* heavily modified by: Ed Keizer, Vrije Universiteit, Amsterdam
*/
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/dir.h>
#include <em_path.h>
#include <pc_size.h>
#include <local.h>
#define MAX_FLAG 40 /* The Max. no of '{' flags allowed */
#define void int
char *pc_path = PEM_PATH ;
char *err_path = ERR_PATH;
int toterr;
int parent;
char *eeflag;
char *vvflag = "-V";
int no_pemflag = 0 ;
char *pemflag[MAX_FLAG];
char *eflag;
char *wflag;
int sizes[sz_last+1] = {
2, /* sz_addr */
8, /* sz_real */
0, /* sz_head */
512, /* sz_buff */
4096, /* sz_mset */
2, /* sz_iset */
};
#define CALLSIZE 60
char *callvector[CALLSIZE];
char **av;
int ac;
int fileargs; /* number of recognized, processed args */
int flagargs;
char *progname;
char *source;
#define CHARSIZE 2500
#define CHARMARG 50
char charbuf[CHARSIZE];
char *charp = charbuf;
char *tmp_dir = TMP_DIR;
char *unique = "pcXXXXXX";
char sigs[] = {
SIGHUP,
SIGINT,
SIGTERM,
0
};
/*
* forward function declarations
*/
void finish();
void pem();
int list();
char *flag();
char *tempfile();
char **initvector();
char *basename();
/*
* used library routines and data
*/
extern char *sys_errlist[];
extern int errno;
int atoi();
void exit();
void sleep();
void execv();
char *sbrk();
int chdir();
int fork();
int wait();
int getpid();
int open();
int close();
int read();
main(argc,argv) char **argv; {
register char *p;
char *files[3] ;
for (p = sigs; *p; p++)
if (signal(*p,finish) == SIG_IGN)
signal(*p,SIG_IGN);
ac = argc;
av = argv;
progname = *av++;
init();
while ( --ac>0 ) {
p = *av++;
if (*p == '-') {
flagargs++;
p = flag(p);
} else {
if ( fileargs>=3 ) fatal("Too many file arguments") ;
files[fileargs++]= p;
}
}
if ( fileargs!=3 ) fatal("Not enough arguments") ;
source=files[2] ;
pem(files[0],files[1]) ;
finish();
}
char *flag(f) char *f; {
register char *p;
p = f+1;
switch (*p++) {
case 'e':
eflag = f;
break;
case 'E':
eeflag = f;
break;
case 'w':
wflag = f;
break;
case 'V':
vvflag = f;
return(0);
case '{':
if ( no_pemflag>=MAX_FLAG ) {
ermess("too many flags, ignored %s",f) ;
} else {
pemflag[no_pemflag++] = p;
}
return(0);
case 'R':
pc_path= p ;
return 0 ;
case 'r' :
err_path= p ;
return 0 ;
default:
return(f);
}
if (*p)
fatal("bad flag %s",f);
return(0);
}
initsizes(f) FILE *f; {
register c, i;
register char *p;
p = vvflag + 2;
while (c = *p++) {
i = atoi(p);
while (*p >= '0' && *p <= '9')
p++;
switch (c) {
case 'p': sz_addr = i; continue;
case 'f': sz_real = i; continue;
case 'h': sz_head = i; continue;
case 'b': sz_buff = i; continue;
case 'm': sz_mset = i; continue;
case 'j': sz_iset = i; continue;
case 'w':
case 'i': if (i == 2) continue; break;
case 'l': if (i == 4) continue; break;
}
fatal("bad V-flag %s",vvflag);
}
if (sz_head == 0)
sz_head = 6*sz_word + 2*sz_addr;
for (i = 0; i <= sz_last; i++)
fprintf(f, "%d\n",sizes[i]);
}
/* ------------------ calling sequences -------------------- */
pem(p,q) char *p,*q; {
register char **v,*d;
int i;
FILE *erfil;
v = initvector(pc_path);
d = tempfile('d');
if ((erfil = fopen(d,"w")) == NULL)
syserr(d);
initsizes(erfil);
fprintf(erfil,"%s\n",basename(source));
for ( i=0 ; i<no_pemflag ; i++ ) fprintf(erfil,"%s\n",pemflag[i]);
fclose(erfil);
*v++ = q;
*v++ = d;
call(v,p,(char *)0);
if (toterr == 0)
if (list(p,d) < 0)
toterr++;
donewith(d);
}
/* ------------------- miscellaneous routines --------------- */
char *basename(p) char *p; {
register char *q;
q = p;
while (*q)
if (*q++ == '/')
p = q;
return(p);
}
char *tempfile(suf) {
register char *p,*q;
register i;
p = charp; q = tmp_dir;
while (*p = *q++)
p++;
*p++ = '/';
q = unique;
while (*p = *q++)
p++;
i = fileargs;
do
*p++ = i % 10 + '0';
while (i /= 10);
*p++ = '.'; *p++ = suf; *p++ = '\0';
q = charp; charp = p;
return(q);
}
call(v,in,out) char **v,*in,*out; {
register pid;
int status;
while ((parent = fork()) < 0)
sleep(1);
if (parent == 0) {
if (in) {
close(0);
if (open(in,0) != 0)
syserr(in);
}
if (out) {
close(1);
if (creat(out,0666) != 1)
syserr(out);
}
*v = 0;
execv(callvector[0],callvector+1);
syserr(callvector[0]);
}
while ((pid = wait(&status)) != parent) {
if (pid == -1)
fatal("process %d disappeared",parent);
fatal("unknown child %d died",pid);
}
if ((status & 0177) > 3) {
/*
if ((status & 0200) && tflag==0)
unlink("core");
*/
fatal("signal %d in %s. Ask an expert for help",
status&0177,callvector[0]);
}
if (status & 0177400)
toterr++;
}
char **initvector(path) char *path; {
register char *p,**v;
v = callvector;
p = path;
*v++ = p;
*v++ = basename(p);
return(v);
}
finish() {
register char *p,*q;
register fd;
struct direct dir;
signal(SIGINT,SIG_IGN);
if (parent != 0) {
chdir(tmp_dir);
fd = open(".",0);
while (read(fd,(char *) &dir,sizeof dir) == sizeof dir) {
if (dir.d_ino == 0)
continue;
p = unique;
q = dir.d_name;
while (*p++ == *q++)
if (*p == '\0') {
unlink(dir.d_name);
break;
}
}
close(fd);
}
exit(toterr ? -1 : 0);
}
donewith(p) char *p; {
if (p >= charbuf && p < &charbuf[CHARSIZE])
unlink(p);
}
init() {
register char *p;
register i,fd;
if ((fd = open(tmp_dir,0)) < 0)
tmp_dir = ".";
close(fd);
p = unique+2;
parent = i = getpid();
do
*p++ = i % 10 + '0';
while (i /= 10);
*p++ = '.'; *p = '\0';
}
/* ------------------- pascal listing ----------------------- */
#define MAXERNO 300
#define MAXERRLIST 10
#define IDMAX 8
struct errec {
int erno;
char mess[IDMAX+1];
int mesi;
int chno;
int lino;
};
struct errec curr;
struct errec next;
int *index = 0;
int maxerno;
int errerr;
int errfat;
int listlino;
int listorig;
int listrela;
char *listfnam;
FILE *inpfil;
FILE *mesfil;
FILE *errfil;
int errorline();
int geterrec();
int nexterror();
int list(p,q) char *p,*q; {
if ((errfil = fopen(q,"r")) == NULL)
syserr(q);
if (geterrec() == 0)
if (eeflag==0) {
fclose(errfil);
return(0);
}
if (index == 0) {
index = (int *) sbrk(MAXERNO * sizeof index[0]);
fillindex();
}
if ((inpfil = fopen(p,"r")) == NULL)
syserr(p);
errerr = 0;
errfat = 0;
listlino = 0;
listorig = 0;
listrela = 0;
listfnam = source;
if (eeflag)
listfull();
else if (eflag)
listpartial();
else
listshort();
fclose(errfil);
fclose(inpfil);
fflush(stdout);
return(errfat ? -1 : 1);
}
listshort() {
while (nexterror()) {
while (listlino < curr.lino)
nextline(0);
printf("%s, line %d: ",listfnam,listrela);
string(&curr);
}
}
listfull() {
if (nexterror())
do {
do {
nextline(1);
} while (listlino < curr.lino);
} while (errorline());
while (nextline(1))
;
}
listpartial() {
if (nexterror())
do {
do {
nextline(listlino >= curr.lino-2);
} while (listlino < curr.lino);
} while (errorline());
}
int nextline(printing) {
register ch;
listlino++;
ch = getc(inpfil);
if (ch == '#') {
if (lineline(printing) == 0)
fatal("bad line directive");
return(1);
}
listrela++;
if (listfnam == source)
listorig++;
if (ch != EOF) {
if (printing)
printf("%5d\t",listorig);
do {
if (printing)
putchar(ch);
if (ch == '\n')
return(1);
} while ((ch = getc(inpfil)) != EOF);
}
return(0);
}
lineline(printing) {
register ch;
register char *p,*q;
static char line[100];
p = line;
while ((ch = getc(inpfil)) != '\n') {
if (ch == EOF || p == &line[100-1])
return(0);
*p++ = ch;
}
*p = '\0'; p = line;
if (printing)
printf("\t#%s\n",p);
if ((listrela = atoi(p)-1) < 0)
return(0);
while ((ch = *p++) != '"')
if (ch == '\0')
return(0);
q = p;
while (ch = *p++) {
if (ch == '"') {
*--p = '\0';
if ( source ) {
listfnam = strcmp(q,source)==0 ? source : q;
return(1);
}
source=q ; listfnam=q ;
return 1 ;
}
if (ch == '/')
q = p;
}
return(0);
}
int errorline() {
register c;
register struct errec *p,*q;
struct errec lerr[MAXERRLIST];
int goon;
printf("*** ***");
p = lerr;
c = 0;
do {
if (c < curr.chno) {
printf("%*c",curr.chno-c,'^');
c = curr.chno;
}
if (p < &lerr[MAXERRLIST])
*p++ = curr;
goon = nexterror();
} while (goon && curr.lino==listlino);
putchar('\n');
for (q = lerr; q < p; q++)
string(q);
putchar('\n');
return(goon);
}
int geterrec() {
register ch;
register char *p;
ch = getc(errfil);
next.erno = 0;
next.mesi = -1;
next.mess[0] = '\0';
if (ch == EOF)
return(0);
if (ch >= '0' && ch <= '9') {
ch = getnum(ch,&next.mesi);
} else if (ch == '\'') {
p = next.mess;
while ((ch = getc(errfil)) != ' ' && ch != EOF)
if (p < &next.mess[IDMAX])
*p++ = ch;
*p = '\0';
}
ch = getnum(ch, &next.erno);
ch = getnum(ch, &next.lino);
ch = getnum(ch, &next.chno);
if (ch != '\n')
fatal("bad error line");
return(1);
}
int getnum(ch, ip) register ch; register *ip; {
register neg;
*ip = 0;
while (ch == ' ')
ch = getc(errfil);
if (neg = ch=='-')
ch = getc(errfil);
while (ch >= '0' && ch <= '9') {
*ip = *ip * 10 - '0' + ch;
ch = getc(errfil);
}
if (neg)
*ip = -(*ip);
return(ch);
}
int nexterror() {
do { /* skip warnings if wflag */
curr = next;
if (curr.erno == 0)
return(0);
for (;;) {
if (geterrec() == 0)
break;
if (next.lino != curr.lino || next.chno != curr.chno)
break;
if (curr.erno < 0 && next.erno > 0)
/* promote warnings if they cause fatals */
curr.erno = -curr.erno;
if (next.mess[0] != '\0' || next.mesi != -1)
/* give all parameterized errors */
break;
if (curr.mess[0] != '\0' || curr.mesi != -1)
/* and at least a non-parameterized one */
break;
}
} while (curr.erno < 0 && wflag != 0);
return(1);
}
fillindex() {
register *ip,n,c;
if ((mesfil = fopen(err_path,"r")) == NULL)
syserr(err_path);
ip = index;
*ip++ = 0;
n = 0;
while ((c = getc(mesfil)) != EOF) {
n++;
if (c == '\n') {
*ip++ = n;
if (ip > &index[MAXERNO])
fatal("too many errors on %s",err_path);
}
}
maxerno = ip - index;
}
string(ep) register struct errec *ep; {
register i,n;
errerr++;
if ((i = ep->erno) < 0) {
i = -i;
printf("Warning: ");
} else
errfat++;
if (i == 0 || i >= maxerno)
fatal("bad error number %d",i);
n = index[i] - index[i-1];
fseek(mesfil,(long)index[i-1],0);
while (--n >= 0) {
i = getc(mesfil);
if (i == '%' && --n>=0) {
i = getc(mesfil);
if (i == 'i')
printf("%d", ep->mesi);
else if (i == 's')
printf("%s", ep->mess);
else
putchar(i);
} else
putchar(i);
}
}
/* ------------------- error routines -------------------------- */
/* VARARGS1 */
void ermess(s,a1,a2,a3,a4) char *s; {
fprintf(stderr,"%s: ",progname);
fprintf(stderr,s,a1,a2,a3,a4);
fprintf(stderr,"\n");
}
syserr(s) char *s; {
fatal("%s: %s",s,sys_errlist[errno]);
}
/* VARARGS1 */
void fatal(s,a1,a2,a3,a4) char *s; {
ermess(s,a1,a2,a3,a4);
toterr++;
finish();
}

View File

@@ -1,288 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#include "../../h/em_path.h"
#include "list.h"
#include "trans.h"
#include "grows.h"
#include "dmach.h"
#include "data.h"
#include <stdio.h>
/************************************************************************/
/* */
/* Read machine definitions and transformations */
/* */
/************************************************************************/
#define COMMENT '#'
#define VAR "var"
#define PASS "name"
#define IN "from"
#define OUT "to"
#define PROG "program"
#define MAPF "mapflag"
#define ARGS "args"
#define PROP "prop"
#define RUNT "rts"
#define NEEDT "need"
#define END "end"
extern growstring scanb();
extern growstring scanvars();
int getline() ;
int getinchar() ;
static char *ty_name ;
static char *bol ;
static char *inname ;
setlist(name) char *name ; {
/* Name is sought in the internal tables,
if not present, the a file of that name is sought
in first the current and then the EM Lib directory
*/
inname=name ;
open_in(name) ;
while ( getline() ) {
if ( strcmp(VAR,ty_name)==0 ) {
doassign(bol,(char *)0,0) ;
} else
if ( strcmp(PASS,ty_name)==0 ) {
intrf() ;
} else
error("unknown keyword %s",ty_name) ;
}
close_in();
#ifdef DEBUG
if ( debug>=3 ) vprint("End %s\n",name) ;
#endif
}
intrf() {
register trf *new ;
register char *ptr ;
growstring bline, vline ;
int twice ;
new= (trf *)getcore(sizeof *new) ;
new->t_name= keeps(bol) ;
for (;;) {
if ( !getline() ) {
fuerror("unexpected EOF on %s",inname) ;
}
twice= NO ;
if ( strcmp(ty_name,IN)==0 ) {
if ( new->t_in ) twice=YES ;
new->t_in= keeps(bol);
} else
if ( strcmp(ty_name,OUT)==0 ) {
if ( new->t_out ) twice=YES ;
new->t_out= keeps(bol);
} else
if ( strcmp(ty_name,PROG)==0 ) {
if ( new->t_prog ) twice=YES ;
bline= scanb(bol); /* Scan for \ */
vline= scanvars(gr_start(bline)); /* Scan for {} */
gr_throw(&bline);
new->t_prog= gr_final(&vline);
clr_noscan(new->t_prog);
} else
if ( strcmp(ty_name,MAPF)==0 ) {
/* First read the mapflags line
and scan for backslashes */
bline= scanb(bol) ;
l_add(&new->t_mapf,gr_final(&bline)) ;
} else
if ( strcmp(ty_name,ARGS)==0 ) {
if ( new->t_argd ) twice=YES ;
bline= scanb(bol) ;
new->t_argd= keeps(gr_start(bline)) ;
gr_throw(&bline) ;
} else
if ( strcmp(ty_name,PROP)==0 ) {
for ( ptr=bol ; *ptr ; ptr++ ) {
switch( *ptr ) {
case C_IN: new->t_stdin= YES ; break ;
case C_OUT: new->t_stdout= YES ; break ;
case 'P': new->t_isprep= YES ; break ;
case 'p': new->t_prep= YES ; break ;
case 'm': new->t_prep= MAYBE ; break ;
case 'O': new->t_optim= YES ; break ;
case 'C': new->t_combine= YES ; break ;
default :
error("Unkown option %c in %s for %s",
*ptr,new->t_name,inname) ;
break ;
}
}
} else
if ( strcmp(ty_name,RUNT)==0 ) {
if ( new->t_rts ) twice=YES ;
new->t_rts= keeps(bol) ;
} else
if ( strcmp(ty_name,NEEDT)==0 ) {
if ( new->t_needed ) twice=YES ;
new->t_needed= keeps(bol) ;
} else
if ( strcmp(ty_name,END)==0 ) {
break ;
} else {
fuerror("illegal keyword %s %s",ty_name,bol);
}
if ( twice ) {
werror("%s: specified twice for %s",
ty_name, new->t_name) ;
}
}
if ( ! ( new->t_name && new->t_out && new->t_prog ) ) {
fuerror("insufficient specification for %s in %s",
new->t_name,inname) ;
}
if ( ! new->t_argd ) new->t_argd="" ;
#ifdef DEBUG
if ( debug>=3 ) {
register list_elem *elem ;
vprint("%s: from %s to %s '%s'\n",
new->t_name,new->t_in,new->t_out,new->t_prog) ;
vprint("\targs: ") ; prns(new->t_argd) ;
scanlist( l_first(new->t_mapf), elem ) {
vprint("\t%s\n",l_content(*elem)) ;
}
if ( new->t_rts ) vprint("\trts: %s\n",new->t_rts) ;
if ( new->t_needed ) vprint("\tneeded: %s\n",new->t_needed) ;
}
#endif
l_add(&tr_list,(char *)new) ;
}
/************************** IO from core or file *******************/
static int incore ;
static growstring rline ;
static FILE *infile ;
static char *inptr ;
open_in(name) register char *name ; {
register dmach *cmac ;
gr_init(&rline) ;
for ( cmac= massoc ; cmac->ma_index!= -1 ; cmac++ ) {
if ( strcmp(name,cmac->ma_name)==0 ) {
incore=YES ;
inptr= &intable[cmac->ma_index] ;
return ;
}
}
/* Not in core */
incore= NO ;
gr_cat(&rline,ACK_DIR); gr_cat(&rline,"/") ;
gr_cat(&rline,name) ;
infile= fopen(gr_start(rline),"r") ;
if ( !infile ) {
infile= fopen(name,"r") ;
}
if ( infile==NULL ) {
fuerror("Cannot find description for %s",name) ;
}
}
close_in() {
if ( !incore ) fclose(infile) ;
gr_throw(&rline) ;
}
char *readline() {
/* Get a line from the input,
return 0 if at end,
The line is stored in a volatile buffer,
a pointer to the line is returned.
*/
register int nchar ;
enum { BOL, ESCAPE, SKIPPING, MOL } state = BOL ;
gr_throw(&rline) ;
for (;;) {
nchar= getinchar() ;
if ( nchar==EOF ) {
if ( state!=BOL ) {
werror("incomplete line in %s", inname) ;
}
return 0 ;
}
if ( state==SKIPPING ) {
if ( nchar=='\n' ) {
state= MOL ;
} else {
continue ;
}
}
if ( state==ESCAPE ) {
switch( nchar ) {
case '\n' :
break ;
default :
gr_add(&rline,BSLASH) ;
case COMMENT :
case BSLASH :
gr_add(&rline,nchar) ;
break ;
}
state= MOL ;
continue ;
}
switch ( nchar ) {
case '\n' : gr_add(&rline,0) ;
return gr_start(rline) ;
case COMMENT : state= SKIPPING ;
break ;
case BSLASH : state= ESCAPE ;
break ;
default : gr_add(&rline,nchar) ;
state= MOL ;
}
}
}
int getinchar() {
if ( incore ) {
if ( *inptr==0 ) return EOF ;
return *inptr++ ;
}
return getc(infile) ;
}
int getline() {
register char *c_ptr ;
do {
if ( (c_ptr=readline())==(char *)0 ) return 0 ;
ty_name= skipblank(c_ptr) ;
} while ( *ty_name==0 ) ;
c_ptr= firstblank(ty_name) ;
if ( *c_ptr ) {
*c_ptr++ =0 ;
c_ptr= skipblank(c_ptr) ;
}
bol= c_ptr ;
return 1 ;
}

View File

@@ -1,154 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#include "list.h"
#include "trans.h"
#include "data.h"
#include <signal.h>
#define ARG_MORE 40 /* The size of args chunks to allocate */
static char **arglist ; /* The first argument */
static unsigned argcount ; /* The current number of arguments */
static unsigned argmax; /* The maximum number of arguments so far */
int do_run() {
fatal("-g flag not implemeted") ;
/*NOTREACHED*/
return 0 ;
}
int runphase(phase) register trf *phase ; {
register list_elem *elem ;
if ( v_flag || debug ) {
if ( v_flag==1 && !debug ) {
vprint("%s",phase->t_name) ;
if ( !phase->t_combine ) {
vprint(" %s%s\n",p_basename,
rindex(in.p_path,SUFCHAR) ) ;
} else {
scanlist(l_first(c_arguments), elem) {
vprint(" %s",l_content(*elem)) ;
}
vprint("\n") ;
}
} else {
/* list all args */
vprint("%s",phase->t_prog) ;
scanlist(l_first(phase->t_flags), elem) {
vprint(" %s",l_content(*elem)) ;
}
scanlist(l_first(phase->t_args), elem) {
vprint(" %s",l_content(*elem)) ;
}
vprint("\n") ;
}
}
argcount=0 ;
x_arg(phase->t_name) ;
scanlist(l_first(phase->t_flags), elem) {
x_arg(l_content(*elem)) ;
}
scanlist(l_first(phase->t_args), elem) {
x_arg(l_content(*elem)) ;
}
x_arg( (char *)0 ) ;
return run_exec(phase) ;
}
int run_exec(phase) trf *phase ; {
int status, child, waitchild ;
do_flush();
while ( (child=fork())== -1 ) ;
if ( child ) {
/* The parent */
do {
waitchild= wait(&status) ;
if ( waitchild== -1 ) {
fatal("missing child") ;
}
} while ( waitchild!=child) ;
if ( status ) {
if ( status&0200 && (status&0177)!=SIGQUIT &&
!t_flag ) unlink("core") ;
switch ( status&0177 ) {
case 0 :
break ;
case SIGHUP:
case SIGINT:
case SIGQUIT:
case SIGTERM:
quit(-5) ;
default:
error("%s died with signal %d",
phase->t_prog,status&0177) ;
}
/* The assumption is that processes voluntarely
dying with a non-zero status already produced
some sort of error message to the outside world.
*/
n_error++ ;
return 0 ;
}
return 1 ; /* From the parent */
}
/* The child */
if ( phase->t_stdin ) {
if ( !in.p_path ) {
fatal("no input file for %s",phase->t_name) ;
}
close(0) ;
if ( open(in.p_path,0)!=0 ) {
error("cannot open %s",in.p_path) ;
exit(1) ;
}
}
if ( phase->t_stdout ) {
if ( !out.p_path ) {
fatal("no output file for %s",phase->t_name) ;
}
close(1) ;
if ( creat(out.p_path,0666)!=1 ) {
close(1); dup(2);
error("cannot open %s",out.p_path) ;
exit(1) ;
}
}
execv(phase->t_prog,arglist) ;
if ( phase->t_stdout ) { close(1) ; dup(2) ; }
error("Cannot execute %s",phase->t_prog) ;
exit(1) ;
/*NOTREACHED*/
}
x_arg(string) char *string ; {
/* Add one execute argument to the argument vector */
if ( argcount==argmax ) {
if ( argmax==0 ) {
argmax= 2*ARG_MORE ;
arglist= (char **)getcore(argmax*sizeof (char *)) ;
} else {
argmax += ARG_MORE ;
arglist= (char **)changecore((char *)arglist,
argmax*sizeof (char *)) ;
}
}
*(arglist+argcount++) = string ;
}

View File

@@ -1,244 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#include "list.h"
#include "trans.h"
#include "data.h"
enum f_path setpath() { /* Try to find a transformation path */
start_scan();
/*
The end result is the setting of the t_do flags
in the transformation list.
The list is scanned for possible transformations
stopping at stopsuffix or a combine transformation.
The scan flags are set by this process.
When a transformation is found, it is compared with
the last transformation found, if better (or the first)
the scan bits are copied to the t_do bits, except for
the combiner which is remembered in a global pointer.
At the end of all transformations for all files, the combiner
is called, unless errors occurred.
*/
try(l_first(tr_list),p_suffix);
return scan_end();
}
/******************** data used only while scanning *******************/
static int last_ncount; /* The # of non-optimizing transformations
in the best path sofar */
static int last_ocount; /* The # of optimizing transformations in the
best path sofar */
static int com_err; /* Complain only once about multiple linkers*/
static trf *final; /* The last non-combining transformation */
static int suf_found; /* Was the suffix at least recognized ? */
/******************** The hard work ********************/
start_scan() {
register list_elem *scan ;
scanlist(l_first(tr_list),scan) {
t_cont(*scan)->t_do=NO ; t_cont(*scan)->t_scan=NO ;
t_cont(*scan)->t_keep=NO ;
}
final= (trf *)0 ;
suf_found= 0 ;
#ifdef DEBUG
if ( debug>=3 ) vprint("Scan_start\n");
#endif
last_ncount= -1 ;
last_ocount= 0 ;
}
try(f_scan,suffix) list_elem *f_scan; char *suffix; {
register list_elem *scan ;
register trf *trafo ;
/* Try to find a transformation path starting at f_scan for a
file with the indicated suffix.
If the suffix is already reached or the combiner is found
call scan_found() to OK the scan.
If a transformation is found it calls itself recursively
with as starting point the next transformation in the list.
*/
if ( stopsuffix && *stopsuffix && strcmp(stopsuffix,suffix)==0 ) {
scan_found();
return ;
}
scanlist(f_scan, scan) {
trafo= t_cont(*scan) ;
if ( satisfy(trafo,suffix) ) {
/* Found a transformation */
suf_found= 1;
#ifdef DEBUG
if ( debug>=4 ) {
vprint("Found %s for %s: result %s\n",
trafo->t_name,suffix,trafo->t_out);
}
#endif
trafo->t_scan=YES ;
if ( trafo->t_prep ) {
if ( !cpp_trafo ) {
find_cpp() ;
}
if ( stopsuffix &&
strcmp(stopsuffix,
cpp_trafo->t_out)==0 )
{
scan_found() ;
return ;
}
}
if ( trafo->t_combine ) {
if ( stopsuffix ) {
trafo->t_scan=NO;
if ( *stopsuffix ) return ;
} else {
if( combiner &&
combiner!=trafo && !com_err ){
com_err++ ;
werror("Multiple linkers present %s and %s",
trafo->t_name,combiner->t_name) ;
} else {
combiner=trafo;
}
}
scan_found() ;
} else {
try(l_next(*scan),trafo->t_out);
}
trafo->t_scan= NO ;
}
}
}
scan_found() {
register list_elem *scan;
int ncount, ocount ;
register trf *keepit ;
keepit= (trf *)0 ;
suf_found= 1;
#ifdef DEBUG
if ( debug>=3 ) vprint("Scan found\n") ;
#endif
/* Gather data used in comparison */
ncount=0; ocount=0;
scanlist(l_first(tr_list),scan) {
if (t_cont(*scan)->t_scan) {
#ifdef DEBUG
if ( debug>=4 ) vprint("%s-",t_cont(*scan)->t_name) ;
#endif
if( t_cont(*scan)->t_optim ) ocount++ ;else ncount++ ;
if ( !(t_cont(*scan)->t_combine) ) {
keepit= t_cont(*scan) ;
}
}
}
#ifdef DEBUG
if ( debug>=4 ) vprint("\n");
#endif
/* Is this transformation better then any found yet ? */
#ifdef DEBUG
if ( debug>=3 ) {
vprint("old n:%d, o:%d - new n:%d, o:%d\n",
last_ncount,last_ocount,ncount,ocount) ;
}
#endif
if ( last_ncount== -1 || /* None found yet */
last_ncount>ncount || /* Shorter nec. path */
(last_ncount==ncount && /* Same nec. path, optimize?*/
(Optflag? last_ocount<ocount : last_ocount>ocount ) ) ) {
/* Yes it is */
#ifdef DEBUG
if ( debug>=3 ) vprint("Better\n");
#endif
scanlist(l_first(tr_list),scan) {
t_cont(*scan)->t_do=t_cont(*scan)->t_scan;
}
last_ncount=ncount; last_ocount=ocount;
if ( keepit ) final=keepit ;
}
}
int satisfy(trafo,suffix) register trf *trafo; char *suffix ; {
register char *f_char, *l_char ;
/* Check whether this transformation is present for
the current machine and the parameter suffix is among
the input suffices. If so, return 1. 0 otherwise
*/
if ( trafo->t_isprep ) return 0 ;
l_char=trafo->t_in ;
while ( l_char ) {
f_char= l_char ;
if ( *f_char!=SUFCHAR || ! *(f_char+1) ) {
fuerror("Illegal input suffix entry for %s",
trafo->t_name) ;
}
l_char=index(f_char+1,SUFCHAR);
if ( l_char ? strncmp(f_char,suffix,l_char-f_char)==0 :
strcmp(f_char,suffix)==0 ) {
return 1 ;
}
}
return 0 ;
}
enum f_path scan_end() { /* Finalization */
/* Return value indicating whether a transformation was found */
/* Set the flags for the transformation up to, but not including,
the combiner
*/
#ifdef DEBUG
if ( debug>=3 ) vprint("End_scan\n");
#endif
if ( last_ncount== -1 ) return suf_found ? F_NOPATH : F_NOMATCH ;
#ifdef DEBUG
if ( debug>=2 ) vprint("Transformation found\n");
#endif
if ( cpp_trafo && stopsuffix &&
strcmp(stopsuffix,cpp_trafo->t_out)==0 ) {
final= cpp_trafo ;
}
/* There might not be a final when the file can be eaten
by the combiner
*/
if ( final ) final->t_keep=YES ;
if ( combiner ) {
if ( !combiner->t_do ) error("Combiner YES/NO");
combiner->t_do=NO ;
}
return F_OK ;
}
find_cpp() {
register list_elem *elem ;
scanlist( l_first(tr_list), elem ) {
if ( t_cont(*elem)->t_isprep ) {
if ( cpp_trafo ) fuerror("Multiple cpp's present") ;
cpp_trafo= t_cont(*elem) ;
}
}
if ( !cpp_trafo ) fuerror("No cpp present") ;
}

View File

@@ -1,125 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
/* The processing of string valued variables,
this is an almost self contained module.
Five externally visible routines:
setsvar(name,result)
Associate the name with the result.
name a string pointer
result a string pointer
setpvar(name,routine)
Associate the name with the routine.
name a string pointer
routine a routine id
The parameters name and result are supposed to be pointing to
non-volatile string storage used only for this call.
char *getvar(name)
returns the pointer to a string associated with name,
the pointer is produced by returning result or the
value returned by calling the routine.
name a string pointer
Other routines called
fatal(args*) When something goes wrong
getcore(size) Core allocation
*/
extern char *getcore();
extern fatal();
struct vars {
char *v_name;
enum { routine, string } v_type;
union {
char *v_string;
char *(*v_routine)();
} v_value ;
struct vars *v_next ;
};
static struct vars *v_first ;
static struct vars *newvar(name) char *name; {
register struct vars *new ;
for ( new=v_first ; new ; new= new->v_next ) {
if ( strcmp(name,new->v_name)==0 ) {
throws(name) ;
if ( new->v_type== string ) {
throws(new->v_value.v_string) ;
}
return new ;
}
}
new= (struct vars *)getcore( (unsigned)sizeof (struct vars));
new->v_name= name ;
new->v_next= v_first ;
v_first= new ;
return new ;
}
setsvar(name,str) char *name, *str ; {
register struct vars *new ;
new= newvar(name);
#ifdef DEBUG
if ( debug>=2 ) vprint("%s=%s\n", name, str) ;
#endif
new->v_type= string;
new->v_value.v_string= str;
}
setpvar(name,rout) char *name, *(*rout)() ; {
register struct vars *new ;
new= newvar(name);
#ifdef DEBUG
if ( debug>=2 ) vprint("%s= (*%o)()\n",name,rout) ;
#endif
new->v_type= routine;
new->v_value.v_routine= rout;
}
char *getvar(name) char *name ; {
register struct vars *scan ;
for ( scan=v_first ; scan ; scan= scan->v_next ) {
if ( strcmp(name,scan->v_name)==0 ) {
switch ( scan->v_type ) {
case string:
return scan->v_value.v_string ;
case routine:
return (*scan->v_value.v_routine)() ;
}
}
}
return (char *)0 ;
}

View File

@@ -1,672 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
#include "ack.h"
#include "list.h"
#include "trans.h"
#include "grows.h"
#include "data.h"
/****************************************************************************/
/* Routines for transforming from one file type to another */
/****************************************************************************/
static growstring head ;
static int touch_head= NO ;
static growstring tail ;
static int touch_tail= NO ;
char *headvar(),*tailvar() ;
int transform(phase) register trf *phase ; {
int ok ;
if ( !setfiles(phase) ) return 0 ;
if ( !phase->t_visited ) {
/* The flags are set up once.
At the first time the phase is used.
The program name and flags may already be touched
by vieuwargs.
*/
phase->t_visited=YES ;
if ( !rts && phase->t_rts ) rts= phase->t_rts ;
if ( phase->t_needed ) {
add_head(phase->t_needed) ;
add_tail(phase->t_needed) ;
}
}
getcallargs(phase) ;
ok= runphase(phase) ;
if ( !ok ) rmtemps() ;
/* Free the space occupied by the arguments,
except for the combiner, since we are bound to exit soon
and do not foresee further need of memory space */
if ( !phase->t_combine ) discardargs(phase) ;
disc_files() ;
return ok ;
}
int do_combine() {
setsvar(keeps(RTS), keeps(rts? rts : "") ) ;
if ( !outfile ) outfile= combiner->t_out ;
getmapflags(combiner);
return transform(combiner) ;
}
getmapflags(phase) register trf *phase ; {
register list_elem *elem ;
int scanned ;
register char *ptr ;
scanlist(l_first(flags),elem) {
scanned= *(l_content(*elem))&NO_SCAN ;
*(l_content(*elem)) &= ~NO_SCAN ;
if ( mapflag(&(phase->t_mapf),l_content(*elem)) ) {
scanned=NO_SCAN ;
#ifdef DEBUG
if ( debug >=4 ) {
vprint("phase %s, added mapflag for %s\n",
phase->t_name,
l_content(*elem) ) ;
}
#endif
}
*(l_content(*elem)) |= scanned ;
}
if ( phase->t_combine ) {
scanlist(l_first(c_arguments),elem) {
if ( mapflag(&(phase->t_mapf),l_content(*elem)) ) {
throws(l_content(*elem)) ;
ptr= keeps(getvar(LIBVAR)) ;
clr_noscan(ptr) ;
l_content(*elem)= ptr ;
}
}
scanlist(l_first(flags),elem) {
/* Get the flags remaining for the loader,
That is: all the flags neither eaten by ack nor
one of the subprograms called so-far.
The last fact is indicated by the NO_SCAN bit
in the first character of the flag.
*/
if ( !( *(l_content(*elem))&NO_SCAN ) ) {
l_add(&(phase->t_flags),l_content(*elem)) ;
}
}
}
}
do_Rflag(argp) char *argp ; {
l_add(&R_list,argp) ;
}
char *needvar() {
static growstring needed ;
static int been_here = NO ;
if ( !been_here ) {
gr_init(&needed) ;
been_here=YES ;
gr_cat(&needed,headvar()) ;
gr_cat(&needed,tailvar()) ;
}
return gr_start(needed) ;
}
char *headvar() {
if ( !touch_head) return "" ;
return gr_start(head) ;
}
add_head(str) char *str; {
if ( !touch_head) {
gr_init(&head) ;
touch_head=YES ;
}
gr_cat(&head,str) ;
}
char *tailvar() {
if ( !touch_tail ) return "" ;
return gr_start(tail) ;
}
add_tail(str) char *str ; {
if ( !touch_tail ) {
gr_init(&tail) ;
touch_tail=YES ;
}
gr_cat(&tail,str) ;
}
transini() {
register list_elem *elem ;
register trf *phase ;
scanlist(l_first(R_list), elem) {
set_Rflag(l_content(*elem)) ;
}
l_clear(&R_list) ;
scanlist(l_first(tr_list), elem) {
phase = t_cont(*elem) ;
if ( !phase->t_combine ) getmapflags(phase);
}
setpvar(keeps(NEEDS),needvar) ;
setpvar(keeps(HEAD),headvar) ;
setpvar(keeps(TAIL),tailvar) ;
}
set_Rflag(argp) register char *argp ; {
int seen ;
register char *eos ;
register list_elem *prog ;
register int length ;
char *eq ;
eos= index(&argp[2],'-');
eq= index(&argp[2],EQUAL) ;
if ( !eos ) {
eos= eq ;
} else {
if ( eq && eq<eos ) eos= eq ;
}
if ( !eos ) fuerror("Incorrect use of -R flag") ;
length= eos - &argp[2] ;
seen=NO ;
scanlist(l_first(tr_list), prog) {
if ( strncmp(t_cont(*prog)->t_name, &argp[2], length )==0 ) {
if ( *eos=='-' ) {
l_add(&(t_cont(*prog)->t_flags),eos) ;
} else {
t_cont(*prog)->t_prog= eos+1 ;
}
seen=YES ;
}
}
if ( !seen ) error("Cannot find program for %s",argp) ;
return ;
}
/**************************************************************************/
/* */
/* The creation of arguments for exec for a transformation */
/* */
/**************************************************************************/
growstring scanb(line) char *line ; {
/* Scan a line for backslashes, setting the NO_SCAN bit in characters
preceded by a backslash.
*/
register char *in_c ;
register int token ;
growstring result ;
enum { TEXT, ESCAPED } state = TEXT ;
gr_init(&result) ;
for ( in_c= line ; *in_c ; in_c++ ) {
token= *in_c&0377 ;
switch( state ) {
case TEXT :
if ( token==BSLASH ) {
state= ESCAPED ;
} else {
gr_add(&result,token) ;
}
break ;
case ESCAPED :
gr_add(&result,token|NO_SCAN) ;
state=TEXT ;
break ;
}
}
gr_add(&result,0) ;
if ( state!=TEXT ) werror("flag line ends with %c",BSLASH) ;
return result ;
}
growstring scanvars(line) char *line ; {
/* Scan a line variable replacements started by S_VAR.
Two sequences exist: S_VAR name E_VAR, S_VAR name A_VAR text E_VAR.
neither name nor text may contain further replacements.
In the first form an error message is issued if the name is not
present in the variables, the second form produces text
in that case.
The sequence S_VAR S_VAR is transformed into S_VAR.
This to allow later recognition in mapflags, where B_SLASH
would be preventing any recognition.
*/
register char *in_c ;
register int token ;
growstring result ;
growstring name ;
register char *tr ;
enum { TEXT, FIRST, NAME, SKIP, COPY } state = TEXT ;
gr_init(&result) ; gr_init(&name) ;
for ( in_c= line ; *in_c ; in_c++ ) {
token= *in_c&0377 ;
switch( state ) {
case TEXT :
if ( token==S_VAR ) {
state= FIRST ;
} else {
gr_add(&result,token) ;
}
break ;
case FIRST :
switch ( token ) {
case S_VAR :
state= TEXT ;
gr_add(&result,token) ;
break ;
case A_VAR :
case C_VAR :
fatal("empty string variable name") ;
default :
state=NAME ;
gr_add(&name,token) ;
break ;
}
break ;
case NAME:
switch ( token ) {
case A_VAR :
gr_add(&name,0) ;
if ( tr=getvar(gr_start(name)) ) {
while ( *tr ) {
gr_add(&result,*tr++) ;
}
state=SKIP ;
} else {
state=COPY ;
}
gr_throw(&name) ;
break ;
case C_VAR :
gr_add(&name,0) ;
if ( tr=getvar(gr_start(name)) ) {
while ( *tr ) {
gr_add(&result,*tr++);
}
} else {
werror("No definition for %s",
gr_start(name)) ;
}
state=TEXT ;
gr_throw(&name) ;
break ;
default:
gr_add(&name,token) ;
break ;
}
break ;
case SKIP :
if ( token==C_VAR ) state= TEXT ;
break ;
case COPY :
if ( token==C_VAR ) state= TEXT ; else {
gr_add(&result,token) ;
}
break ;
}
}
gr_add(&result,0) ;
if ( state!=TEXT ) {
werror("flag line misses %c",C_VAR) ;
gr_throw(&name) ;
}
return result ;
}
growstring scanexpr(line) char *line ; {
/* Scan a line for conditional or flag expressions,
dependent on the type. The format is
S_EXPR suflist M_EXPR suflist T_EXPR tail C_EXPR
the head and tail are passed to treat, together with the
growstring for futher treatment.
Nesting is not allowed.
*/
register char *in_c ;
char *heads ;
register int token ;
growstring sufs, tailval ;
growstring result ;
static list_head fsuff, lsuff ;
enum { TEXT, FDOT, FSUF, LDOT, LSUF, FTAIL } state = TEXT ;
gr_init(&result) ; gr_init(&sufs) ; gr_init(&tailval) ;
for ( in_c= line ; *in_c ; in_c++ ) {
token= *in_c&0377 ;
switch( state ) {
case TEXT :
if ( token==S_EXPR ) {
state= FDOT ;
heads=in_c ;
} else gr_add(&result,token) ;
break ;
case FDOT :
if ( token==M_EXPR ) {
state=LDOT ;
break ;
}
token &= ~NO_SCAN ;
if ( token!=SUFCHAR ) {
error("Missing %c in expression",SUFCHAR) ;
}
gr_add(&sufs,token) ; state=FSUF ;
break ;
case FSUF :
if ( token==M_EXPR || (token&~NO_SCAN)==SUFCHAR) {
gr_add(&sufs,0) ;
l_add(&fsuff,gr_final(&sufs)) ;
}
if ( token==M_EXPR ) {
state=LDOT ;
} else gr_add(&sufs,token&~NO_SCAN) ;
break ;
case LDOT :
if ( token==T_EXPR ) {
state=FTAIL ;
break ;
}
token &= ~NO_SCAN ;
if ( token!=SUFCHAR ) {
error("Missing %c in expression",SUFCHAR) ;
}
gr_add(&sufs,token) ; state=LSUF ;
break ;
case LSUF :
if ( token==T_EXPR || (token&~NO_SCAN)==SUFCHAR) {
gr_add(&sufs,0) ;
l_add(&lsuff,gr_final(&sufs)) ;
}
if ( token==T_EXPR ) {
state=FTAIL ;
} else gr_add(&sufs,token&~NO_SCAN) ;
break ;
case FTAIL :
if ( token==C_EXPR ) {
/* Found one !! */
gr_add(&tailval,0) ;
condit(&result,&fsuff,&lsuff,gr_start(tailval)) ;
l_throw(&fsuff) ; l_throw(&lsuff) ;
gr_throw(&tailval) ;
state=TEXT ;
} else gr_add(&tailval,token) ;
break ;
}
}
gr_add(&result,0) ;
if ( state!=TEXT ) {
l_throw(&fsuff) ; l_throw(&lsuff) ; gr_throw(&tailval) ;
werror("flag line has unclosed expression starting with %6s",
heads) ;
}
return result ;
}
condit(line,fsuff,lsuff,tailval) growstring *line ;
list_head *fsuff, *lsuff;
char *tailval ;
{
register list_elem *first ;
register list_elem *last ;
#ifdef DEBUG
if ( debug>=4 ) vprint("Conditional for %s, ",tailval) ;
#endif
scanlist( l_first(*fsuff), first ) {
scanlist( l_first(*lsuff), last ) {
if ( strcmp(l_content(*first),l_content(*last))==0 ) {
/* Found */
#ifdef DEBUG
if ( debug>=4 ) vprint(" matched\n") ;
#endif
while ( *tailval) gr_add(line,*tailval++ ) ;
return ;
}
}
}
#ifdef DEBUG
if ( debug>=4) vprint(" non-matched\n") ;
#endif
}
int mapflag(maplist,cflag) list_head *maplist ; char *cflag ; {
/* Expand a flag expression */
/* The flag "cflag" is checked for each of the mapflags.
A mapflag entry has the form
-text NAME=replacement or -text*text NAME=replacement
The star matches anything as in the shell.
If the entry matches the assignment will take place
This replacement is subjected to argument matching only.
When a match took place the replacement is returned
when not, (char *)0.
The replacement sits in stable storage.
*/
register list_elem *elem ;
scanlist(l_first(*maplist),elem) {
if ( mapexpand(l_content(*elem),cflag) ) {
return 1 ;
}
}
return 0 ;
}
int mapexpand(mapentry,cflag)
char *mapentry, *cflag ;
{
register char *star ;
register char *ptr ;
register char *space ;
int length ;
star=index(mapentry,STAR) ;
space=firstblank(mapentry) ;
if ( star >space ) star= (char *)0 ;
if ( star ) {
length= space-star-1 ;
if ( strncmp(mapentry,cflag,star-mapentry) ||
strncmp(star+1,cflag+strlen(cflag)-length,length) ) {
return 0 ;
}
/* Match */
/* Now set star to the first char of the star
replacement and length to its length
*/
length=strlen(cflag)-(star-mapentry)-length ;
if ( length<0 ) return 0 ;
star=cflag+(star-mapentry) ;
#ifdef DEBUG
if ( debug>=6 ) {
vprint("Starmatch (%s,%s) %.*s\n",
mapentry,cflag,length,star) ;
}
#endif
} else {
if ( strncmp(mapentry,cflag,space-mapentry)!=0 ||
cflag[space-mapentry] ) {
return 0 ;
}
}
ptr= skipblank(space) ;
if ( *ptr==0 ) return 1 ;
doassign(ptr,star,length) ;
return 1 ;
}
doassign(line,star,length) char *line, *star ; {
growstring varval, name, temp ;
register char *ptr ;
gr_init(&varval) ;
gr_init(&name) ;
ptr= line ;
for ( ; *ptr && *ptr!=SPACE && *ptr!=TAB && *ptr!=EQUAL ; ptr++ ) {
gr_add(&name,*ptr) ;
}
ptr= index(ptr,EQUAL) ;
if ( !ptr ) {
error("Missing %c in assignment %s",EQUAL,line);
return ;
}
temp= scanvars(ptr+1) ;
for ( ptr=gr_start(temp); *ptr; ptr++ ) switch ( *ptr ) {
case STAR :
if ( star ) {
while ( length-- ) gr_add(&varval,*star++|NO_SCAN) ;
break ;
}
default :
gr_add(&varval,*ptr) ;
break ;
}
gr_throw(&temp) ;
setsvar(gr_final(&name),gr_final(&varval)) ;
}
#define ISBLANK(c) ( (c)==SPACE || (c)==TAB )
unravel(line,action) char *line ; int (*action)() ; {
/* Unravel the line, get arguments a la shell */
/* each argument is handled to action */
/* The input string is left intact */
register char *in_c ;
register int token ;
enum { BLANK, ARG } state = BLANK ;
growstring argum ;
in_c=line ;
for (;;) {
token= *in_c&0377 ;
switch ( state ) {
case BLANK :
if ( token==0 ) break ;
if ( !ISBLANK(token) ) {
state= ARG ;
gr_init(&argum) ;
gr_add(&argum,token&~NO_SCAN) ;
}
break ;
case ARG :
if ( ISBLANK(token) || token==0 ) {
gr_add(&argum,0) ;
(*action)(gr_start(argum)) ;
gr_throw(&argum) ;
state=BLANK ;
} else {
gr_add(&argum,token&~NO_SCAN) ;
}
break ;
}
if ( token == 0 ) break ;
in_c++ ;
}
}
char *c_rep(string,place,rep) char *string, *place, *rep ; {
/* Produce a string in stable storage produced from 'string'
with the character at place replaced by rep
*/
growstring name ;
register char *nc ;
register char *xc ;
gr_init(&name) ;
for ( nc=string ; *nc && nc<place ; nc++ ) {
gr_add(&name,*nc) ;
}
#ifdef DEBUG
if ( *nc==0 ) fatal("Place is not in string") ;
#endif
for ( xc=rep ; *xc ; xc++ ) gr_add(&name,*xc|NO_SCAN) ;
gr_add(&name,0) ;
gr_cat(&name,nc+1) ;
return gr_final(&name) ;
}
static list_head *curargs ;
addargs(string) char *string ; {
register char *temp, *repc ;
register list_elem *elem ;
repc=index(string,C_IN) ;
if ( repc ) {
/* INPUT FILE TOKEN seen, replace it and scan further */
if ( repc==string && string[1]==0 ) {
if ( in.p_path ) { /* All but combiner */
l_add(curargs,keeps(in.p_path)) ;
} else {
scanlist( l_first(c_arguments), elem ) {
l_add(curargs,l_content(*elem)) ;
}
}
return ;
}
if ( in.p_path ) { /* Not for the combiner */
temp=c_rep(string,repc,in.p_path) ;
addargs(temp) ;
throws(temp) ;
} else { /* For the combiner */
scanlist( l_first(c_arguments), elem ) {
temp=c_rep(string,repc,l_content(*elem)) ;
addargs(temp) ;
throws(temp) ;
}
}
return ;
}
repc=index(string,C_OUT) ;
if ( repc ) {
/* replace the outfile token as with the infile token */
#ifdef DEBUG
if ( !out.p_path ) fatal("missing output filename") ;
#endif
temp=c_rep(string,repc,out.p_path) ;
addargs(temp) ;
throws(temp) ;
return ;
}
temp= keeps(string) ;
clr_noscan(temp) ;
l_add(curargs,temp) ;
}
getcallargs(phase) register trf *phase ; {
growstring arg1, arg2 ;
arg1= scanvars(phase->t_argd) ;
#ifdef DEBUG
if ( debug>=3 ) { vprint("\tvars: ") ; prns(gr_start(arg1)) ; }
#endif
arg2= scanexpr(gr_start(arg1)) ;
#ifdef DEBUG
if ( debug>=3 ) { vprint("\texpr: ") ; prns(gr_start(arg2)) ; }
#endif
gr_throw(&arg1) ;
curargs= &phase->t_args ;
unravel( gr_start(arg2), addargs ) ;
gr_throw(&arg2) ;
}
discardargs(phase) register trf *phase ; {
l_throw(&phase->t_args) ;
}

View File

@@ -1,30 +0,0 @@
/* This structure is the center of all actions */
/* It contains the description of all phases,
the suffices they consume and produce and various properties */
typedef struct transform trf;
struct transform {
char *t_in ; /* Suffices in '.o.k' */
char *t_out ; /* Result '.suffix' or 'name' */
char *t_name ; /* The name of this transformation */
list_head t_mapf ; /* Mapflags argument, uses varrep */
char *t_argd ; /* Argument descriptor, uses varrep */
char *t_needed ; /* Suffix indicating the libraries needed */
char *t_rts ; /* Suffix indicating the major language used*/
int t_stdin:1 ; /* The input is taken on stdin */
int t_stdout:1 ; /* The output comes on stdout */
int t_combine:1 ; /* Transform several files to one result */
int t_visited:1 ; /* NO before setup, YES after */
int t_prep:2 ; /* Needs preprocessor YES/NO/MAYBE */
int t_optim:1 ; /* Is optimizer */
int t_isprep:1 ; /* Is preprocessor */
int t_keep:1 ; /* Keep the output file */
char *t_prog ; /* Pathname for load file */
list_head t_flags ; /* List of flags */
list_head t_args ; /* List of arguments */
int t_scan:1 ; /* Used while finding path's */
int t_do:1 ; /* Is in path to execute */
} ;
#define t_cont(elem) ((trf *)l_content(elem))

View File

@@ -1,190 +0,0 @@
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
*/
/**********************************************************************/
/* */
/* Several utility routines used throughout ack */
/* error handling, string handling and such. */
/* */
/**********************************************************************/
#include "ack.h"
#include <ctype.h>
#include <stdio.h>
extern char *progname ;
extern int w_flag ;
extern int n_error;
extern char *calloc();
extern char *realloc();
#ifdef DEBUG
# define STDOUT stdout
#else
# define STDOUT stderr
#endif
char *basename(string) char *string ; {
static char retval[20] ;
char *last_dot, *last_start ;
register char *store;
register char *fetch ;
register int ctoken ;
last_dot= (char *)0 ;
last_start= string ;
for ( fetch=string ; ; fetch++ ) {
switch ( ctoken= *fetch&0377 ) {
case SUFCHAR : last_dot=fetch ; break ;
case '/' : last_start=fetch+1 ; break ;
case 0 : goto out ;
}
if ( !isascii(ctoken) || !isprint(ctoken) ) {
werror("non-ascii characters in argument %s",string) ;
}
}
out:
if ( ! *last_start ) fuerror("empty filename \"%s\"",string) ;
for ( fetch= last_start, store=retval ;
*fetch && fetch!=last_dot && store< &retval[sizeof retval-1] ;
fetch++, store++ ) {
*store= *fetch ;
}
*store= 0 ;
return retval ;
}
clr_noscan(str) char *str ; {
register char *ptr ;
for ( ptr=str ; *ptr ; ptr++ ) {
*ptr&= ~NO_SCAN ;
}
}
char *skipblank(str) char *str ; {
register char *ptr ;
for ( ptr=str ; *ptr==SPACE || *ptr==TAB ; ptr++ ) ;
return ptr ;
}
char *firstblank(str) char *str ; {
register char *ptr ;
for ( ptr=str ; *ptr && *ptr!=SPACE && *ptr!=TAB ; ptr++ ) ;
return ptr ;
}
/* VARARGS1 */
fatal(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; {
/* Fatal internal error */
fprintf(STDOUT,"%s: fatal internal error, ",progname) ;
fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7);
fprintf(STDOUT,"\n") ;
quit(-2) ;
}
/* VARARGS1 */
vprint(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; {
/* Diagnostic print, no auto NL */
fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7);
}
#ifdef DEBUG
prns(s) register char *s ; {
for ( ; *s ; s++ ) {
putc((*s&0377)&~NO_SCAN,STDOUT) ;
}
putc('\n',STDOUT) ;
}
#endif
/* VARARGS1 */
fuerror(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; {
/* Fatal user error */
fprintf(STDOUT,"%s: ",progname) ;
fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7);
fprintf(STDOUT,"\n") ;
quit(-1) ;
}
/* VARARGS1 */
werror(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; {
/* Warning user error, w_flag */
if ( w_flag ) return ;
fprintf(STDOUT,"%s: warning, ",progname) ;
fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7);
fprintf(STDOUT,"\n") ;
}
/* VARARGS1 */
error(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; {
/* User error, it is the callers responsibility to quit */
fprintf(STDOUT,"%s: ",progname) ;
fprintf(STDOUT,fmt,p1,p2,p3,p4,p5,p6,p7);
fprintf(STDOUT,"\n") ;
n_error++ ;
}
do_flush() {
fflush(stdout) ;
fflush(stderr) ;
}
noodstop() {
quit(-3) ;
}
quit(code) {
rmtemps();
exit(code);
}
/******
char *keeps(string)
Keep the string in stable storage.
throws(string)
Remove the string stored by keep from stable storage.
***********/
char *keeps(str) char *str ; {
register char *result ;
result= getcore( (unsigned)(strlen(str)+1) ) ;
if ( !result ) fatal("Out of core") ;
return strcpy(result,str) ;
}
throws(str) char *str ; {
freecore(str) ;
}
char *getcore(size) unsigned size ; {
register char *retptr ;
retptr= calloc(1,size) ;
if ( !retptr ) fatal("Out of memory") ;
return retptr ;
}
char *changecore(ptr,size) char *ptr ; unsigned size ; {
register char *retptr ;
retptr= realloc(ptr,size) ;
if ( !retptr ) fatal("Out of memory") ;
return retptr ;
}

View File

@@ -1,25 +0,0 @@
# $Header$
PREFLAGS=-I../../h
CFLAGS=$(PREFLAGS)
LDFLAGS=-i
LINTOPTS=-hbxac $(PREFLAGS)
LIBS=../../lib/em_data.a
# LEXLIB is system dependent, try -ll or -lln first
LEXLIB=-lln
cgg: bootgram.o
cc $(LDFLAGS) bootgram.o $(LIBS) $(LEXLIB) -o cgg
install: cgg
cp cgg ../../lib/cgg
cmp: cgg
cmp cgg ../../lib/cgg
lint: bootgram.c
lint $(LINTOPTS) bootgram.c
clean:
rm -f bootgram.o bootgram.c bootlex.c cgg
bootgram.o: bootlex.c
bootgram.o: ../../h/cg_pattern.h

File diff suppressed because it is too large Load Diff

View File

@@ -1,189 +0,0 @@
%{
#ifndef NORCSID
static char rcsid2[]="$Header$";
#endif
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#undef input
#undef output
#undef unput
#define MAXBACKUP 50
%}
%%
"/*" { char c;
c = input();
do {
while (c!='*')
c = input();
c = input();
} while (c!='/');
}
"REGISTERS:" return(REGISTERHEAD);
"TOKENS:" return(TOKENHEAD);
"TOKENEXPRESSIONS:" return(EXPRESSIONHEAD);
"CODE:" return(CODEHEAD);
"MOVES:" return(MOVEHEAD);
"TESTS:" return(TESTHEAD);
"STACKS:" return(STACKHEAD);
"SIZEFACTOR" return(SIZEFAC);
"TIMEFACTOR" return(TIMEFAC);
"FORMAT" return(FORMAT);
"cost" return(COST);
"remove" return(REMOVE);
"|" return(SEP);
"samesign" return(SAMESIGN);
"inreg" return(INREG);
"sfit" return(SFIT);
"ufit" return(UFIT);
"defined" return(DEFINED);
"rom" return(ROM);
"loww" return(LOWW);
"highw" return(HIGHW);
"move" return(MOVE);
"erase" return(ERASE);
"allocate" return(ALLOCATE);
"tostring" return(TOSTRING);
"nocc" return(NOCC);
"setcc" return(SETCC);
"samecc" return(SAMECC);
"test" return(TEST);
"STACK" return(STACK);
"nocoercions" return(NOCOERC);
"&&" return(AND2);
"||" return(OR2);
"==" return(CMPEQ);
"!=" return(CMPNE);
"<=" return(CMPLE);
"<" return(CMPLT);
">" return(CMPGT);
">=" return(CMPGE);
">>" return(RSHIFT);
"<<" return(LSHIFT);
"!" return(NOT);
"~" return(COMP);
"..." return(ELLIPS);
EM_WSIZE { yylval.yy_intp = &wsize; return(CIDENT); }
EM_PSIZE { yylval.yy_intp = &psize; return(CIDENT); }
EM_BSIZE { yylval.yy_intp = &bsize; return(CIDENT); }
REGISTER { yylval.yy_string = "REGISTER"; return(TYPENAME); }
INT { yylval.yy_string = "INT"; return(TYPENAME); }
STRING { yylval.yy_string = "STRING"; return(TYPENAME); }
regvar return(REGVAR);
loop return(LOOP);
pointer return(POINTER);
float return(FLOAT);
return return(RETURN);
[_A-Za-z][_A-Za-z0-9]+ {register ident_p ip;
if(!lookident || (ip=ilookup(yytext,JUSTLOOKING))==0) {
yylval.yy_string = scopy(yytext);return(IDENT);
} else {
yylval.yy_ident = ip;
switch(ip->i_type) {
default:assert(0);
case IREG:return(RIDENT);
case IPRP:return(PIDENT);
case ITOK:return(TIDENT);
case IEXP:return(EIDENT);
}
}
}
[a-z] {yylval.yy_char = yytext[0]; return(LCASELETTER);}
[0-9]* {yylval.yy_int = atoi(yytext);return(NUMBER);}
(\"|"%)") { char *p; int c,tipe;
p=yytext;
for (;;) {
c = input();
switch(c) {
default: *p++=c;break;
case '\\':
*p++=c; *p++=input(); break;
case '\n':
yyerror("Unterminated string");
break;
case '"':
tipe=STRING; goto endstr;
case '%':
c=input();
if (c == '(') {
tipe=LSTRING;goto endstr;
} else {
*p++ = '%'; unput(c); break;
}
}
}
endstr:
*p++ = 0;
yylval.yy_string = scopy(yytext);
return(tipe);
}
[ \t]* |
\n ;
. return(yytext[0]);
%%
char linebuf[256];
char prevbuf[256];
int linep;
int linepos; /* corrected for tabs */
char charstack[MAXBACKUP];
int nbackup=0;
output(c) {
assert(0);
}
input() {
if(nbackup)
return(charstack[--nbackup]);
if(linebuf[linep]==0) {
strcpy(prevbuf,linebuf);
if(fgets(linebuf,256,stdin)==NULL)
return(0);
lino++;
linepos=linep=0;
}
if (linebuf[linep] == '\t')
linepos = (linepos+8) & ~07;
else linepos++;
return(linebuf[linep++]);
}
unput(c) {
chktabsiz(nbackup,MAXBACKUP,"Lexical backup table");
charstack[nbackup++] = c;
}
yyerror(s,a1,a2,a3,a4) string s; {
fprintf(stderr,"%d\t%s%d\t%s\t%*c ",lino-1,prevbuf,lino,linebuf,
linepos-1,'^');
fprintf(stderr,s,a1,a2,a3,a4);
fprintf(stderr,"\n");
nerrors++;
}

View File

@@ -1,202 +0,0 @@
# $Header$
CFILES=main.c getline.c lookup.c var.c process.c backward.c util.c\
alloc.c putline.c cleanup.c peephole.c flow.c reg.c
OFILES=main.o getline.o lookup.o var.o process.o backward.o util.o\
alloc.o putline.o cleanup.o peephole.o flow.o reg.o
KFILES=main.k getline.k lookup.k var.k process.k backward.k util.k\
alloc.k putline.k cleanup.k peephole.k flow.k reg.k
LIBS=../../lib/em_data.a
CFLAGS=-O -DNDEBUG
LDFLAGS=-i
LINT=lint
OPR=wide|opr
XREF=xref -c -w80
PROPTS=
# LEXLIB is implementation dependent, try -ll or -lln first
LEXLIB=-ll
.DEFAULT:
co -q $<
opt: $(OFILES) pattern.o $(LIBS)
cc $(LDFLAGS) $(CFLAGS) $(OFILES) pattern.o $(LIBS) -o opt
test: opt testopt
testopt
cmp : opt
cmp opt ../../lib/em_opt
install:opt
size opt ../../lib/em_opt
cp opt ../../lib/em_opt
pattern.c: patterns mktab
/lib/cpp patterns | mktab > pattern.c
mktab: mktab.o $(LIBS)
cc $(CFLAGS) mktab.o $(LIBS) $(LEXLIB) -o mktab
depend: makedepend
makedepend
lint: $(CFILES) pattern.c
$(LINT) $(CFILES) pattern.c>lint 2>&1
printall:
-pr $(PROPTS) Makefile -n *.h `ls $(CFILES)` mktab.y scan.l patterns|$(OPR)
touch print
print: Makefile *.h $(CFILES) mktab.y scan.l patterns
-pr $(PROPTS) -n $? | $(OPR)
opr:
make pr ^ $(OPR)
pr:
@pr $(PROPTS) -n Makefile *.h $(CFILES) mktab.y scan.l patterns
xref:
$(XREF) *.h $(CFILES) | pr $(PROPTS) -h "XREF EMOPT"|$(OPR)&
sizes: opt
-nm opt | sort -n| /usr/plain/bin/map
clean:
rm -f *.o opt mktab mktab.c scan.c pattern.c
kfiles: $(KFILES)
.SUFFIXES: .k
.c.k: ; cem -c $*.c
# the next lines are generated automatically
# AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
alloc.o: alloc.h
alloc.o: assert.h
alloc.o: line.h
alloc.o: lookup.h
alloc.o: param.h
alloc.o: proinf.h
alloc.o: types.h
backward.o: ../../h/em_mnem.h
backward.o: ../../h/em_pseu.h
backward.o: ../../h/em_spec.h
backward.o: alloc.h
backward.o: assert.h
backward.o: ext.h
backward.o: line.h
backward.o: lookup.h
backward.o: param.h
backward.o: proinf.h
backward.o: types.h
cleanup.o: ../../h/em_mes.h
cleanup.o: ../../h/em_pseu.h
cleanup.o: ../../h/em_spec.h
cleanup.o: assert.h
cleanup.o: ext.h
cleanup.o: lookup.h
cleanup.o: param.h
cleanup.o: types.h
flow.o: ../../h/em_flag.h
flow.o: ../../h/em_mnem.h
flow.o: ../../h/em_spec.h
flow.o: alloc.h
flow.o: ext.h
flow.o: line.h
flow.o: optim.h
flow.o: param.h
flow.o: proinf.h
flow.o: types.h
getline.o: ../../h/em_flag.h
getline.o: ../../h/em_mes.h
getline.o: ../../h/em_pseu.h
getline.o: ../../h/em_spec.h
getline.o: alloc.h
getline.o: assert.h
getline.o: ext.h
getline.o: line.h
getline.o: lookup.h
getline.o: param.h
getline.o: proinf.h
getline.o: types.h
lookup.o: alloc.h
lookup.o: lookup.h
lookup.o: param.h
lookup.o: proinf.h
lookup.o: types.h
main.o: ../../h/em_spec.h
main.o: alloc.h
main.o: ext.h
main.o: param.h
main.o: types.h
mktab.o: ../../h/em_mnem.h
mktab.o: ../../h/em_spec.h
mktab.o: optim.h
mktab.o: param.h
mktab.o: pattern.h
mktab.o: scan.c
mktab.o: types.h
pattern.o: param.h
pattern.o: pattern.h
pattern.o: types.h
peephole.o: ../../h/em_mnem.h
peephole.o: ../../h/em_spec.h
peephole.o: alloc.h
peephole.o: assert.h
peephole.o: ext.h
peephole.o: line.h
peephole.o: lookup.h
peephole.o: optim.h
peephole.o: param.h
peephole.o: pattern.h
peephole.o: proinf.h
peephole.o: types.h
process.o: ../../h/em_pseu.h
process.o: ../../h/em_spec.h
process.o: alloc.h
process.o: assert.h
process.o: ext.h
process.o: line.h
process.o: lookup.h
process.o: param.h
process.o: proinf.h
process.o: types.h
putline.o: ../../h/em_flag.h
putline.o: ../../h/em_mnem.h
putline.o: ../../h/em_pseu.h
putline.o: ../../h/em_spec.h
putline.o: alloc.h
putline.o: assert.h
putline.o: ext.h
putline.o: line.h
putline.o: lookup.h
putline.o: optim.h
putline.o: param.h
putline.o: proinf.h
putline.o: types.h
reg.o: ../../h/em_mes.h
reg.o: ../../h/em_pseu.h
reg.o: ../../h/em_spec.h
reg.o: alloc.h
reg.o: assert.h
reg.o: ext.h
reg.o: line.h
reg.o: param.h
reg.o: proinf.h
reg.o: types.h
scan.o: stdio.h
special.o: param.h
special.o: types.h
util.o: assert.h
util.o: ext.h
util.o: lookup.h
util.o: optim.h
util.o: param.h
util.o: proinf.h
util.o: types.h
var.o: lookup.h
var.o: param.h
var.o: proinf.h
var.o: types.h

View File

@@ -1,448 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include <stdio.h>
#include "param.h"
#include "types.h"
#include "assert.h"
#include "alloc.h"
#include "line.h"
#include "lookup.h"
#include "proinf.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#ifdef USEMALLOC
short * myalloc();
#define newcore(size) myalloc(size)
#define oldcore(p,size) free(p)
#else
/* #define CORECHECK /* if defined tests are made to insure
each block occurs at most once */
#define CCHUNK 1024 /* number of shorts asked from system */
short *newcore(),*freshcore();
extern char *sbrk();
#ifdef COREDEBUG
int shortsasked=0;
#endif
#endif
/*
* The following two sizetables contain the sizes of the various kinds
* of line and argument structures.
* Care has been taken to make this table implementation independent,
* but if you think very hard you might find a compiler failing the
* assumptions made.
* A wasteful but safe approach is to replace every line of them by
* sizeof(line_t)
* and
* sizeof(arg_t)
* respectively.
*/
#define LBASE (sizeof(line_t)-sizeof(un_l_a))
int lsizetab[] = {
LBASE,
LBASE+sizeof(short),
LBASE+sizeof(offset),
LBASE+sizeof(num_p),
LBASE+sizeof(sym_p),
LBASE+sizeof(s_la_sval),
LBASE+sizeof(s_la_lval),
LBASE+sizeof(arg_p),
LBASE
};
#define ABASE (sizeof(arg_t)-sizeof(un_a_a))
int asizetab[] = {
ABASE+sizeof(offset),
ABASE+sizeof(num_p),
ABASE+sizeof(sym_p),
ABASE+sizeof(s_a_val),
ABASE+sizeof(argb_t),
ABASE+sizeof(s_a_con),
ABASE+sizeof(s_a_con),
ABASE+sizeof(s_a_con),
};
/*
* alloc routines:
* Two parts:
* 1) typed alloc and free routines
* 2) untyped raw core allocation
*/
/*
* PART 1
*/
line_p newline(optyp) int optyp; {
register line_p lnp;
register kind=optyp;
if (kind>OPMINI)
kind = OPMINI;
lnp = (line_p) newcore(lsizetab[kind]);
lnp->l_optyp = optyp;
return(lnp);
}
oldline(lnp) register line_p lnp; {
register kind=lnp->l_optyp&BMASK;
if (kind>OPMINI)
kind = OPMINI;
if (kind == OPLIST)
oldargs(lnp->l_a.la_arg);
oldcore((short *) lnp,lsizetab[kind]);
}
arg_p newarg(kind) int kind; {
register arg_p ap;
ap = (arg_p) newcore(asizetab[kind]);
ap->a_typ = kind;
return(ap);
}
oldargs(ap) register arg_p ap; {
register arg_p next;
while (ap != (arg_p) 0) {
next = ap->a_next;
switch(ap->a_typ) {
case ARGSTR:
oldargb(ap->a_a.a_string.ab_next);
break;
case ARGICN:
case ARGUCN:
case ARGFCN:
oldargb(ap->a_a.a_con.ac_con.ab_next);
break;
}
oldcore((short *) ap,asizetab[ap->a_typ]);
ap = next;
}
}
oldargb(abp) register argb_p abp; {
register argb_p next;
while (abp != (argb_p) 0) {
next = abp->ab_next;
oldcore((short *) abp,sizeof (argb_t));
abp = next;
}
}
reg_p newreg() {
return((reg_p) newcore(sizeof(reg_t)));
}
oldreg(rp) reg_p rp; {
oldcore((short *) rp,sizeof(reg_t));
}
num_p newnum() {
return((num_p) newcore(sizeof(num_t)));
}
oldnum(lp) num_p lp; {
oldcore((short *) lp,sizeof(num_t));
}
offset *newrom() {
return((offset *) newcore(MAXROM*sizeof(offset)));
}
sym_p newsym(len) int len; {
/*
* sym_t includes a 2 character s_name at the end
* extend this structure with len-2 characters
*/
return((sym_p) newcore(sizeof(sym_t) - 2 + len));
}
argb_p newargb() {
return((argb_p) newcore(sizeof(argb_t)));
}
#ifndef USEMALLOC
/******************************************************************/
/****** Start of raw core management package *****************/
/******************************************************************/
#define MAXSHORT 30 /* Maximum number of shorts one can ask for */
short *freelist[MAXSHORT];
typedef struct coreblock {
struct coreblock *co_next;
short co_size;
} core_t,*core_p;
#define SINC (sizeof(core_t)/sizeof(short))
#ifdef COREDEBUG
coreverbose() {
register size;
register short *p;
register sum;
sum = 0;
for(size=1;size<MAXSHORT;size++)
for (p=freelist[size];p!=0;p = *(short **) p)
sum += size;
fprintf(stderr,"Used core %u\n",(shortsasked-sum)*sizeof(short));
}
#endif
#ifdef SEPID
compactcore() {
register core_p corelist=0,tp,cl;
int size;
#ifdef COREDEBUG
fprintf(stderr,"Almost out of core\n");
#endif
for(size=SINC;size<MAXSHORT;size++) {
while ((tp = (core_p) freelist[size]) != (core_p) 0) {
freelist[size] = (short *) tp->co_next;
tp->co_size = size;
if (corelist==0 || tp<corelist) {
tp->co_next = corelist;
corelist = tp;
} else {
for(cl=corelist;cl->co_next != 0 && tp>cl->co_next;
cl = cl->co_next)
;
tp->co_next = cl->co_next;
cl->co_next = tp;
}
}
}
while (corelist != 0) {
while ((short *) corelist->co_next ==
(short *) corelist + corelist->co_size) {
corelist->co_size += corelist->co_next->co_size;
corelist->co_next = corelist->co_next->co_next;
}
assert(corelist->co_next==0 ||
(short *) corelist->co_next >
(short *) corelist + corelist->co_size);
while (corelist->co_size >= MAXSHORT+SINC) {
oldcore((short *) corelist + corelist->co_size-(MAXSHORT-1),
sizeof(short)*(MAXSHORT-1));
corelist->co_size -= MAXSHORT;
}
if (corelist->co_size >= MAXSHORT) {
oldcore((short *) corelist + corelist->co_size-SINC,
sizeof(short)*SINC);
corelist->co_size -= SINC;
}
cl = corelist->co_next;
oldcore((short *) corelist, sizeof(short)*corelist->co_size);
corelist = cl;
}
}
short *grabcore(size) int size; {
register short *p;
register trysize;
/*
* Desperate situation, can't get more core from system.
* Postpone giving up just a little bit by splitting up
* larger free blocks if possible.
* Algorithm is worst fit.
*/
assert(size<2*MAXSHORT);
for(trysize=2*MAXSHORT-2; trysize>size; trysize -= 2) {
p = freelist[trysize/sizeof(short)];
if ( p != (short *) 0) {
freelist[trysize/sizeof(short)] = *(short **) p;
oldcore(p+size/sizeof(short),trysize-size);
return(p);
}
}
/*
* Can't get more core from the biggies, try to combine the
* little ones. This is expensive but probably better than
* giving up.
*/
compactcore();
if ((p=freelist[size/sizeof(short)]) != 0) {
freelist[size/sizeof(short)] = * (short **) p;
return(p);
}
for(trysize=2*MAXSHORT-2; trysize>size; trysize -= 2) {
p = freelist[trysize/sizeof(short)];
if ( p != (short *) 0) {
freelist[trysize/sizeof(short)] = *(short **) p;
oldcore(p+size/sizeof(short),trysize-size);
return(p);
}
}
/*
* That's it then. Finished.
*/
return(0);
}
#endif /* SEPID */
short *newcore(size) int size; {
register short *p,*q;
if( size < 2*MAXSHORT ) {
if ((p=freelist[size/sizeof(short)]) != (short *) 0)
freelist[size/sizeof(short)] = *(short **) p;
else {
p = freshcore(size);
#ifdef SEPID
if (p == (short *) 0)
p = grabcore(size);
#endif
}
} else
p = freshcore(size);
if (p == 0)
error("out of memory");
for (q=p; size > 0 ; size -= sizeof(short))
*q++ = 0;
return(p);
}
#ifdef NOMALLOC
/*
* stdio uses malloc and free.
* you can use these as substitutes
*/
char *malloc(size) int size; {
/*
* malloc(III) is called by stdio,
* this routine is a substitute.
*/
return( (char *) newcore(size));
}
free() {
}
#endif
oldcore(p,size) short *p; int size; {
#ifdef CORECHECK
register short *cp;
#endif
assert(size<2*MAXSHORT);
#ifdef CORECHECK
for (cp=freelist[size/sizeof(short)]; cp != (short *) 0;
cp = (short *) *cp)
assert(cp != p);
#endif
*(short **) p = freelist[size/sizeof(short)];
freelist[size/sizeof(short)] = p;
}
short *ccur,*cend;
coreinit(p1,p2) short *p1,*p2; {
/*
* coreinit is called with the boundaries of a piece of
* memory that can be used for starters.
*/
ccur = p1;
cend = p2;
}
short *freshcore(size) int size; {
register short *temp;
static int cchunk=CCHUNK;
while(&ccur[size/sizeof(short)] >= cend && cchunk>0) {
do {
temp = (short *) sbrk(cchunk*sizeof(short));
if (temp == (short *) -1)
cchunk >>= 1;
else if (temp != cend)
ccur = cend = temp;
} while (temp == (short *) -1 && cchunk>0);
cend += cchunk;
#ifdef COREDEBUG
shortsasked += cchunk;
#endif
}
if (cchunk==0)
return(0);
temp = ccur;
ccur = &ccur[size/sizeof(short)];
return(temp);
}
#else /* USEMALLOC */
coreinit() {
/*
* Empty function, no initialization needed
*/
}
short *myalloc(size) register size; {
register short *p,*q;
extern char *malloc();
p = (short *)malloc(size);
if (p == 0)
error("out of memory");
for(q=p;size>0;size -= sizeof(short))
*q++ = 0;
return(p);
}
#endif

View File

@@ -1,55 +0,0 @@
/* $Header$ */
extern line_p newline();
extern offset *newrom();
extern sym_p newsym();
extern num_p newnum();
extern arg_p newarg();
extern argb_p newargb();
extern reg_p newreg();
extern oldline();
extern oldloc();
extern oldreg();
/* #define USEMALLOC /* if defined malloc() and free() are used */
/* #define COREDEBUG /* keep records and print statistics */
/*
* The next define gives if defined the number of pseudo's outside
* procedures that are collected without processing.
* If undefined all pseudo's will be collected but that may
* give trouble on small machines, because of lack of room.
*/
#define PSEUBETWEEN 200
#ifndef USEMALLOC
/*
* Now the real bitsqueezing starts.
* When running on a machine where code and data live in
* separate address-spaces it is worth putting in some extra
* code to save on probably less data.
*/
#define SEPID /* code and data in separate spaces */
/*
* If the stack segment and the data are separate as on a PDP11 under UNIX
* it is worth squeezing some shorts out of the stack page.
*/
#ifndef EM_WSIZE
/*
* Compiled with 'standard' C compiler
*/
#define STACKROOM 3200 /* number of shorts space in stack */
#else
/*
* Compiled with pcc, has trouble with lots of variables
*/
#define STACKROOM 2000
#endif
#else
#define STACKROOM 1 /* 0 gives problems */
#endif /* USEMALLOC */

View File

@@ -1,7 +0,0 @@
/* $Header$ */
#ifndef NDEBUG
#define assert(x) if(!(x)) badassertion(__FILE__,__LINE__)
#else
#define assert(x) /* nothing */
#endif

View File

@@ -1,187 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "types.h"
#include "assert.h"
#include "line.h"
#include "lookup.h"
#include "alloc.h"
#include "proinf.h"
#include "../../h/em_spec.h"
#include "../../h/em_pseu.h"
#include "../../h/em_mnem.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#define local(x) if (((x)->s_flags&SYMKNOWN) == 0)\
x->s_flags &= ~ SYMGLOBAL
#define global(x) if(((x)->s_flags&SYMKNOWN) == 0)\
x->s_flags |= SYMGLOBAL
#define DTYPHOL 1
#define DTYPBSS 2
#define DTYPCON 3
#define DTYPROM 4
byte curdtyp;
bool goodrom;
short curfrag = 3; /* see also peephole.c */
offset rombuf[MAXROM];
int rc;
backward() {
register line_p lnp;
line_p next;
register arg_p ap;
line_p i,p;
int n;
register sym_p sp;
i = p = (line_p) 0;
curdtyp=0;
for (lnp = curpro.lastline; lnp != (line_p) 0; lnp = next) {
next = lnp->l_next;
switch(lnp->l_optyp) {
case OPSYMBOL:
global(lnp->l_a.la_sp);
break;
case OPSVAL:
global(lnp->l_a.la_sval.lasv_sp);
break;
case OPLVAL:
global(lnp->l_a.la_lval.lalv_sp);
break;
case OPLIST:
ap = lnp->l_a.la_arg;
while (ap != (arg_p) 0 ) {
switch(ap->a_typ) {
case ARGSYM:
global(ap->a_a.a_sp);
break;
case ARGVAL:
global(ap->a_a.a_val.av_sp);
}
ap = ap->a_next;
}
break;
}
/*
* references to symbols are processed now.
* for plain instructions nothing else is needed
*/
switch(lnp->l_instr&BMASK) {
/*
* count all local occurences for register counts;
* op_lal is omitted and not by accident.
*/
case op_del:
case op_inl:
case op_ldl:
case op_lil:
case op_lol:
case op_sdl:
case op_sil:
case op_stl:
case op_zrl:
switch(lnp->l_optyp) {
case OPNO:
case OPNUMLAB:
case OPSYMBOL:
case OPSVAL:
case OPLVAL:
case OPLIST:
break;
case OPOFFSET:
incregusage(lnp->l_a.la_offset);
break;
case OPSHORT:
incregusage((offset)lnp->l_a.la_short);
break;
default:
incregusage((offset)(lnp->l_optyp&BMASK)-Z_OPMINI);
break;
}
/* fall through !! */
default:
assert((lnp->l_instr&BMASK)<=op_last);
lnp->l_next = i;
i = lnp;
continue;
case ps_sym:
sp = lnp->l_a.la_sp;
local(sp);
if (curdtyp == DTYPROM && goodrom) {
sp->s_rom = newrom();
for (n=0;n<rc;n++)
sp->s_rom[n] = rombuf[n];
}
sp->s_frag = curfrag;
break;
case ps_hol:
curdtyp = DTYPHOL;
curfrag++;
break;
case ps_bss:
curdtyp = DTYPBSS;
curfrag++;
break;
case ps_con:
if (curdtyp != DTYPCON) {
curdtyp = DTYPCON;
curfrag++;
}
break;
case ps_rom:
if (curdtyp != DTYPROM) {
curdtyp = DTYPROM;
curfrag++;
}
ap = lnp->l_a.la_arg;
rc = 0;
while (ap != (arg_p) 0 && rc < MAXROM) {
if (ap->a_typ == ARGOFF) {
rombuf[rc++] = ap->a_a.a_offset;
ap = ap->a_next;
} else
ap = (arg_p) 0;
}
goodrom = (rc >= 2);
break;
case ps_mes:
break;
case ps_inp:
case ps_ina:
local(lnp->l_a.la_sp);
case ps_exp:
case ps_exa:
case ps_exc:
oldline(lnp);
continue;
}
lnp->l_next = p;
p = lnp;
}
if (prodepth != 0)
local(curpro.symbol);
instrs = i; pseudos = p; curpro.lastline = (line_p) 0;
}

View File

@@ -1,65 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include <stdio.h>
#include "param.h"
#include "types.h"
#include "assert.h"
#include "../../h/em_pseu.h"
#include "../../h/em_spec.h"
#include "../../h/em_mes.h"
#include "lookup.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
cleanup() {
FILE *infile;
register c;
register sym_p *spp,sp;
for (spp=symhash;spp< &symhash[NSYMHASH];spp++)
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
if ((sp->s_flags & SYMOUT) == 0)
outdef(sp);
if(!Lflag)
return;
c=fclose(outfile);
assert(c != EOF);
outfile = stdout;
infile = fopen(template,"r");
if (infile == NULL)
error("temp file disappeared");
outshort(sp_magic);
outinst(ps_mes);
outint(ms_ext);
for (spp=symhash;spp< &symhash[NSYMHASH];spp++)
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
if ((sp->s_flags&(SYMDEF|SYMGLOBAL)) == (SYMDEF|SYMGLOBAL))
outsym(sp);
putc(sp_cend,outfile);
while ( (c=getc(infile)) != EOF)
putc(c,outfile);
c=fclose(infile);
assert(c != EOF);
c=unlink(template);
assert(c == 0);
}

View File

@@ -1,16 +0,0 @@
/* $Header$ */
#ifndef FILE
#include <stdio.h>
#endif
extern unsigned linecount;
extern int prodepth;
extern bool Lflag;
extern bool nflag;
extern byte em_flag[];
extern line_p instrs,pseudos;
extern FILE *outfile;
extern char template[];
extern offset wordsize;
extern offset pointersize;
extern char *progname;

View File

@@ -1,126 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "types.h"
#include "../../h/em_flag.h"
#include "../../h/em_spec.h"
#include "../../h/em_mnem.h"
#include "alloc.h"
#include "line.h"
#include "proinf.h"
#include "optim.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
flow() {
findreach(); /* determine reachable labels */
cleaninstrs(); /* throw away unreachable code */
}
findreach() {
register num_p *npp,np;
reach(instrs);
for(npp=curpro.numhash;npp< &curpro.numhash[NNUMHASH]; npp++)
for(np= *npp; np != (num_p) 0 ; np = np->n_next)
if (np->n_flags&NUMDATA) {
np->n_repl->n_flags |= NUMREACH;
np->n_repl->n_jumps++;
if (!(np->n_flags&NUMSCAN)) {
np->n_flags |= NUMSCAN;
reach(np->n_line->l_next);
}
}
}
reach(lnp) register line_p lnp; {
register num_p np;
for (;lnp != (line_p) 0; lnp = lnp->l_next) {
if(lnp->l_optyp == OPNUMLAB) {
/*
* Branch instruction or label
*/
np = lnp->l_a.la_np;
if ((lnp->l_instr&BMASK) != op_lab)
np = np->n_repl;
np->n_flags |= NUMREACH;
if (!(np->n_flags&NUMSCAN)) {
np->n_flags |= NUMSCAN;
reach(np->n_line->l_next);
}
if ((lnp->l_instr&BMASK) == op_lab)
return;
else
np->n_jumps++;
}
if ((em_flag[(lnp->l_instr&BMASK)-sp_fmnem]&EM_FLO)==FLO_T)
return;
}
}
cleaninstrs() {
register line_p *lpp,lp,*lastbra;
bool reachable,superfluous;
int instr;
lpp = &instrs; lastbra = (line_p *) 0; reachable = TRUE;
while ((lp = *lpp) != (line_p) 0) {
instr = lp->l_instr&BMASK;
if (instr == op_lab) {
if ((lp->l_a.la_np->n_flags&NUMREACH) != 0) {
reachable = TRUE;
if (lastbra != (line_p *) 0
&& (*lastbra)->l_next == lp
&& (*lastbra)->l_a.la_np->n_repl==lp->l_a.la_np) {
oldline(*lastbra);
OPTIM(O_BRALAB);
lpp = lastbra;
*lpp = lp;
lp->l_a.la_np->n_jumps--;
}
}
if ( lp->l_a.la_np->n_repl != lp->l_a.la_np ||
((lp->l_a.la_np->n_flags&NUMDATA)==0 &&
lp->l_a.la_np->n_jumps == 0))
superfluous = TRUE;
else
superfluous = FALSE;
} else
superfluous = FALSE;
if ( (!reachable) || superfluous) {
lp = lp->l_next;
oldline(*lpp);
OPTIM(O_UNREACH);
*lpp = lp;
} else {
if ( instr <= sp_lmnem &&
(em_flag[instr-sp_fmnem]&EM_FLO)==FLO_T) {
reachable = FALSE;
if ((lp->l_instr&BMASK) == op_bra)
lastbra = lpp;
}
lpp = &lp->l_next;
}
}
}

View File

@@ -1,556 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include <stdio.h>
#include "param.h"
#include "types.h"
#include "assert.h"
#include "line.h"
#include "lookup.h"
#include "alloc.h"
#include "proinf.h"
#include "../../h/em_spec.h"
#include "../../h/em_pseu.h"
#include "../../h/em_flag.h"
#include "../../h/em_mes.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
static short tabval; /* temp store for shorts */
static offset tabval2; /* temp store for offsets */
static char string[IDL+1]; /* temp store for names */
/*
* The next constants are close to sp_cend for fast switches
*/
#define INST 256 /* instruction: number in tabval */
#define PSEU 257 /* pseudo: number in tabval */
#define ILBX 258 /* label: number in tabval */
#define DLBX 259 /* symbol: name in string[] */
#define CSTX1 260 /* short constant: stored in tabval */
#define CSTX2 261 /* offset: value in tabval2 */
#define VALX1 262 /* symbol+short: in string[] and tabval */
#define VALX2 263 /* symbol+offset: in string[] and tabval2 */
#define ATEOF 264 /* bumped into end of file */
#define readbyte getchar
short readshort() {
register int l_byte, h_byte;
l_byte = readbyte();
h_byte = readbyte();
if ( h_byte>=128 ) h_byte -= 256 ;
return l_byte | (h_byte*256) ;
}
#ifdef LONGOFF
offset readoffset() {
register long l;
register int h_byte;
l = readbyte();
l |= ((unsigned) readbyte())*256 ;
l |= readbyte()*256L*256L ;
h_byte = readbyte() ;
if ( h_byte>=128 ) h_byte -= 256 ;
return l | (h_byte*256L*256*256L) ;
}
#endif
draininput() {
/*
* called when MES ERR is encountered.
* Drain input in case it is a pipe.
*/
while (getchar() != EOF)
;
}
short getint() {
switch(table2()) {
default: error("int expected");
case CSTX1:
return(tabval);
}
}
sym_p getsym(status) int status; {
switch(table2()) {
default:
error("symbol expected");
case DLBX:
return(symlookup(string,status,0));
case sp_pnam:
return(symlookup(string,status,SYMPRO));
}
}
offset getoff() {
switch (table2()) {
default: error("offset expected");
case CSTX1:
return((offset) tabval);
#ifdef LONGOFF
case CSTX2:
return(tabval2);
#endif
}
}
make_string(n) int n; {
register char *s;
extern char *sprintf();
s=sprintf(string,".%u",n);
assert(s == string);
}
inident() {
register n;
register char *p = string;
register c;
n = getint();
while (n--) {
c = readbyte();
if (p<&string[IDL])
*p++ = c;
}
*p++ = 0;
}
int table3(n) int n; {
switch (n) {
case sp_ilb1: tabval = readbyte(); return(ILBX);
case sp_ilb2: tabval = readshort(); return(ILBX);
case sp_dlb1: make_string(readbyte()); return(DLBX);
case sp_dlb2: make_string(readshort()); return(DLBX);
case sp_dnam: inident(); return(DLBX);
case sp_pnam: inident(); return(n);
case sp_cst2: tabval = readshort(); return(CSTX1);
#ifdef LONGOFF
case sp_cst4: tabval2 = readoffset(); return(CSTX2);
#endif
case sp_doff: if (table2()!=DLBX) error("symbol expected");
switch(table2()) {
default: error("offset expected");
case CSTX1: return(VALX1);
#ifdef LONGOFF
case CSTX2: return(VALX2);
#endif
}
default: return(n);
}
}
int table1() {
register n;
n = readbyte();
if (n == EOF)
return(ATEOF);
if ((n <= sp_lmnem) && (n >= sp_fmnem)) {
tabval = n;
return(INST);
}
if ((n <= sp_lpseu) && (n >= sp_fpseu)) {
tabval = n;
return(PSEU);
}
if ((n < sp_filb0 + sp_nilb0) && (n >= sp_filb0)) {
tabval = n - sp_filb0;
return(ILBX);
}
return(table3(n));
}
int table2() {
register n;
n = readbyte();
if ((n < sp_fcst0 + sp_ncst0) && (n >= sp_fcst0)) {
tabval = n - sp_zcst0;
return(CSTX1);
}
return(table3(n));
}
getlines() {
register line_p lnp;
register instr;
for(;;) {
linecount++;
switch(table1()) {
default:
error("unknown instruction byte");
/* NOTREACHED */
case ATEOF:
if (prodepth!=0)
error("procedure unterminated at eof");
process();
return;
case INST:
tstinpro();
instr = tabval;
break;
case DLBX:
lnp = newline(OPSYMBOL);
lnp->l_instr = ps_sym;
lnp->l_a.la_sp= symlookup(string,DEFINING,0);
lnp->l_next = curpro.lastline;
curpro.lastline = lnp;
continue;
case ILBX:
tstinpro();
lnp = newline(OPNUMLAB);
lnp->l_instr = op_lab;
lnp->l_a.la_np = numlookup((unsigned) tabval);
if (lnp->l_a.la_np->n_line != (line_p) 0)
error("label %u multiple defined",(unsigned) tabval);
lnp->l_a.la_np->n_line = lnp;
lnp->l_next = curpro.lastline;
curpro.lastline = lnp;
continue;
case PSEU:
if(inpseudo(tabval))
return;
continue;
}
/*
* Now we have an instruction number in instr
* There might be an operand, look for it
*/
if ((em_flag[instr-sp_fmnem]&EM_PAR)==PAR_NO) {
lnp = newline(OPNO);
} else switch(table2()) {
default:
error("unknown offset byte");
case sp_cend:
lnp = newline(OPNO);
break;
case CSTX1:
if ((em_flag[instr-sp_fmnem]&EM_PAR)!= PAR_B) {
if (CANMINI(tabval))
lnp = newline(tabval+Z_OPMINI);
else {
lnp = newline(OPSHORT);
lnp->l_a.la_short = tabval;
}
} else {
lnp = newline(OPNUMLAB);
lnp->l_a.la_np = numlookup((unsigned) tabval);
}
break;
#ifdef LONGOFF
case CSTX2:
lnp = newline(OPOFFSET);
lnp->l_a.la_offset = tabval2;
break;
#endif
case ILBX:
tstinpro();
lnp = newline(OPNUMLAB);
lnp->l_a.la_np = numlookup((unsigned) tabval);
break;
case DLBX:
lnp = newline(OPSYMBOL);
lnp->l_a.la_sp = symlookup(string,OCCURRING,0);
break;
case sp_pnam:
lnp = newline(OPSYMBOL);
lnp->l_a.la_sp = symlookup(string,OCCURRING,SYMPRO);
break;
case VALX1:
lnp = newline(OPSVAL);
lnp->l_a.la_sval.lasv_sp = symlookup(string,OCCURRING,0);
lnp->l_a.la_sval.lasv_short = tabval;
break;
#ifdef LONGOFF
case VALX2:
lnp = newline(OPLVAL);
lnp->l_a.la_lval.lalv_sp = symlookup(string,OCCURRING,0);
lnp->l_a.la_lval.lalv_offset = tabval2;
break;
#endif
}
lnp->l_instr = instr;
lnp->l_next = curpro.lastline;
curpro.lastline = lnp;
}
}
argstring(length,abp) offset length; register argb_p abp; {
while (length--) {
if (abp->ab_index == NARGBYTES)
abp = abp->ab_next = newargb();
abp->ab_contents[abp->ab_index++] = readbyte();
}
}
line_p arglist(n) int n; {
line_p lnp;
register arg_p ap,*app;
bool moretocome;
offset length;
/*
* creates an arglist with n elements
* if n == 0 the arglist is variable and terminated by sp_cend
*/
lnp = newline(OPLIST);
app = &lnp->l_a.la_arg;
moretocome = TRUE;
do {
switch(table2()) {
default:
error("unknown byte in arglist");
case CSTX1:
tabval2 = (offset) tabval;
case CSTX2:
*app = ap = newarg(ARGOFF);
ap->a_a.a_offset = tabval2;
app = &ap->a_next;
break;
case ILBX:
tstinpro();
*app = ap = newarg(ARGNUM);
ap->a_a.a_np = numlookup((unsigned) tabval);
ap->a_a.a_np->n_flags |= NUMDATA;
app = &ap->a_next;
break;
case DLBX:
*app = ap = newarg(ARGSYM);
ap->a_a.a_sp = symlookup(string,OCCURRING,0);
app = &ap->a_next;
break;
case sp_pnam:
*app = ap = newarg(ARGSYM);
ap->a_a.a_sp = symlookup(string,OCCURRING,SYMPRO);
app = &ap->a_next;
break;
case VALX1:
tabval2 = (offset) tabval;
case VALX2:
*app = ap = newarg(ARGVAL);
ap->a_a.a_val.av_sp = symlookup(string,OCCURRING,0);
ap->a_a.a_val.av_offset = tabval2;
app = &ap->a_next;
break;
case sp_scon:
*app = ap = newarg(ARGSTR);
length = getoff();
argstring(length,&ap->a_a.a_string);
app = &ap->a_next;
break;
case sp_icon:
*app = ap = newarg(ARGICN);
goto casecon;
case sp_ucon:
*app = ap = newarg(ARGUCN);
goto casecon;
case sp_fcon:
*app = ap = newarg(ARGFCN);
casecon:
length = getint();
ap->a_a.a_con.ac_length = (short) length;
argstring(getoff(),&ap->a_a.a_con.ac_con);
app = &ap->a_next;
break;
case sp_cend:
moretocome = FALSE;
}
if (n && (--n) == 0)
moretocome = FALSE;
} while (moretocome);
return(lnp);
}
offset aoff(ap,n) register arg_p ap; {
while (n>0) {
if (ap != (arg_p) 0)
ap = ap->a_next;
n--;
}
if (ap == (arg_p) 0)
error("too few parameters");
if (ap->a_typ != ARGOFF)
error("offset expected");
return(ap->a_a.a_offset);
}
int inpseudo(n) short n; {
register line_p lnp,head,tail;
short n1,n2;
proinf savearea;
#ifdef PSEUBETWEEN
static int pcount=0;
if (pcount++ >= PSEUBETWEEN && prodepth==0) {
process();
pcount=0;
}
#endif
switch(n) {
default:
error("unknown pseudo");
case ps_bss:
case ps_hol:
lnp = arglist(3);
break;
case ps_rom:
case ps_con:
lnp = arglist(0);
break;
case ps_ina:
case ps_inp:
case ps_exa:
case ps_exp:
lnp = newline(OPSYMBOL);
lnp->l_a.la_sp = getsym(NOTHING);
break;
case ps_exc:
n1 = getint(); n2 = getint();
if (n1 != 0 && n2 != 0) {
tail = curpro.lastline;
while (--n2) tail = tail->l_next;
head = tail;
while (n1--) head = head->l_next;
lnp = tail->l_next;
tail->l_next = head->l_next;
head->l_next = curpro.lastline;
curpro.lastline = lnp;
}
lnp = newline(OPNO);
break;
case ps_mes:
lnp = arglist(0);
switch((int) aoff(lnp->l_a.la_arg,0)) {
case ms_err:
draininput(); exit(-1);
case ms_opt:
nflag = TRUE; break;
case ms_emx:
wordsize = aoff(lnp->l_a.la_arg,1);
pointersize = aoff(lnp->l_a.la_arg,2);
#ifndef LONGOFF
if (wordsize>2)
error("This optimizer cannot handle wordsize>2");
#endif
break;
case ms_gto:
curpro.gtoproc=1;
/* Treat as empty mes ms_reg */
case ms_reg:
tstinpro();
regvar(lnp->l_a.la_arg->a_next);
oldline(lnp);
lnp=newline(OPNO);
n=ps_exc; /* kludge to force out this line */
break;
}
break;
case ps_pro:
if (prodepth>0)
savearea = curpro;
else
process();
curpro.symbol = getsym(DEFINING);
switch(table2()) {
case sp_cend:
curpro.localbytes = (offset) -1;
break;
case CSTX1:
tabval2 = (offset) tabval;
case CSTX2:
curpro.localbytes = tabval2;
break;
default:
error("bad second arg of PRO");
}
prodepth++;
curpro.gtoproc=0;
if (prodepth>1) {
register i;
curpro.lastline = (line_p) 0;
curpro.freg = (reg_p) 0;
for(i=0;i<NNUMHASH;i++)
curpro.numhash[i] = (num_p) 0;
getlines();
curpro = savearea;
prodepth--;
}
return(0);
case ps_end:
if (prodepth==0)
error("END misplaced");
switch(table2()) {
case sp_cend:
if (curpro.localbytes == (offset) -1)
error("bytes for locals still unknown");
break;
case CSTX1:
tabval2 = (offset) tabval;
case CSTX2:
if (curpro.localbytes != (offset) -1 && curpro.localbytes != tabval2)
error("inconsistency in number of bytes for locals");
curpro.localbytes = tabval2;
break;
}
process();
curpro.symbol = (sym_p) 0;
if (prodepth==1) {
prodepth=0;
#ifdef PSEUBETWEEN
pcount=0;
#endif
return(0);
} else
return(1);
}
lnp->l_instr = n;
lnp->l_next = curpro.lastline;
curpro.lastline = lnp;
return(0);
}
tstinpro() {
if (prodepth==0)
error("This is not allowed outside a procedure");
}

View File

@@ -1,88 +0,0 @@
/* $Header$ */
#define NARGBYTES 14
struct argbytes {
argb_p ab_next;
short ab_index;
char ab_contents[NARGBYTES];
};
typedef struct {
sym_p av_sp;
offset av_offset;
} s_a_val;
typedef struct {
short ac_length;
argb_t ac_con;
} s_a_con;
typedef union {
offset a_offset;
num_p a_np;
sym_p a_sp;
s_a_val a_val;
argb_t a_string;
s_a_con a_con;
} un_a_a;
struct arg {
arg_p a_next;
short a_typ;
un_a_a a_a;
};
/* possible values for .a_typ
*/
#define ARGOFF 0
#define ARGNUM 1
#define ARGSYM 2
#define ARGVAL 3
#define ARGSTR 4
#define ARGICN 5
#define ARGUCN 6
#define ARGFCN 7
typedef struct {
sym_p lasv_sp;
short lasv_short;
} s_la_sval;
typedef struct {
sym_p lalv_sp;
offset lalv_offset;
} s_la_lval;
typedef union {
short la_short;
offset la_offset;
num_p la_np;
sym_p la_sp;
s_la_sval la_sval;
s_la_lval la_lval;
arg_p la_arg;
} un_l_a;
struct line {
line_p l_next; /* maintains linked list */
byte l_instr; /* instruction number */
byte l_optyp; /* specifies what follows */
un_l_a l_a;
};
/* Possible values for .l_optyp */
#define OPNO 0 /* no operand */
#define OPSHORT 1 /* 16 bit number */
#define OPOFFSET 2 /* 16 or 32 bit number */
#define OPNUMLAB 3 /* local label for branches */
#define OPSYMBOL 4 /* global label or procedurename */
#define OPSVAL 5 /* symbol + 16 bit constant */
#define OPLVAL 6 /* symbol + 16 or 32 bit constant */
#define OPLIST 7 /* operand list for some pseudos */
#define OPMINI 8 /* start of minis */
#define Z_OPMINI (OPMINI+100) /* tunable */
#define CANMINI(x) ((x)>=OPMINI-Z_OPMINI && (x)<256-Z_OPMINI)

View File

@@ -1,94 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "types.h"
#include "lookup.h"
#include "alloc.h"
#include "proinf.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
unsigned hash(string) char *string; {
register char *p;
register unsigned i,sum;
for (sum=i=0,p=string;*p;i += 3)
sum ^= (*p++)<<(i&07);
return(sum);
}
sym_p symlookup(name,status,flags) char *name; int status,flags; {
register sym_p *spp,sp;
register i;
static short genfrag = 32767;
spp = &symhash[hash(name)%NSYMHASH];
while (*spp != (sym_p) 0)
if (strncmp((*spp)->s_name,name,IDL)==0) {
sp = *spp;
if ((sp->s_flags^flags)&SYMPRO)
error("%s is both proc and datalabel",name);
if (status == DEFINING) {
if (sp->s_flags&SYMDEF)
error("redefined symbol %s",name);
sp->s_flags |= SYMDEF;
}
return(sp);
} else
spp = &(*spp)->s_next;
/*
* symbol not found, enter in table
*/
i = strlen(name) + 1;
if (i & 1)
i++;
if (i > IDL)
i = IDL;
*spp = sp = newsym(i);
strncpy(sp->s_name,name,i);
sp->s_flags = flags;
if (status == DEFINING)
sp->s_flags |= SYMDEF;
sp->s_frag = genfrag--;
return(sp);
}
num_p numlookup(number) unsigned number; {
register num_p *npp, np;
npp = &curpro.numhash[number%NNUMHASH];
while (*npp != (num_p) 0)
if ((*npp)->n_number == number)
return(*npp);
else
npp = &(*npp)->n_next;
/*
* local label not found, enter in tabel
*/
*npp = np = newnum();
np->n_number = number;
np->n_repl = np;
return(np);
}

View File

@@ -1,25 +0,0 @@
/* $Header$ */
#define IDL 100
struct sym {
sym_p s_next;
offset *s_rom;
short s_flags;
short s_frag;
offset s_value;
char s_name[2]; /* to be extended up to IDL */
};
/* contents of .s_flags */
#define SYMPRO 000001
#define SYMGLOBAL 000002
#define SYMKNOWN 000004
#define SYMOUT 000010
#define SYMDEF 000020
#define NSYMHASH 127
extern sym_p symhash[NSYMHASH],symlookup();
#define OCCURRING 0
#define DEFINING 1
#define NOTHING 2

View File

@@ -1,77 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include <stdio.h>
#include "param.h"
#include "types.h"
#include "alloc.h"
#include "../../h/em_spec.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
/*
* Main program for EM optimizer
*/
main(argc,argv) int argc; char *argv[]; {
short somespace[STACKROOM];
progname = argv[0];
while (argc-->1 && **++argv == '-')
flags(*argv);
if (argc>1) {
fprintf(stderr,"Usage: %s [-Ln] [name]\n",progname);
exit(-1);
}
if (argc)
if (freopen(*argv,"r",stdin) == NULL)
error("Cannot open %s",*argv);
fileinit();
coreinit(somespace,somespace+STACKROOM);
getlines();
cleanup();
return(0);
}
flags(s) register char *s; {
for (s++;*s;s++)
switch(*s) {
case 'L': Lflag = TRUE; break;
case 'n': nflag = TRUE; break;
}
}
fileinit() {
char *mktemp();
short readshort();
if (readshort() != (short) sp_magic)
error("wrong input file");
if (Lflag) {
outfile = fopen(mktemp(template),"w");
if (outfile == NULL)
error("can't create %s",template);
} else {
outfile = stdout;
outshort(sp_magic);
}
}

View File

@@ -1,15 +0,0 @@
: '$Header$'
for extension in c y
do
for file in *.$extension
do ofile=`basename $file .$extension`.o
grep '^# *include.*"' $file|sed "s/.*\"\(.*\)\".*/$ofile: \1/"
done
done | sort -u >depend
ed - Makefile <<'!'
/AUTOAUTOAUTO/+,$d
$r depend
w
q
!
rm -f depend

View File

@@ -1,366 +0,0 @@
%{
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include <stdio.h>
#include "param.h"
#include "types.h"
#include "pattern.h"
#include "../../h/em_spec.h"
#include "../../h/em_mnem.h"
#include "optim.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#define MAXNODES 1000
expr_t nodes[MAXNODES];
expr_p lastnode = nodes+1;
int curind,prevind;
int patlen,maxpatlen,rpllen;
int lino = 1;
int patno=1;
#define MAX 100
int patmnem[MAX],rplmnem[MAX],rplexpr[MAX];
byte nparam[N_EX_OPS];
bool nonumlab[N_EX_OPS];
bool onlyconst[N_EX_OPS];
int nerrors=0;
%}
%union {
int y_int;
}
%left OR2
%left AND2
%left OR1
%left XOR1
%left AND1
%left CMPEQ,CMPNE
%left CMPLT,CMPLE,CMPGT,CMPGE
%left RSHIFT,LSHIFT
%left ARPLUS,ARMINUS
%left ARTIMES,ARDIVIDE,ARMOD
%nonassoc NOT,COMP,UMINUS
%nonassoc '$'
%token SFIT,UFIT,NOTREG,PSIZE,WSIZE,DEFINED,SAMESIGN,ROM,ROTATE
%token <y_int> MNEM
%token <y_int> NUMBER
%type <y_int> expr,argno,optexpr
%start patternlist
%%
patternlist
: /* empty */
| patternlist '\n'
| patternlist pattern
;
pattern :
mnemlist optexpr ':' replacement '\n'
{ register i;
outbyte(0); outshort(prevind); prevind=curind-3;
out(patlen);
for (i=0;i<patlen;i++) outbyte(patmnem[i]);
out($2);
out(rpllen);
for (i=0;i<rpllen;i++) {
outbyte(rplmnem[i]);
out(rplexpr[i]);
}
#ifdef DIAGOPT
outshort(patno);
#endif
patno++;
printf("\n");
if (patlen>maxpatlen) maxpatlen=patlen;
}
| error '\n'
{ yyerrok; }
;
replacement
: expr /* special optimization */
{
#ifdef ALLOWSPECIAL
rpllen=1; rplmnem[0]=0; rplexpr[0]=$1;
#else
yyerror("No specials allowed");
#endif
}
| repllist
;
repllist: /* empty */
{ rpllen=0; }
| repllist repl
;
repl : MNEM optexpr
{ rplmnem[rpllen] = $1; rplexpr[rpllen++] = $2; }
;
mnemlist: MNEM
{ patlen=0; patmnem[patlen++] = $1; }
| mnemlist MNEM
{ patmnem[patlen++] = $2; }
;
optexpr : /* empty */
{ $$ = 0; }
| expr
;
expr
: '$' argno
{ $$ = lookup(0,EX_ARG,$2,0); }
| NUMBER
{ $$ = lookup(0,EX_CON,(int)(short)$1,0); }
| PSIZE
{ $$ = lookup(0,EX_POINTERSIZE,0,0); }
| WSIZE
{ $$ = lookup(0,EX_WORDSIZE,0,0); }
| DEFINED '(' expr ')'
{ $$ = lookup(0,EX_DEFINED,$3,0); }
| SAMESIGN '(' expr ',' expr ')'
{ $$ = lookup(1,EX_SAMESIGN,$3,$5); }
| SFIT '(' expr ',' expr ')'
{ $$ = lookup(0,EX_SFIT,$3,$5); }
| UFIT '(' expr ',' expr ')'
{ $$ = lookup(0,EX_UFIT,$3,$5); }
| ROTATE '(' expr ',' expr ')'
{ $$ = lookup(0,EX_ROTATE,$3,$5); }
| NOTREG '(' expr ')'
{ $$ = lookup(0,EX_NOTREG,$3,0); }
| ROM '(' argno ',' expr ')'
{ $$ = lookup(0,EX_ROM,$3,$5); }
| '(' expr ')'
{ $$ = $2; }
| expr CMPEQ expr
{ $$ = lookup(1,EX_CMPEQ,$1,$3); }
| expr CMPNE expr
{ $$ = lookup(1,EX_CMPNE,$1,$3); }
| expr CMPGT expr
{ $$ = lookup(0,EX_CMPGT,$1,$3); }
| expr CMPGE expr
{ $$ = lookup(0,EX_CMPGE,$1,$3); }
| expr CMPLT expr
{ $$ = lookup(0,EX_CMPLT,$1,$3); }
| expr CMPLE expr
{ $$ = lookup(0,EX_CMPLE,$1,$3); }
| expr OR2 expr
{ $$ = lookup(0,EX_OR2,$1,$3); }
| expr AND2 expr
{ $$ = lookup(0,EX_AND2,$1,$3); }
| expr OR1 expr
{ $$ = lookup(1,EX_OR1,$1,$3); }
| expr XOR1 expr
{ $$ = lookup(1,EX_XOR1,$1,$3); }
| expr AND1 expr
{ $$ = lookup(1,EX_AND1,$1,$3); }
| expr ARPLUS expr
{ $$ = lookup(1,EX_PLUS,$1,$3); }
| expr ARMINUS expr
{ $$ = lookup(0,EX_MINUS,$1,$3); }
| expr ARTIMES expr
{ $$ = lookup(1,EX_TIMES,$1,$3); }
| expr ARDIVIDE expr
{ $$ = lookup(0,EX_DIVIDE,$1,$3); }
| expr ARMOD expr
{ $$ = lookup(0,EX_MOD,$1,$3); }
| expr LSHIFT expr
{ $$ = lookup(0,EX_LSHIFT,$1,$3); }
| expr RSHIFT expr
{ $$ = lookup(0,EX_RSHIFT,$1,$3); }
| ARPLUS expr %prec UMINUS
{ $$ = $2; }
| ARMINUS expr %prec UMINUS
{ $$ = lookup(0,EX_UMINUS,$2,0); }
| NOT expr
{ $$ = lookup(0,EX_NOT,$2,0); }
| COMP expr
{ $$ = lookup(0,EX_COMP,$2,0); }
;
argno : NUMBER
{ if ($1<1 || $1>patlen) {
YYERROR;
}
$$ = (int) $1;
}
;
%%
extern char em_mnem[][4];
#define HASHSIZE (2*(sp_lmnem-sp_fmnem))
struct hashmnem {
char h_name[3];
byte h_value;
} hashmnem[HASHSIZE];
inithash() {
register i;
enter("lab",op_lab);
enter("LLP",op_LLP);
enter("LEP",op_LEP);
enter("SLP",op_SLP);
enter("SEP",op_SEP);
for(i=0;i<=sp_lmnem-sp_fmnem;i++)
enter(em_mnem[i],i+sp_fmnem);
}
unsigned hashname(name) register char *name; {
register unsigned h;
h = (*name++)&BMASK;
h = (h<<4)^((*name++)&BMASK);
h = (h<<4)^((*name++)&BMASK);
return(h);
}
enter(name,value) char *name; {
register unsigned h;
h=hashname(name)%HASHSIZE;
while (hashmnem[h].h_name[0] != 0)
h = (h+1)%HASHSIZE;
strncpy(hashmnem[h].h_name,name,3);
hashmnem[h].h_value = value;
}
int mlookup(name) char *name; {
register unsigned h;
h = hashname(name)%HASHSIZE;
while (strncmp(hashmnem[h].h_name,name,3) != 0 &&
hashmnem[h].h_name[0] != 0)
h = (h+1)%HASHSIZE;
return(hashmnem[h].h_value&BMASK); /* 0 if not found */
}
main() {
inithash();
initio();
yyparse();
if (nerrors==0)
printnodes();
return nerrors;
}
yyerror(s) char *s; {
fprintf(stderr,"line %d: %s\n",lino,s);
nerrors++;
}
lookup(comm,operator,lnode,rnode) {
register expr_p p;
for (p=nodes+1;p<lastnode;p++) {
if (p->ex_operator != operator)
continue;
if (!(p->ex_lnode == lnode && p->ex_rnode == rnode ||
comm && p->ex_lnode == rnode && p->ex_rnode == lnode))
continue;
return(p-nodes);
}
if (lastnode >= &nodes[MAXNODES])
yyerror("node table overflow");
lastnode++;
p->ex_operator = operator;
p->ex_lnode = lnode;
p->ex_rnode = rnode;
return(p-nodes);
}
printnodes() {
register expr_p p;
printf("};\n\nshort lastind = %d;\n\nexpr_t enodes[] = {\n",prevind);
for (p=nodes;p<lastnode;p++)
printf("/* %3d */\t%3d,%6u,%6u,\n",
p-nodes,p->ex_operator,p->ex_lnode,p->ex_rnode);
printf("};\n\niarg_t iargs[%d];\n",maxpatlen);
}
initio() {
register i;
printf("#include \"param.h\"\n#include \"types.h\"\n");
printf("#include \"pattern.h\"\n\n");
for(i=0;i<N_EX_OPS;i++) {
nparam[i]=2;
nonumlab[i]=TRUE;
onlyconst[i]=TRUE;
}
nparam[EX_POINTERSIZE] = 0;
nparam[EX_WORDSIZE] = 0;
nparam[EX_CON] = 0;
nparam[EX_ROM] = 0;
nparam[EX_ARG] = 0;
nparam[EX_DEFINED] = 0;
nparam[EX_OR2] = 1;
nparam[EX_AND2] = 1;
nparam[EX_UMINUS] = 1;
nparam[EX_NOT] = 1;
nparam[EX_COMP] = 1;
nparam[EX_NOTREG] = 1;
nonumlab[EX_CMPEQ] = FALSE;
nonumlab[EX_CMPNE] = FALSE;
onlyconst[EX_CMPEQ] = FALSE;
onlyconst[EX_CMPNE] = FALSE;
onlyconst[EX_CMPLE] = FALSE;
onlyconst[EX_CMPLT] = FALSE;
onlyconst[EX_CMPGE] = FALSE;
onlyconst[EX_CMPGT] = FALSE;
onlyconst[EX_PLUS] = FALSE;
onlyconst[EX_MINUS] = FALSE;
printf("byte nparam[] = {");
for (i=0;i<N_EX_OPS;i++) printf("%d,",nparam[i]);
printf("};\nbool nonumlab[] = {");
for (i=0;i<N_EX_OPS;i++) printf("%d,",nonumlab[i]);
printf("};\nbool onlyconst[] = {");
for (i=0;i<N_EX_OPS;i++) printf("%d,",onlyconst[i]);
printf("};\n\nbyte pattern[] = { 0\n");
curind = 1;
}
outbyte(b) {
printf(",%3d",b);
curind++;
}
outshort(s) {
outbyte(s&0377);
outbyte((s>>8)&0377);
}
out(w) {
if (w<255) {
outbyte(w);
} else {
outbyte(255);
outshort(w);
}
}
#include "scan.c"

View File

@@ -1,12 +0,0 @@
/* $Header$ */
/* #define DIAGOPT /* if defined diagnostics are produced */
#ifdef DIAGOPT
#define OPTIM(x) optim(x)
#define O_UNREACH 1001
#define O_BRALAB 1002
#define O_LINLNI 1003
#define O_LINGONE 1004
#else
#define OPTIM(x) /* NOTHING */
#endif

View File

@@ -1,15 +0,0 @@
/* $Header$ */
#define LONGOFF /* if defined long offsets are used */
#define TRUE 1
#define FALSE 0
#define MAXROM 3
#define op_lab (sp_lmnem+1)
#define op_last op_lab
#define ps_sym (sp_lpseu+1)
#define ps_last ps_sym
#define BMASK 0377

View File

@@ -1,126 +0,0 @@
/* $Header$ */
/*
* pattern contains the optimization patterns in an apparently
* unordered fashion. All patterns follow each other unaligned.
* Each pattern looks as follows:
* Byte 0: high byte of hash value associated with this pattern.
* Byte 1-2: index of next pattern with same low byte of hash value.
* Byte 3- : pattern and replacement.
* First comes the pattern length
* then the pattern opcodes,
* then a boolean expression,
* then the one-byte replacement length
* then the intermixed pattern opcodes and operands or
* 0 followed by the one-byte special optimization expression.
* If the DIAGOPT option is set, the optimization is followed
* by the line number in the tables.
*/
/* #define ALLOWSPECIAL /* Special optimizations allowed */
#define PO_HASH 0
#define PO_NEXT 1
#define PO_MATCH 3
struct exprnode {
short ex_operator;
short ex_lnode;
short ex_rnode;
};
typedef struct exprnode expr_t;
typedef struct exprnode *expr_p;
/*
* contents of .ex_operator
*/
#define EX_CON 0
#define EX_ARG 1
#define EX_CMPEQ 2
#define EX_CMPNE 3
#define EX_CMPGT 4
#define EX_CMPGE 5
#define EX_CMPLT 6
#define EX_CMPLE 7
#define EX_OR2 8
#define EX_AND2 9
#define EX_OR1 10
#define EX_XOR1 11
#define EX_AND1 12
#define EX_PLUS 13
#define EX_MINUS 14
#define EX_TIMES 15
#define EX_DIVIDE 16
#define EX_MOD 17
#define EX_LSHIFT 18
#define EX_RSHIFT 19
#define EX_UMINUS 20
#define EX_NOT 21
#define EX_COMP 22
#define EX_ROM 23
#define EX_NOTREG 24
#define EX_POINTERSIZE 25
#define EX_WORDSIZE 26
#define EX_DEFINED 27
#define EX_SAMESIGN 28
#define EX_SFIT 29
#define EX_UFIT 30
#define EX_ROTATE 31
#define N_EX_OPS 32 /* must be one higher then previous */
/*
* Definition of special opcodes used in patterns
*/
#define op_pfirst op_LLP
#define op_LLP (op_last+1)
#define op_LEP (op_last+2)
#define op_SLP (op_last+3)
#define op_SEP (op_last+4)
#define op_plast op_SEP
/*
* Definition of the structure in which instruction operands
* are kept during pattern matching.
*/
typedef struct eval eval_t;
typedef struct eval *eval_p;
struct eval {
short e_typ;
union {
offset e_con;
num_p e_np;
} e_v;
};
/*
* contents of .e_typ
*/
#define EV_UNDEF 0
#define EV_CONST 1
#define EV_NUMLAB 2
#define EV_FRAG 3 /* and all higher numbers */
typedef struct iarg iarg_t;
typedef struct iarg *iarg_p;
struct iarg {
eval_t ia_ev;
sym_p ia_sp;
};
/*
* The next extern declarations refer to data generated by mktab
*/
extern byte pattern[];
extern short lastind;
extern iarg_t iargs[];
extern byte nparam[];
extern bool nonumlab[];
extern bool onlyconst[];
extern expr_t enodes[];

View File

@@ -1,475 +0,0 @@
/* $Header$ */
loc adi loc sbi $2==w && $4==w: loc $1-$3 adi w
ldc adi ldc sbi $2==2*w && $4==2*w: ldc $1-$3 adi 2*w
loc adi loc adi $2==w && $4==w: loc $1+$3 adi w
ldc adi ldc adi $2==2*w && $4==2*w: ldc $1+$3 adi 2*w
adp $1==0:
adp adp : adp $1+$2
adp lof : lof $1+$2
adp ldf : ldf $1+$2
adp loi $1!=0 && $2==w: lof $1
adp loi $1!=0 && $2==2*w: ldf $1
adp stf : stf $1+$2
adp sdf : sdf $1+$2
adp sti $1!=0 && $2==w: stf $1
adp sti $1!=0 && $2==2*w: sdf $1
asp $1==0:
asp asp : asp $1+$2
blm $1==0 : asp 2*p
cmi zeq $1==w: beq $2
cmi zge $1==w: bge $2
cmi zgt $1==w: bgt $2
cmi zle $1==w: ble $2
cmi zlt $1==w: blt $2
cmi zne $1==w: bne $2
dvi ngi $1==$2: ngi $1 dvi $1
lae adp : lae $1+$2
lae blm $2==w: loi w ste $1
lae blm $2==2*w: loi 2*w sde $1
lae ldf : lde $1+$2
lae lof : loe $1+$2
lae loi $2==w: loe $1
lae loi $2==2*w: lde $1
#ifdef INT
lae loi loe $3==$1-w && $2%w==0: lae $3 loi $2+w
lae loi lde $3==$1-2*w && $2%w==0: lae $3 loi $2+2*w
lae loi lae loi $1==$3+$4 && $2%w==0 && $4%w==0: lae $3 loi $2+$4
lae sti ste $3==$1+$2: lae $1 sti $2+w
lae sti sde $3==$1+$2: lae $1 sti $2+2*w
lae sti loc ste $4==$1-w: loc $3 lae $4 sti $2+w
lae sti lol ste $4==$1-w: lol $3 lae $4 sti $2+w
#endif
lae lae blm loe ste $4==$1+$3 && $5==$2+$3: lae $1 lae $2 blm $3+w
lae lae blm lde sde $4==$1+$3 && $5==$2+$3: lae $1 lae $2 blm $3+2*w
lae lae blm lae lae blm $4==$1+$3 && $5==$2+$3: lae $1 lae $2 blm $3+$6
lae lal blm lae lal blm $4==$1+$3 && $5==$2+$3 && samesign($2,$5):
lae $1 lal $2 blm $3+$6
lal lae blm lal lae blm $4==$1+$3 && $5==$2+$3 && samesign($1,$4):
lal $1 lae $2 blm $3+$6
lal lal blm lal lal blm $4==$1+$3 && $5==$2+$3 && samesign($1,$4) && samesign($2,$5):
lal $1 lal $2 blm $3+$6
lal lal sbs $3==w && samesign($1,$2): loc $1-$2
lae sdf : sde $1+$2
lae stf : ste $1+$2
lae sti $2==w: ste $1
lae sti $2==2*w: sde $1
lal adp samesign($1,$1+$2): lal $1+$2
lal blm $2==w: loi w stl $1
lal blm $2==2*w: loi 2*w sdl $1
#ifdef INT
lal sti loc stl notreg($4) && $4==$1-w && samesign($1,$4):
loc $3 lal $4 sti $2+w
lal sti loe stl notreg($4) && $4==$1-w && samesign($1,$4):
loe $3 lal $4 sti $2+w
#endif
lal ldf samesign($1,$1+$2): ldl $1+$2
lal lof samesign($1,$1+$2): lol $1+$2
lal loi $2==w: lol $1
lal loi $2==2*w: ldl $1
#ifdef INT
lal loi lol notreg($3) && $3==$1-w && samesign($1,$3) && $2%w==0:
lal $3 loi $2+w
lal loi ldl notreg($3) && $3==$1-2*w && samesign($1,$3) && $2%w==0:
lal $3 loi $2+2*w
lal loi lal loi $1==$3+$4 && samesign($1,$3) && $2%w==0 && $4%w==0:
lal $3 loi $2+$4
lal sti stl notreg($3) && $3==$1+$2 && samesign($1,$3): lal $1 sti $2+w
lal sti sdl notreg($3) && $3==$1+$2 && samesign($1,$3): lal $1 sti $2+2*w
#endif
lal sdf samesign($1,$1+$2): sdl $1+$2
lal stf samesign($1,$1+$2): stl $1+$2
lal sti $2==w: stl $1
lal sti $2==2*w: sdl $1
#ifdef INT
lde lde $2==$1-2*w: lae $2 loi 4*w
lde loe $2==$1-w: lae $2 loi 3*w
#endif
lde sde $2==$1:
lde sde lde sde $3==$1+2*w && $4==$2+2*w: lae $1 lae $2 blm 4*w
#ifdef INT
ldl ldl $2==$1-2*w && notreg($1) && notreg($2) && samesign($1,$2):
lal $2 loi 4*w
ldl lol $2==$1-w && notreg($1) && notreg($2) && samesign($1,$2):
lal $2 loi 3*w
#endif
ldl sdl $1==$2:
lxa loi lxa sti $3==$1 && $4==$2:
lxa lof lxa stf $3==$1 && $4==$2:
lxa ldf lxa sdf $3==$1 && $4==$2:
lxa stf lxa lof $3==$1 && $4==$2: dup w lxa $1 stf $2
lxa sdf lxa ldf $3==$1 && $4==$2: dup 2*w lxa $1 sdf $2
lxl lof lxl stf $3==$1 && $4==$2:
lxl ldf lxl sdf $3==$1 && $4==$2:
lxl stf lxl lof $3==$1 && $4==$2: dup w lxl $1 stf $2
lxl sdf lxl ldf $3==$1 && $4==$2: dup 2*w lxl $1 sdf $2
lxa sti lxa loi $3==$1 && $4==$2 && $2%w==0: dup $2 lxa $1 sti $2
loc adi $1==-1 && $2==w: dec
loc dec sfit($1-1,8*w) : loc $1-1
loc bgt $1==-1: zge $2
loc ble $1==-1: zlt $2
loc dvi $1==-1 && $2==w: ngi w
ldc dvi $1==-1 && $2==2*w: ngi 2*w
loc loe adi $1==-1 && $3==w: loe $2 dec
loc loe mli $1==-1 && $3==w: loe $2 ngi w
loc lol adi $1==-1 && $3==w: lol $2 dec
loc mli $1==-1 && $2==w: ngi w
ldc mli $1==-1 && $2==2*w: ngi 2*w
loc sbi $1==-1 && $2==w: inc
loc inc sfit($1+1,8*w) : loc $1+1
loc adi $1==0 && $2==w:
ldc adi $1==0 && $2==2*w:
zer adi $1==$2:
loc beq $1==0: zeq $2
loc bge $1==0: zge $2
loc bgt $1==0: zgt $2
loc ble $1==0: zle $2
loc blt $1==0: zlt $2
loc bne $1==0: zne $2
loc cmi teq $1==0 && $2==w: teq
loc cmi tge $1==0 && $2==w: tge
loc cmi tgt $1==0 && $2==w: tgt
loc cmi tle $1==0 && $2==w: tle
loc cmi tlt $1==0 && $2==w: tlt
loc cmi tne $1==0 && $2==w: tne
loc ior $1==0 && $2==w:
ldc ior $1==0 && $2==2*w:
zer ior $1==$2:
loc ste $1==0: zre $2
loc stl $1==0: zrl $2
loc sbi $1==0 && $2==w:
ldc sbi $1==0 && $2==2*w:
zer sbi $1==$2:
loc xor $1==0 && $2==w:
ldc xor $1==0 && $2==2*w:
zer xor $1==$2:
loc adi $1==1 && $2==w: inc
loc bge $1==1: zgt $2
loc blt $1==1: zle $2
loc dvi $1==1 && $2==w:
ldc dvi $1==1 && $2==2*w:
loc loe adi $1==1 && $3==w: loe $2 inc
loc loe mli $1==1 && $3==w: loe $2
loc lol adi $1==1 && $3==w: lol $2 inc
loc lol mli $1==1 && $3==w: lol $2
loc mli $1==1 && $2==w:
loc sbi $1==1 && $2==w: dec
loc loe mli $3==w: loe $2 loc $1 mli w
loc lol mli $3==w: lol $2 loc $1 mli w
ldc lde mli $3==2*w: lde $2 ldc $1 mli 2*w
ldc lde adi $3==2*w: lde $2 ldc $1 adi 2*w
ldc ldl mli $3==2*w: ldl $2 ldc $1 mli 2*w
ldc ldl adi $3==2*w: ldl $2 ldc $1 adi 2*w
loc mli $1==2 && $2==w: loc 1 sli w
loc mli $1==4 && $2==w: loc 2 sli w
loc mli $1==8 && $2==w: loc 3 sli w
loc mli $1==16 && $2==w: loc 4 sli w
loc mli $1==32 && $2==w: loc 5 sli w
loc mli $1==64 && $2==w: loc 6 sli w
loc mli $1==128 && $2==w: loc 7 sli w
loc mli $1==256 && $2==w: loc 8 sli w
loc adi !defined($2): adi $1
loc sbi !defined($2): sbi $1
loc mli !defined($2): mli $1
loc dvi !defined($2): dvi $1
loc rmi !defined($2): rmi $1
loc ngi !defined($2): ngi $1
loc sli !defined($2): sli $1
loc sri !defined($2): sri $1
loc adu !defined($2): adu $1
loc sbu !defined($2): sbu $1
loc mlu !defined($2): mlu $1
loc dvu !defined($2): dvu $1
loc rmu !defined($2): rmu $1
loc slu !defined($2): slu $1
loc sru !defined($2): sru $1
loc adf !defined($2): adf $1
loc sbf !defined($2): sbf $1
loc mlf !defined($2): mlf $1
loc dvf !defined($2): dvf $1
loc ngf !defined($2): ngf $1
loc fif !defined($2): fif $1
loc fef !defined($2): fef $1
loc zer !defined($2): zer $1
loc zrf !defined($2): zrf $1
loc los $2==w: loi $1
loc sts $2==w: sti $1
loc ads $2==w: adp $1
loc ass $2==w: asp $1
loc bls $2==w: blm $1
loc dus $2==w: dup $1
loc loc cii $1==$2:
loc loc cuu $1==$2:
loc loc cff $1==$2:
loc and !defined($2): and $1
loc ior !defined($2): ior $1
loc xor !defined($2): xor $1
loc com !defined($2): com $1
loc rol !defined($2): rol $1
loc rol $1==0:
loc ror !defined($2): ror $1
loc ror $1==0:
loc inn !defined($2): inn $1
loc set !defined($2): set $1
loc cmi !defined($2): cmi $1
loc cmu !defined($2): cmu $1
loc cmf !defined($2): cmf $1
loe dec ste $1==$3: dee $1
loe inc ste $1==$3: ine $1
loe loc mli $2==0 && $3==w: loc 0
#ifdef INT
loe loe $2==$1-w: lde $2
loe loe beq $2==$1+w: lde $1 beq $3
loe loe bge $2==$1+w: lde $1 ble $3
loe loe bgt $2==$1+w: lde $1 blt $3
loe loe ble $2==$1+w: lde $1 bge $3
loe loe blt $2==$1+w: lde $1 bgt $3
loe loe bne $2==$1+w: lde $1 bne $3
loe loe cmi $2==$1+w && $3==w: lde $1 cmi w ngi w
#endif
ngi teq $1==w: teq
ngi tge $1==w: tle
ngi tgt $1==w: tlt
ngi tle $1==w: tge
ngi tlt $1==w: tgt
ngi tne $1==w: tne
#ifdef INT
loe loe mli $2==$1+w && $3==w: lde $1 mli w
loe loe adi $2==$1+w && $3==w: lde $1 adi w
loe loe $1==$2: loe $1 dup w
#endif
loe ste $1==$2:
LLP blm $2==w: loi w sil $1
lol dec stl $1==$3: del $1
lol inc stl $1==$3: inl $1
lol loc mli $2==0 && $3==w: loc 0
LLP loi $2==w: lil $1
#ifdef INT
lol lol $2==$1-w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $2
lol lol beq $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 beq $3
lol lol bge $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 ble $3
lol lol bgt $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 blt $3
lol lol ble $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 bge $3
lol lol blt $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 bgt $3
lol lol bne $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 bne $3
lol lol cmi $3==w && $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 cmi w ngi w
lol lol mli $3==w && $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 mli w
lol lol adi $3==w && $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2):
ldl $1 adi w
lol lol $1==$2: lol $1 dup w
#endif
lol stl $1==$2:
LLP sti $2==w: sil $1
mli ngi $1==$2: ngi $1 mli $1
ngi adi $1==$2: sbi $1
ngf adf $1==$2: sbf $1
ngi sbi $1==$2: adi $1
ngf sbf $1==$2: adf $1
ngi ngi $1==$2:
ngf ngf $1==$2:
#ifdef INT
sde sde $2==$1+2*w: lae $1 sti 4*w
sde ste $2==$1+2*w: lae $1 sti 3*w
sde loc ste $3==$1-w: loc $2 lae $3 sti 3*w
sde lol ste $3==$1-w: lol $2 lae $3 sti 3*w
sde lde $1==$2: dup 2*w sde $1
#endif
sdf $1==0: sti 2*w
#ifdef INT
sdl sdl $2==$1+2*w && notreg($1) && notreg($2) && samesign($1,$2):
lal $1 sti 4*w
sdl stl $2==$1+2*w && notreg($1) && notreg($2) && samesign($1,$2):
lal $1 sti 3*w
sdl loc stl $3==$1-w && notreg($1) && notreg($3) && samesign($1,$3):
loc $2 lal $3 sti 3*w
sdl loe stl $3==$1-w && notreg($1) && notreg($3) && samesign($1,$3):
loe $2 lal $3 sti 3*w
sdl ldl $1==$2: dup 2*w sdl $1
ste loe $1==$2: dup w ste $1
ste ste $2==$1-w: sde $2
ste loc ste $3==$1-w: loc $2 sde $3
ste lol ste $3==$1-w: lol $2 sde $3
stl lol $1==$2: dup w stl $1
#endif
stf $1==0: sti w
sdl ldl ret $1==$2 && $3==2*w: ret 2*w
#ifdef INT
stl stl $2==$1+w && notreg($1) && notreg($2) && samesign($1,$2): sdl $1
stl loc stl $3==$1-w && notreg($1) && notreg($3) && samesign($1,$3):
loc $2 sdl $3
stl loe stl $3==$1-w && notreg($1) && notreg($3) && samesign($1,$3):
loe $2 sdl $3
#endif
stl lol ret $1==$2 && $3==w: ret w
lal sti lal loi ret $1==$3 && $2==$4 && $2==$5: ret $2
loc sbi loc sbi $2==w && $4==w: loc $1+$3 sbi w
ldc sbi ldc sbi $2==2*w && $4==2*w: ldc $1+$3 sbi 2*w
loc sbi loc adi $2==w && $4==w: loc $1-$3 sbi w
ldc sbi ldc adi $2==2*w && $4==2*w: ldc $1-$3 sbi 2*w
teq teq : tne
teq tne : teq
teq zne : zeq $2
teq zeq : zne $2
tge teq : tlt
tge tne : tge
tge zeq : zlt $2
tge zne : zge $2
tgt teq : tle
tgt tne : tgt
tgt zeq : zle $2
tgt zne : zgt $2
tle teq : tgt
tle tne : tle
tle zeq : zgt $2
tle zne : zle $2
tlt teq : tge
tlt tne : tlt
tlt zeq : zge $2
tlt zne : zlt $2
tne teq : teq
tne tne : tne
tne zeq : zeq $2
tne zne : zne $2
#ifdef INT
loc loc loc $1==0 && $2==0 && $3==0 : zer 6
zer loc defined($1) && $2==0: zer $1+w
#endif
loi loc and $1==1 && $3==w && ($2&255)==255: loi 1
loi loc loc cii $1<w && $2==w: loi $1 loc $2 loc $3 cuu
cmp teq : cms p teq
cmp tne : cms p tne
cmu teq defined($1): cms $1 teq
cmu tne defined($1): cms $1 tne
cms zeq $1==w: beq $2
cms zne $1==w: bne $2
lol lae aar adp $3==w: adp $4 lol $1 lae $2 aar w
loe lae aar adp $3==w: adp $4 loe $1 lae $2 aar w
cmi zeq defined($1): cms $1 zeq $2
cmi zne defined($1): cms $1 zne $2
loe inc dup ste $1==$4 && $3==w: ine $1 loe $1
loe dec dup ste $1==$4 && $3==w: dee $1 loe $1
lol inc dup stl $1==$4 && $3==w: inl $1 lol $1
lol dec dup stl $1==$4 && $3==w: del $1 lol $1
adp dup SEP adp $1==-$4 && $2==p: dup p adp $1 SEP $3
adp dup SLP adp $1==-$4 && $2==p: dup p adp $1 SLP $3
inc dup ste dec $2==w: dup w inc ste $3
inc dup stl dec $2==w: dup w inc stl $3
zeq bra lab $1==$3: zne $2 lab $1
zge bra lab $1==$3: zlt $2 lab $1
zgt bra lab $1==$3: zle $2 lab $1
zlt bra lab $1==$3: zge $2 lab $1
zle bra lab $1==$3: zgt $2 lab $1
zne bra lab $1==$3: zeq $2 lab $1
beq bra lab $1==$3: bne $2 lab $1
bge bra lab $1==$3: blt $2 lab $1
bgt bra lab $1==$3: ble $2 lab $1
blt bra lab $1==$3: bge $2 lab $1
ble bra lab $1==$3: bgt $2 lab $1
bne bra lab $1==$3: beq $2 lab $1
lin lin : lin $2
lin lab lin : lab $2 lin $3
lin ret : ret $2
lin bra : bra $2
dup SLP loi $1==p && $3==w: SLP $2 lil $2
dup SLP sti $1==p && $3==w: SLP $2 sil $2
loc cms $1==0 && $2==w: tne
zer $1==w: loc 0
loc loc adi $3==w && sfit($1+$2,8*w) : loc $1+$2
loc loc sbi $3==w && sfit($1-$2,8*w) : loc $1-$2
loc loc mli $3==w && sfit($1*$2,8*w) : loc $1*$2
loc loc dvi $3==w && $2!=0 : loc $1/$2
loc loc and $3==w : loc $1&$2
loc loc ior $3==w : loc $1|$2
loc loc ior $1==0 && $2==0 && $3==2*w :
loc loc xor $3==w : loc $1^$2
loc loc xor $1==0 && $2==0 && $3==2*w :
loc loc rol $3==w : loc rotate($1,$2)
loc loc ror $3==w : loc rotate($1,8*w-$2)
loc ngi $2==w && sfit(-$1,8*w) : loc -$1
loc com $2==w : loc ~$1
ldc ngi $2==2*w : ldc -$1
loc lae aar $3==w && $1>=rom(2,0) && $1 <= rom(2,0)+rom(2,1) :
adp ($1-rom(2,0))*rom(2,2)
loc lae lar $3==w && $1>=rom(2,0) && $1 <= rom(2,0)+rom(2,1) :
adp ($1-rom(2,0))*rom(2,2) loi rom(2,2)
loc lae sar $3==w && $1>=rom(2,0) && $1 <= rom(2,0)+rom(2,1) :
adp ($1-rom(2,0))*rom(2,2) sti rom(2,2)
loc teq : loc $1==0
loc tne : loc $1!=0
loc tge : loc $1>=0
loc tle : loc $1<=0
loc tgt : loc $1>0
loc tlt : loc $1<0
loc zeq $1==0 : bra $2
loc zeq :
loc zne $1!=0 : bra $2
loc zne :
loc zge $1>=0 : bra $2
loc zge :
loc zle $1<=0 : bra $2
loc zle :
loc zgt $1>0 : bra $2
loc zgt :
loc zlt $1<0 : bra $2
loc zlt :
loc loc beq $1==$2 : bra $3
loc loc beq :
loc loc bne $1!=$2 : bra $3
loc loc bne :
loc loc bge $1>=$2 : bra $3
loc loc bge :
loc loc ble $1<=$2 : bra $3
loc loc ble :
loc loc bgt $1>$2 : bra $3
loc loc bgt :
loc loc blt $1<$2 : bra $3
loc loc blt :
lae loi lal sti $2==$4 && $2>4*w : lae $1 lal $3 blm $2
lal loi lae sti $2==$4 && $2>4*w : lal $1 lae $3 blm $2
lal loi lal sti $2==$4 && $2>4*w && ( $3<=$1-$2 || $3>=$1+$2 ) :
lal $1 lal $3 blm $2
lae loi lae sti $2==$4 && $2>4*w && ( !defined($1==$3) || $3<=$1-$2 || $3>=$1+$2 ) :
lae $1 lae $3 blm $2
loc loc loc cif $1==0 && $2==w : zrf $3
loc loc loc ciu $1>=0 && $2==w && $3==2*w : ldc $1
loc loc loc cii $2==w && $3==2*w : ldc $1
loi loc inn $1==$3 && $2>=0 && $2<$1*8 :
lof ($2/(8*w))*w loc $2&(8*w-1) inn w
ldl loc inn $3==2*w && $2>=0 && $2<16*w :
lol $1+($2/(8*w))*w loc $2&(8*w-1) inn w
lde loc inn $3==2*w && $2>=0 && $2<16*w :
loe $1+($2/(8*w))*w loc $2&(8*w-1) inn w
ldf loc inn $3==2*w && $2>=0 && $2<16*w :
lof $1+($2/(8*w))*w loc $2&(8*w-1) inn w
loc inn $1<0 || $1>=8*$2 : asp $2 loc 0
lol loc adi stl $3==w && $1==$4 : loc $2 lol $1 adi w stl $4
lol loe adi stl $3==w && $1==$4 : loe $2 lol $1 adi w stl $4
lol lol adi stl $3==w && $1==$4 && $1!=$2 : lol $2 lol $1 adi w stl $4
loe loc adi ste $3==w && $1==$4 : loc $2 loe $1 adi w ste $4
loe loe adi ste $3==w && $1==$4 && $1!=$2 : loe $2 loe $1 adi w ste $4
loe lol adi ste $3==w && $1==$4 : lol $2 loe $1 adi w ste $4
lol loc ior stl $3==w && $1==$4 : loc $2 lol $1 ior w stl $4
lol loe ior stl $3==w && $1==$4 : loe $2 lol $1 ior w stl $4
lol lol ior stl $3==w && $1==$4 && $1!=$2 : lol $2 lol $1 ior w stl $4
loe loc ior ste $3==w && $1==$4 : loc $2 loe $1 ior w ste $4
loe loe ior ste $3==w && $1==$4 && $1!=$2 : loe $2 loe $1 ior w ste $4
loe lol ior ste $3==w && $1==$4 : lol $2 loe $1 ior w ste $4
lol loc and stl $3==w && $1==$4 : loc $2 lol $1 and w stl $4
lol loe and stl $3==w && $1==$4 : loe $2 lol $1 and w stl $4
lol lol and stl $3==w && $1==$4 && $1!=$2 : lol $2 lol $1 and w stl $4
loe loc and ste $3==w && $1==$4 : loc $2 loe $1 and w ste $4
loe loe and ste $3==w && $1==$4 && $1!=$2 : loe $2 loe $1 and w ste $4
loe lol and ste $3==w && $1==$4 : lol $2 loe $1 and w ste $4
loi asp $1==$2 : asp p
lal loi loc loc loc loc ior $2==4*w && $7==4*w && ($3==0)+($4==0)+($5==0)+($6==0)>2 :
lol $1+3*w loc $3 ior w lol $1+2*w loc $4 ior w lol $1+w loc $5 ior w lol $1 loc $6 ior w
loc dup stl loc dup stl $2==2 && $5==2:
loc $1 stl $3 loc $4 stl $6 loc $1 loc $4

View File

@@ -1,652 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "types.h"
#include "assert.h"
#include "line.h"
#include "lookup.h"
#include "proinf.h"
#include "alloc.h"
#include "pattern.h"
#include "../../h/em_spec.h"
#include "../../h/em_mnem.h"
#include "optim.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
/* #define CHK_HASH /* print numbers patterns are hashed to */
#ifdef CHK_HASH
#include <stdio.h>
#endif
#define ILLHASH 0177777
short pathash[256]; /* table of indices into pattern[] */
int opind = 0; /* second index of next matrix */
byte transl[op_plast-op_pfirst+1][3] = {
/* LLP */ { op_LLP, op_lol, op_ldl },
/* LEP */ { op_LEP, op_loe, op_lde },
/* SLP */ { op_SLP, op_stl, op_sdl },
/* SEP */ { op_SEP, op_ste, op_sde }
};
opcheck(bp) register byte *bp; {
if (((*bp)&BMASK) >= op_pfirst)
*bp = transl[((*bp)&BMASK)-op_pfirst][opind];
}
/*
* The hashing method used is believed to be reasonably efficient.
* A minor speed improvement could be obtained by keeping a boolean
* array telling which opcode has any patterns starting with it.
* Currently only about one third of the opcodes actually have a
* pattern starting with it, but they are the most common ones.
* Estimated improvement possible: about 2%
*/
hashpatterns() {
short index;
register byte *bp,*tp;
register short i;
unsigned short hashvalue;
byte *save;
int patlen;
if (pointersize == wordsize)
opind=1;
else if (pointersize == 2*wordsize)
opind=2;
index = lastind; /* set by mktab */
while (index != 0) {
bp = &pattern[index];
tp = &bp[PO_MATCH];
i = *tp++&BMASK;
if (i==BMASK) {
i = *tp++&BMASK;
i |= (*tp++&BMASK)<<8;
}
save = tp;
patlen = i;
while (i--)
opcheck(tp++);
if ((*tp++&BMASK)==BMASK)
tp += 2;
i = *tp++&BMASK;
if (i==BMASK) {
i = *tp++&BMASK;
i |= (*tp++&BMASK)<<8;
}
while (i--) {
opcheck(tp++);
if ((*tp++&BMASK)==BMASK)
tp += 2;
}
/*
* Now the special opcodes are filled
* in properly, we can hash the pattern
*/
hashvalue = 0;
tp = save;
switch(patlen) {
default: /* 3 or more */
hashvalue = (hashvalue<<4)^(*tp++&BMASK);
case 2:
hashvalue = (hashvalue<<4)^(*tp++&BMASK);
case 1:
hashvalue = (hashvalue<<4)^(*tp++&BMASK);
}
assert(hashvalue!= ILLHASH);
i=index;
index = (bp[PO_NEXT]&BMASK)|(bp[PO_NEXT+1]<<8);
bp[PO_HASH] = hashvalue>>8;
hashvalue &= BMASK;
bp[PO_NEXT] = pathash[hashvalue]&BMASK;
bp[PO_NEXT+1] = pathash[hashvalue]>>8;
pathash[hashvalue] = i;
#ifdef CHK_HASH
fprintf(stderr,"%d\n",hashvalue);
#endif
}
}
peephole() {
static bool phashed = FALSE;
if (!phashed) {
hashpatterns();
phashed=TRUE;
}
optimize();
}
optimize() {
register num_p *npp,np;
register instr;
basicblock(&instrs);
for (npp=curpro.numhash;npp< &curpro.numhash[NNUMHASH]; npp++)
for (np = *npp; np != (num_p) 0; np=np->n_next) {
if(np->n_line->l_next == (line_p) 0)
continue;
instr = np->n_line->l_next->l_instr&BMASK;
if (instr == op_lab || instr == op_bra)
np->n_repl = np->n_line->l_next->l_a.la_np;
else
basicblock(&np->n_line->l_next);
}
}
offset oabs(off) offset off; {
return(off >= 0 ? off : -off);
}
line_p repline(ev,patlen) eval_t ev; {
register line_p lp;
register iarg_p iap;
register sym_p sp;
offset diff,newdiff;
assert(ev.e_typ != EV_UNDEF);
switch(ev.e_typ) {
case EV_CONST:
if ((short) ev.e_v.e_con == ev.e_v.e_con) {
if (CANMINI((short) ev.e_v.e_con))
lp = newline((short) (ev.e_v.e_con)+Z_OPMINI);
else {
lp = newline(OPSHORT);
lp->l_a.la_short = (short) ev.e_v.e_con;
}
} else {
lp = newline(OPOFFSET);
lp->l_a.la_offset = ev.e_v.e_con;
}
return(lp);
case EV_NUMLAB:
lp = newline(OPNUMLAB);
lp->l_a.la_np = ev.e_v.e_np;
return(lp);
default: /* fragment + offset */
/*
* There is a slight problem here, because we have to
* map fragment+offset to symbol+offset.
* Fortunately the fragment we have must be the fragment
* of one of the symbols in the matchpattern.
* So a short search should do the job.
*/
sp = (sym_p) 0;
for (iap= &iargs[patlen-1]; iap >= iargs; iap--)
if (iap->ia_ev.e_typ == ev.e_typ) {
/*
* Although lint complains, diff is not used
* before set.
*
* The proof is left as an exercise to the
* reader.
*/
newdiff = oabs(iap->ia_sp->s_value-ev.e_v.e_con);
if (sp==(sym_p) 0 || newdiff < diff) {
sp = iap->ia_sp;
diff = newdiff;
}
}
assert(sp != (sym_p) 0);
if (diff == 0) {
lp = newline(OPSYMBOL);
lp->l_a.la_sp = sp;
} else {
diff = ev.e_v.e_con - sp->s_value;
if ((short) diff == diff) {
lp = newline(OPSVAL);
lp->l_a.la_sval.lasv_short = (short) diff;
lp->l_a.la_sval.lasv_sp = sp;
} else {
lp = newline(OPLVAL);
lp->l_a.la_lval.lalv_offset = diff;
lp->l_a.la_lval.lalv_sp = sp;
}
}
return(lp);
}
}
offset rotate(w,amount) offset w,amount; {
offset highmask,lowmask;
#ifndef LONGOFF
assert(wordsize<=4);
#endif
highmask = (offset)(-1) << amount;
lowmask = ~highmask;
if (wordsize != 4)
highmask &= wordsize==2 ? 0xFFFF : 0xFF;
return(((w<<amount)&highmask)|((w>>(8*wordsize-amount))&lowmask));
}
eval_t undefres = { EV_UNDEF };
eval_t compute(pexp) register expr_p pexp; {
eval_t leaf1,leaf2,res;
register i;
register sym_p sp;
offset mask;
switch(nparam[pexp->ex_operator]) {
default:
assert(FALSE);
case 2:
leaf2 = compute(&enodes[pexp->ex_rnode]);
if (leaf2.e_typ == EV_UNDEF ||
nonumlab[pexp->ex_operator] && leaf2.e_typ == EV_NUMLAB ||
onlyconst[pexp->ex_operator] && leaf2.e_typ != EV_CONST)
return(undefres);
case 1:
leaf1 = compute(&enodes[pexp->ex_lnode]);
if (leaf1.e_typ == EV_UNDEF ||
nonumlab[pexp->ex_operator] && leaf1.e_typ == EV_NUMLAB ||
onlyconst[pexp->ex_operator] && leaf1.e_typ != EV_CONST)
return(undefres);
case 0:
break;
}
res.e_typ = EV_CONST;
res.e_v.e_con = 0;
switch(pexp->ex_operator) {
default:
assert(FALSE);
case EX_CON:
res.e_v.e_con = (offset) pexp->ex_lnode;
break;
case EX_ARG:
return(iargs[pexp->ex_lnode - 1].ia_ev);
case EX_CMPEQ:
if (leaf1.e_typ != leaf2.e_typ)
return(undefres);
if (leaf1.e_typ == EV_NUMLAB) {
if (leaf1.e_v.e_np == leaf2.e_v.e_np)
res.e_v.e_con = 1;
break;
}
if (leaf1.e_v.e_con == leaf2.e_v.e_con)
res.e_v.e_con = 1;
break;
case EX_CMPNE:
if (leaf1.e_typ != leaf2.e_typ) {
res.e_v.e_con = 1;
break;
}
if (leaf1.e_typ == EV_NUMLAB) {
if (leaf1.e_v.e_np != leaf2.e_v.e_np)
res.e_v.e_con = 1;
break;
}
if (leaf1.e_v.e_con != leaf2.e_v.e_con)
res.e_v.e_con = 1;
break;
case EX_CMPGT:
if (leaf1.e_typ != leaf2.e_typ)
return(undefres);
res.e_v.e_con = leaf1.e_v.e_con > leaf2.e_v.e_con;
break;
case EX_CMPGE:
if (leaf1.e_typ != leaf2.e_typ)
return(undefres);
res.e_v.e_con = leaf1.e_v.e_con >= leaf2.e_v.e_con;
break;
case EX_CMPLT:
if (leaf1.e_typ != leaf2.e_typ)
return(undefres);
res.e_v.e_con = leaf1.e_v.e_con < leaf2.e_v.e_con;
break;
case EX_CMPLE:
if (leaf1.e_typ != leaf2.e_typ)
return(undefres);
res.e_v.e_con = leaf1.e_v.e_con <= leaf2.e_v.e_con;
break;
case EX_OR2:
if (leaf1.e_v.e_con != 0)
return(leaf1);
leaf2 = compute(&enodes[pexp->ex_rnode]);
if (leaf2.e_typ != EV_CONST)
return(undefres);
return(leaf2);
case EX_AND2:
if (leaf1.e_v.e_con == 0)
return(leaf1);
leaf2 = compute(&enodes[pexp->ex_rnode]);
if (leaf2.e_typ != EV_CONST)
return(undefres);
return(leaf2);
case EX_OR1:
res.e_v.e_con = leaf1.e_v.e_con | leaf2.e_v.e_con;
break;
case EX_XOR1:
res.e_v.e_con = leaf1.e_v.e_con ^ leaf2.e_v.e_con;
break;
case EX_AND1:
res.e_v.e_con = leaf1.e_v.e_con & leaf2.e_v.e_con;
break;
case EX_TIMES:
res.e_v.e_con = leaf1.e_v.e_con * leaf2.e_v.e_con;
break;
case EX_DIVIDE:
res.e_v.e_con = leaf1.e_v.e_con / leaf2.e_v.e_con;
break;
case EX_MOD:
res.e_v.e_con = leaf1.e_v.e_con % leaf2.e_v.e_con;
break;
case EX_LSHIFT:
res.e_v.e_con = leaf1.e_v.e_con << leaf2.e_v.e_con;
break;
case EX_RSHIFT:
res.e_v.e_con = leaf1.e_v.e_con >> leaf2.e_v.e_con;
break;
case EX_UMINUS:
res.e_v.e_con = -leaf1.e_v.e_con;
break;
case EX_NOT:
res.e_v.e_con = !leaf1.e_v.e_con;
break;
case EX_COMP:
res.e_v.e_con = ~leaf1.e_v.e_con;
break;
case EX_PLUS:
if (leaf1.e_typ >= EV_FRAG) {
if (leaf2.e_typ >= EV_FRAG)
return(undefres);
res.e_typ = leaf1.e_typ;
} else
res.e_typ = leaf2.e_typ;
res.e_v.e_con = leaf1.e_v.e_con + leaf2.e_v.e_con;
break;
case EX_MINUS:
if (leaf1.e_typ >= EV_FRAG) {
if (leaf2.e_typ == EV_CONST)
res.e_typ = leaf1.e_typ;
else if (leaf2.e_typ != leaf1.e_typ)
return(undefres);
} else if (leaf2.e_typ >= EV_FRAG)
return(undefres);
res.e_v.e_con = leaf1.e_v.e_con - leaf2.e_v.e_con;
break;
case EX_POINTERSIZE:
res.e_v.e_con = pointersize;
break;
case EX_WORDSIZE:
res.e_v.e_con = wordsize;
break;
case EX_NOTREG:
res.e_v.e_con = !inreg(leaf1.e_v.e_con);
break;
case EX_DEFINED:
leaf1 = compute(&enodes[pexp->ex_lnode]);
res.e_v.e_con = leaf1.e_typ != EV_UNDEF;
break;
case EX_SAMESIGN:
res.e_v.e_con = (leaf1.e_v.e_con ^ leaf2.e_v.e_con) >= 0;
break;
case EX_ROM:
if ((sp = iargs[pexp->ex_lnode - 1].ia_sp) != (sym_p) 0 &&
sp->s_rom != (offset *) 0) {
leaf2 = compute(&enodes[pexp->ex_rnode]);
if (leaf2.e_typ != EV_CONST ||
leaf2.e_v.e_con < 0 ||
leaf2.e_v.e_con >= MAXROM)
return(undefres);
res.e_v.e_con = sp->s_rom[leaf2.e_v.e_con];
break;
} else
return(undefres);
case EX_SFIT:
mask = 0;
for (i=leaf2.e_v.e_con - 1;i < 8*sizeof(offset); i++)
mask |= 1<<i;
res.e_v.e_con = (leaf1.e_v.e_con&mask) == 0 ||
(leaf1.e_v.e_con&mask) == mask;
break;
case EX_UFIT:
mask = 0;
for (i=leaf2.e_v.e_con;i < 8*sizeof(offset); i++)
mask |= 1<<i;
res.e_v.e_con = (leaf1.e_v.e_con&mask) == 0;
break;
case EX_ROTATE:
res.e_v.e_con = rotate(leaf1.e_v.e_con,leaf2.e_v.e_con);
break;
}
return(res);
}
#ifdef ALLOWSPECIAL
extern bool special();
#endif
bool tryrepl(lpp,bp,patlen)
line_p *lpp;
register byte *bp;
int patlen;
{
int rpllen,instr,rplval;
register line_p lp;
line_p replacement,*rlpp,tp;
rpllen = *bp++&BMASK;
if (rpllen == BMASK) {
rpllen = *bp++&BMASK;
rpllen |= (*bp++&BMASK)<<8;
}
#ifdef ALLOWSPECIAL
if (rpllen == 1 && *bp == 0)
return(special(lpp,bp+1,patlen));
#endif
replacement = (line_p) 0;
rlpp = &replacement;
while (rpllen--) {
instr = *bp++&BMASK;
rplval = *bp++&BMASK;
if (rplval == BMASK) {
rplval = (*bp++&BMASK);
rplval |= (*bp++&BMASK)<<8;
}
if (rplval)
lp = repline(compute(&enodes[rplval]),patlen);
else
lp = newline(OPNO);
/*
* One replacement instruction is generated,
* link in list and proceed with the next one.
*/
if (instr == op_lab)
lp->l_a.la_np->n_line = lp;
*rlpp = lp;
rlpp = &lp->l_next;
lp->l_instr = instr;
}
/*
* Replace instructions matched by the created replacement
*/
OPTIM((bp[0]&BMASK)|(bp[1]&BMASK)<<8);
for (lp= *lpp;patlen>0;patlen--,tp=lp,lp=lp->l_next)
;
tp->l_next = (line_p) 0;
*rlpp = lp;
lp = *lpp;
*lpp = replacement;
while ( lp != (line_p) 0 ) {
tp = lp->l_next;
oldline(lp);
lp = tp;
}
return(TRUE);
}
bool trypat(lpp,bp,len)
line_p *lpp;
register byte *bp;
int len;
{
register iarg_p iap;
int i,patlen;
register line_p lp;
eval_t result;
patlen = *bp++&BMASK;
if (patlen == BMASK) {
patlen = *bp++&BMASK;
patlen |= (*bp++&BMASK)<<8;
}
if (len == 3) {
if (patlen<3)
return(FALSE);
} else {
if (patlen != len)
return(FALSE);
}
/*
* Length is ok, now check opcodes
*/
for (i=0,lp= *lpp;i<patlen && lp != (line_p) 0;i++,lp=lp->l_next)
if (lp->l_instr != *bp++)
return(FALSE);
if (i != patlen)
return(FALSE);
/*
* opcodes are also correct, now comes the hard part
*/
for(i=0,lp= *lpp,iap= iargs; i<patlen;i++,iap++,lp=lp->l_next) {
switch(lp->l_optyp) {
case OPNO:
iap->ia_ev.e_typ = EV_UNDEF;
break;
default:
iap->ia_ev.e_typ = EV_CONST;
iap->ia_ev.e_v.e_con = (lp->l_optyp&BMASK)-Z_OPMINI;
break;
case OPSHORT:
iap->ia_ev.e_typ = EV_CONST;
iap->ia_ev.e_v.e_con = lp->l_a.la_short;
break;
#ifdef LONGOFF
case OPOFFSET:
iap->ia_ev.e_typ = EV_CONST;
iap->ia_ev.e_v.e_con = lp->l_a.la_offset;
break;
#endif
case OPNUMLAB:
iap->ia_ev.e_typ = EV_NUMLAB;
iap->ia_ev.e_v.e_np = lp->l_a.la_np;
break;
case OPSYMBOL:
iap->ia_ev.e_typ = lp->l_a.la_sp->s_frag;
iap->ia_sp = lp->l_a.la_sp;
iap->ia_ev.e_v.e_con = lp->l_a.la_sp->s_value;
break;
case OPSVAL:
iap->ia_ev.e_typ = lp->l_a.la_sval.lasv_sp->s_frag;
iap->ia_sp = lp->l_a.la_sval.lasv_sp;
iap->ia_ev.e_v.e_con = lp->l_a.la_sval.lasv_sp->s_value + lp->l_a.la_sval.lasv_short;
break;
#ifdef LONGOFF
case OPLVAL:
iap->ia_ev.e_typ = lp->l_a.la_lval.lalv_sp->s_frag;
iap->ia_sp = lp->l_a.la_lval.lalv_sp;
iap->ia_ev.e_v.e_con = lp->l_a.la_lval.lalv_sp->s_value + lp->l_a.la_lval.lalv_offset;
break;
#endif
}
}
i = *bp++&BMASK;
if ( i==BMASK ) {
i = *bp++&BMASK;
i |= (*bp++&BMASK)<<8;
}
if ( i != 0) {
/* there is a condition */
result = compute(&enodes[i]);
if (result.e_typ != EV_CONST || result.e_v.e_con == 0)
return(FALSE);
}
return(tryrepl(lpp,bp,patlen));
}
basicblock(alpp) line_p *alpp; {
register line_p *lpp,lp;
bool madeopt;
unsigned short hash[3];
line_p *next;
register byte *bp;
int i;
short index;
do { /* make pass over basicblock */
lpp = alpp; madeopt = FALSE;
while ((*lpp) != (line_p) 0 && ((*lpp)->l_instr&BMASK) != op_lab) {
lp = *lpp; next = &lp->l_next;
hash[0] = lp->l_instr&BMASK;
lp=lp->l_next;
if (lp != (line_p) 0) {
hash[1] = (hash[0]<<4)^(lp->l_instr&BMASK);
lp=lp->l_next;
if (lp != (line_p) 0)
hash[2] = (hash[1]<<4)^(lp->l_instr&BMASK);
else
hash[2] = ILLHASH;
} else {
hash[1] = ILLHASH;
hash[2] = ILLHASH;
}
/*
* hashvalues computed. Try for longest pattern first
*/
for (i=2;i>=0;i--) {
index = pathash[hash[i]&BMASK];
while (index != 0) {
bp = &pattern[index];
if((bp[PO_HASH]&BMASK) == (hash[i]>>8))
if(trypat(lpp,&bp[PO_MATCH],i+1)) {
madeopt = TRUE;
next = lpp;
i = 0; /* dirty way of double break */
break;
}
index=(bp[PO_NEXT]&BMASK)|(bp[PO_NEXT+1]<<8);
}
}
lpp = next;
}
} while(madeopt); /* as long as there is progress */
}

View File

@@ -1,185 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "types.h"
#include "assert.h"
#include "../../h/em_spec.h"
#include "../../h/em_pseu.h"
#include "alloc.h"
#include "line.h"
#include "lookup.h"
#include "proinf.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
process() {
if (wordsize == 0 || pointersize == 0)
error("No MES EMX encountered");
backward(); /* reverse and cleanup list */
symknown(); /* symbol scope is now known */
if (!nflag)
symvalue(); /* give symbols value */
if (prodepth != 0) {
if (!nflag) {
checklocs(); /* check definition of locals */
peephole(); /* local optimization */
relabel(); /* relabel local labels */
flow(); /* throw away unreachable code */
}
outpro(); /* generate PRO pseudo */
outregs(); /* generate MES ms_reg pseudos */
}
putlines(pseudos); /* pseudos first */
if (prodepth != 0) {
putlines(instrs); /* instructions next */
outend(); /* generate END pseudo */
cleanlocals(); /* forget instruction labels */
} else if(instrs != (line_p) 0)
error("instructions outside procedure");
#ifdef COREDEBUG
coreverbose();
#endif
}
relabel() {
register num_p *npp,np,tp;
register num_p repl,ttp;
/*
* For each label find its final destination after crossjumping.
* Care has to be taken to prevent a loop in the program to
* cause same in the optimizer.
*/
for (npp = curpro.numhash; npp < &curpro.numhash[NNUMHASH]; npp++)
for (np = *npp; np != (num_p) 0; np = np->n_next) {
assert((np->n_line->l_instr&BMASK) == op_lab
&& np->n_line->l_a.la_np == np);
for(tp=np; (tp->n_flags&(NUMKNOWN|NUMMARK))==0;
tp = tp->n_repl)
tp->n_flags |= NUMMARK;
repl = tp->n_repl;
for(tp=np; tp->n_flags&NUMMARK; tp = ttp) {
ttp = tp->n_repl;
tp->n_repl = repl;
tp->n_flags &= ~ NUMMARK;
tp->n_flags |= NUMKNOWN;
}
}
}
symknown() {
register sym_p *spp,sp;
for (spp = symhash; spp < &symhash[NSYMHASH]; spp++)
for (sp = *spp; sp != (sym_p) 0; sp = sp->s_next)
sp->s_flags |= SYMKNOWN;
}
cleanlocals() {
register num_p *npp,np,tp;
for (npp = curpro.numhash; npp < &curpro.numhash[NNUMHASH]; npp++) {
np = *npp;
while (np != (num_p) 0) {
tp = np->n_next;
oldnum(np);
np = tp;
}
*npp = (num_p) 0;
}
}
checklocs() {
register num_p *npp,np;
for (npp=curpro.numhash; npp < & curpro.numhash[NNUMHASH]; npp++)
for (np = *npp; np != (num_p) 0; np=np->n_next)
if (np->n_line == (line_p) 0)
error("local label %u undefined",
(unsigned) np->n_number);
}
offset align(count,alignment) offset count,alignment; {
assert(alignment==1||alignment==2||alignment==4);
return((count+alignment-1)&~(alignment-1));
}
symvalue() {
register line_p lp;
register sym_p sp;
register arg_p ap;
register argb_p abp;
short curfrag = 0;
offset count;
for (lp=pseudos; lp != (line_p) 0; lp = lp->l_next)
switch(lp->l_instr&BMASK) {
default:
assert(FALSE);
case ps_sym:
sp = lp->l_a.la_sp;
if (sp->s_frag != curfrag) {
count = 0;
curfrag = sp->s_frag;
}
count = align(count,wordsize);
sp->s_value = count;
break;
case ps_bss:
case ps_hol:
/* nothing to do, all bss pseudos are in diff frags */
case ps_mes:
break;
case ps_con:
case ps_rom:
for (ap=lp->l_a.la_arg; ap != (arg_p) 0; ap = ap->a_next)
switch(ap->a_typ) {
default:
assert(FALSE);
case ARGOFF:
count = align(count,wordsize)+wordsize;
break;
case ARGNUM:
case ARGSYM:
case ARGVAL:
count = align(count,wordsize)+pointersize;
break;
case ARGICN:
case ARGUCN:
case ARGFCN:
if (ap->a_a.a_con.ac_length < wordsize)
count = align(count,(offset)ap->a_a.a_con.ac_length);
else
count = align(count,wordsize);
count += ap->a_a.a_con.ac_length;
break;
case ARGSTR:
for (abp = &ap->a_a.a_string; abp != (argb_p) 0;
abp = abp->ab_next)
count += abp->ab_index;
break;
}
}
}

View File

@@ -1,36 +0,0 @@
/* $Header$ */
struct num {
num_p n_next;
unsigned n_number;
unsigned n_jumps;
num_p n_repl;
short n_flags;
line_p n_line;
};
/* contents of .n_flags */
#define NUMDATA 000001
#define NUMREACH 000002
#define NUMKNOWN 000004
#define NUMMARK 000010
#define NUMSCAN 000020
#define NNUMHASH 37
extern num_p numlookup();
struct regs {
reg_p r_next;
offset r_par[4];
};
typedef struct proinf {
offset localbytes;
line_p lastline;
sym_p symbol;
reg_p freg;
bool gtoproc;
num_p numhash[NNUMHASH];
} proinf;
extern proinf curpro;

View File

@@ -1,379 +0,0 @@
#ifndef NORCSID
static char rcsid[] = "$Header$";
#endif
#include "param.h"
#include "types.h"
#include "assert.h"
#include "../../h/em_spec.h"
#include "../../h/em_pseu.h"
#include "../../h/em_mnem.h"
#include "../../h/em_flag.h"
#include "alloc.h"
#include "line.h"
#include "lookup.h"
#include "proinf.h"
#include "optim.h"
#include "ext.h"
/*
* (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
*
* This product is part of the Amsterdam Compiler Kit.
*
* Permission to use, sell, duplicate or disclose this software must be
* obtained in writing. Requests for such permissions may be sent to
*
* Dr. Andrew S. Tanenbaum
* Wiskundig Seminarium
* Vrije Universiteit
* Postbox 7161
* 1007 MC Amsterdam
* The Netherlands
*
* Author: Hans van Staveren
*/
#define outbyte(b) putc(b,outfile)
putlines(lnp) register line_p lnp; {
register arg_p ap;
line_p temp;
register instr;
short curlin= -2;
short thislin;
while ( lnp != (line_p) 0) {
instr = lnp->l_instr&BMASK;
switch(lnp->l_optyp) {
case OPSYMBOL:
if ((lnp->l_instr&BMASK) == ps_sym)
outdef(lnp->l_a.la_sp);
else
outocc(lnp->l_a.la_sp);
break;
case OPSVAL:
outocc(lnp->l_a.la_sval.lasv_sp);
break;
#ifdef LONGOFF
case OPLVAL:
outocc(lnp->l_a.la_lval.lalv_sp);
break;
#endif
case OPLIST:
ap = lnp->l_a.la_arg;
while (ap != (arg_p) 0) {
switch(ap->a_typ) {
case ARGSYM:
outocc(ap->a_a.a_sp);
break;
case ARGVAL:
outocc(ap->a_a.a_val.av_sp);
break;
}
ap = ap->a_next;
}
break;
}
/*
* global symbols now taken care of
*/
switch(instr) {
case ps_sym:
break;
case op_lni:
if (curlin != -2)
curlin++;
outinst(instr);
break;
case op_lin:
switch(lnp->l_optyp) {
case OPNO:
case OPOFFSET:
case OPNUMLAB:
case OPSYMBOL:
case OPSVAL:
case OPLVAL:
case OPLIST:
outinst(instr);
goto processoperand;
case OPSHORT:
thislin = lnp->l_a.la_short;
break;
default:
thislin = (lnp->l_optyp&BMASK)-Z_OPMINI;
break;
}
if (thislin == curlin && !nflag) {
temp = lnp->l_next;
oldline(lnp);
lnp = temp;
OPTIM(O_LINGONE);
continue;
} else if (thislin == curlin+1 && !nflag) {
instr = op_lni;
outinst(instr);
temp = lnp->l_next;
oldline(lnp);
OPTIM(O_LINLNI);
lnp = newline(OPNO);
lnp->l_next = temp;
lnp->l_instr = instr;
} else {
outinst(instr);
}
curlin = thislin;
break;
case op_lab:
curlin = -2;
break;
default:
outinst(instr);
}
processoperand:
switch(lnp->l_optyp) {
case OPNO:
if ((em_flag[instr-sp_fmnem]&EM_PAR)!=PAR_NO)
outbyte( (byte) sp_cend) ;
break;
default:
outint((lnp->l_optyp&BMASK)-Z_OPMINI);
break;
case OPSHORT:
outint(lnp->l_a.la_short);
break;
#ifdef LONGOFF
case OPOFFSET:
outoff(lnp->l_a.la_offset);
break;
#endif
case OPNUMLAB:
if (instr == op_lab)
numlab(lnp->l_a.la_np->n_repl);
else if (instr < sp_fpseu) /* plain instruction */
outint((short) lnp->l_a.la_np->n_repl->n_number);
else
outnum(lnp->l_a.la_np->n_repl);
break;
case OPSYMBOL:
outsym(lnp->l_a.la_sp);
break;
case OPSVAL:
outbyte( (byte) sp_doff) ;
outsym(lnp->l_a.la_sval.lasv_sp);
outint(lnp->l_a.la_sval.lasv_short);
break;
#ifdef LONGOFF
case OPLVAL:
outbyte( (byte) sp_doff) ;
outsym(lnp->l_a.la_lval.lalv_sp);
outoff(lnp->l_a.la_lval.lalv_offset);
break;
#endif
case OPLIST:
putargs(lnp->l_a.la_arg);
switch(instr) {
case ps_con:
case ps_rom:
case ps_mes:
outbyte( (byte) sp_cend) ;
}
}
/*
* instruction is output now.
* remove its useless body
*/
temp = lnp->l_next;
oldline(lnp);
lnp = temp;
if (ferror(outfile))
error("write error");
}
}
putargs(ap) register arg_p ap; {
while (ap != (arg_p) 0) {
switch(ap->a_typ) {
default:
assert(FALSE);
case ARGOFF:
outoff(ap->a_a.a_offset);
break;
case ARGNUM:
outnum(ap->a_a.a_np->n_repl);
break;
case ARGSYM:
outsym(ap->a_a.a_sp);
break;
case ARGVAL:
outbyte( (byte) sp_doff) ;
outsym(ap->a_a.a_val.av_sp);
outoff(ap->a_a.a_val.av_offset);
break;
case ARGSTR:
outbyte( (byte) sp_scon) ;
putstr(&ap->a_a.a_string);
break;
case ARGICN:
outbyte( (byte) sp_icon) ;
goto casecon;
case ARGUCN:
outbyte( (byte) sp_ucon) ;
goto casecon;
case ARGFCN:
outbyte( (byte) sp_fcon) ;
casecon:
outint(ap->a_a.a_con.ac_length);
putstr(&ap->a_a.a_con.ac_con);
break;
}
ap = ap->a_next;
}
}
putstr(abp) register argb_p abp; {
register argb_p tbp;
register length;
length = 0;
tbp = abp;
while (tbp!= (argb_p) 0) {
length += tbp->ab_index;
tbp = tbp->ab_next;
}
outint(length);
while (abp != (argb_p) 0) {
for (length=0;length<abp->ab_index;length++)
outbyte( (byte) abp->ab_contents[length] );
abp = abp->ab_next;
}
}
outdef(sp) register sym_p sp; {
/*
* The surrounding If statement is removed to be friendly
* to Backend writers having to deal with assemblers
* not following our conventions.
if ((sp->s_flags&SYMOUT)==0) {
*/
sp->s_flags |= SYMOUT;
if (sp->s_flags&SYMGLOBAL) {
outinst(sp->s_flags&SYMPRO ? ps_exp : ps_exa);
outsym(sp);
}
/*
}
*/
}
outocc(sp) register sym_p sp; {
if ((sp->s_flags&SYMOUT)==0) {
sp->s_flags |= SYMOUT;
if ((sp->s_flags&SYMGLOBAL)==0) {
outinst(sp->s_flags&SYMPRO ? ps_inp : ps_ina);
outsym(sp);
}
}
}
outpro() {
outdef(curpro.symbol);
outinst(ps_pro);
outsym(curpro.symbol);
outoff(curpro.localbytes);
}
outend() {
outinst(ps_end);
outoff(curpro.localbytes);
}
outinst(m) {
outbyte( (byte) m );
}
outoff(off) offset off; {
#ifdef LONGOFF
if ((short) off == off)
#endif
outint((short) off);
#ifdef LONGOFF
else {
outbyte( (byte) sp_cst4) ;
outshort( (short) (off&0177777L) );
outshort( (short) (off>>16) );
}
#endif
}
outint(i) short i; {
if (i>= -sp_zcst0 && i< sp_ncst0-sp_zcst0)
outbyte( (byte) (i+sp_zcst0+sp_fcst0) );
else {
outbyte( (byte) sp_cst2) ;
outshort(i);
}
}
outshort(i) short i; {
outbyte( (byte) (i&BMASK) );
outbyte( (byte) (i>>8) );
}
numlab(np) register num_p np; {
if (np->n_number < sp_nilb0)
outbyte( (byte) (np->n_number + sp_filb0) );
else
outnum(np);
}
outnum(np) register num_p np; {
if(np->n_number<256) {
outbyte( (byte) sp_ilb1) ;
outbyte( (byte) (np->n_number) );
} else {
outbyte( (byte) sp_ilb2) ;
outshort((short) np->n_number);
}
}
outsym(sp) register sym_p sp; {
register byte *p;
register unsigned num;
if (sp->s_name[0] == '.') {
num = atoi(&sp->s_name[1]);
if (num < 256) {
outbyte( (byte) sp_dlb1) ;
outbyte( (byte) (num) );
} else {
outbyte( (byte) sp_dlb2) ;
outshort((short) num);
}
} else {
p= sp->s_name;
while (*p && p < &sp->s_name[IDL])
p++;
num = p - sp->s_name;
outbyte( (byte) (sp->s_flags&SYMPRO ? sp_pnam : sp_dnam) );
outint((short) num);
p = sp->s_name;
while (num--)
outbyte( (byte) *p++ );
}
}

Some files were not shown because too many files have changed in this diff Show More