* 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/jit_private.h, lib/lightning.c: Add a
second pass from start when computing register live ranges.
This should be used temporarily, and is required for certain
loop constructs, with several consecutive blocks not referencing
a live register.
* lib/jit_rewind.c: New file implementing generic functions
to "rewind", or rewrite IR code sequences.
* include/lightning.h: Add several new codes, that previously
were a function call, that would synthesize the operation.
Now, there is a code for the operation, and a new flag to
know an operation is synthesized.
* include/lightning/jit_private.h: Add several new macros to
help construct synthesized IR code sequences.
* lib/Makefile.am: Update for lib/jit_rewind.c.
* lib/jit_disasm.c: Update for a small rework on jit_node_t,
so that --enable-devel-disassembler does not need a change
in the layout of jit_node_t.
* lib/jit_names.c: Update for the new codes.
* lib/jit_print.c: Update to print more readable output, and
flag synthesized IR code sequences.
* lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
lib/jit_arm-sz.c, lib/jit_arm.c, lib/jit_x86-sz.c,
lib/jit_x86.c: Update for new synthesized IR code sequences.
* lib/jit_ppc-cpu.c, lib/jit_ppc-fpu., lib/jit_ppc-sz.c,
lib/jit_ppc.c, lib/jit_mips-cpu.c, lib/jit_mips-fpu.c,
lib/jit_mips-sz.c, lib/jit_mips.c, lib/jit_s390-fpu.c,
lib/jit_s390-sz.c, lib/jit_s390.c: Update for new synthesized
IR code sequences and correct bugs in the initial varargs
implementation support.
* lib/jit_alpha-sz.c, lib/jit_alpha.c, lib/jit_hppa-sz.c,
lib/jit_hppa.c, lib/jit_ia64-sz.c, lib/jit_ia64.c,
lib/jit_sparc-sz.c, lib/jit_sparc.c: Add generic, untested
support for the new synthesized IR code sequences. Known
most likely broken right now, and should be corrected once
access to these hosts is available.
* lib/lightning.c: Update for new IR codes, and add support
for not yet existing instructions that change third argument.
* size.c: Change to use different tables for LE and BE PowerPC.
Correct a wrong endif for x32.
* include/lightning.h, include/lightning/jit_private.h,
lib/jit_names.c, lib/lightning.c: Add initial support
for the new jit_va_start, jit_va_arg, jit_va_arg_d, and
jit_va_end interfaces. The jit_va_start call is supposed
to return a va_list compatible pointer, but not yet
decided if it will be "declared" stdarg compatible,
as for now only x86 support has been added (and should
be compatible), but issues may arise on other backends.
* check/lightning.c: Add wrappers to call the new jit_va_*
interfaces.
* lib/jit_x86-cpu.c, lib/jit_x86.c: Implement the new
jit_va_* for x86.
* lib/jit_x86-sz.c: Add fields, but not yet fully updated,
as this is an intermediate commit.
* lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
lib/jit_alpha-sz.c, lib/jit_alpha.c,
lib/jit_arm-sz.c, lib/jit_arm.c,
lib/jit_hppa-sz.c, lib/jit_hppa.c,
lib/jit_ia64-sz.c, lib/jit_ia64.c,
lib/jit_mips-sz.c, lib/jit_mips.c,
lib/jit_ppc-sz.c, lib/jit_ppc.c,
lib/jit_s390-sz.c, lib/jit_s390.c,
lib/jit_sparc-sz.c, lib/jit_sparc.c: Prepare for the
new jit_va_* interfaces. Not yet implemented, and will
cause an assertion if used.
* check/va_list.tst: Simple early test case, that works
on x86_64, x32, ix86, cygwin, and cygwin64.
* 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.
* configure.ac, include/lightning/jit_private.h,
lib/jit_aarch64.c, lib/jit_alpha.c, lib/jit_arm.c,
lib/jit_disasm.c, lib/jit_hppa.c, lib/jit_ia64.c,
lib/jit_mips.c, lib/jit_ppc.c, lib/jit_print.c,
lib/jit_s390.c, lib/jit_sparc.c, lib/jit_x86.c: Add a new
--enable-devel-disassembler option, that should be used
during development, or lightning debug. This option
intermixes previous jit_print and jit_disassemble
output, making it easier to visualize what lightning
call was used, and what code was generated.
* include/lightning.h, include/lightning/jit_private.h,
include/lightning/jit_s390x.h, lib/jit_disasm.c,
lib/jit_s390x-cpu.c, lib/jit_s390x-fpu.c, lib/jit_s390x-sz.c,
lib/jit_s390x.c, lib/jit_size.c, lib/lightning.c:
Add support for generating jit for s390 32 bit. This change
also removed %f15 from the list of temporaries fpr registers;
it was not being used, but if were, it would corrupt the
stack frame because the spill address would overwrite grp
offsets.
* include/lightning/jit_private.h, include/lightning/jit_x86.h,
lib/jit_disasm.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,
size.c: Implement support for the x32 abi. Built and
tested on Gentoo default/linux/amd64/13.0/x32 profile.
* include/lightning/jit_private.h, 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 a private jit_flush call, that flushes
the cache, if applicable, aligning down to the
previous and up to the next page boundary.
Make jit_memcpy, jit_memmove, jit_data take const pointers to
allow jit_note to be used with a const string (e.g. a string
literal, __FILE__ or __func__). This is needed for GNU Smalltalk
to silence compiler warnings.
Sadly "const jit_pointer_t" is not the same as "typedef const void *"
so I introduced a new typedef for a const jit pointer. The other
option would be to replace jit_pointer_t with void*.
* 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.
* check/lightning.c: Add a hopefully temporary kludge to not use
sprintf and sscanf returned by dlsym. This is required to pass
the varargs test.
* include/lightning/jit_private.h: Use symbolic name for first
integer register argument, as this is different in sysv and
win64 abi.
* include/lightning/jit_x86.h: Add conditionals and definitions
for Windows x64 (under __CYGWIN__ preprocessor conditional).
* lib/jit_x86-cpu.c: Correct one instruction encoding bug, that
was working by accident. Only use rax to rdx for some byte
operations to work on compatibility mode (that is, to generate
the proper encoding, instead of actually generating encoding
for high byte registers, e.g. %bh).
Add proper prolog and epilog for windows x64.
* lib/jit_x86-sse.c: Correct a swapped rex prefix for float
operations.
* lib/jit_x86.c: Adjust to support Windows x64 abi.
* check/check.x87.nodata.sh: New file, previously used but that
was missing git.
* include/lightning/jit_alpha.h, lib/jit_alpha-cpu.c,
lib/jit_alpha-fpu.c, lib/jit_alpha-sz.c, lib/jit_alpha.c:
New files implementing a lightning Alpha port. Thanks
to Trent Nelson and snakebit.net staff for providing access
to an Alpha system.
* check/float.tst, check/lightning.c, configure.ac,
include/lightning.h, include/lightning/Makefile.am,
include/lightning/jit_private.h, lib/Makefile.am,
lib/jit_disasm.c, lib/jit_size.c, lib/lightning.c:
Minor changes to adapt for the new Alpha port.
* lib/jit_memory.c: Do not call free on NULL pointers.
* include/lightning/jit_private.h, lib/jit_note.c,
lib/lightning.c: Add a wrapper to memcpy and memmove
to not actually call those functions with a zero size
argument, and likely also a null src or dst.
* include/lightning/jit_private.h, lib/jit_disasm.c,
lib/lightning.c: Remove the global jit_progname variable.
It was being only used in jit_init_debug, that is called
from init_jit, so, just pass an argument.
* include/lightning/jit_aarch64.h, include/lightning/jit_arm.h,
include/lightning/jit_hppa.h, include/lightning/jit_ia64.h,
include/lightning/jit_mips.h, include/lightning/jit_ppc.h,
include/lightning/jit_private.h, include/lightning/jit_s390x.h,
include/lightning/jit_sparc.h, include/lightning/jit_x86.h:
Do not add jit_regset_t, JIT_RA0, and JIT_FA0 to the installed
header file. These types and definitions are supposed to be
only used internally.
* include/lightning.h, include/lightning/jit_private.h,
lib/lightning.c: Implement the new jit_set_data() interface,
and the new jit_get_data() helper. Like jit_set_code(),
jit_realize() should be called before jit_set_data().
The most common usage should be jit_set_data(JIT_DISABLE_DATA
| JIT_DISABLE_NOTE), to force synthesize any float/double
constant in the stack and not generate any debug information.
* lib/jit_note.c: Minor change to debug note generation as
now it uses an alternate temporary data buffer during constants
and debug generation to accommodate the possibility of the user
setting an alternate data buffer.
* lib/jit_hppa-fpu.c, lib/jit_s390x.c, lib/jit_s390x-cpu.c,
lib/jit_s390x-fpu.c, lib/jit_sparc.c, lib/jit_sparc-fpu.c,
lib/jit_x86-sse.c, lib/jit_x86-x87.c: Implement jit_set_data.
* lib/jit_hppa-sz.c, lib/jit_sparc-sz.c, lib/jit_x86-sz.c,
lib/jit_s390x-sz.c: Update for several instructions that now
have a different maximum length due to jit_set_data.
* lib/jit_mips-fpu.c: Implement jit_set_data, but missing
validation on n32 and n64 abis (and/or big endian).
* lib/jit_mips-sz.c: Update for changes in o32.
* lib/jit_ppc-fpu.c: Implement jit_set_data, but missing
validation on Darwin PPC.
* lib/jit_ppc-sz.c: Update for changes in powerpc 32 and
64 bit.
* lib/jit_ia64-fpu.c: Implement untested jit_set_data.
* TODO: Add note to list ports that were not tested for the
new jit_set_data() feature, due to no longer having access
to them.
* check/nodata.c: New file implementing a simple test exercising
several different conditions created by jit_set_data().
* check/check.nodata.sh: New file implementing a wrapper
over the existing *.tst files, that runs all tests without
using a data buffer for constants; only meaningful (and
enabled) on architectures that used to store float/double
constants on a read only data buffer.
* configure.ac, check/Makefile.am: Update for the new test
cases.
* check/lightning.c: Implement the new "-d" option that
sets an internal flag to call jit_set_data() disable
constants and debug, that is, using only a pure code
buffer.
* include/lightning.h, include/lightning/jit_private.h,
lib/lightning.c: Implement the new jit_set_code() interface,
that allows instructing lightning to use an alternate code
buffer. The new jit_realize() function should be called
before jit_set_code(), and usually call jit_get_code()
to query the amount of bytes expected to be required for
the code.
* lib/jit_size.c: Minor update to have less chances of
miscalculating the code buffer by starting the counter
with the size of the longest instruction instead of zero,
as code emit fails if at any moment less than the longest
instruction bytes are available.
* check/setcode.c: New file implementing some basic tests
of the new jit_set_code() interface.
* check/Makefile.am: Update for newer test case.
* lib/jit_aarch64-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_s390x-sz.c, lib/jit_size.c, lib/jit_sparc-sz.c,
lib/jit_x86-sz.c: New files implementing static tables
with longest known instructions length generated to match
a lightning instruction. These tables should make it easier
to make it very unlikely to ever miscalculate, or by too
much, the size of a code buffer.
* lib/jit_size.c: New file that aids to either collect
jit code size information, or use the information depending
on build options.
* size.c: New helper file that parses input for, and create
an initial jit_$arch-sz.c file, that needs some minor edit
for arches with multiple configurations.
* configure.ac, Makefile.am: Add the new, devel mode only
--enable-devel-get-jit-size configure option, that sets
compile time flags to collect jit code size information,
that will be used as input for the "noinst size program".
* lib/jit_aarch64.c, lib/jit_arm.c, lib/jit_disasm.c,
lib/jit_hppa.c, lib/jit_ia64.c, lib/jit_memory.c,
lib/jit_mips.c, lib/jit_ppc.c, lib/jit_s390x.c,
lib/jit_sparc.c, lib/jit_x86.c, lib/lightning.c: Minor
changes for the --enable-devel-get-jit-size build mode,
as well as the "production build mode" with jit code
size information.
* include/lightning.h, include/lightning/jit_private.h,
lib/jit_note.c: Change the code argument of jit_get_note
to a jit_pointer_t and make jit_get_note a public interface.
It was intended so since start, as a way to map an offset
in the code to a function name, file name and line number
mapping.
* doc/body.texi: Correct reversed arguments in example of
usage in a (possibly) multi threaded, multiple jit_state_t
environments.
* include/lightning/jit_arm.h, include/lightning/jit_private.h,
lib/jit_arm-cpu.c, lib/jit_arm.c: Make a previously, non
documented, global state private to the related jit_state_t
generating code.
* include/lightning/jit_s390x.h, lib/jit_s390x-cpu.c,
lib/jit_s390x-fpu.c, lib/jit_s390x.c: New files
implementing the new s390x port.
* configure.ac, include/lightning.h,
include/lightning/Makefile.am,
include/lightning/jit_private.h,
lib/Makefile.am, lib/jit_disasm.c, lib/lightning.c:
Minor adaptation for the new s390x backend.
* check/float.tst: Update for the s390x result of
truncating +Inf to integer.
* check/qalu_mul.tst: Add extra test cases to better test
high word of signed multiplication as the result is
adjust from unsigned multiplication on s390x.
* include/lightning/jit_aarch64.h, lib/jit_aarch64-cpu.c,
lib/jit_aarch64-fpu.c, lib/jit_aarch64.c: New files
implementing the new aarch64 port, as a new architecture,
not as an expansion of the existing armv[4-7] port.
* check/lightning.c: Add aarch64 support and a small
change to recognize character constants as immediate
values.
* check/float.tst: Add aarch64 preprocessor conditionals
to select proper expected value when converting [+-]Inf
and NaN to integer.
* include/lightning/jit_arm.h, lib/jit_arm.c: Minor changes
to better match the new aarch64 files.
* configure.ac, include/lightning.h,
include/lightning/Makefile.am, include/lightning/jit_private.h,
lib/Makefile.am, lib/lightning.c: Minor adjustments
for the aarch64 port.
Many thanks to Trent Nelson from snakebite.org for giving access to a
build farm with several different architectures and operating systems.
* check/lightning.c, lib/jit_disasm.c, lib/jit_ppc-cpu.c,
lib/jit_ppc-fpu.c, lib/jit_ppc.c, include/lightning.h,
include/lightning/jit_ppc.h, include/lightning/jit_private.h:
Adapt code to work on 32 bit AIX ppc using gcc. Most changes
are basically to adapt the elf64 logic to 32 bit, as it does
not use the same convention of 32 bit Darwin ppc.
* check/stack.tst: Add a fake memcpy function to the test
case if running under AIX, as it is not available to dlsym.
* configure.ac: Check for getopt.h header, not available in
AIX.
* include/lightning/jit_hppa.h, lib/jit_hppa-cpu.c,
lib/jit_hppa-fpu.c, lib/jit_hppa.c: New files implementing
the hppa port. Built on Debian Linux PA-RISC 2.0, 32 bit.
* check/float.tst: Add preprocessor for hppa expected
values when converting NaN and +-Inf to an integer.
* check/ldst.inc: Ensure double load/store tests use an
8 byte aligned address by default.
* lib/lightning.c: Correct a bug found during tests in
the new port, where qmul* and qdiv* were not properly
setting one of the result registers as modified in the
function, what would be a problem if the only "write"
usage were the qmul* or qdiv*.
* check/varargs.tst, check/varargs.ok: Add one extra
interleaved integer/double test to validate proper code
generation in the extra case.
* check/lightning.c, configure.ac, include/lightning.h,
include/lightning/Makefile.am,
include/lightning/jit_private.h, lib/Makefile.am,
lib/jit_disasm.c: Update for the hppa port.
* include/lightning/jit_ia64.h, include/lightning/jit_private.h,
lib/jit_ia64-cpu.c, lib/jit_ia64-fpu.c, lib/jit_ia64.c,
lib/lightning.c: Rework code to detect need of a "stop" to
also handle predicates, as if a predicate is written, it
cannot be read in the same instruction group.
Use a single jit_regset_t variable for all registers when
checking need for a stop (increment value by 128 for
float registers).
Correct wrong "subi" implementation, as the code executed
is r0=im-r1, not r0=r1-im.
Use standard lightning 6 fpr registers, and rework to
use callee save float registers, that may be spill/reloaded
in prolog/epilog. This is required because some jit
instructions implementations need to call functions; currently
integer div/mod and float sqrt, what may change the value of
scratch float registers.
Rework point of "sync" of branches that need to return a
patch'able address, because the need for a "stop" before a
predicate read causes all branches to be the instruction
in slot 0, as there is no template to "stop" and branch
in the same instruction "bundle".
* 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.c, lib/jit_memory.c,
lib/jit_mips.c, lib/jit_ppc.c, lib/jit_sparc.c, lib/jit_x86.c,
lib/lightning.c: Do not start over jit generation if can grow
the code buffer with mremap without moving the base pointer.
* lib/jit_memory.c: Implement a simple memory allocation wrapper
to allow overriding calls to malloc/calloc/realloc/free, as well
as ensuring all memory containing pointers is zero or points to
allocated memory.
* include/lightning.h, include/lightning/jit_private.h: Definitions
for the memory allocation wrapper.
* lib/Makefile.am: Update for new jit_memory.c file.
* lib/jit_arm.c, lib/jit_disasm.c, lib/jit_mips.c, lib/jit_note.c,
lib/jit_ppc.c, lib/jit_sparc.c, lib/jit_x86.c, lib/lightning.c:
Use the new memory allocation wrapper code.
* configure.ac, include/lightning/jit_private.h, lib/lightning.c:
Remove dependency on gmp. Only a simple bitmap was required, and
that was not enough reason to force linking to gmp and possible
complications caused by it.
* include/lightning.h: Add check for __powerpc__ defined
in Linux, while Darwin defines __ppc__.
* include/lightning/jit_ppc.h: Adjust register definitions
for Darwin 32 bit and Linux 64 bit ppc usage and/or ABI.
* include/lightning/jit_private.h: Add proper check for
Linux __powerpc__ and an data definition for an workaround
to properly handle code that starts with a jump to a "main"
label.
* lib/jit_disasm.c: Add extra disassembler initialization
for __powerpc64__.
* lib/jit_ppc-cpu.c: Add extra macros and functions, and
correct/adapt previous ones to handle powerpc64.
* lib/jit_ppc-fpu.c: Adapt for 64 bit wordsize. Basically
add conversion from/to int32/int64 and proper handling of
load/store offsets too large for 32 bit.
* lib/jit_ppc.c: Add calls to 64 bit codes and adaptation
for the PowerPC 64 bit Linux ABI.
* lib/jit_arm.c, lib/jit_mips.c, lib/jit_sparc, lib/jit_x86.c,
lib/lightning.c: Correct off by one error when restarting jit
of a function due to finding too late that needs to spill/reload
some register. Problem was found by accident on a very special
condition during PowerPC 64 code adaptation.
* 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.
* 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.
* include/lightning/jit_private.h, lib/jit_note.c, lib/lightning.c:
Store all annotation information in the mmap'ed area reserved for
read only data. This adds code to not allocate memory for jit_note_t
objects, and to relocate jit_line_t objects and its contents after
calculating annotation information. The jit_line_t objects are
relocated because it is not possible to always calculate before
hand data layout because note information may be extended or
redundant entries removed, as well as allowed to be added in
non sequential order.
A bug was also corrected in _jit_set_note, that was causing it
to allocate new jit_line_t objects when not needed. It was still
working correctly, but allocating way more memory than required.
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.
* check/3to2.tst, check/add.tst, check/allocai.tst, check/bp.tst,
check/call.tst, check/ccall.c, check/clobber.tst, check/divi.tst,
check/fib.tst, check/ldsti.tst, check/ldstr-c.tst, check/ldstr.tst,
check/ldstxi-c.tst, check/ldstxi.tst, check/ldstxr-c.tst,
check/ldstxr.tst, check/lightning.c, check/rpn.tst, check/stack.tst,
check/varargs.tst, include/lightning.h,
include/lightning/jit_private.h, lib/jit_arm.c, lib/jit_disasm.c,
lib/jit_mips.c, lib/jit_note.c, lib/jit_ppc.c, lib/jit_print.c,
lib/jit_x86.c, lib/lightning.c: Extend the "jit_note" abstraction
with the new "jit_name" call, that receives a string argument, and
should usually be called to mark boundaries of functions of code
generating jit (that is, it is not expected that the language
generating jit map its functions to jit functions).
* check/add.tst, check/allocai.tst, check/bp.tst, check/divi.tst,
check/fib.tst, check/lightning.c, include/lightning/jit_arm.h,
include/lightning/jit_mips.h, include/lightning/jit_ppc.h,
include/lightning/jit_private.h, include/lightning/jit_x86.h:
Make JIT_RET, JIT_FRET and JIT_SP private. These should not be
used in any operations due to frequently having special
constraints (usually JIT_FRET). JIT_FP must be made available
because it must be used as the base register to access stack
space allocated with jit_allocai.
* lib/jit_note.c: New file implementing a simple string+integer
annotation, that should be used to map filename and line number
to offsets in the generated jit.
* include/lightning.h, lib/lightning.c: Update for the new
note code.
Add an extra mandatory argument to init_jit, that is used
as argument to bfd_openr.
Change from generic void* to char* the argument to jit_note
and add an extra integer argument, to map to filename and
line number.
* check/ccall.c, check/lightning.c, include/lightning/jit_private.h,
lib/jit_arm.c, lib/jit_disasm.c, lib/jit_mips.c, lib/jit_ppc.c,
lib/jit_print.c, lib/jit_x86.c: lib/Makefile.am: Update for the
new annotation code.
* configure.ac, check/Makefile.am: Update to work with latest
automake.
* check/cccall.c, check/ccall.ok: New test case to validate
interleaved calls from/to C code and jit.
* check/Makefile.am: Update for the new ccall test case.
* include/lightning.h, lib/lightning.c: Add the new jit_address
call that returns the real/final address of a "note" in the
generated jit. It requires a jit_node_t as returned by the
jit_note call, and is only valid after calling jit_emit.
Add an intermediate solution to properly handle arm
soft and softfp modes that move a double to an integer register
pair. Currently it just adds extra tests for the condition,
but the proper solution should be to have extra lightning
codes for these conditions, codes which should be only used
by the backends that need it, and merged with the existing
jit_pusharg*_{f,d}.
* include/lightning/jit_private.h: Add new jit_state_t flag
to know it finished jit_emit, so that calls to jit_address
are valid.
* lib/jit_mips.c: Correct abi implementation so that the
new ccall test case pass. Major problem was using
_jit->function.self.arg{i,f} as boolean values, but that
would cause lightning.c:patch_registers() to incorrectly
assume only one register was used as argument when calling
jit_regarg_p(); _jit->function.self.arg{i,f} must be the
number of registers used as arguments (in all backends).
* lib/jit_x86.c: Add workaround, by marking %rax as used,
to a special condition, when running out of registers and the
allocator trying to spill and reload %rax, but %rax was used
as a pointer to a function, what would cause the reload to
destroy the return value. This condition can be better
generalized, but the current solution is good enough.
* include/lightning/jit_ppc.h, lib/jit_ppc-cpu.c, lib/jit_ppc.c:
Rewrite logic to handle arguments, as the original code was
written based on a SysV pdf about the generic powerpc ABI,
what did "invent" a new abi for the previous test cases, but
failed in the new ccall test in Darwin PPC. Now it properly
handles 13 float registers for arguments, as well as proper
computation of stack offsets when running out of registers
for arguments.
* include/lightning.h, include/lightning/jit_private.h,
lib/jit_arm.c, lib/jit_mips.c, lib/jit_ppc.c, lib/jit_x86.c,
lib/lightning.c: Make jit_ellipsis implementation not
backend specific. It is not intended to handle va_list
like objects at runtime, as jit_arg* and jit_getarg*
return constant values resolved at parse time, so, effectively
it is not possible to create printf like jit functions, as
there is no va_start, va_arg, va_end, etc, abstraction. This
limitation should be kept for the sake of making new ports
easier.