1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-02 04:40:29 +02:00
Commit graph

22 commits

Author SHA1 Message Date
pcpa
9afca85921 Rework to better describe what is used only during jit generation.
* 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-03-06 16:49:26 -03:00
pcpa
610a569300 Add framework for sparc port.
* 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.
2013-02-18 01:18:54 -03:00
pcpa
60c1c545fc Implement the "live" code to explicitly tell a register is live.
*include/lightning.h, lib/lightning.c: Add the new jit_live code
	to explicitly mark a register as live. It is required to avoid
	assuming functions always return a value in the gpr and fpr return
	register, and to avoid the need of some very specialized codes
	that vary too much from backend to backend, to instruct the
	optimization code the return register is live.

	* lib/jit_arm.c, lib/jit_mips.c, lib/jit_ppc.c, lib/jit_print.c,
	lib/jit_x86.c: Update for the new jit_live code.

	* check/ret.ok, check/ret.tst: New files implementing a simple
	test case that would previously fail at least in ix86/x86_64.

	* check/Makefile.am: Update for new "ret" test case.
2013-02-05 14:14:25 -02:00
pcpa
7b2c9cfb2a Correct qmul and qdiv in ppc.
* lib/jit_ppc-cpu.c, lib/jit_ppc.c: Validate and correct
	problems in the qmul and qdiv ppc implementation.
2013-02-05 14:06:41 -02:00
pcpa
d91b25d1be Implement the qmul and qdiv instructions.
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.
2013-02-04 18:54:37 -02:00
pcpa
44d4fa5444 Add heuristic code to estimate space and resize if required jit buffer. 2013-01-29 16:37:43 -02:00
pcpa
9e86ef12cf Add the new jit_name call to mark function boundaries
* 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).
2013-01-18 18:05:57 -02:00
pcpa
a34410eee2 Add filename and line number annotation abstraction.
* 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.
2013-01-11 15:29:35 -02:00
pcpa
9d2566ee0a Add the new ccall test case to test interleaved C and jit function calls
* 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.
2013-01-05 16:14:59 -02:00
pcpa
2e6c680d70 Change type of return of jit_arg* and argument to jit_getarg*
* check/lightning.c, include/lightning.h, lib/jit_arm.c,
	lib/jit_mips.c, lib/jit_ppc.c, lib/jit_print.c,	lib/jit_x86.c,
	lib/lightning.c: Change return value of jit_arg{,_f,_d} to
	a jit_node_t* object, that should be used as argument to
	jit_getarg_{c,uc,s,us,i,ui,l,f,d}. This just requires changing
	from jit_int32_t to jit_pointer_t (or jit_node_t*) the "handle"
	for the getarg calls, with the benefit that it makes it easy
	to implement patching of the stack address of non register
	arguments, this way allowing to implement variable size stack
	frames if applicable; useful if there are too many registers and
	jit functions uses only a few callee save registers.
2012-12-28 10:35:14 -02:00
pcpa
374f58bb16 Add missing jit_htonr to ppc backend.
* lib/jit_ppc-cpu.c, lib/jit_ppc.c: Implement logic for
	jit_htonr for big endian, so that ppc (big endian) pass the
	new clobber.tst test case.
2012-12-22 16:30:43 -02:00
pcpa
2751320022 Correct stack.tst test case on ppc. Now all tests pass in all backends.
* include/lightning/jit_ppc.h: Correct mismatch of JIT_F{1,5}
	with enum codes, that were correct, and returned by jit_f().

	* lib/jit_ppc-cpu.c, lib/jit_ppc-fpu.c, lib/jit_ppc.c: Properly
	implement and better describe values when generating stack
	frames.
2012-12-20 14:34:28 -02:00
pcpa
a74318a1d7 Add new test case to check stack integrity on complex stack frames.
* 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.
2012-12-19 18:07:12 -02:00
pcpa
03559bb8cc Make it clear stdarg like abstraction is not supported.
* 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.
2012-12-14 15:21:39 -02:00
pcpa
6227bf5bf9 Add new varargs test and correct related test case failures in all ports. 2012-12-13 18:26:57 -02:00
pcpa
0b89a17ca2 Add jit_ellipis and remove jit_prepare argument.
* include/lightning.h, lib/jit_arm.c, lib/jit_mips.c,
	lib/jit_ppc.c, lib/jit_x86.c, lib/lightning.c: Change jit_prepare
	to no longer receive an argument. If receiving an argument, it
	should be an ABI specifier, not a boolean if varargs or not,
	and add the new jit_ellipsis call, to specify where the
	ellipsis is in the C prototype of the function being called.
	Note that currently it is not supported to define varargs
	functions and it will be ignored if calling jit_ellipsis not
	in a prepare/finish* block, but this should be addressed.

	* check/allocai.tst, check/alu_add.tst, check/alu_and.tst,
	check/alu_com.tst, check/alu_div.tst, check/alu_lsh.tst,
	check/alu_mul.tst, check/alu_neg.tst, check/alu_or.tst,
	check/alu_rem.tst, check/alu_rsh.tst, check/alu_sub.tst,
	check/alu_xor.tst, check/alux_add.tst, check/alux_sub.tst,
	check/bp.tst, check/branch.tst, check/cvt.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/rpn.tst,
	check/lightning.c: Update for the change to jit_prepare and
	addition of jit_ellipsis.
2012-12-12 22:59:52 -02:00
pcpa
a04df966c0 Make all current test cases pass in Darwin PowerPC.
* 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.
2012-12-11 13:14:09 -02:00
pcpa
760fab8d37 Correct mips backend implementation to pass initial tests.
* 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.
2012-12-04 12:39:10 -02:00
pcpa
01be83d480 Make mips backend compile on a qemu image.
* include/lightning/jit_mips.h, lib/jit_mips.c: Update to
	make the mips backend compile in a qemu image.

	* lib/jit_ppc.c: Minor adaptations to help in having the
	ppc backend compilable.
2012-12-04 00:27:44 -02:00
pcpa
712877a5a4 Correct implementation problems on ix86.
* 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-03 09:40:08 -02:00
pcpa
90a187a12e Correct integer multiplication and add extra test case.
* lib/jit_ppc.c: Assign copyright ownership to FSF.

	* lib/jit_x86-cpu.c: Correct integer multiplication that was
	generating code with reversed register arguments.

	* check/rpn.ok, check/rpn.tst: New test case file.
2012-12-03 00:07:29 -02:00
pcpa
b7c8db4ba4 Add extra files implementing different jit backends.
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.
2012-12-02 22:58:40 -02:00