|
|
1.1 ! root 1: \documentstyle[11pt]{article} ! 2: ! 3: \title{Installing lcc} ! 4: ! 5: \author{Christopher W. Fraser\\ ! 6: AT\&T Bell Laboratories, 600 Mountain Avenue,\\ ! 7: Murray Hill, NJ 07974 ! 8: \and ! 9: David R. Hanson\\ ! 10: Department of Computer Science, Princeton University,\\ ! 11: Princeton, NJ 08544} ! 12: ! 13: \date{August 24, 1990} ! 14: ! 15: \begin{document} ! 16: ! 17: \maketitle ! 18: ! 19: \section{Introduction} ! 20: ! 21: \verb|lcc| is a retargetable compiler for C as defined ! 22: by the ANSI Standard X3.159--1989. ! 23: \verb|lcc| is in production use ! 24: at Princeton University and AT\&T Bell Laboratories. ! 25: When used with a conforming preprocessor and library, ! 26: \verb|lcc| passes the conformance section of Version 2.00 of the Plum-Hall ! 27: Validation Suite for ANSI~C, except that it ! 28: does not detect underflow/overflow in constant expressions. ! 29: ! 30: Extract the distribution into its own directory. ! 31: All paths below are relative to this directory. ! 32: ! 33: All distributions include the following top-level directories; ! 34: ``front-end'' distributions include {\em only} these directories. ! 35: ! 36: \begin{center} ! 37: \begin{tabular}{ll} ! 38: \tt c & front end \\ ! 39: \tt etc & driver, man page, this document \\ ! 40: \tt include & ANSI include files \\ ! 41: \tt tst & test suite \\ ! 42: \tt gen0 & ``symbolic'' code generator \\ ! 43: \end{tabular} ! 44: \end{center} ! 45: ``Front-end'' distributions include no code generators ! 46: and only Section~6 of this document applies. ! 47: ! 48: ``Full'' distributions include code generators for the VAX, MIPS, ! 49: and Motorola 68020 with the 68881 floating-point co-processor. ! 50: These distributions add the following top-level directories. ! 51: ! 52: \begin{center} ! 53: \begin{tabular}{ll} ! 54: \tt gen2 & production code generators \\ ! 55: \tt gen3 & demonstration VAX code generator \\ ! 56: \end{tabular} ! 57: \end{center} ! 58: ! 59: Installation of a production compiler ! 60: involves three steps performed in the following order. ! 61: \begin{enumerate} ! 62: \item Decide where to install the man page, the include files, ! 63: the compiler, and \verb|lcc|, the driver program; see Section~2. ! 64: ! 65: \item Install a host-specific driver; see Section~3. ! 66: ! 67: \item Install a host- and target-specific compiler; see Section~4. ! 68: \end{enumerate} ! 69: ! 70: \verb|c/version.h| identifies the version of the distribution ! 71: as {\tt (($x$<<8)|$y$)} for version {\tt $x$.$y$}, ! 72: and \verb|LOG| describes the changes from the previous version. ! 73: ! 74: ! 75: \section{Paths} ! 76: ! 77: Installation consists of three files and one directory; ! 78: these are summarized below along with paths used in typical installations. ! 79: ! 80: \begin{center} ! 81: \begin{tabular}{ll} ! 82: \tt /usr/local/man/man1/lcc.1 & the man page \\ ! 83: \tt /usr/local/lib/rcc & the compiler \\ ! 84: \tt /usr/local/bin/lcc & the driver \\ ! 85: \tt /usr/local/include/ansi & include files (a directory) \\ ! 86: \end{tabular} ! 87: \end{center} ! 88: ! 89: These files can be placed in other, site-specific locations, ! 90: but the compiler should be named \verb|rcc|. ! 91: If the driver isn't named \verb|lcc|, edit the man page (\verb|etc/lcc.1|). ! 92: ! 93: Include files are in directories named \verb|include/|{\it target}\verb|_|{\it system}, ! 94: where {\it target\/} is one of \verb|mips|, \verb|mc|, \verb|vax|, or \verb|sparc|, ! 95: and {\it system\/} is one of ! 96: \verb|bsd| (4.3BSD UNIX), ! 97: \verb|ultrix| (ULTRIX 3.0), ! 98: \verb|mips| (RISC/os 4.0), ! 99: \verb|sun| (SUNOS 4.0), and ! 100: \verb|iris| (IRIX System V Release 3.2). ! 101: Not all combinations of {\it target}, {\it system\/} are provided ! 102: and many don't make sense. ! 103: Choose the include files that are appropriate for your system, ! 104: or make a copy of a closely related set and edit them. ! 105: ! 106: For example, if the paths shown above are chosen and if ! 107: \verb|include/vax_ultrix| has the appropriate include files, ! 108: install the man page and include files by ! 109: \begin{verbatim} ! 110: $ cp etc/lcc.1 /usr/local/man/man1 ! 111: $ cp include/vax_ultrix/*.h /usr/local/include/ansi ! 112: \end{verbatim} ! 113: ! 114: ! 115: \section{Installing the Driver} ! 116: ! 117: The preprocessor, compiler, assembler, and loader are ! 118: invoked by a driver program, \verb|lcc|, which is similar ! 119: to \verb|cc| on most systems. It's described in the man page ! 120: \verb|etc/lcc.1|. ! 121: The driver is built by combining the host-independent ! 122: part, \verb|etc/lcc.c|, with a small host-specific part. ! 123: By convention, host-specific parts are named {\it hostname}\verb|.c|, ! 124: where {\it hostname\/} is the local name for the host on which \verb|lcc| ! 125: is being installed. \verb|etc| holds many examples. ! 126: Comments in most give the details of the ! 127: particular host; pick one that is closely related to your host, ! 128: copy it to \verb|etc/|{\it yourhostname}\verb|.c|, ! 129: and edit it as described below. ! 130: You should not have to edit \verb|etc/lcc.c|. ! 131: ! 132: Debug your version of the driver by running it ! 133: with the \verb|-v -v| options, which cause it to echo the ! 134: commands it would execute, but not to execute them. ! 135: ! 136: Here's \verb|etc/ffserver.c|, which we'll use as an example ! 137: in describing how to edit a host-specific part. ! 138: This example illustrates all of the important features. ! 139: \begin{verbatim} ! 140: /* VAXes running UNIX 4.3BSD or ULTRIX at Princeton University */ ! 141: ! 142: #include <string.h> ! 143: ! 144: char *cpp[] = { "/usr/gnu/lib/gcc-cpp", "-undef", "-Dvax", ! 145: "$1", "$2", "$3", 0 }; ! 146: char *include[] = { "-I/usr/local/include/ansi", 0 }; ! 147: char *com[] = { "/usr/local/lib/rcc", "$1", "$2", "$3", 0 }; ! 148: char *as[] = { "/bin/as", "-J", "-o", "$3", "$1", "$2", 0 }; ! 149: char *ld[] = { "/bin/ld", "-o", "$3", "/lib/crt0.o", "-X", ! 150: "$1", "$2", "", "-lm", "", "-lc", 0 }; ! 151: ! 152: int option(arg) char *arg; { ! 153: if (strcmp(arg, "-g") == 0) ! 154: ld[9] = "-lg"; ! 155: else if (strcmp(arg, "-p") == 0) { ! 156: ld[3] = "/lib/mcrt0.o"; ! 157: ld[10] = "-lc_p"; ! 158: } else if (strcmp(arg, "-pg") == 0) { ! 159: ld[3] = "/usr/lib/gcrt0.o"; ! 160: ld[10] = "-lc_p"; ! 161: } else if (strcmp(arg, "-b") == 0 ! 162: && access("/usr/local/lib/bbexit.o", 4) == 0) ! 163: ld[7] = "/usr/local/lib/bbexit.o"; ! 164: else ! 165: return 0; ! 166: return 1; ! 167: } ! 168: \end{verbatim} ! 169: ! 170: Most of the host-specific code is data that ! 171: gives prototypes for the commands that invoke ! 172: the preprocessor, compiler, assembler, and loader. ! 173: Each command prototype is an array of pointers to strings ! 174: terminated with a null pointer; ! 175: the first string is the full path name of the command and the others ! 176: are the arguments or argument placeholders, which are described below. ! 177: ! 178: The \verb|cpp| array gives the command for running the preprocessor. ! 179: \verb|lcc| is intended to be used with an ANSI preprocessor, ! 180: such as the GNU C preprocessor available from the Free Software Foundation. ! 181: If the GNU preprocessor is used, ! 182: it must be named \verb|gcc-cpp| in order for \verb|lcc|'s \verb|-N| option ! 183: to work correctly. ! 184: ! 185: Literal arguments specified in prototype, e.g., \verb|"-Dvax"| in ! 186: the \verb|cpp| command above, are passed to the command as given. ! 187: ! 188: The strings \verb|"$1"|, \verb|"$2"|, and \verb|"$3"| in ! 189: prototypes are placeholders for {\em lists} of arguments that ! 190: are substituted in a copy of the prototype before the command is executed. ! 191: \verb|$1| is replaced by the {\em options} specified by the user; ! 192: for the preprocessor, this list always contains at least ! 193: \verb|-Dunix| and \verb|-D__LCC__|. ! 194: \verb|$2| is replaced by the {\em input} files, ! 195: and \verb|$3| is replaced by the {\em output} file. ! 196: ! 197: Zero-length arguments after replacement are removed from ! 198: the argument list before the command is invoked. So, e.g., ! 199: if the preprocessor is invoked without an output file, ! 200: \verb|"$3"| becomes \verb|""|, which is removed from the final argument list. ! 201: ! 202: For example, to specify a preprocessor command prototype to invoke ! 203: \verb|/bin/cpp| with the options \verb|-Dvax| and \verb|-Dultrix|, ! 204: the \verb|cpp| array would be ! 205: \begin{verbatim} ! 206: char *cpp[] = { "/bin/cpp", "-Dvax", "-Dultrix", ! 207: "$1", "$2", "$3", 0 }; ! 208: \end{verbatim} ! 209: ! 210: The \verb|include| array is a list of \verb|-I| options that ! 211: specify which directives should be searched to satisfy include directives. ! 212: These directories are searched in the order given. ! 213: The first directory should be the one to which the ANSI ! 214: header files were copied in Section~2. ! 215: The driver adds these options to \verb|cpp|'s arguments ! 216: when it invokes the preprocessor. ! 217: ! 218: \verb|com| gives the command for invoking the compiler. ! 219: This prototype can appear exactly as shown above, except ! 220: that the command name should be edited to reflect the ! 221: location of the compiler chosen in Section~2. ! 222: ! 223: \verb|as| gives the command for invoking the assembler. ! 224: ! 225: \verb|ld| gives the command for invoking the loader. ! 226: For the other commands, the list \verb|$2| contains a single file; ! 227: for \verb|ld|, \verb|$2| contains all `.o' files and libraries, and ! 228: \verb|$3| is \verb|a.out|, unless the \verb|-o| option is specified. ! 229: As suggested in the code above, \verb|ld| must also specify ! 230: the appropriate startup code and default libraries. ! 231: ! 232: The \verb|option| function is described below; ! 233: for now, use an existing \verb|option| function or one that returns \verb|0|. ! 234: ! 235: After specifying the prototypes, compile the driver by ! 236: \begin{verbatim} ! 237: $ cd etc ! 238: $ make HOST=ffserver ! 239: \end{verbatim} ! 240: where \verb|ffserver| is replaced by {\it yourhostname}. ! 241: Run the resulting \verb|a.out| with the options \verb|-v -v| ! 242: to display the commands that would be executed, e.g., ! 243: \begin{verbatim} ! 244: $ a.out -v -v foo.c baz.c mylib.a -lcurses ! 245: a.out version 1.2 ! 246: foo.c: ! 247: /usr/gnu/lib/gcc-cpp -undef -Dvax -Dunix -D__LCC__ -v ! 248: -I/usr/local/include/ansi foo.c | ! 249: /usr/local/lib/rcc -v - /tmp/lcc00024.s ! 250: /bin/as -J -o foo.o /tmp/lcc00024.s ! 251: baz.c: ! 252: /usr/gnu/lib/gcc-cpp -undef -Dvax -Dunix -D__LCC__ -v ! 253: -I/usr/local/include/ansi baz.c | ! 254: /usr/local/lib/rcc -v - /tmp/lcc00024.s ! 255: /bin/as -J -o baz.o /tmp/lcc00024.s ! 256: /bin/ld -o a.out /lib/crt0.o -X foo.o baz.o mylib.a ! 257: -lcurses -lm -lc ! 258: rm /tmp/lcc00024.s ! 259: \end{verbatim} ! 260: Leading spaces indicate lines that have been folded manually to fit this page. ! 261: Note the use of a pipeline to connect the preprocessor and compiler. ! 262: \verb|lcc| arranges this pipeline itself; it does not call the shell. ! 263: ! 264: As the output shows, \verb|lcc| places temporary files in \verb|/tmp|. ! 265: Alternatives can be specified by defining \verb|TEMPDIR| in \verb|CFLAGS| ! 266: when making the driver, e.g., ! 267: \begin{verbatim} ! 268: $ make CFLAGS='-DTEMPDIR=\"/usr/tmp\"' HOST=ffserver ! 269: \end{verbatim} ! 270: causes \verb|lcc| to place temporary files in \verb|/usr/tmp|. ! 271: ! 272: Once the driver is completed, install it by ! 273: \begin{verbatim} ! 274: $ cp a.out /usr/local/bin/lcc ! 275: \end{verbatim} ! 276: where the destination is the location chosen for \verb|lcc| in Section~2. ! 277: ! 278: The \verb|option| function is called for the options ! 279: \verb|-g|, \verb|-p|, \verb|-pg|, and \verb|-b| because these compiler options might ! 280: also affect the loader's arguments. For these options, ! 281: the driver calls \verb|option(arg)| to give the host-specific ! 282: code an opportunity to edit the \verb|ld| prototype, if necessary. ! 283: \verb|option| can change \verb|ld|, if necessary, and return \verb|1| to ! 284: announce its acceptance of the option. If the option ! 285: is unsupported, \verb|option| should return \verb|0|. ! 286: ! 287: For example, in response to \verb|-g|, the \verb|option| function shown above ! 288: changes \verb|ld[9]| from \verb|""| to \verb|"-lg"|, which causes ! 289: a debugging library to be loaded. If \verb|-g| is not specified, ! 290: the \verb|""| argument is omitted from the \verb|ld| command ! 291: because it's empty. ! 292: ! 293: Likewise, the \verb|-pg| causes \verb|option| to change the name ! 294: of the startup code and the name of the default C library. Note that ! 295: \verb|option| has been written to support simultaneous use ! 296: of \verb|-g| and \verb|-pg|, e.g., ! 297: \begin{verbatim} ! 298: $ a.out -v -v -g -pg foo.o baz.o -o myfoo ! 299: a.out version 1.2 ! 300: /bin/ld -o myfoo /usr/lib/gcrt0.o -X foo.o baz.o -lm -lg -lc_p ! 301: rm /tmp/lcc00660.s ! 302: \end{verbatim} ! 303: ! 304: To support Sun's \verb|-f68881| option, the driver also ! 305: passes any option beginning with \verb|-f| to \verb|option|. ! 306: ! 307: The option \verb|-Wo|{\it arg\/} causes the driver to pass {\it arg\/} ! 308: to \verb|option|. Such options have no other effect; this mechanism ! 309: is provide to support system-specific options that affect the ! 310: commands executed by the driver. ! 311: ! 312: The \verb|-b| option causes the compiler to generate ! 313: code to count the number of times each expression is executed. ! 314: The \verb|exit| function in \verb|etc/bbexit.c| writes these ! 315: counts to \verb|prof.out| when the program terminates. ! 316: If \verb|option| is called with \verb|-b|, ! 317: it must edit the \verb|ld| command accordingly, ! 318: as shown above. This version of \verb|option| uses ! 319: the \verb|access| system call to insure that \verb|bbexit.o| is installed before ! 320: editing the \verb|ld| command. To install \verb|bbexit.o| execute ! 321: \begin{verbatim} ! 322: $ make bbexit.o ! 323: $ cp bbexit.o /usr/local/lib/bbexit.o ! 324: \end{verbatim} ! 325: If necessary, change \verb|/usr/local/lib| to reflect local conventions. ! 326: The \verb|exit| function in \verb|etc/bbexit.c| works on the ! 327: systems listed in \S2, but may need to be modified for other systems. ! 328: ! 329: If \verb|option| supports \verb|-b|, you should also ! 330: install \verb|etc/bprint.c|, which reads \verb|prof.out| ! 331: and generates a listing annotated with execution counts. ! 332: After \verb|lcc| is installed, install \verb|bprint| with the commands ! 333: \begin{verbatim} ! 334: $ make bbexit.o bprint ! 335: $ cp bprint /usr/local/bin/bprint ! 336: $ cp bprint.1 /usr/local/man/man1 ! 337: \end{verbatim} ! 338: The \verb|makefile| uses \verb|lcc| to compile \verb|bprint.c|; ! 339: you must use \verb|lcc| or another ANSI~C compiler ! 340: because \verb|bprint.c| is written in ANSI~C. ! 341: \verb|bprint.c| includes \verb|"../c/profio.c"|, so it must ! 342: be compiled in \verb|etc|. ! 343: ! 344: To complete the driver, ! 345: write an appropriate \verb|option| function for your system, ! 346: and make and install the driver as described above. ! 347: ! 348: ! 349: \section{Installing a Production Compiler} ! 350: ! 351: \verb|gen2| contains source code common to all of the production ! 352: code generators and directories for each of the supported targets: ! 353: ! 354: \begin{center} ! 355: \begin{tabular}{ll} ! 356: \tt gen2/vax & VAX code generator \\ ! 357: \tt gen2/mips & MIPS code generator \\ ! 358: \tt gen2/mc & Motorola 68020 \& 68881 code generator \\ ! 359: \end{tabular} ! 360: \end{center} ! 361: ! 362: A production compiler, \verb|rcc|, is built by compiling it ! 363: with the host C compiler and then using the result to re-compile itself. ! 364: A test suite is used to ! 365: verify that the compiler is working correctly. ! 366: The examples below use the VAX compiler to illustrate this process. ! 367: You must have the driver, \verb|lcc|, installed in order ! 368: to build and test \verb|rcc|. ! 369: If any of the steps below fail, contact us (see Section~7). ! 370: ! 371: The \verb|makefile| runs the shell script ! 372: \verb|gen2/run| on each C program in the test suite, \verb|tst|. ! 373: The assignment to \verb|os| in \verb|gen2/run| indicates the target operating ! 374: system; edit this assignment if it's incorrect for your system. ! 375: ! 376: To build a VAX \verb|rcc|, execute the commands ! 377: \begin{verbatim} ! 378: $ cd gen2/vax ! 379: $ make ! 380: \end{verbatim} ! 381: There may be a few warnings, but there should be no errors. ! 382: ! 383: Once \verb|rcc| is built with the host C compiler, ! 384: run the test suite to verify that \verb|rcc| is working correctly: ! 385: \begin{verbatim} ! 386: $ make test ! 387: vax-bsd 8q: ! 388: vax-bsd array: ! 389: vax-bsd cf: ! 390: vax-bsd cq: ! 391: vax-bsd cvt: ! 392: vax-bsd fields: ! 393: vax-bsd front: ! 394: vax-bsd incr: ! 395: vax-bsd init: ! 396: vax-bsd paranoia: ! 397: 3456c3456 ! 398: < .align 2; _881:.long 0xc5ac37a7,0x4788471b ! 399: --- ! 400: > .align 2; _881:.long 0xc5ac37a7,0x4784471b ! 401: 3674c3674 ! 402: < .align 2; _72:.long 0xd70a3d23,0xa3d83d70 ! 403: --- ! 404: > .align 2; _72:.long 0xd70a3d23,0xa3d73d70 ! 405: 3688c3688 ! 406: < .align 2; _14:.long 0x126e3b83,0x4fe0978d ! 407: --- ! 408: > .align 2; _14:.long 0x126e3b83,0x4fdf978d ! 409: vax-bsd sort: ! 410: vax-bsd spill: ! 411: vax-bsd stdarg: ! 412: vax-bsd struct: ! 413: vax-bsd switch: ! 414: vax-bsd wf1: ! 415: vax-bsd yacc: ! 416: \end{verbatim} ! 417: For each C program in the test suite, ! 418: \verb|gen2/run| compiles the program and uses \verb|diff| ! 419: to compare the generated assembly code ! 420: with the expected code (the expected VAX code for \verb|tst/8q.c| is ! 421: in \verb|gen2/vax/tst/8q.s.bak|, etc.). If there are differences, the script ! 422: executes the generated code with the input given in \verb|tst| ! 423: (the input for \verb|tst/8q.c| is in \verb|tst/8q.0|, etc.) ! 424: and compares the output with the expected output ! 425: (the expected output from \verb|tst/8q.c| on the VAX is ! 426: in \verb|gen2/vax/tst/8q.1|, etc.). The script also compares the ! 427: diagnostics from the compiler with the expected diagnostics. ! 428: ! 429: As shown above, there may be a few differences between the generated code ! 430: and the expected code for the VAX. ! 431: These differences occur because the expected code is ! 432: generated by cross compilation ! 433: on a MIPS and the least-significant bits of some floating-point constants ! 434: differ from those bits in constants generated on a VAX. ! 435: There should be no differences in the output from executing the test programs. ! 436: ! 437: If you edited the assignment to \verb|os| in \verb|gen2/run|, ! 438: a few differences may occur because of differences between the ANSI headers ! 439: for your system and those for the default system. ! 440: ! 441: If your host is a little-endian MIPS, such as those from DEC, ! 442: there will be numerous differences (about 335 lines) because the expected code ! 443: is generated on a big-endian MIPS. Most of the differences ! 444: are in floating-point constants and data and instructions ! 445: concerning bit fields. It is easy to examine ! 446: the differences and verify that they are all due to the different ! 447: addressing order. Also, the output from \verb|tst/paranoia.c| ! 448: may differ trivially; if so, you'll need to \verb|make test| a second ! 449: time to finish the suite. ! 450: ! 451: The \verb|vax-bsd| preceding the name of each test program in the output ! 452: above indicates a {\it target\/\it-system\/} combination, e.g., ! 453: ``generating code for a \verb|vax| running the ! 454: \verb|bsd| operating system''. ! 455: ! 456: Next, build \verb|rcc| again using the just-built \verb|rcc|: ! 457: \begin{verbatim} ! 458: $ make triple ! 459: rm -f *.o ! 460: make CC=lcc CFLAGS='-B./ -d0.1 -A -DPROTO -DENUMS' LDFLAGS='-s' rcc ! 461: lcc -c -B./ -d0.1 -A -DPROTO -DENUMS -I. -I.. -I../../c ../../c/dag.c ! 462: ... ! 463: lcc -s -o rcc dag.o ... sel.o ! 464: od +8 <rcc >tst/od2 ! 465: rm -f *.o ! 466: make CC=lcc CFLAGS='-B./ -d0.1 -A -DPROTO -DENUMS' LDFLAGS='-s' rcc ! 467: lcc -c -B./ -d0.1 -A -DPROTO -DENUMS -I. -I.. -I../../c ../../c/dag.c ! 468: ... ! 469: lcc -s -o rcc dag.o ... sel.o ! 470: od +8 <rcc >tst/od3 ! 471: cmp tst/od[23] && rm tst/od[23] ! 472: \end{verbatim} ! 473: This command builds \verb|rcc| twice; once using the ! 474: \verb|cc|-built \verb|rcc| and again using the \verb|lcc|-built \verb|rcc|. ! 475: After building each version, an octal dump of the resulting binary is made, ! 476: and the two dumps are compared. They should be identical, as shown ! 477: at the end of the output above. ! 478: If they aren't, our compiler is generating bad code. ! 479: This triple-compilation test is described in ! 480: B.~J. Cornelius, I.~R. Lowman, and D.~J. Robson, ! 481: `Steady-State Compilers,' {\it Software---Practice \& Experience \bf 14}, ! 482: 8 (Aug.\ 1984) 705--9. (They name four generations because they ! 483: number them differently.) ! 484: ! 485: The final version of \verb|rcc| should also pass the test suite; ! 486: i.e., the output from \verb|make test| ! 487: should be identical to that from the previous \verb|make test|. ! 488: ! 489: Now install the final version of \verb|rcc|: ! 490: \begin{verbatim} ! 491: $ cp rcc /usr/local/lib/rcc ! 492: \end{verbatim} ! 493: where the destination is the location chosen for \verb|rcc| in Section~2. ! 494: ! 495: The \verb|make| commands described above can be done with a single command: ! 496: \begin{verbatim} ! 497: $ make test triple test ! 498: \end{verbatim} ! 499: and \verb|make clean| cleans up, but does not remove \verb|rcc|. ! 500: ! 501: The software used to build the production code generators ! 502: is described in C.~W. Fraser, `A Language for Writing Code Generators,' ! 503: {\it Proc.\ SIGPLAN Conf.\ on Programming Language Design and Implementation}, ! 504: Portland, June 1989, 238--45. It is not yet available. ! 505: ! 506: ! 507: \section{Building the Demonstration VAX Compiler} ! 508: ! 509: The code generator in \verb|gen3| emits naive VAX code. ! 510: It is not a production code generator. It is included only ! 511: to illustrate the interface between the front end ! 512: and the code generator. If you want to replace \verb|lcc|'s code generator, ! 513: study it and not the larger production code generators. ! 514: ! 515: The command ! 516: \begin{verbatim} ! 517: $ make test ! 518: \end{verbatim} ! 519: builds and tests the demonstration VAX code generator. ! 520: The \verb|makefile| uses \verb|lcc| instead of \verb|cc| ! 521: because \verb|gen3/gen.c| is written in ANSI~C. ! 522: If \verb|lcc| is unavailable, use another ANSI~C compiler, e.g., \verb|gcc|, ! 523: and use a command like ! 524: \begin{verbatim} ! 525: $ make CC=gcc test ! 526: \end{verbatim} ! 527: to build the demonstration compiler. Alternatively, you can specify ! 528: another ANSI~C compiler by editing the first line in \verb|makefile|. ! 529: ! 530: There may be warnings, but there should be no errors. ! 531: As for the production code generators, this command ! 532: tests \verb|rcc| by running a shell script, ! 533: \verb|gen3/run|, on each C program in the test suite. ! 534: This script compiles a program and compares the generated VAX code ! 535: with the expected code (the expected VAX code for \verb|tst/8q.c| is ! 536: in \verb|gen3/tst/8q.s.bak|, etc.). There should be no differences. ! 537: If there are differences, the script executes the generated code ! 538: and compares the output with the expected output ! 539: (the expected output from \verb|tst/8q.c| is ! 540: in \verb|gen3/tst/8q.1|, etc.). ! 541: ! 542: \verb|make triple| is the same as for the production compilers, and ! 543: \verb|make clean| cleans up, but does not remove \verb|rcc|. ! 544: ! 545: ! 546: \section{Building the Symbolic Compiler} ! 547: ! 548: The code generator in \verb|gen0| documents the ! 549: interface between the front end and the code generator and is used routinely in ! 550: front-end development. The output of this code generator is a printable ! 551: representation of the input program, e.g., the dags constructed by the ! 552: front end are printed, and other interface functions print their arguments. ! 553: The output is not executable, unlike the output of the demonstration ! 554: VAX code generator. ! 555: ! 556: The interface is defined by a small set of functions in ! 557: \verb|gen0/symbolic.c|. Some of the interface functions are defined as ! 558: macros in \verb|gen0/config.h| along with other machine-specific parameters. ! 559: The dag language constitutes the bulk of the interface. The ! 560: operators are enumerated in \verb|c/ops.h|. Each generic operator (e.g., ! 561: \verb|ADD|) has several type-specific variants indicated by type suffixes ! 562: (e.g., \verb|ADDI|, \verb|ADDF|, \verb|ADDP|, etc.). The suffixes are defined in ! 563: \verb|c/ops.h|. The dag nodes (\verb|struct node|) are defined in \verb|c/c.h|; the ! 564: \verb|Xnode| field is machine specific and is defined in \verb|gen0/config.h|. ! 565: \verb|c/c.h| defines almost all of the data structures used the front end. ! 566: ! 567: The command ! 568: \begin{verbatim} ! 569: $ make test ! 570: \end{verbatim} ! 571: builds the symbolic compiler, \verb|rcc|, and tests it by running the shell script ! 572: \verb|gen0/run| on each C program in the test suite, \verb|tst|. ! 573: This script compiles a program and uses \verb|diff| to compare the generated symbolic code ! 574: with the expected code (the expected code for \verb|tst/8q.c| is ! 575: in \verb|gen0/tst/8q.s.bak|, etc.). There should be no differences. ! 576: The script also compares the ! 577: diagnostics from the compiler with the expected diagnostics ! 578: (the expected diagnostics for \verb|tst/8q.c| are ! 579: in \verb|tst/8q.2|, etc.). ! 580: ! 581: \verb|make clean| cleans up, but does not remove \verb|rcc|. ! 582: ! 583: ! 584: \section{Reporting Bugs} ! 585: ! 586: Bugs can be reported by sending mail with the shortest program ! 587: that exposes them and the details reported by \verb|lcc|'s \verb|-v| ! 588: option to \verb|[email protected]|. ! 589: Other questions and comments can be mailed to \verb|[email protected]|. ! 590: ! 591: \end{document}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.