1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-06 07:30:28 +02:00
Commit graph

243 commits

Author SHA1 Message Date
pcpa
183ed91756 IA64: Correct code to save/restore r2 used as lightning JIT_FP.
* lib/jit_ia64-cpu.c: Correct incorrect logic when restoring
	the value of the "r2" callee save register.
2013-09-10 21:17:44 -03:00
pcpa
c6ced6662d Add missing jit_clear_state to documentation sample. 2013-09-09 19:21:49 -03:00
pcpa
b279feb7c5 Add fallback logic instead of error if cannot figure __WORDSIZE.
This was an issue on FreeBSD 8.x, and the logic used is the same as
FreeBSD 9.1 stdint.h.
2013-09-09 19:19:45 -03:00
pcpa
b8770059dc Correct wrong test and update of arm thumb offset information.
* lib/jit_arm-cpu.c, lib/jit_arm.c: Correct wrong test and update
	of the thumb offset information, when checking if needing to
	patch a jump from arm to thumb mode. The problem would happen when
	remapping the code buffer, and the new address being lower than
	the previous one.
2013-08-29 17:08:05 -03:00
pcpa
ba182b139a Avoid possible problem if built with gcc 4.8 or newer.
The problem happens due to undefined behavior in post increment when
accessing data through an union and the data being modified in the
expression.
2013-08-29 12:59:40 -03:00
pcpa
bc0786e933 test for zlib in configure.ac 2013-08-27 18:29:31 -03:00
pcpa
ecf753f94f Correct build and check on NetBSD amd64.
* configure.ac: Extend FreeBSD test to also handle NetBSD.

	* lib/jit_x86-cpu.c: Correct wrongly defined offset type of
	ldxi_ui. Problem detected when building on NetBSD.

	* lib/lightning.c: Adjust code to handle NetBSD mremap,
	where arguments do not match Linux mremap.
2013-08-26 16:31:42 -03:00
pcpa
7f677a6d4f Correct build and make check on gcc111 - AIX 7.1.
lib/jit_ppc.c: Correct C sequence point problem miscalculating
	the actual function address in a function descriptor. Problem
	happens with gcc 4.8.1 at least.
2013-08-26 15:53:40 -03:00
pcpa
32b3d7a7a4 Correct build on FreeBSD/amd64 2013-08-26 12:40:20 -03:00
pcpa
aa1e0be49b GNU lightning 2.0.0 release 2013-08-23 15:16:18 -03:00
pcpa
b5763c42aa Correct license to properly advertise LGPLv3 and not GPLv3. 2013-08-11 18:08:52 -03:00
pcpa
19e227e035 Correct off by one bug on s390x subi.
* lib/jit_s390x-cpu.c: Correct code checking if immediate
	fits instruction, but using the negated value.
2013-08-11 18:07:44 -03:00
pcpa
c078a972b4 Cosmetic removal of white spaces in end of lines. 2013-08-10 11:38:43 -03:00
pcpa
f6ee396ccb New s390x port built on the hercules emulator and fedora 16 image.
* include/lightning/jit_s390x.h, lib/jit_s390x-cpu.c,
	lib/jit_s390x-fpu.c, lib/jit_s390x.c: New files
	implementing the new s390x port.

	* configure.ac, include/lightning.h,
	include/lightning/Makefile.am,
	include/lightning/jit_private.h,
	lib/Makefile.am, lib/jit_disasm.c, lib/lightning.c:
	Minor adaptation for the new s390x backend.

	* check/float.tst: Update for the s390x result of
	truncating +Inf to integer.

	* check/qalu_mul.tst: Add extra test cases to better test
	high word of signed multiplication as the result is
	adjust from unsigned multiplication on s390x.
2013-07-28 14:13:39 -03:00
pcpa
a3891adb4b Do not assume cast of nan or inf double to float always work.
* check/lightning.c: Do not assume casting a double NaN or
	Inf to float will produce the expected float NaN or Inf.
	This is not true at least under s390x.
