From 3897de94ed10452312eead4838e1f7324bccc68c Mon Sep 17 00:00:00 2001 From: ssmith Date: Wed, 25 Oct 1995 19:19:32 +0000 Subject: [PATCH] Initial revision --- v8/src/compiler/machines/i386/compiler.cbf | 48 ++ v8/src/compiler/machines/i386/compiler.pkg | 606 +++++++++++++++++++++ v8/src/compiler/machines/i386/compiler.sf | 121 ++++ 3 files changed, 775 insertions(+) create mode 100644 v8/src/compiler/machines/i386/compiler.cbf create mode 100644 v8/src/compiler/machines/i386/compiler.pkg create mode 100644 v8/src/compiler/machines/i386/compiler.sf diff --git a/v8/src/compiler/machines/i386/compiler.cbf b/v8/src/compiler/machines/i386/compiler.cbf new file mode 100644 index 000000000..27e097b4f --- /dev/null +++ b/v8/src/compiler/machines/i386/compiler.cbf @@ -0,0 +1,48 @@ +#| -*-Scheme-*- + +$Id: compiler.cbf,v 1.1 1995/10/25 19:19:32 ssmith Exp $ + +Copyright (c) 1988-1994 Massachusetts Institute of Technology + +This material was developed by the Scheme project at the Massachusetts +Institute of Technology, Department of Electrical Engineering and +Computer Science. Permission to copy this software, to redistribute +it, and to use it for any purpose is granted, subject to the following +restrictions and understandings. + +1. Any copy made of this software must include this copyright notice +in full. + +2. Users of this software agree to make their best efforts (a) to +return to the MIT Scheme project any improvements or extensions that +they make, so that these may be included in future releases; and (b) +to inform MIT of noteworthy uses of this software. + +3. All materials developed as a consequence of the use of this +software shall duly acknowledge such use, in accordance with the usual +standards of acknowledging credit in academic research. + +4. MIT has made no warrantee or representation that the operation of +this software will be error-free, and MIT is under no obligation to +provide any services, by way of maintenance, update, or otherwise. + +5. In conjunction with products arising from the use of this material, +there shall be no use of the name of the Massachusetts Institute of +Technology nor of any adaptation thereof in any advertising, +promotional, or sales literature without prior written consent from +MIT in each case. |# + +;;;; Script to incrementally compile the compiler (from .bins) + +(fluid-let ((compiler:coalescing-constant-warnings? #f)) + (for-each compile-directory + '("back" + "base" + "machines/spectrum" + "rtlbase" + ; unused "rtlgen" + "rtlopt" + "midend" + ; unused "fggen" + ; unused "fgopt" + ))) \ No newline at end of file diff --git a/v8/src/compiler/machines/i386/compiler.pkg b/v8/src/compiler/machines/i386/compiler.pkg new file mode 100644 index 000000000..8bd348f56 --- /dev/null +++ b/v8/src/compiler/machines/i386/compiler.pkg @@ -0,0 +1,606 @@ +#| -*-Scheme-*- + +$Id: compiler.pkg,v 1.1 1995/10/25 19:19:32 ssmith Exp $ + +Copyright (c) 1988-1995 Massachusetts Institute of Technology + +This material was developed by the Scheme project at the Massachusetts +Institute of Technology, Department of Electrical Engineering and +Computer Science. Permission to copy this software, to redistribute +it, and to use it for any purpose is granted, subject to the following +restrictions and understandings. + +1. Any copy made of this software must include this copyright notice +in full. + +2. Users of this software agree to make their best efforts (a) to +return to the MIT Scheme project any improvements or extensions that +they make, so that these may be included in future releases; and (b) +to inform MIT of noteworthy uses of this software. + +3. All materials developed as a consequence of the use of this +software shall duly acknowledge such use, in accordance with the usual +standards of acknowledging credit in academic research. + +4. MIT has made no warrantee or representation that the operation of +this software will be error-free, and MIT is under no obligation to +provide any services, by way of maintenance, update, or otherwise. + +5. In conjunction with products arising from the use of this material, +there shall be no use of the name of the Massachusetts Institute of +Technology nor of any adaptation thereof in any advertising, +promotional, or sales literature without prior written consent from +MIT in each case. |# + +;;;; Compiler Packaging + +(global-definitions "../runtime/runtime") + +(define-package (compiler) + (files "base/switch" + "base/object" ;tagged object support + "base/enumer" ;enumerations + "base/sets" ;set abstraction + "base/fasthash" ;eq-hash tables + "base/mvalue" ;multiple-value support + "base/scode" ;SCode abstraction + "machines/spectrum/machin" ;machine dependent stuff + "back/asutl" ;back-end odds and ends + "base/utils" ;odds and ends + "base/stats" ;statistics abstraction + + "base/cfg1" ;control flow graph + "base/cfg2" + "base/cfg3" + + "rtlbase/rgraph" ;program graph abstraction + "rtlbase/rtlty1" ;RTL: type definitions + "rtlbase/rtlty2" ;RTL: type definitions + "rtlbase/rtlexp" ;RTL: expression operations + "rtlbase/rtlcon" ;RTL: complex constructors + "rtlbase/rtlreg" ;RTL: registers + "rtlbase/rtlcfg" ;RTL: CFG types + "rtlbase/rtlobj" ;RTL: CFG objects + "rtlbase/regset" ;RTL: register sets + "rtlbase/valclass" ;RTL: value classes + + "back/insseq" ;LAP instruction sequences + ;; New stuff + "base/parass" ;parallel assignment + ;; End of new stuff + ) + (parent ()) + (export () + compiler:analyze-side-effects? + compiler:assume-safe-fixnums? + compiler:cache-free-variables? + compiler:coalescing-constant-warnings? + compiler:code-compression? + compiler:compile-by-procedures? + compiler:cse? + compiler:default-top-level-declarations + compiler:enable-expansion-declarations? + compiler:enable-integration-declarations? + compiler:enable-statistics? + compiler:generate-kmp-files? + compiler:generate-lap-files? + compiler:generate-range-checks? + compiler:generate-rtl-files? + compiler:generate-stack-checks? + compiler:generate-type-checks? + compiler:generate-profiling-instructions? + compiler:guru? + compiler:implicit-self-static? + compiler:intersperse-rtl-in-lap? + compiler:noisy? + compiler:open-code-flonum-checks? + compiler:open-code-primitives? + compiler:optimize-environments? + compiler:package-optimization-level + compiler:preserve-data-structures? + compiler:show-phases? + compiler:show-procedures? + compiler:show-subphases? + compiler:show-time-reports? + compiler:use-multiclosures? + + compiler:display-statistics + compiler:reset-statistics!)) + +(define-package (compiler macros) + (files "base/macros") + (parent ()) + (export (compiler) + assembler-syntax-table + compiler-syntax-table + early-syntax-table + lap-generator-syntax-table) + (import (runtime macros) + parse-define-syntax) + (initialization (initialize-package!))) + +(define-package (compiler declarations) + (files "machines/spectrum/decls") + (parent (compiler)) + (export (compiler) + sc + syntax-files!) + (import (scode-optimizer top-level) + sf/internal) + (initialization (initialize-package!))) + +(define-package (compiler top-level) + (files "base/toplev" + "base/crstop" + "base/asstop") + (parent (compiler)) + (export () + cbf + cf + compile-bin-file + compile-expression + compile-procedure + compile-scode + compiler:dump-bci-file + compiler:dump-bci/bcs-files + compiler:dump-bif/bsm-files + compiler:dump-inf-file + compiler:dump-info-file + compiler:reset! + cross-compile-bin-file + cross-compile-bin-file-end) + (export (compiler) + canonicalize-label-name + ;; New stuff + *argument-registers* + ;; End of new stuff + *procedure-result?* + ) + (export (compiler midend) + *output-prefix* + compiler-phase + compiler-subphase + with-kmp-output-port + compile-recursively/new) + (export (compiler rtl-generator) + *ic-procedure-headers* + *rtl-continuations* + *rtl-expression* + *rtl-graphs* + *rtl-procedures*) + (export (compiler lap-syntaxer) + *block-label* + *external-labels* + label->object) + (export (compiler debug) + *root-expression* + *rtl-procedures* + *rtl-graphs*) + (import (runtime compiler-info) + make-compiled-module + compiled-module? + compiled-module/expression + make-dbg-locator + dbg-locator/file + dbg-locator/timestamp + make-dbg-wrapper + split-inf-structure!) + (import (runtime unparser) + *unparse-uninterned-symbols-by-name?*)) + +(define-package (compiler debug) + (files "base/debug") + (parent (compiler)) + (export () + debug/find-continuation + debug/find-entry-node + debug/find-procedure + debug/where + dump-rtl + po + show-bblock-rtl + show-rtl + write-rtl-instructions) + (import (runtime pretty-printer) + *pp-primitives-by-name*) + (import (runtime unparser) + *unparse-uninterned-symbols-by-name?*)) + +(define-package (compiler pattern-matcher/lookup) + (files "base/pmlook") + (parent (compiler)) + (export (compiler) + make-pattern-variable + pattern-lookup + pattern-variable-name + pattern-variable? + pattern-variables)) + +(define-package (compiler pattern-matcher/parser) + (files "base/pmpars") + (parent (compiler)) + (export (compiler) + parse-rule + compile-pattern + rule-result-expression) + (export (compiler macros) + parse-rule + compile-pattern + rule-result-expression)) + +(define-package (compiler pattern-matcher/early) + (files "base/pmerly") + (parent (compiler)) + (export (compiler) + early-parse-rule + early-pattern-lookup + early-make-rule + make-database-transformer + make-symbol-transformer + make-bit-mask-transformer)) + +(define-package (compiler debugging-information) + (files "base/infnew") + (parent (compiler)) + (export (compiler top-level) + info-generation-phase-1 + info-generation-phase-2 + info-generation-phase-3) + (export (compiler rtl-generator) + generated-dbg-continuation) + (import (runtime compiler-info) + make-dbg-info + + make-dbg-expression + dbg-expression/block + dbg-expression/label + set-dbg-expression/block! + set-dbg-expression/label! + + ;;make-dbg-procedure + ;;dbg-procedure/block + ;;dbg-procedure/label + ;;dbg-procedure/external-label + ;;set-dbg-procedure/external-label! + ;;dbg-procedureobject)) + +(define-package (compiler rtl-cse) + (files "rtlopt/rcse1" ;RTL common subexpression eliminator + "rtlopt/rcse2" + "rtlopt/rcsemrg" ;CSE control-flow merge + "rtlopt/rcseep" ;CSE expression predicates + "rtlopt/rcseht" ;CSE hash table + "rtlopt/rcserq" ;CSE register/quantity abstractions + "rtlopt/rcsesr" ;CSE stack references + ) + (parent (compiler)) + (export (compiler top-level) common-subexpression-elimination)) + +(define-package (compiler rtl-optimizer) + (files "rtlopt/rdebug") + (parent (compiler))) + +(define-package (compiler rtl-optimizer invertible-expression-elimination) + (files "rtlopt/rinvex") + (parent (compiler rtl-optimizer)) + (export (compiler top-level) invertible-expression-elimination)) + +(define-package (compiler rtl-optimizer common-suffix-merging) + (files "rtlopt/rtlcsm") + (parent (compiler rtl-optimizer)) + (export (compiler top-level) merge-common-suffixes!)) + +(define-package (compiler rtl-optimizer rtl-dataflow-analysis) + (files "rtlopt/rdflow") + (parent (compiler rtl-optimizer)) + (export (compiler top-level) rtl-dataflow-analysis)) + +(define-package (compiler rtl-optimizer rtl-rewriting) + (files "rtlopt/rerite") + (parent (compiler rtl-optimizer)) + (export (compiler top-level) + rtl-rewriting:post-cse + rtl-rewriting:pre-cse) + (export (compiler lap-syntaxer) + add-pre-cse-rewriting-rule! + add-rewriting-rule!)) + +(define-package (compiler rtl-optimizer lifetime-analysis) + (files "rtlopt/rlife") + (parent (compiler rtl-optimizer)) + (export (compiler top-level) lifetime-analysis) + (export (compiler rtl-optimizer code-compression) mark-set-registers!)) + +(define-package (compiler rtl-optimizer code-compression) + (files "rtlopt/rcompr") + (parent (compiler rtl-optimizer)) + (export (compiler top-level) code-compression)) + +(define-package (compiler rtl-optimizer register-allocation) + (files "rtlopt/ralloc") + (parent (compiler rtl-optimizer)) + (export (compiler top-level) register-allocation)) + +(define-package (compiler lap-syntaxer) + (files "back/lapgn1" ;LAP generator + "back/lapgn2" ; " " + "back/lapgn3" ; " " + "back/regmap" ;Hardware register allocator + "machines/spectrum/lapgen" ;code generation rules + "machines/spectrum/rules1" ; " " " + "machines/spectrum/rules2" ; " " " + "machines/spectrum/rules3" ; " " " + "machines/spectrum/rules4" ; " " " + "machines/spectrum/rulfix" ; " " " + "machines/spectrum/rulflo" ; " " " + "machines/spectrum/rulrew" ;code rewriting rules + "back/syntax" ;Generic syntax phase + "back/syerly" ;Early binding version + "machines/spectrum/coerce" ;Coercions: integer -> bit string + "back/asmmac" ;Macros for hairy syntax + "machines/spectrum/insmac" ;Macros for hairy syntax + "machines/spectrum/inerly" ;Early binding version + "machines/spectrum/instr1" ;Spectrum instruction utilities + "machines/spectrum/instr2" ;Spectrum instructions + "machines/spectrum/instr3" ; " " + ) + (parent (compiler)) + (export (compiler) + available-machine-registers + pseudo-register-offset + interpreter-memtop-pointer + fits-in-5-bits-signed? + lap-generator/match-rtl-instruction + lap:make-entry-point + lap:make-label-statement + lap:make-unconditional-branch + lap:syntax-instruction) + (export (compiler top-level) + *block-associations* + *block-profiles* + *interned-assignments* + *interned-constants* + *interned-global-links* + *interned-uuo-links* + *interned-static-variables* + *interned-variables* + *next-constant* + generate-lap) + (export (compiler assembler) + profile-info/insert-info!) + (import (scode-optimizer expansion) + scode->scode-expander)) + +(define-package (compiler lap-syntaxer map-merger) + (files "back/mermap") + (parent (compiler lap-syntaxer)) + (export (compiler lap-syntaxer) + merge-register-maps)) + +(define-package (compiler lap-syntaxer linearizer) + (files "back/linear") + (parent (compiler lap-syntaxer)) + (export (compiler lap-syntaxer) + add-end-of-block-code! + add-extra-code! + bblock-linearize-lap + extra-code-block/xtra + declare-extra-code-block! + find-extra-code-block + linearize-lap + set-current-branches! + set-extra-code-block/xtra!) + ;; New stuff + (export (compiler) + *strongly-heed-branch-preferences?*) + ;; End of new stuff + (export (compiler top-level) + *end-of-block-code* + linearize-lap)) + +(define-package (compiler lap-optimizer) + (files "machines/spectrum/lapopt") + (parent (compiler)) + (import (compiler lap-syntaxer) + entry->address + invert-condition + hook:compiler-profile-count) + (export (compiler lap-syntaxer) + lap:mark-preferred-branch!) + (export (compiler top-level) + optimize-linear-lap)) + +(define-package (compiler assembler) + (files "machines/spectrum/assmd" ;Machine dependent + "back/symtab" ;Symbol tables + "back/bitutl" ;Assembly blocks + "back/bittop" ;Assembler top level + ) + (parent (compiler)) + (export (compiler) + instruction-append) + (export (compiler top-level) + assemble)) + +(define-package (compiler disassembler) + (files "machines/spectrum/dassm1" + "machines/spectrum/dassm2" + "machines/spectrum/dassm3") + (parent (compiler)) + (export () + compiler:write-lap-file + compiler:disassemble + compiler:disassemble-memory) + (import (compiler lap-syntaxer) + code:-alist + hook:-alist) + (import (runtime compiler-info) + compiled-code-block/labels + compiled-entry/filename-and-index + compiled-module? + compiled-module/all-compiled-code-blocks + dbg-label/external? + dbg-label/name + dbg-labels/find-offset)) + +;;; New stuff + +(define-package (compiler midend) + (files "midend/graph" + "midend/synutl" + "midend/kmp" + "midend/midend" + "midend/utils" + "midend/effects" + "midend/fakeprim" + "midend/types" + "midend/typedb" ; must go before typerew + "midend/dbgstr" + "midend/dbgred" + "midend/inlate" + "midend/envconv" + "midend/alpha" + "midend/expand" + "midend/assconv" + "midend/cleanup" + "midend/earlyrew" + "midend/typerew" + "midend/lamlift" + "midend/closconv" + ;; "midend/staticfy" ; broken, for now + "midend/applicat" + "midend/simplify" + "midend/cpsconv" + "midend/laterew" + "midend/compat" + "midend/stackopt" + "midend/indexify" + "midend/rtlgen" + "midend/copier" + "midend/coerce" + "midend/dataflow" + "midend/split" + "midend/widen") + (parent (compiler)) + (import (runtime compiler-info) + make-dbg-expression + ;;make-dbg-procedure + make-dbg-continuation + make-dbg-block + ;;set-dbg-block/procedure! + ;;make-dbg-variable + ;;dbg-variable/value + ;;set-dbg-variable/value! + ) + (export (compiler top-level) + kmp/pp kmp/ppp + *envconv/compile-by-procedures?* + *envconv/procedure-result?* + kmp->rtl + optimize-kmp + rtlgen/top-level + rtlgen/argument-registers + rtlgen/available-registers + scode->kmp + within-midend) + (export (compiler) + internal-error + internal-warning) + (export () + compiler:debug) + (import (runtime compiler-info) + dbg-label/offset)) + +(define-package (compiler rtl-parser) + (files "rtlbase/rtlpars") + (parent (compiler)) + (export (compiler) + rtl->rtl-graph)) + +;; End of New stuff diff --git a/v8/src/compiler/machines/i386/compiler.sf b/v8/src/compiler/machines/i386/compiler.sf new file mode 100644 index 000000000..14bf516c7 --- /dev/null +++ b/v8/src/compiler/machines/i386/compiler.sf @@ -0,0 +1,121 @@ +#| -*-Scheme-*- + +$Id: compiler.sf,v 1.1 1995/10/25 19:19:32 ssmith Exp $ + +Copyright (c) 1988-95 Massachusetts Institute of Technology + +This material was developed by the Scheme project at the Massachusetts +Institute of Technology, Department of Electrical Engineering and +Computer Science. Permission to copy this software, to redistribute +it, and to use it for any purpose is granted, subject to the following +restrictions and understandings. + +1. Any copy made of this software must include this copyright notice +in full. + +2. Users of this software agree to make their best efforts (a) to +return to the MIT Scheme project any improvements or extensions that +they make, so that these may be included in future releases; and (b) +to inform MIT of noteworthy uses of this software. + +3. All materials developed as a consequence of the use of this +software shall duly acknowledge such use, in accordance with the usual +standards of acknowledging credit in academic research. + +4. MIT has made no warrantee or representation that the operation of +this software will be error-free, and MIT is under no obligation to +provide any services, by way of maintenance, update, or otherwise. + +5. In conjunction with products arising from the use of this material, +there shall be no use of the name of the Massachusetts Institute of +Technology nor of any adaptation thereof in any advertising, +promotional, or sales literature without prior written consent from +MIT in each case. |# + +;;;; Script to incrementally syntax the compiler + +;; Guarantee that the package modeller is loaded. +(load-option 'SF) +(load-option 'CREF) + +;; Guarantee that the compiler's package structure exists. +(if (not (name->package '(COMPILER))) + (begin + ;; If there is no existing package constructor, generate one. + (if (not (file-exists? "compiler.bco")) + (begin + ((access cref/generate-trivial-constructor + (->environment '(CROSS-REFERENCE))) + "compiler") + (sf "compiler.con"))) + (load "compiler.bco"))) + +;; Guarantee that the necessary syntactic transforms and optimizers +;; are loaded. +(if (lexical-unreferenceable? (->environment '(COMPILER)) 'SYNTAX-FILES!) + (let ((sf-and-load + (lambda (files package) + (sf-conditionally files) + (for-each (lambda (file) + (load (string-append file ".bin") package)) + files)))) + (load-option 'HASH-TABLE) + (write-string "\n\n---- Loading compile-time files ----") + (sf-and-load '("midend/synutl") '()) ;; This should go elsewhere! + (sf-and-load '("base/switch") '(COMPILER)) + (sf-and-load '("base/macros") '(COMPILER MACROS)) + ((access initialize-package! (->environment '(COMPILER MACROS)))) + (sf-and-load '("machines/spectrum/decls") '(COMPILER DECLARATIONS)) + (let ((environment (->environment '(COMPILER DECLARATIONS)))) + (set! (access source-file-expression environment) "*.scm") + ((access initialize-package! environment))) + (sf-and-load '("base/pmlook") '(COMPILER PATTERN-MATCHER/LOOKUP)) + (sf-and-load '("base/pmpars") '(COMPILER PATTERN-MATCHER/PARSER)) + (fluid-let ((sf/default-syntax-table + (access compiler-syntax-table + (->environment '(COMPILER MACROS))))) + (sf-and-load '("machines/spectrum/machin") '(COMPILER))) + (fluid-let ((sf/default-declarations + '((integrate-external "insseq") + (integrate-external "machin") + (usual-definition (set expt))))) + (sf-and-load '("machines/spectrum/assmd") '(COMPILER ASSEMBLER))) + (sf-and-load '("back/syntax") '(COMPILER LAP-SYNTAXER)) + (sf-and-load '("machines/spectrum/coerce" "back/asmmac" + "machines/spectrum/insmac") + '(COMPILER LAP-SYNTAXER)) + (sf-and-load '("base/scode") '(COMPILER)) + (sf-and-load '("base/pmerly") '(COMPILER PATTERN-MATCHER/EARLY)) + (sf-and-load '("machines/spectrum/inerly" "back/syerly") + '(COMPILER LAP-SYNTAXER)))) + +(if (lexical-unreferenceable? (->environment '()) '%matchup) + (let ((sf-and-load + (lambda (files package) + (sf-conditionally files) + (for-each (lambda (file) + (load (string-append file ".bin") package)) + files)))) + (write-string "\n\n---- Loading compile-time files ----") + (sf-and-load '("midend/synutl") '()))) ;; This should go elsewhere! + +;; Load the assembler instruction database. +(in-package (->environment '(COMPILER LAP-SYNTAXER)) + (if (and compiler:enable-expansion-declarations? + (null? early-instructions)) + (fluid-let ((load-noisily? false) + (load/suppress-loading-message? false)) + (write-string "\n\n---- Pre-loading instruction sets ----") + (for-each (lambda (name) + (load (string-append "machines/spectrum/" name ".scm") + '(COMPILER LAP-SYNTAXER) + early-syntax-table)) + '("instr1" "instr2" "instr3"))))) + +;; Resyntax any files that need it. +((access syntax-files! (->environment '(COMPILER)))) + +;; Rebuild the package constructors and cref. +(cref/generate-constructors "compiler") +(sf "compiler.con") +(sf "compiler.ldr") \ No newline at end of file -- 2.25.1