* 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.
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/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.
* check/alu.inc, check/alu_add.ok, check/alu_add.tst,
check/alu_and.ok, check/alu_and.tst, check/alu_com.ok,
check/alu_com.tst, check/alu_div.ok, check/alu_div.tst,
check/alu_lsh.ok, check/alu_lsh.tst, check/alu_mul.ok,
check/alu_mul.tst, check/alu_neg.ok, check/alu_neg.tst,
check/alu_or.ok, check/alu_or.tst, check/alu_rem.ok,
check/alu_rem.tst, check/alu_rsh.ok, check/alu_rsh.tst,
check/alu_sub.ok, check/alu_sub.tst, check/alu_xor.ok,
check/alu_xor.tst, check/alux_add.ok, check/alux_add.tst,
check/alux_sub.ok, check/alux_sub.tst, check/branch.ok,
check/branch.tst: New test cases for arithmetic and branch
tests.
* check/Makefile.am: Update for new test cases.
* include/lightning/jit_private.h: Make the jit_reg_free_p
macro shared by all backends. Previously was added for the
arm backend, but is useful in the x86_64 backend when checking
state of "special purpose register".
Also add the new jit_class_named register class, that must be
or'ed with the register value if calling jit_get_reg expecting
an specific value, because the specific register value may be
zero, that previously was treated as no register requested.
* lib/jit_arm-cpu.c: Correct argument order for T2_MVN.
* lib/jit_arm-swf.c: Call the proper function for double
divide. The "software float" implementation just calls
libgcc functions.
* lib/jit_arm.c: Return float/double values in the float
register if using the hard float ABI.
* lib/jit_x86-cpu.c: Change the can_sign_extend_int_p macro
to not include -0x80000000L, because there is code that
"abuses" it and thinks it can negate the immediate value
after calling that macro.
Correct implementation of jit_subi that had a wrong code
patch logic doing subtraction with reversed arguments.
Correct REX prefix calculation in the jit_muli implementation.
Correct logic to get/unget %*ax and %*dx registers in divremr
and divremi.
Correct divremi that was using the symbolic, unique %*ax
value in on place (not using the _REGNO name suffix).
Correct cut&paste error causing it to use "xor" instead of
"or" in one code path of the jit_ori implementation.
Correct several flaws when clobbering registers and/or when
one of the arguments was %*cx in the rotshr wrapper function
implementing most shift operations.
* lib/lightning.c: No longer expect that the backend be smart
enough to know what to do when asking for a named register
if that register is already an argument or is live. It fails
if it is an argument, or if register is live, fails if cannot
spill.
No longer incorrectly assume that eqr_{f,d} and ltgr_{f,d} are
safe to inverse value tests in jump thread optimization.
* check/Makefile.am, check/cvt.ok, check/cvt.tst: Add new
"cvt" test case to test conversion from/to int/float types.
* check/lightning.c: Only define truncr_{f,d}_l in 64 bit mode.
* include/lightning.h: Correct typo that caused it to define
jit_truncr_{f,d}_l in 32 bit mode.
* lib/jit_arm-cpu.c: Avoid assertion failure in the signed/unsigned
extend opcodes generation as it shares an interface for 3 argument
opcode generation.
* lib/jit_x86-cpu.c: Correct wrong argument passed to
jit_unget_reg in the andi implementation and wrong byte
unsigned extend code generation.
* lib/jit_x86-sse.c: Correct conversion from "word" to float or
double as is dependent on wordsize.
* configure.ac, include/lightning/jit_private.h, lib/jit_arm-cpu.c,
lib/jit_arm-swf.c, lib/jit_arm.c, check/Makefile.am: Correct
implementation of the arm backend port to build and pass the
current test cases. Tested on armv7 with softfp abi.
* lib/jit_disasm.c: Rename and change prototype of static
disassemble function as in the arm backend it is required
to access state information stored in the jit_state_t object.
* check/3to2.tst, check/add.tst: Correct test case code assuming
JIT_RO and JIT_RET are the same, and even if they are the same,
the logic was incorrect because it must always call jit_retval*
to fetch a function call return before any other instruction.
The arm backend hash a special condition if jit_retval is not
called, because "r0" is not JIT_R0, but is JIT_RET and *also*
the first argument for a called function, so JIT_RET must be
only used as an argument to jit_retval.
* TODO: New file listing important tasks to be resolved.
* 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.