* lib/jit_ppc-cpu.c: Make movr a function that checks arguments
so that other code can safely assume it is a noop if src and dst
are the same register.
Implement rem{r,i}{,_u} as a div{,u}/mul/sub.
Correct ANDIS, ORIS and XORIS calls to cast the argument to
unsigned before the shift to avoid an assertion if the argument
had the topmost bit set.
Implement lshi, rshi and rshi_u as functions to test for a
zero argument, that would otherwise trigger an assertion when
computing the shift value.
Do a simple implementation of bm{s,c}{r,i} with a temporary,
"andr" of arguments and jump based on comparison with zero.
Correct typo in ldxi_c.
* lib/jit_ppc-fpu.c: Correct wrong arguments to FDIV* and STF*.
* lib/jit_ppc.c: Correct wrong check for 6 instead of 8 integer
arguments in registers. If calling a varargs function and
passing a float or double argument, also either store the
value in the stack or in integer registers, as varargs functions
do not fetch it from float registers.
Add "case" for new functions and incorrectly missing ones.
Call libgcc's __clear_cache, that should know what to do
if the hardware needs flushing cache before execution.
* lib/lightning.c: Do a simple/trivial logic in jit_regset_scan1,
that should make it easier for the compiler to optimize it, and
that also corrects the previously wrong code for big endian, and
that was causing problems in ppc due to not saving all callee save
registers as it was not "finding" them in the regset due to the
little endian assumption bug.
* configure.ac: Only default to using the builtin disassembler
if on GNU/Linux. This should be temporary, due to requiring
/proc/self/exe.
Correctly check $target_cpu for powerpc.
* include/lightning/jit_ppc.h: Correctly implement jit_v_num.
* include/lightning/jit_private.h: Declare proper prototype
for jit_init_debug and jit_finish_debug.
* lib/jit_ppc-cpu.c: Remove code to save/restore callee save
float registers, as it is not required since those float
registers are not usable currently.
Change prolog and epilog generation to, at least comparing
code, match what gcc generates in "gcc -O0", but it is still
failing in Darwin PPC, apparently due to the __clear_cache
call not being enough, as frequently it will also fail to
execute, and the code buffer is all zeroes.
* lib/lightning.c: Do not fail in jit_regset_scan1 calls due
to passing 64 as argument on computers with 64 registers.
* 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.
* 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>
* tests/Makefile.am, tests/3to2.c, tests/3to2.ok, tests/add.c,
tests/add.ok, tests/allocai.c, tests/allocai.ok, tests/bp.c,
tests/bp.ok, tests/divi.c, tests/divi.ok, tests/fib.c, tests/fib.ok,
tests/fibdelay.c, tests/fibdelay.ok, tests/fibit.c, tests/fibit.ok,
tests/funcfp.c, tests/funcfp.ok, tests/incr.c, tests/incr.ok,
tests/ldst.c, tests/ldst.ok, tests/ldxi.c, tests/ldxi.ok,
tests/modi.c, tests/modi.ok, tests/movi.c, tests/movi.ok,
tests/printf.c, tests/printf.ok, tests/printf2.c, tests/printf2.ok,
tests/ret.c, tests/ret.ok, tests/rpn.c, tests/rpn.ok, tests/rpnfp.c,
tests/rpnfp.ok, tests/sete.c, tests/sete.ok, tests/testfp.c,
tests/testfp.ok, tests-run-test: Removed previous test suite, in
favor of a newer one in the check subdirectory.
* check/3to2.ok, check/3to2.tst, check/add.ok, check/add.tst,
check/allocai.ok, check/allocai.tst, check/bp.ok, check/bp.tst,
check/divi.ok, check/divi.tst, check/fib.ok, check/fib.tst:
New sample input for the new test program, loosely matching
several of the previous test cases.
* check/Makefile.am: New test suite makefile.
* check/check.sh, check/run-test: New wrapper files for the
new test suite.
* check/lightning.c: New file. The main driver of the new test
suite, that compiles to a parser of a very simple assembly like
language, generates jit and executes it.
* check/all.tst: New file. A generic debug and sample test file
with a directive to prevent it from being executed, and useful to
read disassembly of all possible instructions, using a fixed set
of registers.
* include/Makefile.am, include/lightning.h,
include/lightning/Makefile.am, 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,
lib/Makefile.am, lib/jit_disasm.c, lib/jit_print.c,
lib/jit_x86-cpu.c, lib/jit_x86-sse.c, lib/jit_x86-x87.c,
lib/jit_x86.c, lib/lightning.c: New files. These files are
written from scratch, only by <pcpa@gnu.org>, and have now
copyright assignment to the FSF. This is the core of the new
lightning rework. Previously it was integrated in code with
a garbage collector and several custom types like vectors and
hash tables, so this first code merge with lightning converts
that code into a library extracting only the jit bits, and at
first only for x86_64 GNU/Linux.
* lightning.h, m4/lightning.m4: Removed. These are no longer
required in the new lightning code.
.gitignore, Makefile.am, configure.ac: Update for the new
lightning code.