2013-07-28 14:05:38 -03:00
pcpa
ab7d15ddd2 Properly check tests output.
* check/check.arm.sh, check/check.sh, check/check.swf.sh,
	check/check.x87.sh: Properly check test programs output,
	not just rely on the test program self testing the results
	and not crashing.
2013-07-28 14:01:22 -03:00
pcpa
e99c157842 Cosmetic removal of unused macros.
* lib/jit_aarch64.c: Remove unused macros left from cut&paste
	of jit_arm.c.
2013-07-28 13:58:06 -03:00
pcpa
89a0b7a10b New aarch64 port built on the Foundation v8 emulator.
* include/lightning/jit_aarch64.h, lib/jit_aarch64-cpu.c,
	lib/jit_aarch64-fpu.c, lib/jit_aarch64.c: New files
	implementing the new aarch64 port, as a new architecture,
	not as an expansion of the existing armv[4-7] port.

	* check/lightning.c: Add aarch64 support and a small
	change to recognize character constants as immediate
	values.

	* check/float.tst: Add aarch64 preprocessor conditionals
	to select proper expected value when converting [+-]Inf
	and NaN to integer.

	* include/lightning/jit_arm.h, lib/jit_arm.c: Minor changes
	to better match the new aarch64 files.

	* configure.ac, include/lightning.h,
	include/lightning/Makefile.am, include/lightning/jit_private.h,
	lib/Makefile.am, lib/lightning.c: Minor adjustments
	for the aarch64 port.
2013-07-16 20:09:02 -03:00
pcpa
4f9b9d9b2e Second alpha release 1.99a 2013-07-08 11:58:03 -03:00
pcpa
8b28150303 Correct mips o32 abi that was broken when adding n32 abi support.
* lib/jit_mips.c: Correct cut&paste error that caused wrong
	stack offset calculation for double arguments in stack in
	the o32 abi.
	Correct typo in the __LITTLE_ENDIAN macro name, that came
	from cut&paste error in the original typo in lib/jit_ppc.c.

	* lib/jit_ia64.c, lib/jit_ppc.c: Correct typo in the
	__LITTLE_ENDIAN macro name.
2013-06-25 12:21:07 -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
dbe0fb9bfa Correct build and pass all tests on Solaris x86.
* include/lightning.h: Minor extra preprocessor testing
	to "detect" byte order on x86 solaris, that now builds
	and pass all test cases.
2013-06-18 23:22:07 -03:00
pcpa
af92c5adfe Correct build and pass all tests on Solaris Sparc.
* 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.
2013-06-18 22:54:29 -03:00
pcpa
7807aab036 Update ia64 port to work on HP-UX.
* configure.ac: Force -mlp64 to CFLAGS on HP-UX ia64 port.
	It is the only supported mode, and expects gcc as C compiler.

	* include/lightning.h, lib/jit_ia64-cpu.c, lib/jit_ia64.c:
	Correct ia64 port to work on HP-UX that runs it in big endian
	mode.
2013-06-14 15:47:13 -03:00
pcpa
443b7467c8 Remove redundancy in the hppa cache synchronization code.
* lib/jit_hppa.c: Sanitize the cache synchronization inline
	assembly code that was doing twice the work and redundantly
	flushing the end address every loop iteration.
2013-06-10 16:23:44 -03:00
pcpa
e82e5be448 Build and pass all test cases on a multiprocessor HP-UX.
* configure.ac, check/Makefile.am, doc/Makefile.am: Do not
	explicitly link to -ldl, but instead autodetect the library
	with dlopen, dlsym, etc.

	* check/lightning.c: Add workaround to apparently buggy
	getopt in HP-UX that sets optind to the wrong index, and
	use RTLD_NEXT on HP-UX instead of RTLD_DEFAULT to dlsym
	global symbols.

	* include/lightning.h: Rework definitions of wordsize and
	byte order to detect proper values on HP-UX.

	* lib/lightning.c: Minor correction to use MAP_ANONYMOUS
	instead of MAP_ANON on HP-UX.

	* lib/jit_hppa.c: Float arguments must be passed on integer
	registers on HP-UX, not only for varargs functions.
	  Add code to properly clear instruction cache. This was
	not required on Debian hppa port, but may have been working
	by accident.

	* lib/jit_hppa-cpu.c: Follow pattern of HP-UX binaries and
	use bve,n instead of bv,n to return from functions.

	* lib/jit_hppa-fpu.c: For some reason "fst? frX,rX,(rY)" did
	not work on the tested computer	(HP-UX B.11.23 U 9000/785 HP-UX)
	so the code was changed, at first for __hpux only to add the
	base and offset register and use the instruction with an
	immediate (zero) offset.
