* include/lightning/jit_private.h: Add new register classes to
flag float registers and double only registers, required for sparc64
where only low 32 bit fpr registers can be used for single precision
operations.
Add new 128 bit jit_regset_t type for sparc64 register set.
* include/lightning/jit_sparc.h, lib/jit_sparc-cpu.c, lib/jit_sparc-fpu.c,
lib/jit_sparc-sz.c, lib/jit_sparc.c: Update for 64 bits sparc.
* lib/lightning.c: Update for new jit_regset_t required for sparc64.
* include/lightning.h, include/lightning/jit_private.h,
lib/jit_aarch64-cpu.c, lib/jit_aarch64.c,
lib/jit_alpha-cpu.c, lib/jit_alpha.c,
lib/jit_arm-cpu.c, lib/jit_arm.c,
lib/jit_hppa-cpu.c, lib/jit_hppa.c,
lib/jit_ia64-cpu.c, lib/jit_ia64.c,
lib/jit_mips-cpu.c, lib/jit_mips.c,
lib/jit_ppc-cpu.c, lib/jit_ppc.c,
lib/jit_s390-cpu.c, lib/jit_s390.c,
lib/jit_sparc-cpu.c, lib/jit_sparc.c,
lib/jit_x86-cpu.c, lib/jit_x86.c: Implement the new
jit_allocar(offs, size) interface, that receives
two integer registers arguments, allocates space
dynamically in the stack, returns the offset in
the first argument, and uses the second argument
for the size in bytes of the memory to be allocated.
* check/allocar.ok, check/allocar.tst: New files
implementing test cases for the new jit_allocar
interface.
* check/Makefile.am, check/lightning.c: Update for
the new test case and interface.
* doc/body.texi: Add documentation of the new
interface.
* include/lightning.h: Split jit_htonr in the new 3 interfaces
jit_htonr_us, jit_htonr_ui and jit_htonr_ul, the later only
available on 64 bit. The plain/untyped jit_htonr macro call
maps to the wordsize one.
* lib/jit_aarch64-cpu.c, lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
lib/jit_alpha-cpu.c, lib/jit_alpha-sz.c, lib/jit_alpha.c,
lib/jit_arm-cpu.c, lib/jit_arm-sz.c, lib/jit_arm.c,
lib/jit_hppa-cpu.c, lib/jit_hppa-sz.c, lib/jit_hppa.c,
lib/jit_ia64-cpu.c, lib/jit_ia64-sz.c, lib/jit_ia64.c,
lib/jit_mips-cpu.c, lib/jit_mips-sz.c, lib/jit_mips.c,
lib/jit_ppc-cpu.c, lib/jit_ppc-sz.c, lib/jit_ppc.c,
lib/jit_s390x-cpu.c, lib/jit_s390x-sz.c, lib/jit_s390x.c,
lib/jit_sparc-cpu.c, lib/jit_sparc-sz.c, lib/jit_sparc.c,
lib/jit_x86-cpu.c, lib/jit_x86-sz.c, lib/jit_x86.c:
Update backends for the new jit_htonr*.
* check/lightning.c, lib/jit_names.c, lib/lightning.c:
Update for the new jit_htonr* interfaces.
* check/Makefile.am: Update for new test cases.
* check/hton.ok, check/hton.tst: New test cases.
* check/alu_rsb.ok, check/alu_rsb.tst: New files implementing
tests for jit_rsb*.
* check/Makefile.am, check/lightning.c, include/lightning.h,
lib/jit_aarch64-cpu.c, lib/jit_aarch64-fpu.c, lib/jit_aarch64-sz.c,
lib/jit_aarch64.c, lib/jit_alpha-cpu.c, lib/jit_alpha-fpu.c,
lib/jit_alpha-sz.c, lib/jit_alpha.c, lib/jit_arm-cpu.c,
lib/jit_arm-swf.c, lib/jit_arm-sz.c, lib/jit_arm-vfp.c,
lib/jit_arm.c, lib/jit_hppa-cpu.c, lib/jit_hppa-fpu.c,
lib/jit_hppa-sz.c, lib/jit_hppa.c, lib/jit_ia64-cpu.c,
lib/jit_ia64-fpu.c, lib/jit_ia64-sz.c, lib/jit_ia64.c,
lib/jit_mips-cpu.c, lib/jit_mips-fpu.c, lib/jit_mips-sz.c,
lib/jit_mips.c, lib/jit_names.c, lib/jit_ppc-cpu.c,
lib/jit_ppc-fpu.c, lib/jit_ppc-sz.c, lib/jit_ppc.c,
lib/jit_s390x-cpu.c, lib/jit_s390x-fpu.c, lib/jit_s390x-sz.c,
lib/jit_s390x.c, lib/jit_sparc-cpu.c, lib/jit_sparc-fpu.c,
lib/jit_sparc-sz.c, lib/jit_sparc.c, lib/jit_x86-cpu.c,
lib/jit_x86-sse.c, lib/jit_x86-sz.c, lib/jit_x86-x87.c,
lib/jit_x86.c, lib/lightning.c: Implement jit_rsb*. This
was a missing lightning 1.x interface, that on most
backends is synthesized, but on a few backends (hppa and ia64),
it can generate better code as on those there is, or the
only instruction with an immediate is in "rsb" format
(left operand).
* lib/jit_aarch64-cpu.c, lib/jit_alpha-cpu.c, lib/jit_arm-cpu.c,
lib/jit_hppa-cpu.c, lib/jit_mips-cpu.c, lib/jit_ppc-cpu.c,
lib/jit_sparc-cpu.c: Implement or correct the internal
nop(count) call that receives an argument that tells the
modulo bytes to align the code for the next instruction.
* include/lightning.h, lib/lightning.c, lib/jit_aarch64.c,
lib/jit_alpha.c, lib/jit_arm.c, lib/jit_hppa.c, lib/jit_ia64.c,
lib/jit_mips.c, lib/jit_ppc.c, lib/jit_s390x.c, lib/jit_sparc.c,
lib/jit_x86.c: Implement the new jit_align() call that receive
an argument, that tells the modulo, in bytes, to align the
next instruction. In most backends the only value that makes
a difference is a value that matches sizeof(void*), as all
other values usually are already automatically aligned in
labels, but not guaranteed to be aligned at word size bytes.
* check/align.ok, check/align.tst: New files, implementing
a simple test for the new jit_align() interface.
* check/Makefile.am, check/lightning.c, lib/jit_aarch64-sz.c,
lib/jit_alpha-sz.c, lib/jit_arm-sz.c, lib/jit_hppa-sz.c,
lib/jit_ia64-sz.c, lib/jit_mips-sz.c, lib/jit_ppc-sz.c,
lib/jit_print.c, lib/jit_s390x-sz.c, lib/jit_sparc-sz.c,
lib/jit_x86-sz.c: Update for the new jit_code_align code and
the jit_align() interface.
* include/lightning.h, include/lightning/jit_private.h,
lib/jit_aarch64-cpu.c, lib/jit_alpha-cpu.c, lib/jit_arm-cpu.c,
lib/jit_hppa-cpu.c, lib/jit_ia64-cpu.c, lib/jit_mips-cpu.c,
lib/jit_ppc-cpu.c, lib/jit_s390x-cpu.c, lib/jit_sparc-cpu.c,
lib/jit_x86-cpu.c, lib/lightning.c: Implement the new
jit_frame and jit_tramp interfaces, that allow writing
trampoline like calls, where a single dispatcher jit buffer
is written, and later other jit buffers are created, with
the same stack frame layout as the dispatcher. This is the
logic that GNU Smalltalk used in lightning 1.x, and is required
to make a sane port for lighting 2.x.
* jit_ia64-cpu.c: Implement support for jit_frame and jit_tramp,
and also correct wrong encoding for B4 instructions, that
implement jmpr, as well as correct reverse logic in _jmpr,
that was moving the branch register to the jump register,
and not vice-versa.
Also, if a stack frame is to be assumed, always assume it may
call a function with up to 8 arguments, regardless of the
hint frame argument.
* lib/jit_arm.c: Add a new must_align_p() interface to ensure
function prologs are always aligned. This condition was
previously always true, somewhat by accident, but with
jit_tramp it is not guaranteed.
* jit_ia64-cpu.c: lib/jit_ppc.c: Add minor special handling
required to implement jit_tramp, where a function descriptor
should not be added before a prolog, as jit_tramp means omit
prolog.
* check/lightning.c: Update test driver for the new interfaces.
* check/Makefile.am, check/tramp.tst, check/tramp.ok: Add
a simple test and example of the jit_frame and jit_tramp
usage implementing a simple Fibonacci function using a
simulation of an interpreter stack and how it would handle
state in language specific variables.
* doc/body.texi: Add documentation for jit_frame and
jit_tramp.
* lib/jit_aarch64-cpu.c, lib/jit_aarch64-fpu.c,
lib/jit_arm-cpu.c, lib/jit_arm-vfp.c,
lib/jit_hppa-cpu.c, lib/jit_hppa-fpu.c,
lib/jit_ia64-cpu.c, lib/jit_ia64-fpu.c,
lib/jit_mips-cpu.c, lib/jit_mips-fpu.c,
lib/jit_ppc-cpu.c, lib/jit_ppc-fpu.c,
lib/jit_s390x-cpu.c, lib/jit_s390x-fpu.c,
lib/jit_s390x.c, lib/jit_sparc-cpu.c,
lib/jit_x86-cpu.c, lib/jit_x86-sse.c,
lib/jit_x86-x87.c: Review generation of all branch
instructions and always adds the jit_class_nospill
bitfield for temporary registers that cannot be spilled
because the reload would be after a conditional jump; the
patch only adds an extra assertion. These conditions do
not happen on documented lightning usage, but can happen
if one uses the not exported jit_get_reg and jit_unget_reg
calls and cause enough register starvation.
* lib/jit_sparc-cpu.c: Correct compiler warning of value
used before assignment. The usage is bogus as the api
requires always patching jumps, but the random value used
could cause an assertion due to invalid displacement.
* lib/jit_sparc.c: Always load and store double arguments
in stack as 2 float loads or stores, for safety, as unaligned
access is not allowed in Sparc Solaris.
* include/lightning/jit_private.h, lib/jit_arm.c,
lib/jit_mips-cpu.c, lib/jit_mips.c, lib/jit_ppc-cpu.c,
lib/jit_ppc.c, lib/jit_print.c, lib/jit_sparc-cpu.c,
lib/jit_sparc.c, lib/jit_x86-cpu.c, lib/jit_x86.c,
lib/lightning.c: Change all jit_regset macros to take
a pointer argument, to avoid structure copies when
adding a port to an architecture with more than 64
registers.
* include/lightning/jit_private.h, lib/jit_arm-cpu.c,
lib/jit_arm.c, lib/jit_disasm.c, lib/jit_mips-cpu.c,
lib/jit_mips.c, lib/jit_note.c, lib/jit_ppc-cpu.c,
lib/jit_ppc.c, lib/jit_print.c, lib/jit_sparc-cpu.c,
lib/jit_sparc.c, lib/jit_x86-cpu.c, lib/jit_x86.c,
lib/lightning.c: Add an extra structure for data storage
during jit generation, and release it after generating
jit, to reduce a bit memory usage, and also to make it
easier to understand what data is available during
jit runtime.
* check/lightning.c: Remove state flag to work with partial
sparc port, by just disassembling if there was incomplete
code generation.
* jit_sparc-cpu.c: Correct wrong range check for immediate
integer constants (off by one bit shift).
Correct macro implementing equivalent "rd %y, rd" assembly.
Implement qmul* and qdiv*.
* jit_sparc.c: Update for qmul* and qdiv* and remove logic
to handle incomplete code generation during sparc port.
* check/float.tst: Add sparc to list of known NaN and +-Inf
to integer conversion.
* check/lightning.c: Define __sparc__ to preprocessor in
the sparc backend.
* include/lightning/jit_private.h: Correct wrong definition
of emit_stxi_d, that has lived for a long time, but would
cause problems whenever needing to spill/reload a float
register.
* include/lightning/jit_sparc.h: Can only use %g2,%g3,%g4
for scratch variables, as other "global" registers are
reserved for the system, e.g. libc.
Reorder float register naming to make it easier to
access odd float registers, so that generating code for
pusharg and getarg is easier for the IR.
* lib/jit_mips-cpu.c, lib/jit_ppc-cpu.c: Update to match
new code in jit_sparc-cpu.c. It must call jit_get_reg
with jit_class_nospill if using the register to move
an unconditional branch address to it, as the reload
will not happen (actually could happen in the delay
slot...)
* lib/jit_sparc-cpu.c: Correct wrong macro definition for
ldxr_s.
Properly implement div* and implement rem. Div* needs
to use the y register, and rem* needs to be synthesized.
Correct b?sub* macro definitions.
* lib/jit_sparc-fpu.c: Correct reversed float to/from double
conversion.
Correct wrong jit_get_reg call asking for a gpr and then
using the fpr with that number.
Correct wrong branch displacement computation for
conditional branches.
* lib/jit_sparc.c: Correct getarg_d and pushargi_d implementation.
Add rem* entries to the switch converting IR to machine code.
* lib/lightning.c: Correct a problem detected when adding
the jit_class_nospill flag to jit_get_reg, that was caused
when having a branch to an "epilog" node, what would cause
the code to think all registers in unknown state were live,
while in truth, all registers in unknown state in the
"just after return" point are actually dead.
* include/lightning/jit_sparc.h, lib/jit_sparc-cpu.c,
lib/jit_sparc-fpu.c, lib/jit_sparc.c: New files implementing
the basic framework of the sparc port.
* configure.ac, include/lightning.h, include/lightning/Makefile.am,
include/lightning/jit_private.h, lib/jit_disasm.c: Update
for the sparc port framework.
* lib/jit_mips.c: Correct reversed retr/reti logic.
* lib/jit_ppc.c: Correct misspelled __LITTLE_ENDIAN.
* lib/lightning.c: Always do byte hashing in hash_data, because
the logic to "compress" strings causes large pointers to not
be guaranteed aligned at 4 byte boundaries.
Update for the sparc port framework.