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

21 commits

Author SHA1 Message Date
pcpa
960280decd Implement the jit_rsb* interface.
* 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).
2014-10-18 11:31:18 -03:00
pcpa
afae5407f6 Implement the jit_align interface
* 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.
2014-10-14 17:05:25 -03:00
pcpa
839341a498 Implement jit_frame and jit_tramp interfaces
* 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.
2014-10-14 17:04:40 -03:00
pcpa
b58960638d Add consistency check on temporaries during a jump
* lib/jit_aarch64-cpu.c, lib/jit_aarch64-fpu.c,
	lib/jit_arm-cpu.c, lib/jit_arm-vfp.c,
	lib/jit_hppa-cpu.c, lib/jit_hppa-fpu.c,
	lib/jit_ia64-cpu.c, lib/jit_ia64-fpu.c,
	lib/jit_mips-cpu.c, lib/jit_mips-fpu.c,
	lib/jit_ppc-cpu.c, lib/jit_ppc-fpu.c,
	lib/jit_s390x-cpu.c, lib/jit_s390x-fpu.c,
	lib/jit_s390x.c, lib/jit_sparc-cpu.c,
	lib/jit_x86-cpu.c, lib/jit_x86-sse.c,
	lib/jit_x86-x87.c: Review generation of all branch
	instructions and always adds the jit_class_nospill
	bitfield for temporary registers that cannot be	spilled
	because the reload would be after a conditional jump; the
	patch only adds an extra assertion. These conditions do
	not happen on documented lightning usage, but can happen
	if one uses the not exported jit_get_reg and jit_unget_reg
	calls and cause enough register starvation.
2014-08-16 20:31:55 -03:00
pcpa
cf2be67c5a MIPS: Correct use of wrong test register
* lib/jit_mips-cpu.c: Correct typo in the jit_bmsr
	implementation that was using the wrong test result
	register.
2014-08-10 11:21:57 -03:00
pcpa
52bfc67192 MIPS: Build and pass all test cases on mips64.
* include/lightning/jit_mips.h, lib/jit_mips-cpu.c,
	lib/jit_mips-sz.c, lib/jit_mips.c, size: Build and
	pass all test cases on Irix big endian mips using
	the 64 bit abi.
2013-10-04 00:01:31 -03:00
pcpa
b5763c42aa Correct license to properly advertise LGPLv3 and not GPLv3. 2013-08-11 18:08:52 -03:00
pcpa
c078a972b4 Cosmetic removal of white spaces in end of lines. 2013-08-10 11:38:43 -03:00
pcpa
d6110f6cf3 Build and pass all tests on big endian Irix mips using the n32 abi.
* check/lightning.c, configure.ac, include/lightning.h,
	lib/lightning.c: Add tests and quirks to build/detect
	and/or work on Irix.

	* include/lightning/jit_mips.h, lib/jit_mips-cpu.c,
	lib/jit_mips-fpu.c, lib/jit_mips.c: Adapt code to run
	in big endian mips, using the n32 abi.
2013-06-22 19:44:00 -03:00
pcpa
ce6ab1f09e Prepare for the first alpha release of lightning 2.0. 2013-06-05 20:18:54 -03:00
pcpa
c2e4eb621d Add basic Itanium port infrastructure.
* 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.
2013-04-25 21:56:32 -03:00
pcpa
7bdd22bd99 Make it simpler to add support for more than 64 registers.
* 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.
2013-04-10 15:07:01 -03:00
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
e304bc8bf9 Pass all but the (not yet implemented) qmul and qdiv tests in sparc
* 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.
2013-02-19 01:06:18 -03: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
1287a2d448 Correct extra regressions found by the call.tst test case.
* lib/jit_arm.c, lib/jit_mips-cpu.c, lib/jit_mips.c: Correct
	regressions when patching jit_calli for a forward function.

	* lib/jit_ppc-cpu.c: Correct wrong arguments to ANDI opcode
	in jit_getarg_u{c,s} implementation.
2012-12-28 10:28:50 -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
a3fbc5da96 Correct test cases in the mips backend.
* lib/jit_mips-cpu.c: Correct all current test cases.
	  Call the "xori" not the "XORI" macro for jit_xori implementation,
	as the XORI macro handles only 16 bit unsigned values.
	  Call the "movr" macro, not the "movi" macro in the special
	case of adding or subtracting zero.
	  Use the proper temporary register in the jit_andr implementation.
2012-12-10 21:14:50 -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
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
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