2013-06-09 18:31:50 -03:00
pcpa
3e5a12f747 Adjust lightning to work on ppc AIX.
Many thanks to Trent Nelson from snakebite.org for giving access to a
build farm with several different architectures and operating systems.

	* check/lightning.c, lib/jit_disasm.c, lib/jit_ppc-cpu.c,
	lib/jit_ppc-fpu.c, lib/jit_ppc.c, include/lightning.h,
	include/lightning/jit_ppc.h, include/lightning/jit_private.h:
	Adapt code to work on 32 bit AIX ppc using gcc. Most changes
	are basically to adapt the elf64 logic to 32 bit, as it does
	not use the same convention of 32 bit Darwin ppc.

	* check/stack.tst: Add a fake memcpy function to the test
	case if running under AIX, as it is not available to dlsym.

	* configure.ac: Check for getopt.h header, not available in
	AIX.
2013-06-07 21:27:52 -03:00
pcpa
ce6ab1f09e Prepare for the first alpha release of lightning 2.0. 2013-06-05 20:18:54 -03:00
pcpa
3356b9d93a Add functional hppa port. All tests pass.
* include/lightning/jit_hppa.h, lib/jit_hppa-cpu.c,
	lib/jit_hppa-fpu.c, lib/jit_hppa.c: New files implementing
	the hppa port. Built on Debian Linux PA-RISC 2.0, 32 bit.

	* check/float.tst: Add preprocessor for hppa expected
	values when converting NaN and +-Inf to an integer.

	* check/ldst.inc: Ensure double load/store tests use an
	8 byte aligned address by default.

	* lib/lightning.c: Correct a bug found during tests in
	the new port, where qmul* and qdiv* were not properly
	setting one of the result registers as modified in the
	function, what would be a problem if the only "write"
	usage were the qmul* or qdiv*.

	* check/varargs.tst, check/varargs.ok: Add one extra
	interleaved integer/double test to validate proper code
	generation in the extra case.

	* check/lightning.c, configure.ac, include/lightning.h,
	include/lightning/Makefile.am,
	include/lightning/jit_private.h, lib/Makefile.am,
	lib/jit_disasm.c: Update for the hppa port.
2013-06-01 01:53:33 -03:00
pcpa
e80b244f34 Remove remaining ia64 port debug code. 2013-04-27 22:49:15 -03:00
pcpa
6ef03b0e04 Finish Itanium port, correcting remaining failing test cases.
* check/varargs.tst: Correct misplaced .align directive
	that was causing the double buffer to not be aligned at
	8 bytes.
	* lib/jit_ia64-cpu.c:
	  Properly implement abi for excess arguments passed on
	stack.
	  Simplify load/store with immediate displacement argument
	with zero value.
	  Simplify some calls to "subi" changing to "addi" with
	a negative argument.
	  Remove some #if 0'ed code, that could be useful in
	special conditions, but the most useful one would be
	to "optimize" "static" jit functions, but for the sake
	of simplicity, jit functions are implemented in a way
	that can be passed back to C code as C function pointers.
	  Add an attribute to prototypes of several unused functions.
	These functions are defined for the sake of implementing all
	Itanium documented instructions, but a significant amount of
	them is not used by lightning.
	* lib/jit_ia64-fpu.c: Simplify load/store with zero immediate
	displacement and add unused attribute for functions not used
	by lightning, but required to provide macros implementing all
	Itanium documented instructions.
	* lib/jit_ia64.c: Update for the properly implemented abi
	for stack arguments.
	* lib/lightning.c: Mark an unused function as such.
