From: Taylor R Campbell Date: Sun, 13 Jan 2019 06:08:23 +0000 (+0000) Subject: Draft aarch64 back end. X-Git-Tag: mit-scheme-pucked-10.1.20~11^2~66^2~96 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=d64cc6aa017fcb7445727373541027d3849e23b0;p=mit-scheme.git Draft aarch64 back end. Nowhere near completion yet, long TODO list, not compile-tested, &c. Not sure if I'll find any more copious spare time to work on this for a while. --- diff --git a/src/compiler/machines/aarch64/.dir-locals.el b/src/compiler/machines/aarch64/.dir-locals.el new file mode 100644 index 000000000..8ce86e2c3 --- /dev/null +++ b/src/compiler/machines/aarch64/.dir-locals.el @@ -0,0 +1 @@ +((nil (indent-tabs-mode . nil))) diff --git a/src/compiler/machines/aarch64/TODO b/src/compiler/machines/aarch64/TODO new file mode 100644 index 000000000..08af65f71 --- /dev/null +++ b/src/compiler/machines/aarch64/TODO @@ -0,0 +1,21 @@ +- Make it work. + [ ] assmd + [ ] cmpauxmd + [ ] coerce + [ ] insmac + [ ] instr: branch tensioning, review it all, simd, float + [ ] insutl + [ ] logical immediate encoding +- Confirm apply target/pc registers match in: + . rules3 (invocation:computed-jump) + . cmpauxmd + . uuo link code in aarch64.c (currently uses x0/x1, should use x16/x17) + . trampoline code, if necessary + . wherever else +- Verify the branch condition codes. +- Open-coded flonum arithmetic. +- Better fixnum operations with constant operands. +- Fast division by multiplication. +- Fixnum multiply-add/sub/negate. +- Consider NaN-tagging. +- Write a disassembler. diff --git a/src/compiler/machines/aarch64/compiler.cbf b/src/compiler/machines/aarch64/compiler.cbf new file mode 100644 index 000000000..1eeb84eb1 --- /dev/null +++ b/src/compiler/machines/aarch64/compiler.cbf @@ -0,0 +1,38 @@ +#| -*-Scheme-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, + 2017, 2018, 2019 Massachusetts Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +MIT/GNU Scheme is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +|# + +;;;; Script to incrementally compile the compiler (from .bins) + +(fluid-let ((compiler:coalescing-constant-warnings? #f)) + (for-each compile-directory + '("back" + "base" + "fggen" + "fgopt" + "machines/aarch64" + "rtlbase" + "rtlgen" + "rtlopt"))) diff --git a/src/compiler/machines/aarch64/compiler.pkg b/src/compiler/machines/aarch64/compiler.pkg new file mode 100644 index 000000000..52a7ad963 --- /dev/null +++ b/src/compiler/machines/aarch64/compiler.pkg @@ -0,0 +1,784 @@ +#| -*-Scheme-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, + 2017, 2018, 2019 Massachusetts Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +MIT/GNU Scheme is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +|# + +;;;; Compiler Packaging + +(global-definitions "../runtime/runtime") +(global-definitions "../sf/sf") + +(define-package (compiler) + (files "base/switch" + "base/object" ;tagged object support + "base/enumer" ;enumerations + "base/sets" ;set abstraction + "base/mvalue" ;multiple-value support + "base/scode" ;SCode abstraction + "machines/aarch64/machine" ;machine dependent stuff + "back/asutl" ;back-end odds and ends + "base/utils" ;odds and ends + + "base/cfg1" ;control flow graph + "base/cfg2" + "base/cfg3" + + "base/ctypes" ;CFG datatypes + + "base/rvalue" ;Right hand values + "base/lvalue" ;Left hand values + "base/blocks" ;rvalue: blocks + "base/proced" ;rvalue: procedures + "base/contin" ;rvalue: continuations + + "base/subprb" ;subproblem datatype + + "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 + ) + (parent ()) + (export () + compiler:analyze-side-effects? + compiler:cache-free-variables? + compiler:coalescing-constant-warnings? + compiler:code-compression? + compiler:compile-by-procedures? + compiler:cross-compiling? + compiler:cse? + compiler:default-top-level-declarations + compiler:enable-integration-declarations? + compiler:generate-lap-files? + compiler:generate-range-checks? + compiler:generate-rtl-files? + compiler:generate-stack-checks? + compiler:generate-type-checks? + compiler:implicit-self-static? + compiler:intersperse-rtl-in-lap? + compiler:noisy? + compiler:open-code-floating-point-arithmetic? + 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?) + (import (runtime system-macros) + ucode-primitive + ucode-type) + (import () + (scode/access-environment scode-access-environment) + (scode/access-name scode-access-name) + (scode/access? scode-access?) + (scode/assignment-name scode-assignment-name) + (scode/assignment-value scode-assignment-value) + (scode/assignment? scode-assignment?) + (scode/combination-operands scode-combination-operands) + (scode/combination-operator scode-combination-operator) + (scode/combination? scode-combination?) + (scode/comment-expression scode-comment-expression) + (scode/comment-text scode-comment-text) + (scode/comment? scode-comment?) + (scode/conditional-alternative scode-conditional-alternative) + (scode/conditional-consequent scode-conditional-consequent) + (scode/conditional-predicate scode-conditional-predicate) + (scode/conditional? scode-conditional?) + (scode/constant? scode-constant?) + (scode/declaration-expression scode-declaration-expression) + (scode/declaration-text scode-declaration-text) + (scode/declaration? scode-declaration?) + (scode/definition-name scode-definition-name) + (scode/definition-value scode-definition-value) + (scode/definition? scode-definition?) + (scode/delay-expression scode-delay-expression) + (scode/delay? scode-delay?) + (scode/disjunction-alternative scode-disjunction-alternative) + (scode/disjunction-predicate scode-disjunction-predicate) + (scode/disjunction? scode-disjunction?) + (scode/lambda-components scode-lambda-components) + (scode/lambda-body scode-lambda-body) + (scode/lambda-name scode-lambda-name) + (scode/lambda? scode-lambda?) + (scode/make-access make-scode-access) + (scode/make-assignment make-scode-assignment) + (scode/make-combination make-scode-combination) + (scode/make-comment make-scode-comment) + (scode/make-conditional make-scode-conditional) + (scode/make-declaration make-scode-declaration) + (scode/make-definition make-scode-definition) + (scode/make-delay make-scode-delay) + (scode/make-disjunction make-scode-disjunction) + (scode/make-lambda make-scode-lambda) + (scode/make-open-block make-scode-open-block) + (scode/make-quotation make-scode-quotation) + (scode/make-sequence make-scode-sequence) + (scode/make-the-environment make-scode-the-environment) + (scode/make-unassigned? make-scode-unassigned?) + (scode/make-variable make-scode-variable) + (scode/open-block-actions scode-open-block-actions) + (scode/open-block-declarations scode-open-block-declarations) + (scode/open-block-names scode-open-block-names) + (scode/open-block? scode-open-block?) + (scode/primitive-procedure? primitive-procedure?) + (scode/procedure? procedure?) + (scode/quotation-expression scode-quotation-expression) + (scode/quotation? scode-quotation?) + (scode/sequence-actions scode-sequence-actions) + (scode/sequence? scode-sequence?) + (scode/set-lambda-body! set-scode-lambda-body!) + (scode/symbol? symbol?) + (scode/the-environment? scode-the-environment?) + (scode/unassigned?-name scode-unassigned?-name) + (scode/unassigned?? scode-unassigned??) + (scode/variable-name scode-variable-name) + (scode/variable? scode-variable?))) + +(define-package (compiler reference-contexts) + (files "base/refctx") + (parent (compiler)) + (export (compiler) + add-reference-context/adjacent-parents! + initialize-reference-contexts! + make-reference-context + modify-reference-contexts! + reference-context/adjacent-parent? + reference-context/block + reference-context/offset + reference-context/procedure + reference-context? + set-reference-context/offset!)) + +(define-package (compiler macros) + (files "base/macros") + (parent (compiler)) + (export (compiler) + cfg-node-case + define-enumeration + define-export + define-lvalue + define-pnode + define-root-type + define-rtl-expression + define-rtl-predicate + define-rtl-statement + define-rule + define-rvalue + define-snode + define-vector-slots + descriptor-list + enumeration-case + inst-ea + lap + last-reference + make-lvalue + make-pnode + make-rvalue + make-snode + package + rule-matcher)) + +(define-package (compiler declarations) + (files "machines/aarch64/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-directory + compile-bin-file + compile-file + compile-file:force? + compile-file:override-usual-integrations + compile-file:sf-only? + compile-file:show-dependencies? + compile-procedure + compile-scode + compiler:compiled-code-pathname-type + compiler:reset! + lap->code) + (export (compiler) + canonicalize-label-name) + (export (compiler fg-generator) + *tl-metadata* + compile-recursively) + (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) + map-r7rs-scode-file + map-scode-library + r7rs-scode-file? + scode-library-name) + (import (scode-optimizer build-utilities) + directory-processor)) + +(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-fg + show-fg-node + show-rtl + write-rtl-instructions)) + +(define-package (compiler pattern-matcher/lookup) + (files "base/pmlook") + (parent (compiler)) + (export (compiler) + generate-pattern-matcher + make-pattern-variable + pattern-contains-duplicates? + pattern-lookup + pattern-lookup-1 + pattern-lookup-2 + pattern-variable-name + pattern-variable? + pattern-variables)) + +(define-package (compiler pattern-matcher/parser) + (files "base/pmpars") + (parent (compiler)) + (export (compiler) + make-rule-matcher + parse-rule + rule->matcher + rule-result-expression) + (export (compiler macros) + make-rule-matcher + parse-rule + rule->matcher + 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/label! + + make-dbg-procedure + dbg-procedure/block + dbg-procedure/label + set-dbg-procedure/label! + dbg-procedure/name + dbg-procedure/required + dbg-procedure/optional + dbg-procedure/rest + dbg-procedure/auxiliary + dbg-procedure/external-label + set-dbg-procedure/external-label! + dbg-procedureflow-graph converter + "fggen/declar" ;Declaration handling + ) + (parent (compiler)) + (export (compiler top-level) + canonicalize/top-level + construct-graph) + (import (runtime scode-data) + &pair-car + &pair-cdr + &triple-first + &triple-second + &triple-third)) + +(define-package (compiler fg-optimizer) + (files "fgopt/outer" ;outer analysis + "fgopt/sideff" ;side effect analysis + ) + (parent (compiler)) + (export (compiler top-level) + clear-call-graph! + compute-call-graph! + outer-analysis + side-effect-analysis)) + +(define-package (compiler fg-optimizer fold-constants) + (files "fgopt/folcon") + (parent (compiler fg-optimizer)) + (export (compiler top-level) fold-constants)) + +(define-package (compiler fg-optimizer operator-analysis) + (files "fgopt/operan") + (parent (compiler fg-optimizer)) + (export (compiler top-level) operator-analysis)) + +(define-package (compiler fg-optimizer variable-indirection) + (files "fgopt/varind") + (parent (compiler fg-optimizer)) + (export (compiler top-level) initialize-variable-indirections!)) + +(define-package (compiler fg-optimizer environment-optimization) + (files "fgopt/envopt") + (parent (compiler fg-optimizer)) + (export (compiler top-level) optimize-environments!)) + +(define-package (compiler fg-optimizer closure-analysis) + (files "fgopt/closan") + (parent (compiler fg-optimizer)) + (export (compiler top-level) identify-closure-limits!)) + +(define-package (compiler fg-optimizer continuation-analysis) + (files "fgopt/contan") + (parent (compiler fg-optimizer)) + (export (compiler top-level) + continuation-analysis + setup-block-static-links!)) + +(define-package (compiler fg-optimizer compute-node-offsets) + (files "fgopt/offset") + (parent (compiler fg-optimizer)) + (export (compiler top-level) compute-node-offsets)) + +(define-package (compiler fg-optimizer connectivity-analysis) + (files "fgopt/conect") + (parent (compiler fg-optimizer)) + (export (compiler top-level) connectivity-analysis)) + +(define-package (compiler fg-optimizer delete-integrated-parameters) + (files "fgopt/delint") + (parent (compiler fg-optimizer)) + (export (compiler top-level) delete-integrated-parameters)) + +(define-package (compiler fg-optimizer design-environment-frames) + (files "fgopt/desenv") + (parent (compiler fg-optimizer)) + (export (compiler top-level) design-environment-frames!)) + +(define-package (compiler fg-optimizer setup-block-types) + (files "fgopt/blktyp") + (parent (compiler fg-optimizer)) + (export (compiler top-level) + setup-block-types! + setup-closure-contexts!) + (export (compiler) + indirection-block-procedure)) + +(define-package (compiler fg-optimizer simplicity-analysis) + (files "fgopt/simple") + (parent (compiler fg-optimizer)) + (export (compiler top-level) simplicity-analysis) + (export (compiler fg-optimizer subproblem-ordering) + new-subproblem/compute-simplicity!)) + +(define-package (compiler fg-optimizer simulate-application) + (files "fgopt/simapp") + (parent (compiler fg-optimizer)) + (export (compiler top-level) simulate-application)) + +(define-package (compiler fg-optimizer subproblem-free-variables) + (files "fgopt/subfre") + (parent (compiler fg-optimizer)) + (export (compiler top-level) compute-subproblem-free-variables) + (export (compiler fg-optimizer) map-union) + (export (compiler fg-optimizer subproblem-ordering) + new-subproblem/compute-free-variables!)) + +(define-package (compiler fg-optimizer subproblem-ordering) + (files "fgopt/order") + (parent (compiler fg-optimizer)) + (export (compiler top-level) subproblem-ordering)) + +(define-package (compiler fg-optimizer subproblem-ordering reuse-frames) + (files "fgopt/reord" "fgopt/reuse") + (parent (compiler fg-optimizer subproblem-ordering)) + (export (compiler top-level) setup-frame-adjustments) + (export (compiler fg-optimizer subproblem-ordering) + order-subproblems/maybe-overwrite-block)) + +(define-package (compiler fg-optimizer subproblem-ordering parameter-analysis) + (files "fgopt/param") + (parent (compiler fg-optimizer subproblem-ordering)) + (export (compiler fg-optimizer subproblem-ordering) + parameter-analysis)) + +(define-package (compiler fg-optimizer return-equivalencing) + (files "fgopt/reteqv") + (parent (compiler fg-optimizer)) + (export (compiler top-level) find-equivalent-returns!)) + +(define-package (compiler rtl-generator) + (files "rtlgen/rtlgen" ;RTL generator + "rtlgen/rgstmt" ;statements + "rtlgen/fndvar" ;find variables + "machines/aarch64/rgspcm" ;special close-coded primitives + "rtlbase/rtline" ;linearizer + ) + (parent (compiler)) + (export (compiler) + make-linearizer) + (export (compiler top-level) + generate/top-level + linearize-rtl + setup-bblock-continuations!) + (export (compiler debug) + linearize-rtl) + (import (compiler top-level) + label->object)) + +(define-package (compiler rtl-generator generate/procedure-header) + (files "rtlgen/rgproc") + (parent (compiler rtl-generator)) + (export (compiler rtl-generator) generate/procedure-header)) + +(define-package (compiler rtl-generator combination/inline) + (files "rtlgen/opncod") + (parent (compiler rtl-generator)) + (export (compiler rtl-generator) combination/inline) + (export (compiler top-level) open-coding-analysis)) + +(define-package (compiler rtl-generator find-block) + (files "rtlgen/fndblk") + (parent (compiler rtl-generator)) + (export (compiler rtl-generator) find-block)) + +(define-package (compiler rtl-generator generate/rvalue) + (files "rtlgen/rgrval") + (parent (compiler rtl-generator)) + (export (compiler rtl-generator) + generate/rvalue + load-closure-environment + make-cons-closure-indirection + make-cons-closure-redirection + make-closure-redirection + make-ic-cons + make-non-trivial-closure-cons + make-trivial-closure-cons + redirect-closure)) + +(define-package (compiler rtl-generator generate/combination) + (files "rtlgen/rgcomb") + (parent (compiler rtl-generator)) + (export (compiler rtl-generator) + generate/combination + rtl:bump-closure) + (export (compiler rtl-generator combination/inline) + generate/invocation-prefix)) + +(define-package (compiler rtl-generator generate/return) + (files "rtlgen/rgretn") + (parent (compiler rtl-generator)) + (export (compiler rtl-generator) + make-return-operand + generate/return + generate/return* + generate/trivial-return)) + +(define-package (compiler rtl-cse) + (files "rtlopt/rcse1" ;RTL common subexpression eliminator + "rtlopt/rcse2" + "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-rewriting-rule! + add-pre-cse-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 + "back/checks" ;Interrupt checks + "machines/aarch64/lapgen" ;code generation rules + "machines/aarch64/rules1" ; " " " + "machines/aarch64/rules2" ; " " " + "machines/aarch64/rules3" ; " " " + "machines/aarch64/rules4" ; " " " + "machines/aarch64/rulfix" ; " " " + "machines/aarch64/rulflo" ; " " " + "machines/aarch64/rulrew" ;code rewriting rules + "back/syntax" ;Generic syntax phase + "back/syerly" ;Early binding version + "machines/aarch64/coerce" ;Coercions: integer -> bit string + "back/asmmac" ;Macros for hairy syntax + "machines/aarch64/insmac" ;Macros for hairy syntax + "machines/aarch64/insutl" ;aarch64 instruction utilities + "machines/aarch64/instr1" ;aarch64 instructions + "machines/aarch64/instr2" ; " " + "machines/aarch64/instrf" ; " " fp instructions + ) + (parent (compiler)) + (export (compiler) + available-machine-registers + 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* + *interned-assignments* + *interned-constants* + *interned-global-links* + *interned-uuo-links* + *interned-static-variables* + *interned-variables* + *next-constant* + generate-lap) + (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!) + (export (compiler top-level) + *end-of-block-code* + linearize-lap)) + +(define-package (compiler lap-optimizer) + (files "machines/aarch64/lapopt") + (parent (compiler)) + (export (compiler top-level) + optimize-linear-lap)) + +(define-package (compiler assembler) + (files "machines/aarch64/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/aarch64/dassm1" + "machines/aarch64/dassm2" + "machines/aarch64/dassm3") + (parent (compiler)) + (export () + compiler:write-lap-file + compiler:disassemble) + (import (runtime compiler-info) + compiled-code-block/dbg-info + dbg-info-vector/blocks-vector + dbg-info-vector? + dbg-info/labels + dbg-label/external? + dbg-label/name + dbg-labels/find-offset)) diff --git a/src/compiler/machines/aarch64/compiler.sf b/src/compiler/machines/aarch64/compiler.sf new file mode 100644 index 000000000..74b77c285 --- /dev/null +++ b/src/compiler/machines/aarch64/compiler.sf @@ -0,0 +1,89 @@ +#| -*-Scheme-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, + 2017, 2018, 2019 Massachusetts Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +MIT/GNU Scheme is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +|# + +;;;; Script to incrementally syntax the compiler + +(load-option 'cref) +(load-option 'sf) + +;; Guarantee that the compiler's package structure exists. +(if (not (name->package '(compiler))) + (let ((package-set + (merge-pathnames + (enough-pathname + (merge-pathnames (package-set-pathname "compiler")) + cref/source-root) + cref/object-root))) + (if (not (file-exists? package-set)) + (cref/generate-trivial-constructor "compiler")) + (construct-packages-from-file (fasload package-set)))) + +;; Guarantee that the necessary syntactic transforms and optimizers +;; are loaded. +(if (lexical-unreferenceable? (->environment '(compiler)) 'syntax-files!) + (let ((sf-and-load + (lambda (files package) + (fluid-let ((sf/default-syntax-table (->environment package))) + (sf-conditionally files)) + (for-each (lambda (file) + (receive (scm bin spec) + (sf/pathname-defaulting file #f #f) + scm spec + (load bin package))) + files)))) + (load-option 'hash-table) + (fresh-line) + (newline) + (write-string "---- Loading compile-time files ----") + (newline) + (sf-and-load '("base/switch") '(compiler)) + (sf-and-load '("base/macros") '(compiler macros)) + (sf-and-load '("machines/aarch64/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)) + (sf-and-load '("machines/aarch64/machine") '(compiler)) + (fluid-let ((sf/default-declarations + '((integrate-external "insseq") + (integrate-external "machine") + (usual-definition (set expt))))) + (sf-and-load '("machines/aarch64/assmd") '(compiler assembler))) + (sf-and-load '("back/syntax") '(compiler lap-syntaxer)) + (sf-and-load '("machines/aarch64/coerce" + "back/asmmac" + "machines/aarch64/insmac") + '(compiler lap-syntaxer)) + (sf-and-load '("base/scode") '(compiler)) + (sf-and-load '("base/pmerly") '(compiler pattern-matcher/early)) + (sf-and-load '("back/syerly") '(compiler lap-syntaxer)))) + +;; Resyntax any files that need it. +((access syntax-files! (->environment '(compiler)))) + +;; Rebuild the package constructors and cref. +(cref/generate-constructors "compiler") \ No newline at end of file diff --git a/src/compiler/machines/aarch64/decls.scm b/src/compiler/machines/aarch64/decls.scm new file mode 100644 index 000000000..66ace9402 --- /dev/null +++ b/src/compiler/machines/aarch64/decls.scm @@ -0,0 +1,596 @@ +#| -*-Scheme-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, + 2017, 2018, 2019 Massachusetts Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +MIT/GNU Scheme is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +|# + +;;;; Compiler File Dependencies +;;; package: (compiler declarations) + +(declare (usual-integrations)) + +(define (initialize-package!) + (add-event-receiver! event:after-restore reset-source-nodes!) + (reset-source-nodes!)) + +(define (reset-source-nodes!) + (set! source-filenames '()) + (set! source-hash) + (set! source-nodes) + (set! source-nodes/by-rank) + unspecific) + +(define (maybe-setup-source-nodes!) + (if (null? source-filenames) + (setup-source-nodes!))) + +(define (setup-source-nodes!) + (let ((filenames + (append-map! + (lambda (subdirectory) + (map (lambda (pathname) + (string-append subdirectory + "/" + (pathname-name pathname))) + (directory-read + (string-append subdirectory + "/" + source-file-expression)))) + '("back" "base" "fggen" "fgopt" "rtlbase" "rtlgen" "rtlopt" + "machines/aarch64")))) + (if (null? filenames) + (error "Can't find source files of compiler")) + (set! source-filenames filenames)) + (set! source-hash (make-string-hash-table)) + (set! source-nodes + (map (lambda (filename) + (let ((node (make/source-node filename))) + (hash-table-set! source-hash filename node) + node)) + source-filenames)) + (initialize/syntax-dependencies!) + (initialize/integration-dependencies!) + (source-nodes/rank!)) + +(define source-file-expression "*.scm") +(define source-filenames) +(define source-hash) +(define source-nodes) +(define source-nodes/by-rank) + +(define (filename/append directory . names) + (map (lambda (name) (string-append directory "/" name)) names)) + +(define-structure (source-node + (conc-name source-node/) + (constructor %make/source-node (filename pathname))) + (filename #f read-only #t) + (pathname #f read-only #t) + (forward-links '()) + (backward-links '()) + (forward-closure '()) + (backward-closure '()) + (dependencies '()) + (dependents '()) + (rank #f) + (syntax-table #f) + (declarations '()) + (modification-time #f)) + +(define (make/source-node filename) + (%make/source-node filename (->pathname filename))) + +(define (filename->source-node filename) + (let ((node (hash-table-ref/default source-hash filename #f))) + (if (not node) + (error "Unknown source file:" filename)) + node)) + +(define (source-node/circular? node) + (memq node (source-node/backward-closure node))) + +(define (source-node/link! node dependency) + (if (not (memq dependency (source-node/backward-links node))) + (begin + (set-source-node/backward-links! + node + (cons dependency (source-node/backward-links node))) + (set-source-node/forward-links! + dependency + (cons node (source-node/forward-links dependency))) + (source-node/close! node dependency)))) + +(define (source-node/close! node dependency) + (if (not (memq dependency (source-node/backward-closure node))) + (begin + (set-source-node/backward-closure! + node + (cons dependency (source-node/backward-closure node))) + (set-source-node/forward-closure! + dependency + (cons node (source-node/forward-closure dependency))) + (for-each (lambda (dependency) + (source-node/close! node dependency)) + (source-node/backward-closure dependency)) + (for-each (lambda (node) + (source-node/close! node dependency)) + (source-node/forward-closure node))))) + +;;;; Rank + +(define (source-nodes/rank!) + (compute-dependencies! source-nodes) + (compute-ranks! source-nodes) + (set! source-nodes/by-rank (source-nodes/sort-by-rank source-nodes)) + unspecific) + +(define (compute-dependencies! nodes) + (for-each (lambda (node) + (set-source-node/dependencies! + node + (remove (lambda (node*) + (memq node (source-node/backward-closure node*))) + (source-node/backward-closure node))) + (set-source-node/dependents! + node + (remove (lambda (node*) + (memq node (source-node/forward-closure node*))) + (source-node/forward-closure node)))) + nodes)) + +(define (compute-ranks! nodes) + (let loop ((nodes nodes) (unranked-nodes '())) + (if (null? nodes) + (if (not (null? unranked-nodes)) + (loop unranked-nodes '())) + (loop (cdr nodes) + (let ((node (car nodes))) + (let ((rank (source-node/rank* node))) + (if rank + (begin + (set-source-node/rank! node rank) + unranked-nodes) + (cons node unranked-nodes)))))))) + +(define (source-node/rank* node) + (let loop ((nodes (source-node/dependencies node)) (rank -1)) + (if (null? nodes) + (1+ rank) + (let ((rank* (source-node/rank (car nodes)))) + (and rank* + (loop (cdr nodes) (max rank rank*))))))) + +(define (source-nodes/sort-by-rank nodes) + (sort nodes (lambda (x y) (< (source-node/rank x) (source-node/rank y))))) + +;;;; File Syntaxer + +(define (syntax-files!) + (maybe-setup-source-nodes!) + (for-each + (lambda (node) + (let ((modification-time + (receive (scm bin spec) + (sf/pathname-defaulting (source-node/pathname node) #f #f) + spec + (let ((source (file-modification-time scm)) + (binary (file-modification-time bin))) + (if (not source) + (error "Missing source file" (source-node/filename node))) + (and binary (< source binary) binary))))) + (set-source-node/modification-time! node modification-time) + (if (not modification-time) + (write-notification-line + (lambda (port) + (write-string "Source file newer than binary: " port) + (write (source-node/filename node) port)))))) + source-nodes) + (if compiler:enable-integration-declarations? + (begin + (for-each + (lambda (node) + (let ((time (source-node/modification-time node))) + (if (and time + (any (lambda (node*) + (let ((newer? + (let ((time* + (source-node/modification-time + node*))) + (or (not time*) + (> time* time))))) + (if newer? + (write-notification-line + (lambda (port) + (write-string "Binary file " port) + (write (source-node/filename node) port) + (write-string " newer than dependency " + port) + (write (source-node/filename node*) + port)))) + newer?)) + (source-node/dependencies node))) + (set-source-node/modification-time! node #f)))) + source-nodes) + (for-each + (lambda (node) + (if (not (source-node/modification-time node)) + (for-each (lambda (node*) + (if (source-node/modification-time node*) + (write-notification-line + (lambda (port) + (write-string "Binary file " port) + (write (source-node/filename node*) port) + (write-string " depends on " port) + (write (source-node/filename node) port)))) + (set-source-node/modification-time! node* #f)) + (source-node/forward-closure node)))) + source-nodes))) + (for-each (lambda (node) + (if (not (source-node/modification-time node)) + (pathname-delete! + (pathname-new-type (source-node/pathname node) "ext")))) + source-nodes/by-rank) + (write-notification-line + (lambda (port) + (write-string "Begin pass 1:" port))) + (bind-condition-handler (list condition-type:simple-warning) + (lambda (condition) + (if (string=? (access-condition condition 'MESSAGE) + "Missing externs file:") + (muffle-warning))) + (lambda () + (for-each (lambda (node) + (if (not (source-node/modification-time node)) + (source-node/syntax! node))) + source-nodes/by-rank))) + (if (any (lambda (node) + (and (not (source-node/modification-time node)) + (source-node/circular? node))) + source-nodes/by-rank) + (begin + (write-notification-line + (lambda (port) + (write-string "Begin pass 2:" port))) + (for-each (lambda (node) + (if (not (source-node/modification-time node)) + (if (source-node/circular? node) + (source-node/syntax! node) + (source-node/touch! node)))) + source-nodes/by-rank)))) + +(define (source-node/touch! node) + (receive (input-pathname bin-pathname spec-pathname) + (sf/pathname-defaulting (source-node/pathname node) "" #f) + input-pathname + (pathname-touch! bin-pathname) + (pathname-touch! (pathname-new-type bin-pathname "ext")) + (if spec-pathname (pathname-touch! spec-pathname)))) + +(define (pathname-touch! pathname) + (if (file-exists? pathname) + (begin + (write-notification-line + (lambda (port) + (write-string "Touch file: " port) + (write (enough-namestring pathname) port))) + (file-touch pathname)))) + +(define (pathname-delete! pathname) + (if (file-exists? pathname) + (begin + (write-notification-line + (lambda (port) + (write-string "Delete file: " port) + (write (enough-namestring pathname) port))) + (delete-file pathname)))) + +(define (sc filename) + (maybe-setup-source-nodes!) + (source-node/syntax! (filename->source-node filename))) + +(define (source-node/syntax! node) + (receive (input-pathname bin-pathname spec-pathname) + (sf/pathname-defaulting (source-node/pathname node) "" #f) + (sf/internal + input-pathname bin-pathname spec-pathname + (source-node/syntax-table node) + ((if compiler:enable-integration-declarations? + identity-procedure + (lambda (declarations) + (remove integration-declaration? declarations))) + (source-node/declarations node))))) + +;;;; Syntax dependencies + +(define (initialize/syntax-dependencies!) + (let ((file-dependency/syntax/join + (lambda (filenames syntax-table) + (for-each (lambda (filename) + (set-source-node/syntax-table! + (filename->source-node filename) + syntax-table)) + filenames)))) + (file-dependency/syntax/join + (append (filename/append "base" + "toplev" "asstop" "crstop" + "blocks" "cfg1" "cfg2" "cfg3" "constr" + "contin" "ctypes" "debug" "enumer" + "infnew" "lvalue" "object" "pmerly" "proced" + "refctx" "rvalue" "scode" "sets" "subprb" + "switch" "utils") + (filename/append "back" + "asmmac" "bittop" "bitutl" "checks" "insseq" + "lapgn1" "lapgn2" "lapgn3" "linear" "regmap" + "symtab" "syntax") + (filename/append "machines/aarch64" + "dassm1" "insmac" "lapopt" "machine" "rgspcm" + "rulrew") + (filename/append "fggen" + "declar" "fggen" "canon") + (filename/append "fgopt" + "blktyp" "closan" "conect" "contan" "delint" + "desenv" "envopt" "folcon" "offset" "operan" + "order" "outer" "param" "reord" "reteqv" "reuse" + "sideff" "simapp" "simple" "subfre" "varind") + (filename/append "rtlbase" + "regset" "rgraph" "rtlcfg" "rtlcon" "rtlexp" + "rtline" "rtlobj" "rtlreg" "rtlty1" "rtlty2" + "valclass") + (filename/append "rtlgen" + "fndblk" "fndvar" "opncod" "rgcomb" "rgproc" + "rgretn" "rgrval" "rgstmt" "rtlgen") + (filename/append "rtlopt" + "ralloc" "rcompr" "rcse1" "rcse2" "rcseep" + "rcseht" "rcserq" "rcsesr" "rdebug" "rdflow" + "rerite" "rinvex" "rlife" "rtlcsm")) + (->environment '(COMPILER))) + (file-dependency/syntax/join + (filename/append "machines/aarch64" + "lapgen" + "rules1" "rules2" "rules3" "rules4" "rulfix" "rulflo" + "insutl" "instr1" "instr2" "instrf") + (->environment '(COMPILER LAP-SYNTAXER))))) + +;;;; Integration Dependencies + +(define (initialize/integration-dependencies!) + + (define (add-declaration! declaration filenames) + (for-each (lambda (filenames) + (let ((node (filename->source-node filenames))) + (set-source-node/declarations! + node + (cons declaration + (source-node/declarations node))))) + filenames)) + + (let* ((front-end-base + (filename/append "base" + "blocks" "cfg1" "cfg2" "cfg3" + "contin" "ctypes" "enumer" "lvalue" + "object" "proced" "rvalue" + "scode" "subprb" "utils")) + (aarch64-base + (append (filename/append "machines/aarch64" "machine") + (filename/append "back" "asutl"))) + (rtl-base + (filename/append "rtlbase" + "rgraph" "rtlcfg" "rtlobj" "rtlreg" "rtlty1" + "rtlty2")) + (cse-base + (filename/append "rtlopt" + "rcse1" "rcseht" "rcserq" "rcsesr")) + (cse-all + (append (filename/append "rtlopt" + "rcse2" "rcseep") + cse-base)) + (instruction-base + (filename/append "machines/aarch64" "assmd" "machine")) + (lapgen-base + (append (filename/append "back" "linear" "regmap") + (filename/append "machines/aarch64" "lapgen"))) + (assembler-base + (append (filename/append "back" "symtab") + (filename/append "machines/aarch64" "insutl"))) + (lapgen-body + (append + (filename/append "back" "checks" "lapgn1" "lapgn2" "syntax") + (filename/append "machines/aarch64" + "rules1" "rules2" "rules3" "rules4" + "rulfix" "rulflo"))) + (assembler-body + (append + (filename/append "back" "bittop") + (filename/append "machines/aarch64" + "instr1" "instr2" "instrf")))) + + (define (file-dependency/integration/join filenames dependencies) + (for-each (lambda (filename) + (file-dependency/integration/make filename dependencies)) + filenames)) + + (define (file-dependency/integration/make filename dependencies) + (let ((node (filename->source-node filename))) + (for-each (lambda (dependency) + (let ((node* (filename->source-node dependency))) + (if (not (eq? node node*)) + (source-node/link! node node*)))) + dependencies))) + + (define (define-integration-dependencies directory name directory* . names) + (file-dependency/integration/make + (string-append directory "/" name) + (apply filename/append directory* names))) + + (define-integration-dependencies "machines/aarch64" + "machine" "back" "asutl") + (define-integration-dependencies "base" "object" "base" "enumer") + (define-integration-dependencies "base" "enumer" "base" "object") + (define-integration-dependencies "base" "cfg1" "base" "object") + (define-integration-dependencies "base" "cfg2" "base" + "cfg1" "cfg3" "object") + (define-integration-dependencies "base" "cfg3" "base" "cfg1" "cfg2") + (define-integration-dependencies "base" "ctypes" "base" + "blocks" "cfg1" "cfg2" "cfg3" "contin" "lvalue" "object" "subprb") + (define-integration-dependencies "base" "rvalue" "base" + "blocks" "cfg1" "cfg2" "cfg3" "enumer" "lvalue" "object" "utils") + (define-integration-dependencies "base" "lvalue" "base" + "blocks" "object" "proced" "rvalue" "utils") + (define-integration-dependencies "base" "blocks" "base" + "enumer" "lvalue" "object" "proced" "rvalue") + (define-integration-dependencies "base" "proced" "base" + "blocks" "cfg1" "cfg2" "cfg3" "contin" "enumer" "lvalue" "object" + "rvalue" "utils") + (define-integration-dependencies "base" "contin" "base" + "blocks" "cfg3" "ctypes") + (define-integration-dependencies "base" "subprb" "base" + "cfg3" "contin" "enumer" "object" "proced") + + (define-integration-dependencies "machines/aarch64" "machine" "rtlbase" + "rtlreg" "rtlty1" "rtlty2") + + (define-integration-dependencies "rtlbase" "rgraph" "base" "cfg1" "cfg2") + (define-integration-dependencies "rtlbase" "rgraph" "machines/aarch64" + "machine") + (define-integration-dependencies "rtlbase" "rtlcfg" "base" + "cfg1" "cfg2" "cfg3") + (define-integration-dependencies "rtlbase" "rtlcon" "base" "cfg3" "utils") + (define-integration-dependencies "rtlbase" "rtlcon" "machines/aarch64" + "machine") + (file-dependency/integration/join (filename/append "rtlbase" "rtlcon") + rtl-base) + (define-integration-dependencies "rtlbase" "rtlexp" "rtlbase" + "rtlreg" "rtlty1") + (define-integration-dependencies "rtlbase" "rtline" "base" "cfg1" "cfg2") + (define-integration-dependencies "rtlbase" "rtline" "rtlbase" + "rtlcfg" "rtlty2") + (define-integration-dependencies "rtlbase" "rtlobj" "base" + "cfg1" "object" "utils") + (define-integration-dependencies "rtlbase" "rtlreg" "machines/aarch64" + "machine") + (define-integration-dependencies "rtlbase" "rtlreg" "rtlbase" + "rgraph" "rtlty1") + (define-integration-dependencies "rtlbase" "rtlty1" "rtlbase" "rtlcfg") + (define-integration-dependencies "rtlbase" "rtlty2" "machines/aarch64" + "machine") + (define-integration-dependencies "rtlbase" "rtlty2" "rtlbase" "rtlty1") + + (file-dependency/integration/join + (append + (filename/append "base" "refctx") + (filename/append "fggen" + "declar" "fggen") ; "canon" needs no integrations + (filename/append "fgopt" + "blktyp" "closan" "conect" "contan" "delint" "desenv" + "envopt" "folcon" "offset" "operan" "order" "param" + "outer" "reuse" "reteqv" "sideff" "simapp" "simple" + "subfre" "varind")) + (append aarch64-base front-end-base)) + + (define-integration-dependencies "fgopt" "reuse" "fgopt" "reord") + + (file-dependency/integration/join + (filename/append "rtlgen" + "fndblk" "fndvar" "opncod" "rgcomb" "rgproc" "rgretn" + "rgrval" "rgstmt" "rtlgen") + (append aarch64-base front-end-base rtl-base)) + + (file-dependency/integration/join + (append cse-all + (filename/append "rtlopt" "ralloc" "rcompr" "rdebug" "rdflow" + "rerite" "rinvex" "rlife" "rtlcsm") + (filename/append "machines/aarch64" "rulrew")) + (append aarch64-base rtl-base)) + + (file-dependency/integration/join cse-all cse-base) + + (file-dependency/integration/join + (filename/append "rtlopt" "ralloc" "rcompr" "rdebug" "rlife") + (filename/append "rtlbase" "regset")) + + (file-dependency/integration/join + (filename/append "rtlopt" "rcseht" "rcserq") + (filename/append "base" "object")) + + (define-integration-dependencies "rtlopt" "rlife" "base" "cfg2") + + (let ((dependents + (append instruction-base + lapgen-base + lapgen-body + assembler-base + assembler-body + (filename/append "back" "linear" "syerly")))) + (add-declaration! '(USUAL-DEFINITION (SET EXPT)) dependents) + (file-dependency/integration/join dependents instruction-base)) + + (file-dependency/integration/join (append lapgen-base lapgen-body) + lapgen-base) + + (file-dependency/integration/join (append assembler-base assembler-body) + assembler-base) + + (define-integration-dependencies "back" "checks" "base" "cfg1" "cfg2") + (define-integration-dependencies "back" "checks" "rtlbase" + "rtlcfg" "rtlobj" "rtlty1") + (define-integration-dependencies "back" "lapgn1" "base" + "cfg1" "cfg2" "utils") + (define-integration-dependencies "back" "lapgn1" "rtlbase" + "rgraph" "rtlcfg") + (define-integration-dependencies "back" "lapgn2" "rtlbase" "rtlreg") + (define-integration-dependencies "back" "linear" "base" "cfg1" "cfg2") + (define-integration-dependencies "back" "linear" "rtlbase" "rtlcfg") + (define-integration-dependencies "back" "mermap" "back" "regmap") + (define-integration-dependencies "back" "regmap" "base" "utils") + (define-integration-dependencies "back" "symtab" "base" "utils")) + + (for-each (lambda (node) + (let ((links (source-node/backward-links node))) + (if (not (null? links)) + (set-source-node/declarations! + node + (cons (make-integration-declaration + (source-node/pathname node) + (map source-node/pathname links)) + (source-node/declarations node)))))) + source-nodes)) + +(define (make-integration-declaration pathname integration-dependencies) + `(INTEGRATE-EXTERNAL + ,@(map (let ((default + (make-pathname + #f + #f + (cons 'RELATIVE + (make-list + (length (cdr (pathname-directory pathname))) + 'UP)) + #f + #f + #f))) + (lambda (pathname) + (merge-pathnames pathname default))) + integration-dependencies))) + +(define (integration-declaration? declaration) + (eq? (car declaration) 'INTEGRATE-EXTERNAL)) diff --git a/src/compiler/machines/aarch64/instr.scm b/src/compiler/machines/aarch64/instr.scm new file mode 100644 index 000000000..d4b328495 --- /dev/null +++ b/src/compiler/machines/aarch64/instr.scm @@ -0,0 +1,1905 @@ +#| -*-Scheme-*- + +Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, + 2017, 2018, 2019 Massachusetts Institute of Technology + +This file is part of MIT/GNU Scheme. + +MIT/GNU Scheme is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +MIT/GNU Scheme is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with MIT/GNU Scheme; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, +USA. + +|# + +;;;; AArch Instruction Set +;;; package: (compiler lap-syntaxer) + +(declare (usual-integrations)) + +;;; Idea for branch tensioning: in every @PCR, allow an optional +;;; temporary register, like (@PCR