summaryrefslogtreecommitdiff
path: root/module/system
AgeCommit message (Collapse)AuthorFilesLines
2018-07-29Emit instrument-entry before programsAndy Wingo1-37/+45
* module/system/vm/assembler.scm (<jit-data>, <meta>): Rework to have <meta> create the <jit-data> in the end-program, so that jit-data isn't mutable. Record start and end PC values relative to '.rtl-text so that we don't need any more linker symbols. (emit-instrument-entry*, emit-instrument-loop*, begin-program): (end-program): Adapt. (begin-kw-arity): Include the initial instrument-entry in the first arity. (link-data, link-constants): Write the init routine before interning constants so that we correctly emit the jit-data for the init routine. * libguile/programs.c (try_parse_arity): Skip over a scm_op_instrument_entry, if any.
2018-07-29Emit instrument-loop in loops.Andy Wingo1-7/+49
* am/bootstrap.am (SOURCES): * module/Makefile.am (SOURCES): Handle renamve of handle-interrupts.scm to loop-instrumentation.scm. * libguile/jit.h (SCM_JIT_COUNTER_ENTRY_INCREMENT): Rename from SCM_JIT_COUNTER_CALL_INCREMENT. * libguile/vm-engine.c (instrument-entry): Rename from instrument-call. * module/language/cps/compile-bytecode.scm (compile-function): Add handle-interrupts code before calls and returns. Compile the "instrument-loop" primcall to an "instrument-loop" instruction and a "handle-interrupts" instruction. (lower-cps): Adapt to add-loop-instrumentation name change. * module/language/cps/loop-instrumentation.scm: Rename from handle-interrupts.scm and just add "instrument-loop" primcalls in loops. The compiler will add handle-interrupts primcalls as appropriate. * module/system/vm/assembler.scm (<jit-data>): New data type, for emitting embedded JIT data. (<meta>): Add field for current JIT data. (make-meta): Initialize current JIT data. (emit-instrument-entry*, emit-instrument-loop*): New instruction emitters that reference the current JIT data. (end-program): Now that all labels are known, arrange to serialize the JIT data. (link-data): Reserve space for JIT data, and add relocs to initialize the "start" / "end" fields.
2018-07-29Add instrument-call, instrument-loop VM instructionsAndy Wingo1-0/+2
* libguile/jit.h (struct scm_jit_function_data) (enum scm_jit_counter_value): New data types. * libguile/jit.c (scm_jit_compute_mcode, scm_jit_enter_mcode): New function stubs. Adapt label/offset compilers to take pointers. * libguile/vm-engine.c (instrument-call, instrument-loop): New instructions. * libguile/vm.c: Add jit.h include. * module/system/vm/assembler.scm (emit-instrument-call) (emit-instrument-loop): New exports.
2018-07-24Add -Wshadowed-toplevel.Ludovic Courtès1-1/+8
* module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): New variable. * module/language/tree-il/compile-cps.scm (%warning-passes): Add it. * module/system/base/message.scm (%warning-types): Add it. * test-suite/tests/tree-il.test ("warnings")["shadowed-toplevel"]: New test prefix. * module/ice-9/boot-9.scm (%auto-compilation-options): Add it. * doc/ref/api-evaluation.texi (Compilation): Add 'shadowed-toplevel' and 'macro-use-before-definition'.
2018-07-20Multiple-value returns now start from slot 0, not slot 1Andy Wingo1-0/+1
This should reduce frame sizes. * libguile/vm-engine.c (halt): Adapt to multiple-values change. Also adapt to not having the boot closure on the stack. (receive, receive-values, subr-call, foreign-call): Adapt to expect values one slot down. (prompt): Capture one less word for the values return. * libguile/vm.c (vm_dispatch_pop_continuation_hook): (vm_dispatch_abort_hook): Adapt for where to expect values. (vm_builtin_values_code): Add a call to shuffle-down before returning. This is more overhead than what existed before, but the hope is that the savings elsewhere pay off. (vm_builtin_values_code): Adapt to different values location. (reinstate_continuation_x, compose_continuation): Adapt to place resume args at right position. (capture_delimited_continuation): Remove unused sp and ip arguments. (abort_to_prompt): Adapt to capture_delimited_continuation change. (scm_call_n): Adapt to not reserve space for the boot closure. * module/language/cps/compile-bytecode.scm (compile-function): When returning values, adapt reset-frame call for return calling convention change. Adapt truncating or rest returns to expect values in the right place. * module/language/cps/slot-allocation.scm (compute-shuffles): (allocate-lazy-vars, allocate-slots): Allocate values from the "proc slot", not proc-slot + 1. * module/system/vm/assembler.scm (emit-init-constants): Reset the frame before returning so that the return value is in the right place. * test-suite/tests/rtl.test: Update for return convention change. * libguile/foreign.c (get_foreign_stub_code): Update for return calling convention change.
2018-07-20Rework VM approach to shuffling unknown numbers of argsAndy Wingo2-20/+10
* libguile/vm-engine.c (shuffle-down, expand-apply-argument): New instructions. (tail-call, tail-call-label, return-values): Don't reset the frame. The compiler should reset the frame appropriately. (tail-call/shuffle, tail-apply): Remove unused instructions. * libguile/vm.c (vm_builtin_apply_code): Use new shuffle-down and expand-apply-argument opcodes. (vm_builtin_call_with_values_code): Replace tail-call/shuffle with shuffle-down then tail-call. * libguile/jit.c (compile_shuffle_down, compile_expand_apply_argument): Add compiler stubs (COMPILE_X8_F12_F12): New definition. (compile_tail_call_shuffle, compile_tail_apply): Remove unused compilers. * module/language/cps/compile-bytecode.scm (compile-function): Emit reset-frame before tail calls and returns. * module/system/vm/assembler.scm (system): Remove unbound "emit-return" export. * module/system/vm/disassembler.scm (code-annotation) (instruction-has-fallthrough?, define-stack-effect-parser): Adapt for opcode changes.
2018-07-20Reserve frame word for machine return addressAndy Wingo1-1/+1
* libguile/frames.h: Add machine return address to diagram. (SCM_FRAME_MACHINE_RETURN_ADDRESS): (SCM_FRAME_SET_MACHINE_RETURN_ADDRESS): New macros. (SCM_FRAME_PREVIOUS_SP): (SCM_FRAME_DYNAMIC_LINK): (SCM_FRAME_SET_DYNAMIC_LINK): Adapt for new frame size. * libguile/vm-engine.c (halt): Set frame size to 3. (call, call-label): Set mRA to 0. * libguile/vm.c (push_interrupt_frame, reinstate_continuation_x): (scm_call_n): Set frame size to 3. In push_interrupt_frame, init the mRA of the frame. (vm_builtin_call_with_values_code, vm_handle_interrupt_code): Allocate larger frames. * module/language/cps/slot-allocation.scm (allocate-slots): Frame size is 3. * module/system/vm/disassembler.scm (define-clobber-parser): Bump frame size.
2018-07-20Prepare for frames having separate virtual and machine return addrsAndy Wingo1-1/+2
* libguile/frames.c (scm_frame_return_address): Use SCM_FRAME_VIRTUAL_RETURN_ADDRESS. (scm_c_frame_previous): Likewise. * libguile/frames.h: Update diagram for new names. (union scm_vm_stack_element): Rename "as_ip" to "as_vcode", and add "as_mcode" for machine code pointers. (SCM_FRAME_VIRTUAL_RETURN_ADDRESS) (SCM_FRAME_SET_VIRTUAL_RETURN_ADDRESS): Rename to these, from SCM_FRAME_RETURN_ADDRESS and SCM_FRAME_SET_RETURN_ADDRESS. * libguile/vm-engine.c (halt, call, call-label, return-values) (return-from-interrupt): Adapt to renamings. Make "halt" have frame size as a parameter. * libguile/vm.c (scm_i_vm_mark_stack): Adapt to renaming. (push_interrupt_frame): Take mRA as additional argument. In future we will set it as frame mRA. (capture_continuation): Adapt to renaming. (scm_call_n): Adapt to renaming and make frame size adjustable. (push_interrupt_frame, reinstate_continuation_x): Make frame size adjustable. * module/language/cps/slot-allocation.scm (allocate-slots): Make frame size adjustable. * libguile/intrinsics.h (scm_t_thread_mra_intrinsic): New type; use for push_interrupt_frame. (scm_t_thread_u8_scm_sp_vra_intrinsic): Rename from the same but was "ra" instead of "vra", and change type to uint32_t*. * module/system/vm/disassembler.scm (define-clobber-parser): Parameterize clobber set for calls by frame size.
2018-06-28linker: Don't rely on out-of-range bv-ref exceptions.Ludovic Courtès1-3/+3
* module/system/vm/linker.scm (find-shstrndx): Check whether NAME is lower than the length of BV; remove 'false-if-exception' around 'string-table-ref' call.
2018-06-27Compile current-module as intrinsic callAndy Wingo1-1/+5
* libguile/fluids.c (scm_i_fluid_ref): New internal function. (scm_fluid_ref): Use scm_i_fluid_ref. * libguile/intrinsics.h: * libguile/intrinsics.c (current_module): New intrinsic. * libguile/modules.c (scm_i_current_module): New internal function. (scm_current_module): Use new internal function. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add current-module as an intrinsic primitive. * module/system/vm/assembler.scm (define-scm<-thread-intrinsic): (current-module): Arrange to compile to intrinsic call.
2018-06-24types: Recognize 'scm_t_port_type' and decode port type name.Ludovic Courtès1-6/+30
* module/system/base/types.scm (read-c-string, inferior-port-type): New procedures. (inferior-port): Use 'inferior-port-type' to determine the port type. (cell->object): Rename 'flags+type' to 'flags' in the '%tc7-port' case. * test-suite/tests/types.test ("opaque objects"): Adjust port testse. (test-inferior-ports): New macro. ("ports"): New test prefix.
2018-06-11elisp: Fix cross-compilation support.Mark H Weaver1-2/+8
* module/system/base/target.scm (with-native-target): New exported procedure. * module/language/elisp/spec.scm: In the top-level body expression, call 'compile-and-load' within 'with-native-target' to compile native code. * module/language/elisp/compile-tree-il.scm (eval-when-compile, defmacro): Compile native code.
2018-05-14Compile "define!" via intrinsicAndy Wingo1-1/+2
* libguile/intrinsics.c (scm_bootstrap_intrinsics): * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add new define! intrinsic. * module/language/cps/compile-bytecode.scm (compile-function): Adapt compilation for define! to take two arguments. * module/language/cps/effects-analysis.scm (current-module): Update define! for two arguments. * module/language/tree-il/compile-cps.scm (convert): When reifying "define", grab the current module. * module/system/vm/assembler.scm (define!): Define assembler as intrinsic.
2018-05-14Remove backend support for cached-module-box et al.Andy Wingo3-42/+5
* module/language/cps/compile-bytecode.scm (compile-function): Remove unused assemblers for cached-module-box, cached-toplevel-box, and cache-current-module!. * module/language/cps/effects-analysis.scm (&cache): New memory kind. (cache-current-module!): Set &cache memory, not &box. (resolve-module, lookup-module, cache-ref, cache-set!): Add effect annotations. * module/system/vm/assembler.scm (emit-cache-current-module!) (emit-cached-toplevel-box, emit-cached-module-box): Remove assemblers. * module/system/vm/disassembler.scm (code-annotation, fold-code-range): Remove special cases for toplevel-box and module-box. * module/system/xref.scm (program-callee-rev-vars): Add a FIXME for the future.
2018-05-14Add cache-ref, cache-set! macro-instructionsAndy Wingo1-13/+16
* module/system/vm/assembler.scm (<cache-cell>): Remove "scope" member. Just be an opaque key comparable with equal?. (intern-cache-cell): Remove scope arg. (intern-module-cache-cell): Remove; callers use intern-cache-cell now. (cache-current-module!, cached-toplevel-box, cached-module-box): Create cache keys that by construction won't collide between types. (cache-ref, cache-set!): Add new macro assemblers. * module/language/cps/reify-primitives.scm: * module/language/cps/compile-bytecode.scm: Add cases for new macro instructions.
2018-05-14Add intrinsics for module operationsAndy Wingo1-0/+7
* libguile/intrinsics.c (scm_bootstrap_intrinsics): * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): * module/system/vm/assembler.scm (resolve-module, lookup): New intrinsics. * module/language/cps/compile-bytecode: Add cases for primcalls corresponding to new intrinsics.
2018-05-01lsh, rsh etc are intrinsicsAndy Wingo1-4/+11
* libguile/intrinsics.c (lsh, rsh, lsh_immediate, rsh_immediate): New intrinsics. (scm_bootstrap_intrinsics): Wire up the intrinsics. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add new intrinsics. * libguile/vm-engine.c (call-scm<-scm-u64): New intrinsic caller. (lsh, rsh, lsh/immediate, rsh/immediate): Disable. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add new intrinsics. * module/system/vm/assembler.scm: Adapt assemblers for new intrinsics.
2018-04-29push and pop dynamic state via intrinsicsAndy Wingo1-5/+10
* libguile/intrinsics.c (push_dynamic_state, pop_dynamic_state): New intrinsics. (scm_bootstrap_intrinsics): Add new intrinsics. * libguile/intrinsics.h: Declare new intrinsics. * libguile/vm-engine.c (call-thread-scm): New intrinsic caller. (push-dynamic-state, pop-dynamic-state): Disable. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add new intrinsics. * module/system/vm/assembler.scm (push-dynamic-state) (pop-dynamic-state): Emit as intrinsics.
2018-04-29Intrinsics for dynamic state instructionsAndy Wingo1-6/+12
* libguile/intrinsics.c (wind, unwind, push_fluid, pop_fluid) (fluid_ref): New intrinsics. (scm_bootstrap_intrinsics): Wire them up. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Declare new intrinsics. * libguile/vm-engine.c (wind, unwind, push_fluid, pop_fluid) (fluid_ref): Disable these instructions. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add new intrinsics. * module/system/vm/assembler.scm (wind, unwind, push_fluid, pop_fluid) (fluid_ref): Assemble as intrinsics.
2018-04-29Add support for dynamic-state-related intrinsicsAndy Wingo1-0/+19
* libguile/vm-engine.c (call-thread, call-thread-scm-scm) (call-scm<-thread-scm): New intrinsics. * module/system/vm/assembler.scm (define-thread-scm-scm-intrinsic) (define-thread-intrinsic, define-scm<-thread-scm-intrinsic): New helpers. (encode-X8_S12_S12-C32!/shuffle): New shuffler. * libguile/intrinsics.h: Add new intrinsic types.
2018-04-13Explode atomic box ops to new atomic instructionsAndy Wingo3-6/+10
* libguile/instructions.c (FOR_EACH_INSTRUCTION_WORD_TYPE): Add C8_S24 word type. * libguile/vm-engine.c (UNPACK_8_24): New helper. (atomic-scm-ref/immediate, atomic-scm-set!/immediate) (atomic-swap-scm!/immediate, atomic-scm-compare-and-swap!/immediate): New instructions. (make-atomic-box, atomic-box-ref, atomic-box-set!, atomic-box-swap!) (atomic-box-compare-and-swap!): Disable these ops. * module/language/bytecode.scm (compute-instruction-arity): Add C8_S24 support. * module/system/vm/assembler.scm: Add C8_S24 support. Export assemblers for new opcodes. * module/system/vm/disassembler.scm (disassembler): Support C8_S24. * module/language/cps/compile-bytecode.scm (compile-function): Replace old atomic-box assemblers with the new instructions. * module/language/cps/effects-analysis.scm (annotation->memory-kind): * module/language/cps/types.scm (annotation->type): Add cases for atomic boxes. Mark as all memory kinds because atomic ops serialize memory accesses. * module/language/tree-il/compile-cps.scm (make-atomic-box): (ensure-atomic-box, atomic-box-ref, atomic-box-set!): (atomic-box-swap!, atomic-box-compare-and-swap!): Explode these ops to more basic instructions. * module/system/base/types/internal.scm (%tc7-atomic-box): Add forgotten export.
2018-04-12logsub is intrinsicAndy Wingo1-1/+2
* libguile/intrinsics.h: * libguile/intrinsics.c (logsub): New intrinsic. (scm_bootstrap_intrinsics): Init new intrinsic. * libguile/vm-engine.c (logsub): Disable. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add logsub. * module/system/vm/assembler.scm: Update logsub intrinsic assembler.
2018-04-12u64->scm, s64->scm intrinsicsAndy Wingo1-2/+10
* libguile/intrinsics.h (u64->scm, s64->scm): New intrinsics. * libguile/intrinsics.c (scm_bootstrap_intrinsics): Initialize new intrinsics. * libguile/vm-engine.c (call-scm<-u64, call-scm<-s64): New intrinsic callers. (u64->scm, s64->scm): Disable instructions. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add new intrinsics as macro-instructions. * module/system/vm/assembler.scm (define-scm<-u64-intrinsic): (define-scm<-s64-intrinsic, u64->scm, s64->scm): Wire up new intrinsics.
2018-04-12scm->u64, scm->s64, scm->u64/truncate intrinsicsAndy Wingo1-3/+12
* libguile/intrinsics.c (scm_to_uint64_truncate): New intrinsic. (scm_bootstrap_intrinsics): Init new intrinsics. * libguile/intrinsics.h: Add scm->u64, scm->u64/truncate, and scm->s64 as intrinsics, with their corresponding types. * libguile/vm-engine.c (call-u64<-scm, call-s64<-scm): New intrinsic calling ops. (scm->u64, scm->s64, scm->u64/truncate): Disable opcodes. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add intrinsics as new macroinstructions. * module/system/vm/assembler.scm: Declare new intrinsic assemblers.
2018-04-10Disable f64->scm instructionAndy Wingo1-1/+0
* libguile/vm-engine.c (f64->scm): Disable instruction. * module/language/cps/compile-bytecode.scm (compile-function): Remove f64->scm case. * module/system/vm/assembler.scm: Remove emit-f64->scm export.
2018-04-10Slim heap-allocated flonumsAndy Wingo1-2/+2
* libguile/numbers.h (struct scm_t_double, struct scm_t_complex): Avoid adding an extra padding word on systems with 8-byte pointers. * module/system/base/types.scm (cell->object): Update to compute correct offset of embedded double.
2018-04-10Add scm->f64 intrinsicAndy Wingo1-1/+5
* libguile/vm-engine.c (call-f64<-scm): New intrinsic kind. (scm->f64): Disable instruction. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): * libguile/intrinsics.c (scm_bootstrap_intrinsics): * module/language/cps/reify-primitives.scm (compute-known-primitives): * module/system/vm/assembler.scm (define-f64<-scm-intrinsic): Add scm->f64.
2018-04-10Class-of is intrinsicAndy Wingo1-1/+2
* libguile/vm-engine.c (class-of): Disable. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add class-of as macro-instruction. * libguile/intrinsics.c (scm_bootstrap_intrinsics): Add class-of. * libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS): Add class-of. * module/system/vm/assembler.scm (class-of): Define as intrinsic.
2018-04-10string->number, etc intrinsicsAndy Wingo1-3/+18
* libguile/intrinsics.c (string_to_number): New helper. (scm_bootstrap_intrinsics): Init new intrinsics. * libguile/intrinsics.h (string->number, string->symbol) (symbol->keyword): Add new intrinsics. * libguile/vm-engine.c (call-scm<-scm): New intrinsic dispatcher. (string->number, string->symbol, symbol->keyword): Disable these instructions. * module/system/vm/assembler.scm (encode-X8_S12_S12-C32<-/shuffle): (define-scm<-scm-intrinsic): Enable scm<-scm intrinsics. (string->number, string->symbol, symbol->keyword): New intrinsic assemblers.
2018-04-10Add $code CPS expression typeAndy Wingo1-1/+0
* module/language/cps.scm ($code): New CPS type, for labels as values. Add cases to all CPS type dispatches. $closure now indicates only statically allocated closures. * module/language/cps/closure-conversion.scm (convert-one): Only reify $closure for statically allocated procedures. Otherwise allocate an object using low-level primitives. * module/language/cps/compile-bytecode.scm (compile-function): Remove make-closure case. * module/language/cps/slot-allocation.scm (compute-var-representations): $code produces a u64 value. * module/system/vm/assembler.scm: Remove make-closure export. * module/language/cps/contification.scm: * module/language/cps/cse.scm: * module/language/cps/dce.scm: * module/language/cps/devirtualize-integers.scm: * module/language/cps/effects-analysis.scm: * module/language/cps/licm.scm: * module/language/cps/peel-loops.scm: * module/language/cps/renumber.scm: * module/language/cps/rotate-loops.scm: * module/language/cps/simplify.scm: * module/language/cps/specialize-numbers.scm: * module/language/cps/types.scm: * module/language/cps/utils.scm: * module/language/cps/verify.scm: Add cases for $code.
2018-04-10Add load-label instructionAndy Wingo2-0/+10
* libguile/vm-engine.c (load-label): New instruction. * module/system/vm/assembler.scm: Add emit-load-label. * module/system/vm/disassembler.scm (code-annotation): (fold-code-range): Add load-label support.
2018-04-10Instruction explosion for char->integerAndy Wingo1-1/+0
* module/language/cps/effects-analysis.scm: * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/types.scm: * module/language/cps/compile-bytecode.scm (compile-function): Remove char->integer cases. * module/system/vm/assembler.scm: Remove emit-char->integer export. * module/language/tree-il/compile-cps.scm (char->integer): Define instruction exploder.
2018-04-10Remove integer->char opAndy Wingo1-1/+0
* libguile/vm-engine.c (integer->char): Remove unused op. * module/language/cps/types.scm: * module/language/cps/effects-analysis.scm: * module/language/cps/compile-bytecode.scm (compile-function): Remove integer->char cases. * module/system/vm/assembler.scm: Remove emit-integer->char.
2018-04-10Explode "string-set!"Andy Wingo1-1/+2
* module/language/cps/effects-analysis.scm (string-ref): Remove effects declaration, given that the primitive is exploded now. * module/language/cps/reify-primitives.scm (compute-known-primitives): Add string-set!. * libguile/vm-engine.c (string-set!): Disable opcode. * module/language/cps/types.scm (string-ref, string-set!): Remove type checker and inferrers for string-ref and string-set!, as both are exploded. In the case of string-set! there are still type-check effects in the intrinsic call but they can't be elided by the checker, as we don't track when strings are read-only. * module/language/tree-il/compile-cps.scm (ensure-char): New helper. (string-set!): New primcall exploded converter.
2018-04-10Add string-set! intrinsicAndy Wingo1-0/+14
* libguile/intrinsics.c (string_set_x): New intrinsic. (scm_bootstrap_intrinsics): Initialize intrinsic. * libguile/intrinsics.h: Add string-set! intrinsic. * libguile/vm-engine.c (call-scm-u64-u64): New intrinsic trampoline. * module/system/vm/assembler.scm (encode-X8_S8_S8_S8-C32!/shuffle): New shuffling encoder. (define-scm-u64-u64-intrinsic): New helper.
2018-04-09Remove now-unused string-length, string-refAndy Wingo1-2/+0
* libguile/vm-engine.c (string-length, string-ref): Remove instructions. * module/system/vm/assembler.scm: Remove assembler exports as well.
2018-04-08Add VM ops needed for string-refAndy Wingo1-0/+3
* libguile/vm-engine.c (tail-pointer-ref/immediate, tag-char) (untag-char): New instructions. * module/language/cps/compile-bytecode.scm (compile-function): Add support for new instructions. * module/language/cps/cse.scm (compute-equivalent-subexpressions): CSE cases for tag-char / untag-char. * module/language/cps/effects-analysis.scm: * module/language/cps/types.scm: Add cases for new primcalls. * module/language/cps/reify-primitives.scm (reify-primitives): Update comment. * module/language/cps/slot-allocation.scm (compute-var-representations): Add cases for untag-char, tail-pointer-ref/immediate. * module/language/cps/specialize-primcalls.scm (specialize-primcalls): Add untag-char case, and add FIXME comment for tag-char. * module/system/vm/assembler.scm: Export new assemblers.
2018-03-30Compile some generic arithmetic to intrinsic callsAndy Wingo1-12/+54
* libguile/intrinsics.h: Rename intrinsic types added in previous commit. * libguile/vm-engine.c (call-scm<-scm-scm, call-scm<-scm-uimm): New instructions. * libguile/vm.c: Include intrinsics.h. * module/language/bytecode.scm * module/language/bytecode.scm (*intrinsic-codes*, *intrinsic-names*): New internal definitions. (intrinsic-name->index, intrinsic-index->name): New exported definitions. * module/system/vm/assembler.scm (encode-X8_S8_S8_S8-C32<-/shuffle): (encode-X8_S8_S8_C8-C32<-/shuffle): New shuffling encoders. (shuffling-encoder-name): Add case for new shuffling encoders. (define-scm<-scm-scm-intrinsic, define-scm<-scm-uimm-intrinsic): New helpers. Define encoders for "add", etc.
2018-03-15Recognize RISC-V compilation targets.Shea Levy1-0/+2
* module/system/base/target.scm (cpu-endianness): Add case for "riscv" variants. Signed-off-by: Shea Levy <shea@shealevy.com> Signed-off-by: Mark H Weaver <mhw@netris.org>
2018-01-22Remove unneeded assembly shuffle routines.Andy Wingo1-17/+0
* module/system/vm/assembler.scm (encode-X8_S12_S12-X8_C24!/shuffle) (encode-X8_S12_S12-X8_C24<-/shuffle): Remove now-unneeded shufflers.
2018-01-22Remove free-ref, free-set!Andy Wingo2-4/+0
* libguile/vm-engine.c (free-ref, free-set!): Remove ops. * module/language/cps/effects-analysis.scm: * module/system/vm/assembler.scm: * module/system/vm/disassembler.scm (code-annotation): * module/language/cps/compile-bytecode.scm (compile-function): Remove support for free-ref / free-set!.
2018-01-22Remove optimizer and backend support for struct opsAndy Wingo1-7/+0
* module/language/cps/compile-bytecode.scm: * module/language/cps/cse.scm: * module/language/cps/effects-analysis.scm: * module/language/cps/reify-primitives.scm: * module/language/cps/specialize-primcalls.scm: * module/language/cps/types.scm: * module/language/tree-il/cps-primitives.scm: * module/system/vm/assembler.scm: Remove support for struct-ref, struct-set!, allocate-struct, struct-vtable CPS primcalls and bytecode instructions.
2018-01-16Remove optimizer and backend support for bv-u8-ref et alAndy Wingo1-21/+0
* module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/effects-analysis.scm: * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/types.scm: * module/system/vm/assembler.scm: Remove optimizer and backend support for bv- ops.
2018-01-14Rename gc-pointer-ref to pointer-refAndy Wingo2-4/+4
The pointer dereferencing instructions will keep the pointer alive by referencing a containing object. * module/language/cps/compile-bytecode.scm: * libguile/vm-engine.c: * module/language/cps/cse.scm: * module/language/cps/effects-analysis.scm: * module/language/cps/reify-primitives.scm: * module/language/cps/slot-allocation.scm: * module/language/cps/specialize-primcalls.scm: * module/language/cps/types.scm: * module/system/vm/assembler.scm: * module/system/vm/debug.scm: Rename instructions.
2018-01-14Add raw u8-ref, etc instructionsAndy Wingo1-0/+21
* libguile/vm-engine.c (PTR_REF, PTR_SET): New helper macros. (u8-ref, u16-ref, u32-ref, u64-ref, s8-ref, s16-ref, s32-ref, s64-ref) (u8-set!, u16-set!, u32-set!, u64-set!, s8-set!, s16-set!, s32-set!, s64-set!) (f32-ref, f64-ref, f32-set!, f64-set!): New instructions. * module/system/vm/assembler.scm: * module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/types.scm: Add optimizer and backend support for the new instructions.
2018-01-10Add optimizer and backend support for gc-pointer-refAndy Wingo1-0/+3
* module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/cse.scm (compute-equivalent-subexpressions): * module/language/cps/effects-analysis.scm: * module/language/cps/reify-primitives.scm (reify-primitives): * module/language/cps/slot-allocation.scm (compute-var-representations): * module/language/cps/specialize-primcalls.scm (specialize-primcalls): * module/language/cps/types.scm (gc-pointer-ref/immediate): (gc-pointer-set!/immediate): * module/system/vm/assembler.scm: Add support for pointer-ref.
2018-01-10Add support for raw gc-managed pointer localsAndy Wingo2-4/+6
* libguile/vm-engine.c (gc-pointer-ref/immediate) (gc-pointer-set!/immediate): New instructions. (SP_REF_PTR, SP_SET_PTR): New helper definitions. * libguile/vm.c (SLOT_DESC_LIVE_GC): Rename from SLOT_DESC_LIVE_SCM, as it can indicate GC-protected raw pointers also. (scm_i_vm_mark_stack): Adapt. * module/system/vm/assembler.scm (write-arities): * module/system/vm/debug.scm (arity-definitions): Add gcptr representation. This is a binary-incompatible change!
2018-01-10Remove box instructionsAndy Wingo1-3/+0
* libguile/vm-engine.c (box, box-ref, box-set!): Remove these instructions. * module/system/vm/assembler.scm: Remove assemblers for box-ref et al. * libguile/vm.c (vm_error_not_a_variable): Remove unused function.
2018-01-07Remove special optimizer and backend support for pairsAndy Wingo1-5/+0
* module/language/cps/compile-bytecode.scm (compile-function): * module/language/cps/cse.scm (compute-equivalent-subexpressions): * module/language/cps/dce.scm (compute-live-code): * module/language/cps/effects-analysis.scm: * module/language/cps/types.scm: Remove support for cons, car, etc primcalls. * module/language/cps/effects-analysis.scm (&car, &cdr): Remove undefined exports. * module/system/vm/assembler.scm: Remove emit-cons, etc exports.
2018-01-07Re-add compiler backend support for immutable vectorsAndy Wingo1-0/+2
* module/language/cps/compile-bytecode.scm (compile-function): Add cases for mutable-vector? and immutable-vector?. * module/system/vm/assembler.scm: Export emit-mutable-vector? and emit-immutable-vector?.