2013-04-27 22:31:29 -03:00
pcpa
cee4ccb7d4 Correct remaining test cases, but not yet ones with stack arguments.
lib/jit_ia64-cpu.c:
	  Correct immediate range check of integer comparisons when
	inverting arguments.
	  Correct gei_u that was not decrementing immediate when
	inverting arguments.
	  Correct b?add* and b?sub* that were not properly updating
	the result register.
2013-04-27 17:58:17 -03:00
pcpa
119ea1e97d Correct the cvt.tst test case on Itanium.
* lib/jit_ia64-cpu.c: Correct wrong mapping of 2 instructions
	in "M-, stop, M-, stop" translation, that was ignoring the
	last stop (implemented as a nop I- stop).

	* lib/jit_ia64-fpu.c: Properly implement fnorm.s and fnorm.d,
	as well as the proper integer to float or double conversion.
2013-04-27 17:16:01 -03:00
pcpa
f52b976390 Correct all ldst test cases.
* lib/jit_ia64-cpu.c: Correct bogus implementation of ldr_T
	for signed integers, that was using ld1.s, ld2.s and ld4.s.
	The ".s" stands for speculative load, not sign extend.

	* lib/jit_ia64-fpu.c: Correct bogus implementation of ldxr_T
	for float and double. The third (actually, second) argument
	is indeed added to the base register, but the base register
	is modified. The actual M7 implementation was already correct,
	just the ldxr_f and ldxr_d implementation that was kept in
	a prototype state, misinterpreting what M7 does.
2013-04-27 16:13:44 -03:00
pcpa
2475ae88d4 Correct float division and LX with stop code generation.
* lib/jit_ia64-cpu.c: Correct X2 pattern matching by preventing
	it to attempt to require a stop between the L and the X
	instruction; that is, check the registers and predicates
	before emitting the L instruction, not after.

	* lib/jit_ia64-fpu.c: Slightly simplify and correct
	divr_f and divrd_d implementation.

	* check/lightning.c: Add __ia64__ preprocessor define
	on Itanium.

	* check/alu.inc, check/clobber.tst, check/float.tst: Define
	several macros conditionally to __ia64__. This is required
	because __ia64__ jit generation can use way too many memory,
	due to not implementing instruction reordering to avoid
	as much as possible "stops", what causes way too many nops
	to be generated, as well as the fact that division and
	remainder requires function calls, and float division
	requires significant code to implement.
2013-04-27 04:37:57 -03:00
pcpa
caeb6d6e11 Implement fpr register arguments and minor extra fixes.
* include/lightning.h: Add new backend specific movr_w_d,
	movr_d_w and movi_d_w codes as helpers to ia64 varargs
	functions arguments.

	* lib/jit_ia64-cpu.c:
	  Correct wrong encoding of A5 small integers.
	  Correct define of "mux" instruction modifiers.
	  Correct ordering of arguments and predicates of cmp_xy
	implementation with immediate arguments; like most other
	codes with an immediate, the immediate is the second, not
	the third argument.

	* lib/jit_ia64-fpu.c: Actual implementation of the code
	to move to/from gpr to/from fpr, to implement varargs abi.

	* lib/jit_ia64.c: Make fpr argument registers not allocatable
	as temporaries, no need for the extra checks when there are
	plenty registers.

	* lib/jit_print.c, lib/lightning.c: Minor updates for the
	new movr_w_d, movr_d_w and movi_d_w codes.
2013-04-27 01:41:46 -03:00
pcpa
b663d29bea Correct race condition if register is written more than once
* lib/jit_ia64-cpu.c, lib/jit_ia64-fpu.c: Correct code to
	also insert a stop to break an instruction group if a
	register is written more than once in the same group.
	This may happen if a register is argument and result of
	some lightning call (not a real instruction). The most
	common case should be code in the pattern:
		movl rn=largenum
		...
		mov rn=smallnum
	where "rn" would end up holding "largenum".
	But the problem possibly could happen in other circumstances.
