Make makegen/m4.sh report m4 failure by returning 1.
Previously, the return code of m4 was totally ignored, because it was
invoked only in a pipeline not at the end. Because of brain damage
in shell script, we have to use a temporary file to let the subshell
in which we run m4 report the failure to the script so that the
script can know to return 1.
Matt Birkholz [Sat, 10 Apr 2010 23:20:27 +0000 (16:20 -0700)]
Got the svm1 back end to assemble... something.
No disassembler yet. Added lapgen rules until it compiled the whole
system.
* src/Makefile.in (microcode/svm1-defns.h): Detect changes to machine
definition and re-compile it, BEFORE compile-microcode.
(subdir-list): New. Cough up SUBDIRS.
* src/Stage.sh: New. Uses `make subdir-list' to get SUBDIRS from the
Makefile, allowing this script to be invoked with arguments, via
shell command line, not make.
* src/compiler/Clean.sh: Added make.bin to the remove list.
* src/compiler/Stage.sh, src/etc/Stage.sh (make-cross): This new Stage
command stashes compilation AND cross-compilation products.
* src/compiler/machines/svm/assembler-compiler.scm: Added rule-matcher
anti-syntax, so that assembler-runtime.scm can be loaded.
* src/compiler/machines/svm/assembler-rules.scm: Changed the offset
addressing mode to take signed 8 and 16 bit offsets.
* src/compiler/machines/svm/assembler-runtime.scm: Added variable-width
instruction encoders to the fixed-width encoders of the machine
description.
Punted symbolic-expressions. All such are now passed up to the assembler
top-level.
(match-pattern): Get the list of values leftmost-first.
(register-reference?): Punt these redundant definitions. Register
references are now part of machine.scm.
(any-register?, word-register?, float-register?): Not used.
(word-register-reference?, float-register-reference?): Use the register
reference munging procedures.
(encode-rref): The machine expects float register numbers to start with 0.
* src/compiler/machines/svm/compile-assembler.scm: Load assembler-compiler
before assembler-runtime.
* src/compiler/machines/svm/compiler.pkg: Import instructions;
add-instruction! is not sufficient for this assembler. And the register
reference procedures are now in scope via the (compiler) package.
* src/compiler/machines/svm/lapgen.scm: Punt environment register. Move
register reference procedures to machine.scm.
Fixed applications of inst:copy.
Use BLOCK-OFFSET directives in external labels.
Move evaluation of parse-memory-address rule bodies into lapgen rule
bodies, where procedures like word-source can gen. LAP.
* src/compiler/machines/svm/machine.scm: Added a new fixed register -- the
interpreter-register-block -- for easy access to the interpreter's
interrupt-mask, lexpr-actuals, etc. Punted the environment register, now
accessible via interpreter-register-block.
(define-generic-unary-operations, define-generic-binary-operations):
Punted. These instructions do not need type parameters. Added them to the
corresponding define-bi/unary-operations lists.
(load-immediate-operand?): Typo.
(ea:environment, ea:lexpr-actuals): New, using the new interpreter-
register-block register.
Fixed the other ea: procedures to use register references, not numbers.
(define-traps): Allow the C-friendly synonyms to be specified. Provide the
necessary synonyms for +, -, *, /, 1+, -1+, =, < and >. Punt non-existent
traps: the lookup-apply, conditionally-serialize and *-trap traps. The
reference-trap trap is actually the lookup trap. The unassigned?-trap trap
is actually the unassigned? trap. Etc.
(register-reference, register-reference?, etc.): Create the fixed registers
and register references from one list. Provide the register reference
procedures here, for the (compiler assembler) and (compiler lap-syntaxer)
packages, AND assembler-compiler.
* src/compiler/machines/svm/make.scm: Initialize the assembler instructions.
* src/compiler/machines/svm/rules.scm: Get the right type of target/source
for inst:load/store.
Fixed applications of inst:copy, inst:increment.
Expect a thunk from parse-memory-address.
There is no single-arg predicate LT, but there is an SLT.
(OVERFLOW-TEST): Without a register argument (or implicit condition
register) fixnum methods must test for overflow.
Added a few rules to recognize float constants being loaded into registers,
used as the second arg. in flonum-pred-2-args instructions, or as an
argument to flonum-1/2-arg instructions.
Get the correct type of register for flonum instructions.
(INVOCATION:CACHE-REFERENCE): Punt fixed registers. Use the extension
register if possible, and temporaries for the rest.
(INVOCATION:LOOKUP): No such utility, and the lookup-apply trap is no more.
(INVOCATION:PRIMITIVE): trap:primitive-lexpr-apply takes just one arg.
Store the arg count in the interpreter's lexpr-actuals register.
(move-frame-up): Compare registers (numbers), not references. The arg is a
reference.
inst:load-pointer does not take an address, just a register.
(generate/closure-header): Don't skip the external/internal equate when
nentries is zero.
(generate/quotation-header, generate/remote-link): Rename registers to
indicate usage.
(generate/remote-links): Keep the interpreter's environment in a temporary
register.
Typos.
Punted several rewrite rules that replace registers with their known
values. This is useless here, where instructions like + and load-pointer
only take register operands.
* src/etc/compile-svm.sh: Re-written to do a proper cross-compilation, with
host-compiled cross-compiler. Swaps host and cross compiler products
in/out of stages X and 0, respectively. Thus a rebuild does not have to
recompile much, not even the previously cross-compiled files.
* src/etc/create-makefiles.sh, src/microcode/makegen/makeinit.sh: Use
--batch-mode.
* src/etc/functions.sh (run_cmd_in_dir): Echo dir name as well as command
line.
(maybe_mv): New. Punts moving e.g. *.moc if there are none.
* src/microcode/svm1-defns.h: New machine definition. See changes to
assembler-rules.scm and machine.scm.
* src/microcode/svm1-interp.c (initialize_svm1): Initialize new fixed
register interpreter-register-block. Fix initialization of the float
registers.
(rt-defn-decoder-constructor): Removed leftover references to
coding-type, which became an implicit rt-coding-type parameter.
* src/compiler/machines/svm/assembler-runtime.scm
(init-assembler-instructions!): New skeleton. Error actions.
(make-symbol-table): Renamed "make-typed-symbol-table", to keep it
distinct from back/symtab.scm's "symbol-table", which is used by the
assembler top-level (back/bittop.scm, back/bitutl.scm).
(Assembler Machine Dependencies): New. Just the required (per CREF
analysis) bindings, pilfered from i386/assmd.scm.
(Instructions, Memory addressing, Traps, Machine registers): Removed
to machine.scm.
(Register references): Removed to lapgen.scm, except
word-register-reference? and float-register-reference?. Then had to
copy register-reference?, and import register-reference AND
reference->register.
(Symbolic addresses): Commented out for now.
* src/compiler/machines/svm/compile-assembler.scm: Punt loading
write-mit-scheme-copyright from ../../../runtime/version, and the
commented out LAP macrology.
* src/compiler/machines/svm/compiler.pkg (compiler lap-syntaxer):
Include CREF, for decls.scm. Moved assembler-runtime.scm,
assembler-db.scm, and svm1-opcodes.scm to (compiler assembler).
(compiler assembler): Added back/symtab.scm to complete the
machine-independent assembler top-level. Import from (compiler
lap-syntaxer) some of the register-reference procedures that just
moved to lapgen.scm. Import add-instruction!.
* src/compiler/machines/svm/compiler.sf: Load option SF. This file is
intended to run in a band withOUT an existing (compiler) package.
* src/compiler/machines/svm/decls.scm (init-packages): No longer used.
(setup-source-nodes! env): Typo.
* src/compiler/machines/svm/disassembler.scm: For now a no-op.
Deleted the code copied verbatim from i386/dassm1.scm.
(Register references): New from assembler-runtime.
(register-reference): Fixed to include the
un-available-machine-registers.
(rref:word-0, etc.): New.
(make-internal-procedure-label): Fixed to use new
encode-internal-procedure-offset.
(encode-internal-procedure-offset): New. Copied from
encode-continuation-offset.
(invert-condition): Make conditions a proper alist.
(interpreter-call-argument?, interpreter-call-temporary)
(rtl:simple-offset?, simple-offset->ea!): New from i386, like
interpreter-call-argument->machine-register!, BUT uses
prefix-instructions!, if necessary, and a temporary which, with Good
Luck, will use the same alias as the argument.
(parse-memory-address): Fixed to avoid thinking (un-thunking?) #f.
* src/compiler/machines/svm/lapopt.scm (optimize-linear-lap): Now a
no-op. Deleted the code copied verbatim from i386/lapopt, i.e. all of
it.
* src/compiler/machines/svm/machine.scm (Architecture Parameters):
Needed endianness, scheme-datum-width, and some *-fixnum/*-limit
bindings.
(Instructions, Memory addressing, Traps, Machine registers): New from
assembler-runtime.scm. This makes the regnum:*, inst:*, trap:* and
ea:* bindings available to (compiler lap-syntaxer) AND (compiler
lap-optimizer), assuming the latter eventually wants to generate some
LAP, as in other back-ends.
(interpreter-register:environment, etc.): New from i386.
(define-machine-register): Closing the syntactic environment around
e.g., interpreter-value-register, causes it to be renamed. Generate
defines with bare symbols for binding names.
(rtl:machine-register?): Map ALL registers, including dynamic-link,
environment, and all of the interpreter-call-result: registers.
(Closure format): Added a closure-entry-size binding, as in other
architectures, a reflection of CLOSURE_ENTRY_SIZE in
microcode/cmpintmd/svm1.h.
* src/compiler/machines/svm/make.scm: New. Cribbed from i386.
* src/compiler/machines/svm/rgspcm.scm: Typo.
* src/compiler/machines/svm/rules.scm: Fixed some typos, e.g. source
vs. target, trap:[compiler-]lexpr-apply, etc. Added a few rules for
CONSTANTs and CONS-POINTERs. Expect just an effective address from
parse-memory-address.
(interrupt-check): Punted, along with shared closure interrupt code.
simple-procedure-header only needs to generate an interrupt-test-*
instruction.
(generate/cons-closure, generate/cons-multi-closure): Replaced the old
i386 code.
(generate/closure-header): Replaced the old i386 code. Use
simple-procedure-header.
(generate/make-magic-closure-constant, make-closure-longword)
(make-closure-code-longword): Punted. Compiled closure entries do not
even have a format word!
(CONS-MULTICLOSURE, generate/quotation-header, generate/remote-link)
(generate/remote-links): Replaced the old i386 code.
(INTERPRETER-CALL:): Provide interpreter-call-temporary argument to
the trap:* instructions.
(integer-power-of-2?): Added, for FIXNUM-2-ARGS.
* src/configure.ac (ALL_TARGET): Set to "all-svm".
* src/etc/compile-svm.sh: New.
* src/microcode/cmpintmd/svm1.c, svm1.h: Extern read_u16, for
svm1-interp.
* src/microcode/option.c (add_to_library_path, quote_string)
(strlen_after_quoting, must_quote_char_p): Removed. No longer in use.
* src/microcode/svm1-interp.c (enter_closure): Use CLOSURE_COUNT_SIZE,
CLOSURE_ENTRY_SIZE, skip_compiled_closure_padding and read_u16. This
makes enter_closure look like the other closure handling procedures in
cmpintmd/svm1.c.