* 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.
* include/lightning/jit_mips.h, lib/jit_mips-cpu.c,
lib/jit_mips-sz.c, lib/jit_mips.c, size: Build and
pass all test cases on Irix big endian mips using
the 64 bit abi.
* check/lightning.c, configure.ac, include/lightning.h,
lib/lightning.c: Add tests and quirks to build/detect
and/or work on Irix.
* include/lightning/jit_mips.h, lib/jit_mips-cpu.c,
lib/jit_mips-fpu.c, lib/jit_mips.c: Adapt code to run
in big endian mips, using the n32 abi.
* include/lightning/jit_ia64.h, lib/jit_ia64-cpu.c,
lib/jit_ia64-fpu.c, lib/jit_ia64.c: New files implementing
the basic infrastructure of an Itanium port. The code
compiles and can generate jit for basic hello world like
functions.
* check/lightning.c, configure.ac, include/lightning.h,
include/lightning/Makefile.am, include/lightning/jit_private.h,
lib/Makefile.am, lib/lightning.c: Update for the Itanium
port.
* lib/jit_mips-cpu.c, lib/jit_mips.c: Correct typo and
make the jit_carry register local to the jit_state_t.
This matches code reviewed in the Itanium port, that
should use the same base logic to handle carry/borrow.
* 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/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.
2013-02-04 Paulo Andrade <pcpa@gnu.org>
* include/lightning.h, include/lightning/jit_private.h,
lib/jit_arm-cpu.c, lib/jit_arm.c, lib/jit_mips-cpu.c,
lib/jit_mips.c, lib/jit_ppc-cpu.c, lib/jit_ppc.c,
lib/jit_x86-cpu.c, lib/jit_x86.c, lib/lightning.c:
Implement the new qmul and qdiv instructions that return signed
and unsigned lo/hi multiplication result and div/rem division result.
These should be useful for jit translation of code that needs to
know if a multiplication overflows (no branch opcode added) or if
a division is exact (easy check if remainder is zero).
* check/lightning.c, lib/jit_print.c, check/Makefile.am,
check/all.tst: Update for the new qmul and qdiv instructions.
* check/qalu.inc, check/qalu_div.ok, check/qalu_div.tst,
check/qalu_mul.ok, check/qalu_mul.tst: New files implementing
simple test cases for qmul and qdiv.
* lib/jit_arm.c, lib/jit_mips-cpu.c, lib/jit_mips.c: Correct
regressions when patching jit_calli for a forward function.
* lib/jit_ppc-cpu.c: Correct wrong arguments to ANDI opcode
in jit_getarg_u{c,s} implementation.
* check/stack.ok, check/stack.tst: New files to test data
integrity on a deep chain of stack frames.
* lib/jit_arm.c, lib/jit_arm-cpu.c, lib/jit_mips.c,
lib/jit_mips-cpu.c, lib/jit_ppc.c, lib/jit_ppc-cpu.c,
lib/jit_x86.c, lib/jit_x86-cpu.c: Calculate _jit->function->stack
in the emit stage, otherwise it will calculate it wrong if
need to jit_allocai space to spill registers.
* lib/lightning.c: Correct wrong offset when updating the
"current" jit function pointer in the code that may need to
allocate stack space to spill registers.
* check/lightning.c: Correct off by one data space check.
* check/Makefile.am: Update for new test case.
* lib/jit_mips-cpu.c: Correct all current test cases.
Call the "xori" not the "XORI" macro for jit_xori implementation,
as the XORI macro handles only 16 bit unsigned values.
Call the "movr" macro, not the "movi" macro in the special
case of adding or subtracting zero.
Use the proper temporary register in the jit_andr implementation.
* include/lightning/jit_mips.h, lib/jit_mips-cpu.c,
lib/jit_mips-fpu.c, lib/jit_mips.c: Correct float/double
argument handling and make the mips backend pass the initial
test cases.
* include/lightning.h, ib/jit_print.c, lib/lightning.c:
Add extra enum values for argument handling functions that
could not be abstracted to the current codes, that is, when
float values need to move from/to gpr from/to fpr. It would
be more tempting to add such primitives, but they would have
wordsize limitations, and it is not expected to add codes
with one gpr argument for 64 bit and two for 32 bit.
* lib/jit_ppc.c: Check _jit->function before calling jit_epilog()
to avoid a runtime exception.
* check/all.tst, check/lightning.c: Only declare or use 64 bit
interfaces on 64 bit builds.
* check/fib.tst: Use simpler logic to not need preprocessor
conditionals for 32 or 64 bit.
* include/lightning.h: Only declare 64 bit macros on a 64 bit
build. Code using lightning must know about wordsize and the
jit generation limitations, also, this way it generates a
compile time failure, not a runtime assertion.
* include/lightning/jit_x86.h: Correct typo in macro name.
* lib/jit_arm.c, lib/jit_arm-cpu.c, lib/jit_mips.c,
lib/jit_mips-cpu.c, lib/jit_ppc.c, lib/jit_ppc-cpu.c,
lib/jit_x86.c, lib/jit_x86-cpu.c: Correct wrong code to get
current jit function pointer.
* lib/lightning.c: Move call to the simplify() optimization
to after register liveness is known. Previous code did work
by accident but now with proper test cases the problem was
noticed.
* lib/jit_disasm.c: Always cast bfd_vma to long long when
passing it as printf argument.
2012-12-02 Paulo Andrade <pcpa@gnu.org>
* lib/jit_x86-cpu.c, lib/jit_x86-sse.c, lib/jit_x86-x87.c:
Actually change copyright owner to FSF as avertised.
* lib/jit_arm-cpu.c, lib/jit_arm-swf.c,
lib/jit_arm-vfp.c, lib/jit_arm.c,
lib/jit_mips-cpu.c, lib/jit_mips-fpu.c, lib/jit_mips.c,
lib/jit_ppc-cpu.c, lib/jit_ppc-fpu.c, lib/jit_ppc.c: New
files implementing initial code different jit backends.
* include/lightning/jit_private.h: Add extra field to the
private jit_patch_t type, required by the arm port.
* lib/Makefile.am: Update for the new backend implementation
files.