2013-04-26 21:26:00 -03:00
pcpa
746f3bb6c7 Correct jit implementation to pass several test cases.
* include/lightning/jit_ia64.h, lib/jit_ia64-cpu.c,
	lib/jit_ia64-fpu.c, lib/jit_ia64.c:
	  Relocate JIT_Rn registers to the local registers, as, like
	float registers, div/rem and sqrt are implemented as function
	calls, and may overwrite non saved scratch registers.
	  Change patch_at to receive a jit_code_t instead of a
	jit_node_t, so that it is easier to "inline" patches when
	some instruction requires complex code to implement, e.g.
	uneq and ltgt.
	  Correct arguments to FMA and FMA like instructions that,
	due to a cut&paste error were passing the wrong argument
	to the related F- implementation function.
	  Rewrite ltgt to return the proper result if one (or both)
	of the arguments is unordered.
2013-04-26 21:07:40 -03:00
pcpa
89f1e2f608 Properly split instruction groups for predicate registers.
* include/lightning/jit_ia64.h, include/lightning/jit_private.h,
	lib/jit_ia64-cpu.c, lib/jit_ia64-fpu.c, lib/jit_ia64.c,
	lib/lightning.c: Rework code to detect need of a "stop" to
	also handle predicates, as if a predicate is written, it
	cannot be read in the same instruction group.
	  Use a single jit_regset_t variable for all registers when
	checking need for a stop (increment value by 128 for
	float registers).
	  Correct wrong "subi" implementation, as the code executed
	is r0=im-r1, not r0=r1-im.
	  Use standard lightning 6 fpr registers, and rework to
	use callee save float registers, that may be spill/reloaded
	in prolog/epilog. This is required because some jit
	instructions implementations need to call functions; currently
	integer div/mod and float sqrt, what may change the value of
	scratch float registers.
	  Rework point of "sync" of branches that need to return a
	patch'able address, because the need for a "stop" before a
	predicate read causes all branches to be the instruction
	in slot 0, as there is no template to "stop" and branch
	in the same instruction "bundle".
2013-04-26 06:02:29 -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
066db584c9 Ensure the end argument of __clear_cache is page aligned.
* lib/jit_arm.c, lib/jit_ppc.c: Do not rely on __clear_cache
	aligning to the next page boundary the end argument. It may
	actually truncate it.
2013-04-08 18:00:36 -03:00
pcpa
51c96f9e19 Do not start over jit generation if can safely grow buffer size.
* 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.
2013-03-29 12:53:40 -03:00
pcpa
c39def9dce Add a simple memory management wrapper.
* 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.
2013-03-29 12:10:36 -03:00
pcpa
be9068f2ee Correct wrong shift value for 32 bit 2013-03-22 19:48:44 -03:00
pcpa
f341d91e2b Remove non optional gmp dependency.
* configure.ac, include/lightning/jit_private.h, lib/lightning.c:
	Remove dependency on gmp. Only a simple bitmap was required, and
	that was not enough reason to force linking to gmp and possible
	complications caused by it.
2013-03-22 18:28:42 -03:00
pcpa
7ef8060fb2 Adapt PowerPC port to work in Darwin 32 bit and Linux 64 bit.
* 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.
2013-03-10 15:36:25 -03:00
pcpa
19123bae5d Add missing __ppc__ definition.
* check/lightning.c: Add missing ppc preprocessor definition.
2013-03-08 12:13:09 -03:00
pcpa
5d60ba7b05 Minor updates when testing on a prototype, quadcore Loongson mips.
* check/float.tst: Comment out the int to negative infinity
	test in mips for the moment because not all Loongson agrees
	on the result.

	* lib/jit_disasm.c: Add a test instead of an assertion
	when loading symbols for disassembly due to a failure with
	a simple binutils build in Debian mipsel64.
2013-03-06 16:57:43 -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