* 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, lib/jit_aarch64.c,
lib/jit_alpha.c, lib/jit_arm-vfp.c, lib/jit_arm.c,
lib/jit_hppa.c, lib/jit_ia64.c, lib/jit_mips.c,
lib/jit_ppc.c, lib/jit_s390.c, lib/jit_sparc.c,
lib/jit_x86.c: Add the new jit_arg_register_p predicate.
The predicate is expected to be used to know if an
argument is in a register, what would need special
handling if code that can overwrite non callee save
registers is executed.
* check/carg.c: New test case to check consistency and
expected usage of jit_arg_register_p.
* check/Makefile.am: Update for new test case.
* include/lightning/jit_aarch64.h,
include/lightning/jit_alpha.h,
include/lightning/jit_arm.h,
include/lightning/jit_hppa.h,
include/lightning/jit_mips.h,
include/lightning/jit_ppc.h,
include/lightning/jit_s390.h,
include/lightning/jit_sparc.h,
include/lightning/jit_x86.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_s390.c,
lib/jit_sparc.c, lib/jit_x86.c: Remove jit_arg_reg_p and
jit_arg_f_reg_p from a public header, and define it only
on port specific files where an integer offset is used
to qualify an argument identifier. Exported code expects
an opaque pointer (but of jit_node_t* type) to "qualify"
an argument identifier.
This patch, and the code review/simplification done during
it also corrected some bugs:
o Inconsistent jit_arg_d value of double argument after 3
integer arguments in arm for jit_functions; tested, C
functions were being properly called.
o Inconsistent use of getarg_{f,d} and putarg*_{f,d} on
s390 (32-bit) that happened to not have a proper test
case, as it would only happen for jit functions, and
tested, called C functions had proper arguments.
o Corrected a "last minute" correction that did not go
to the committed version, and would not compile on hppa,
due to bad _jit_putargi_d prototype definition.
* include/lightning.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_s390.c, lib/jit_sparc.c, lib/jit_x86.c:
Implement jit_putarg*. It works as a mix of jit_getarg*
and jit_pusharg*, in the way that the first argument is
a register or immediate, and the second is a pointer
returned by jit_arg*. The use of the interface is to change
values of arguments to the current jit function.
* check/put.ok, check/put.tst: New test cases exercising
the new jit_putarg* interface.
* check/Makefile.am, check/lightning.c: Update for the
new test case and 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.
* 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.
* 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: Add an
assertion to all code generation "drivers" to ensure
_jitc->regarg is empty or in an expected state, after
translation of a lightning instruction to native code.
This change was a brute force test to find out other cases
of a temporary not being release (like was happening with
_bmsi and _bmci on x86), but no other case was found,
after running make check, with assertions enabled, on all
backends.
* 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.
* 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, lib/lightning.c: Allow jit_jmpi on a
target that is not a node. This may lead to hard to
debug code generation, but is a required feature for
certain generators, like the ones that used lightning
1.2x. Note that previously, but not really well
documented, it was instructed to use:
jit_movi(rn, addr); jit_jmpr(rn);
but now, plain:
jit_patch_abs(jit_jmpi(), addr);
should also work.
* 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.
* 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.
* 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.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.
* 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/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.