Sozobon C Compiler Release 1.2 The Sozobon C Compiler Release 1.2 from Sozobon, Limited Tony Andrews Johann Ruegg Joe Treat 8/28/89 1. Introduction This document describes release 1.2 of the Sozobon C compiler. This is a (relatively) minor update to the first release of the compiler made in October, 1988. Version 1.2 contains new versions of the compiler and optimizer only. This is basically a preview of the improved compiler features and code generation that will be coming in the next major release. By releasing these pieces early we can get your bug reports and incorporate fixes before making a major release. The rest of this document will briefly describe the changes that have been made. 2. Compiler Changes 2.1 Preprocessor Changes Many of the compiler changes involve enhancements to the preprocessor. The builtin macros "__FILE__" and "__LINE__" are now supported and are replaced by the current source file name and line number respectively. The "defined" directive is now supported in "#if" statements, as in: #if defined(VAX) || defined(SOZOBON) stuff #endif Note that the parentheses above are required. Another change is that in an "#if" statement, undefined macros expand to zero. This makes it possible to write code like: #if VAX || SOZOBON stuff #endif - 1 - Sozobon C Compiler Release 1.2 2.2 Code Generation Several bugs have been fixed in this area and other general improvements have been made. The compiler also now places comments in the generated code describing the size and location of function parameters and local variables. These comments may be useful to assembly hackers, but are provided primarily to enable the optimizer to do some new things (described later). The comments have one of the following two forms: ;var size offset name ;reg size register name The first form describes a local or parameter on the stack. The second form describes a register variable. 2.3 Command Line The command line options are essentially the same, which permits the use of the current 'cc' command. The only change is that when running 'hcc' directly, multiple source file names may be given on the command line. 3. Optimizer Changes Many new peephole optimizations have been added, but the biggest change to the optimizer is the addition of a feature that I call "registerizing". The basic idea is to identify highly referenced parameters and local variables and automatically turn them into register variables. This is fairly tricky, and doing it safely requires some help from the compiler. This is the reason for the "hints" described above. The optimizer looks at these hints and uses them to help decide which variables can and should be placed in registers. If you make careful use of register declarations in your source code, you may not notice this feature much. It helps most with code that doesn't make good use of register variables. Partly due to limitations of the current implementation, you can generally do better if you place the register declarations in your code yourself. The reasons for this are: 1. The optimizer only uses D registers for the register which isn't as good for pointer variables (although it works just fine). 2. The optimizer decides what to registerize based on the number of references it finds to a variable. This optimizes primarily for space, although time is improved as well, of course. To optimize for time, the optimizer would need to detect loops in the assembly code and weight references within loops by some reasonable amount. This hasn't been done yet. - 2 - Sozobon C Compiler Release 1.2 In spite of these comments, the optimizer does pretty well, and registerizing improves most code quite a bit. In fact, for the dhrystone benchmark, the Sozobon compiler performs better with no register declarations in the source than with the register declarations enabled. Registerizing can be disabled on the optimizer command line with the "-r" option. Otherwise, the optimizer is compatible with the old version and can be used with the current 'cc' command. 4. Distribution The Sozobon C compiler is distributed in both binary and source code form. The standard distribution contains both. The programs and code are copyrighted, but may be freely distributed, subject to the following restrictions: 1. No charge may be made other than reasonable charges for reproduction. 2. Modified versions must be clearly marked as such. 3. The authors are not responsible for any harmful consequences of using this software, even if they result from defects in it. This software is neither shareware nor public domain. While we don't ask for contributions, we also want to insure that our work continues to be freely available to everyone. By not putting our work in the public domain, we can prevent others from taking our software and charging you for it. The term "freeware" best describes our approach to distribution. 4.2 Getting an Official Release If you are unable to locate a complete copy of the compiler, a full release of the compiler can be ordered directly from Sozobon, Limited by sending $10 (US) to: Tony Andrews 5902E Gunbarrel Ave. Boulder, CO 80301 USA The release includes all executables and source code for version 1.0 of the compiler as well as the upgrades contained in version 1.2. Be sure to include your return address, and specify single or double sided disks. Checks should be payable to "Tony Andrews". If you can find a copy of the compiler through other means, there is absolutely no need to send us any money. The compiler is free. In fact, we strongly encourage anyone who receives a copy of the compiler to pass it along to others via bulletin boards, online services, and user groups. - 3 - Sozobon C Compiler Release 1.2 5. Coming Attractions A new major release of the compiler is in the works and should go into beta testing sometime in the fall. Some of the features that will be coming are: * Support for Minix as well as TOS * Long external names (the current limit is 7) * Less memory consumption, in general, by the compiler passes * Runtime profiling and report generation (call counts only) * Better placement of temporary files * Support for either 16 or 32 bit int's * Improved floating point support (c/o David Brooks) * GEM bindings (c/o Ian Lepore) 6. Support In this release, we're especially interested in receiving bug reports. There are many changes to the compiler and optimizer, so we'd like to use this release to shake out any bugs before we put out our major release later in the year. To help us get more accurate bug reports we've included a reporting form within this release. To send us a bug, simply edit a copy of the bug report form and send it to us by email or by regular means. We're reachable electronically at: UUCP: onecom!wldrdg!tony Citadel: tony@FWBBS Send regular mail to: Tony Andrews 5902E Gunbarrel Ave. Boulder, CO 80301 USA While we can't guarantee a personal response to each bug, we DO appreciate your reports. - 4 -