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

88 commits

Author SHA1 Message Date
Paulo Andrade
2cea99361b Build and pass all tests on 32 and 64 bit sparc
* include/lightning/jit_private.h: Add new register classes to
	flag float registers and double only registers, required for sparc64
	where only low 32 bit fpr registers can be used for single precision
	operations.
	Add new 128 bit jit_regset_t type for sparc64 register set.

	* include/lightning/jit_sparc.h, lib/jit_sparc-cpu.c, lib/jit_sparc-fpu.c,
	lib/jit_sparc-sz.c, lib/jit_sparc.c: Update for 64 bits sparc.

	* lib/lightning.c: Update for new jit_regset_t required for sparc64.
2018-04-20 10:37:37 -03:00
Paulo Andrade
ed5589ce59 Build and pass all test cases on Alpha Linux
* check/lightning.c, include/lightning.h: Add the new jit_va_push
	interface. That should be called when passing a va_list to a C
	function. This is required because on Alpha a va_list is passed
	by value, and lightning does not know about data types, so, cannot
	understand it is pushing a va_list as argument.

	* lib/jit_names.c, lib/lightning.c: Minor changes for the new
	jit_code_va_push.

	* check/cva_list.c: Update only test case using jit_va_push, to
	pass a va_list to a C function.

	doc/body.texi: Better documentation of the varargs interface.

	* jit_alpha.c, jit_alpha-cpu.c: Update to properly push a
	C va_list and correctly calculate varargs offset.

	* lib/jit_aarch64-sz.c, lib/jit_aarch64.c, lib/jit_alpha-sz.c,
	lib/jit_arm-sz.c, lib/jit_arm.c, lib/jit_hppa-sz.c, lib/jit_hppa.c,
	lib/jit_ia64-sz.c, lib/jit_ia64.c, lib/jit_mips-sz.c, lib/jit_mips.c,
	lib/jit_ppc-sz.c, lib/jit_ppc.c, lib/jit_s390-sz.c, lib/jit_s390.c,
	lib/jit_sparc-sz.c, lib/jit_sparc.c, lib/jit_x86-sz.c, lib/jit_x86.c:
	Update for the new jit_va_push interface.
2018-02-26 09:48:50 -03:00
pcpa
59f32e85c3 Add extra argument to jit_update to prevent recursion on branches
* lib/lightning.c: Avoid deep recursions when computing live
	register ranges.
2018-01-31 17:09:29 -05:00
pcpa
3fc2eb2f95 Update copyright year 2017-09-14 10:44:12 -04:00
pcpa
d761499315 Add a second pass to compute live register ranges
* include/lightning/jit_private.h, lib/lightning.c: Add a
	second pass from start when computing register live ranges.
	This should be used temporarily, and is required for certain
	loop constructs, with several consecutive blocks not referencing
	a live register.
2017-05-09 13:27:37 -04:00
pcpa
aa939b8ef8 Correct wrong live information for some code patterns
* lib/lightning.c: Correct wrong movr simplification,
	remove no longer needed code to set return registers live
	and update live register set when reaching a label boundary,
	but do not descend if the block has been already visited.
	The later need some tuning for complex code generation, where
	it will still have issues.
2016-05-05 17:55:29 -03:00
pcpa
b00c750830 Correct wrong movr simplification 2016-05-05 11:19:45 -03:00
pcpa
d0a5bd8d3d Implement new synthesized IR codes sequences
* lib/jit_rewind.c: New file implementing generic functions
	to "rewind", or rewrite IR code sequences.

	* include/lightning.h: Add several new codes, that previously
	were a function call, that would synthesize the operation.
	Now, there is a code for the operation, and a new flag to
	know an operation is synthesized.

	* include/lightning/jit_private.h: Add several new macros to
	help construct synthesized IR code sequences.

	* lib/Makefile.am: Update for lib/jit_rewind.c.

	* lib/jit_disasm.c: Update for a small rework on jit_node_t,
	so that --enable-devel-disassembler does not need a change
	in the layout of jit_node_t.

	* lib/jit_names.c: Update for the new codes.

	* lib/jit_print.c: Update to print more readable output, and
	flag synthesized IR code sequences.

	* lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
	lib/jit_arm-sz.c, lib/jit_arm.c, lib/jit_x86-sz.c,
	lib/jit_x86.c: Update for new synthesized IR code sequences.

	* lib/jit_ppc-cpu.c, lib/jit_ppc-fpu., lib/jit_ppc-sz.c,
	lib/jit_ppc.c, lib/jit_mips-cpu.c, lib/jit_mips-fpu.c,
	lib/jit_mips-sz.c, lib/jit_mips.c, lib/jit_s390-fpu.c,
	lib/jit_s390-sz.c, lib/jit_s390.c: Update for new synthesized
	IR code sequences and correct bugs in the initial varargs
	implementation support.

	* lib/jit_alpha-sz.c, lib/jit_alpha.c, lib/jit_hppa-sz.c,
	lib/jit_hppa.c, lib/jit_ia64-sz.c, lib/jit_ia64.c,
	lib/jit_sparc-sz.c, lib/jit_sparc.c: Add generic, untested
	support for the new synthesized	IR code sequences. Known
	most likely broken right now, and should be corrected once
	access to these hosts is available.

	* lib/lightning.c: Update for new IR codes, and add support
	for not yet existing instructions that change third argument.

	* size.c: Change to use different tables for LE and BE PowerPC.
	Correct a wrong endif for x32.
2015-06-04 18:53:07 -03:00
pcpa
d639674549 Add initial support to implement vararg jit functions
* include/lightning.h, include/lightning/jit_private.h,
	lib/jit_names.c, lib/lightning.c: Add initial support
	for the new jit_va_start, jit_va_arg, jit_va_arg_d, and
	jit_va_end interfaces. The jit_va_start call is supposed
	to return a va_list compatible pointer, but not yet
	decided if it will be "declared" stdarg compatible,
	as for now only x86 support has been added (and should
	be compatible), but issues may arise on other backends.

	* check/lightning.c: Add wrappers to call the new jit_va_*
	interfaces.

	* lib/jit_x86-cpu.c, lib/jit_x86.c: Implement the new
	jit_va_* for x86.

	* lib/jit_x86-sz.c: Add fields, but not yet fully updated,
	as this is an intermediate commit.

	* lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
	lib/jit_alpha-sz.c, lib/jit_alpha.c,
	lib/jit_arm-sz.c, lib/jit_arm.c,
	lib/jit_hppa-sz.c, lib/jit_hppa.c,
	lib/jit_ia64-sz.c, lib/jit_ia64.c,
	lib/jit_mips-sz.c, lib/jit_mips.c,
	lib/jit_ppc-sz.c, lib/jit_ppc.c,
	lib/jit_s390-sz.c, lib/jit_s390.c,
	lib/jit_sparc-sz.c, lib/jit_sparc.c: Prepare for the
	new jit_va_* interfaces. Not yet implemented, and will
	cause an assertion if used.

	* check/va_list.tst: Simple early test case, that works
	on x86_64, x32, ix86, cygwin, and cygwin64.
2015-04-27 21:12:32 -03:00
pcpa
a15f261afc Update copyright date 2015-04-26 14:33:41 -03:00
pcpa
1507bc7ee5 Properly correct read of freed memory 2015-03-08 16:22:10 -03:00
pcpa
2597bf3c13 Correct inconsistency with jit_regno_patch
* lib/lightning.c: Remove the jit_regno_patch bitfield
	register fields before actual emit, as it is only really
	used before emit, otherwise, on special	conditions it
	may consider live registers as dead during code emit.
2015-02-16 15:07:36 -02:00
Paulo Andrade
f6970c62cf Correct the reason the simplify_stxi bug was not noticed before
* lib/lightning.c: Correct the reason the bug in
	simplify_stxi was not triggered before, it was due to
	incorrectly resetting the value->code field, what was
	causing it to never properly optimize:
		stxi Im0 Rb0 Rt0
		ldxi Rt1 Rb1 Im1
	when Rb0 == Rb1, Rt0 == Rt1 and Im0 == Im1
	There was another possible issue, that has been also
	addressed in this commit, that would be the case of
	Rbn == Rtn, where no redundancy removal is possible.
2015-02-03 15:42:50 -02:00
Paulo Andrade
5724068b1c Correct wrong check in simplify_stxi.
* lib/lightning.c: Correct wrong check in simplify_stxi.
	The test was incorrectly comparing the target register
	and the displacement offset. This was a time bomb bug,
	that would trigger in code like:
		stxi Im0 Rb0 Rt0
		stxi Im1 Rb1 Rt1
	if Rb0 == Rb1 && Rt0 == Rt1 && Im0 == Rt1, that is,
	the wrong check was Im0 == Rt1, instead of the supposed
	Im0 == Imm1 (that was what the code mean't to do). It
	was removing the second stxi assuming it was redundantly
	generated; as that is not uncommon pattern on
	translators generating jit.
2015-02-03 15:19:21 -02:00
pcpa
192f89c0ee S390: Replace s390x filenames with s390
* include/lightning/jit_s390.h, lib/jit_s390-cpu.c,
	lib/jit_s390-fpu.c, lib/jit_s390-sz.c, lib/jit_s390.c:
	Renamed s390x* files to s390*.

	* check/float.tst, check/lightning.c, configure.ac,
	include/lightning.h, include/lightning/Makefile.am,
	lib/Makefile.am, lib/jit_s390.c, lib/jit_size.c,
	lib/lightning.c: Update for renamed files.
2015-01-08 13:01:49 -02:00
pcpa
32c4f90a2b S390: Add support for 32 bit.
* include/lightning.h, include/lightning/jit_private.h,
        include/lightning/jit_s390x.h, lib/jit_disasm.c,
        lib/jit_s390x-cpu.c, lib/jit_s390x-fpu.c, lib/jit_s390x-sz.c,
        lib/jit_s390x.c, lib/jit_size.c, lib/lightning.c:
	Add support for generating jit for s390 32 bit. This change
	also removed %f15 from the list of temporaries fpr registers;
	it was not being used, but if were, it would corrupt the
	stack frame because the spill address would overwrite grp
	offsets.
2015-01-08 10:45:30 -02:00
pcpa
88aa2fcad2 Implement new, typed, jit_htonr* interfaces
* include/lightning.h: Split jit_htonr in the new 3 interfaces
	jit_htonr_us, jit_htonr_ui and jit_htonr_ul, the later only
	available on 64 bit. The plain/untyped jit_htonr macro call
	maps to the wordsize one.
	* lib/jit_aarch64-cpu.c,  lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
	lib/jit_alpha-cpu.c, lib/jit_alpha-sz.c, lib/jit_alpha.c,
	lib/jit_arm-cpu.c, lib/jit_arm-sz.c, lib/jit_arm.c,
	lib/jit_hppa-cpu.c, lib/jit_hppa-sz.c, lib/jit_hppa.c,
	lib/jit_ia64-cpu.c, lib/jit_ia64-sz.c, lib/jit_ia64.c,
	lib/jit_mips-cpu.c, lib/jit_mips-sz.c, lib/jit_mips.c,
	lib/jit_ppc-cpu.c, lib/jit_ppc-sz.c, lib/jit_ppc.c,
	lib/jit_s390x-cpu.c, lib/jit_s390x-sz.c, lib/jit_s390x.c,
	lib/jit_sparc-cpu.c, lib/jit_sparc-sz.c, lib/jit_sparc.c,
	lib/jit_x86-cpu.c, lib/jit_x86-sz.c, lib/jit_x86.c:
	Update backends for the new jit_htonr*.
	* check/lightning.c, lib/jit_names.c, lib/lightning.c:
	Update for the new jit_htonr* interfaces.
	* check/Makefile.am: Update for new test cases.
	* check/hton.ok, check/hton.tst: New test cases.
2014-12-25 23:06:24 -02:00
pcpa
c95a356c1a Remove a wrong optimization of callee save registers 2014-11-24 12:40:32 -02:00
pcpa
85ab988cd1 Resync with new patch to make functions receive a const argument 2014-11-01 22:32:23 -02:00
Holger Hans Peter Freyther
2229200c44 misc: Make jit_note and related functions take a const argument
Make jit_memcpy, jit_memmove, jit_data take const pointers to
allow jit_note to be used with a const string (e.g. a string
literal, __FILE__ or __func__). This is needed for GNU Smalltalk
to silence compiler warnings.

Sadly "const jit_pointer_t" is not the same as "typedef const void *"
so I introduced a new typedef for a const jit pointer. The other
option would be to replace jit_pointer_t with void*.
2014-11-01 18:52:27 -02:00
pcpa
9c5e2b511e Add label predicates
* include/lightning.h, lib/lightning.c: Add three predicates
	to query information about labels. jit_forward_p(label)
	will return non zero if the label is "forward", that is
	need a call to jit_link(label), jit_indirect_p(label)
	that returns non zero if the label was created with the
	jit_indirect() call, and jit_target_p(label) that will
	return non zero if there is at least one jump patched
	to land at that label.
2014-10-21 15:32:24 -02:00
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
20a2f1f9c5 Allow jit_jmpi on an immediate constant address.
* 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, lib/lightning.c: Allow jit_jmpi on a
	target that is not a node. This may lead to hard to
	debug code generation, but is a required feature for
	certain generators, like the ones that used lightning
	1.2x. Note that previously, but not really well
	documented, it was instructed to use:
	jit_movi(rn, addr); jit_jmpr(rn);
	but now, plain:
	jit_patch_abs(jit_jmpi(), addr);
	should also work.
2014-10-14 17:04:13 -03:00
pcpa
c8bb0dad56 Consider all callee_save_p regs as live on non trackable jumps 2014-09-07 15:32:32 -03:00
pcpa
45c4df506c Only mark callee save regs as live on jumps that cannot be tracked.
* lib/lightning.c: Do not mark all registers in unknown state
	as live on jit_jmpr, or jit_jmpi to an absolute address. Instead,
	treat it as a function call, and only consider JIT_Vn registers
	as possibly live.
2014-09-01 16:27:19 -03:00
pcpa
05b88d9d45 ALPHA: Implement lightning Alpha port.
* include/lightning/jit_alpha.h, lib/jit_alpha-cpu.c,
        lib/jit_alpha-fpu.c, lib/jit_alpha-sz.c, lib/jit_alpha.c:
	New files implementing a lightning Alpha port. Thanks
	to Trent Nelson and snakebit.net staff for providing access
	to an Alpha system.

        * check/float.tst, check/lightning.c, configure.ac,
        include/lightning.h, include/lightning/Makefile.am,
        include/lightning/jit_private.h, lib/Makefile.am,
        lib/jit_disasm.c, lib/jit_size.c, lib/lightning.c:
	Minor changes to adapt for the new Alpha port.
2014-08-10 11:48:35 -03:00
pcpa
53dd28d682 Always mark return registers as live in epilog
* lib/lightning.c: Always mark JIT_RET and JIT_FRET as
	live in a function epilog. This is required because
	on some ports a complex sequence, allocating one or more
	registers, may be required to jump from a ret* to the
	epilog, and the lightning api does not have annotations
	to know if a function returns a value, or the type of
	the return value.
2014-08-10 11:39:53 -03:00
pcpa
f79f9777b1 Correct change of possibly wrong bitmask in jit_update
* lib/lightning.c: Change the correct live bitmask of
	return registers after a function call in jit_update.
2014-08-10 11:36:08 -03:00
pcpa
dbf2847e47 Do not have assertions with a long type test
* lib/lightning.c: Change assertions to have an int
	result and correct a bad bit mask assertion.
2014-08-10 11:33:00 -03:00
pcpa
0d9ac79a12 Do not pass null for free, memcpy and memmove
* lib/jit_memory.c: Do not call free on NULL pointers.

	* include/lightning/jit_private.h, lib/jit_note.c,
	lib/lightning.c: Add a wrapper to memcpy and memmove
	to not actually call those functions with a zero size
	argument, and likely also a null src or dst.
2014-07-29 10:29:49 -03:00
pcpa
a8c180a926 Remove the global but not advertised jit_progname variable
* include/lightning/jit_private.h, lib/jit_disasm.c,
	lib/lightning.c: Remove the global jit_progname variable.
	It was being only used in jit_init_debug, that is called
	from init_jit, so, just pass an argument.
2014-07-27 16:48:52 -03:00
pcpa
33ee2337c7 Implement the new jit_set_data interface.
* include/lightning.h, include/lightning/jit_private.h,
	lib/lightning.c: Implement the new jit_set_data() interface,
	and the new jit_get_data() helper. Like jit_set_code(),
	jit_realize() should be called before jit_set_data().
	The most common usage should be jit_set_data(JIT_DISABLE_DATA
	| JIT_DISABLE_NOTE), to force synthesize any float/double
	constant in the stack and not generate any debug information.

	* lib/jit_note.c: Minor change to debug note generation as
	now it uses an alternate temporary data buffer during constants
	and debug generation to accommodate the possibility of the user
	setting an alternate data buffer.

	* lib/jit_hppa-fpu.c, lib/jit_s390x.c, lib/jit_s390x-cpu.c,
	lib/jit_s390x-fpu.c, lib/jit_sparc.c, lib/jit_sparc-fpu.c,
	lib/jit_x86-sse.c, lib/jit_x86-x87.c: Implement jit_set_data.

	* lib/jit_hppa-sz.c, lib/jit_sparc-sz.c, lib/jit_x86-sz.c,
	lib/jit_s390x-sz.c: Update for several instructions that now
	have a different maximum length due to jit_set_data.

	* lib/jit_mips-fpu.c: Implement jit_set_data, but missing
	validation on n32 and n64 abis (and/or big endian).

	* lib/jit_mips-sz.c: Update for changes in o32.

	* lib/jit_ppc-fpu.c: Implement jit_set_data, but missing
	validation on Darwin PPC.

	* lib/jit_ppc-sz.c: Update for changes in powerpc 32 and
	64 bit.

	* lib/jit_ia64-fpu.c: Implement untested jit_set_data.

	* TODO: Add note to list ports that were not tested for the
	new jit_set_data() feature, due to no longer having access
	to them.

	* check/nodata.c: New file implementing a simple test exercising
	several different conditions created by jit_set_data().

	* check/check.nodata.sh: New file implementing a wrapper
	over the existing *.tst files, that runs all tests without
	using a data buffer for constants; only meaningful (and
	enabled) on architectures that used to store float/double
	constants on a read only data buffer.

	* configure.ac, check/Makefile.am: Update for the new test
	cases.

	* check/lightning.c: Implement the new "-d" option that
	sets an internal flag to call jit_set_data() disable
	constants and debug, that is, using only a pure code
	buffer.
2014-03-12 14:50:31 -03:00
pcpa
79bc3d03dd Implement the new jit_set_code interface.
* include/lightning.h, include/lightning/jit_private.h,
	lib/lightning.c: Implement the new jit_set_code() interface,
	that allows instructing lightning to use an alternate code
	buffer. The new jit_realize() function should be called
	before jit_set_code(), and usually call jit_get_code()
	to query the amount of bytes expected to be required for
	the code.

	* lib/jit_size.c: Minor update to have less chances of
	miscalculating the code buffer by starting the counter
	with the size of the longest instruction instead of zero,
	as code emit fails if at any moment less than the longest
	instruction bytes are available.

	* check/setcode.c: New file implementing some basic tests
	of the new jit_set_code() interface.

	* check/Makefile.am: Update for newer test case.
2014-03-11 11:40:42 -03:00
pcpa
a9433b5a2c Implement and document the new jit_indirect call.
* include/lightning.h, lib/lightning.c: Add the new
	jit_indirect() call, that returns a special label node,
	and tells lightning that the label may be the target of
	an indirect jump.

	* doc/body.texi: Document the new jit_indirect() call, and
	add examples of different ways to create labels and branches.
2014-03-06 18:20:29 -03:00
pcpa
6e75c0352d Rewrite jit_regset_scan1 for easier optimization.
* include/lightning/jit_aarch64.h, include/lightning/jit_arm.h,
	include/lightning/jit_hppa.h, include/lightning/jit_ia64.h,
	include/lightning/jit_mips.h, include/lightning/jit_ppc.h,
	include/lightning/jit_s390x.h, include/lightning/jit_sparc.h,
	include/lightning/jit_x86.h: Change jit_regset_t to an
	unsigned type, to allow safe right shift.

	* lib/lightning.c: Rewrite jit_regset_scan1 to allow easier
	compiler optimization.
2014-02-19 14:38:14 -03:00
pcpa
a264ccee75 Add assertion to detect double patching.
This triggers the bug at the right point, otherwise, double patching
may be quite hard to track.
2013-10-16 01:13:46 -03:00
pcpa
f42a251ff1 Correct misplaced check for already visited blocks 2013-10-01 13:51:01 -03:00
pcpa
b768fab8b1 Add code to calculate code buffer size based on devel time information.
* lib/jit_aarch64-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_s390x-sz.c, lib/jit_size.c, lib/jit_sparc-sz.c,
	lib/jit_x86-sz.c: New files implementing static tables
	with longest known instructions length generated to match
	a lightning instruction. These tables should make it easier
	to make it very unlikely to ever miscalculate, or by too
	much, the size of a code buffer.

	* lib/jit_size.c: New file that aids to either collect
	jit code size information, or use the information depending
	on build options.

	* size.c: New helper file that parses input for, and create
	an initial jit_$arch-sz.c file, that needs some minor edit
	for arches with multiple configurations.

	* configure.ac, Makefile.am: Add the new, devel mode only
	--enable-devel-get-jit-size configure option, that sets
	compile time flags to collect jit code size information,
	that will be used as input for the "noinst size program".

	* lib/jit_aarch64.c, lib/jit_arm.c, lib/jit_disasm.c,
	lib/jit_hppa.c, lib/jit_ia64.c, lib/jit_memory.c,
	lib/jit_mips.c, lib/jit_ppc.c, lib/jit_s390x.c,
	lib/jit_sparc.c, lib/jit_x86.c, lib/lightning.c: Minor
	changes for the --enable-devel-get-jit-size build mode,
	as well as the "production build mode" with jit code
	size information.
2013-09-24 03:31:54 -03:00
pcpa
95e3fbc8bc Add the new jit_pointer_p predicate interface.
* include/lightning.h, lib/lightning.c: Add the new
	jit_pointer_p interface, that returns a boolean value
	telling if the pointer argument is inside the jit
	code buffer. This is useful to avoid the need to add
	extra labels and calls to jit_address to figure bounds
	of code buffer, and still keep internal data private.
2013-09-14 14:43:05 -03:00
pcpa
a62f405751 Add the jit_callee_save_p interface and extra register definitions.
* check/self.c, check/self.ok: New files implementing simple
	consistency check assertions. At first validating some macros
	that use values from different sources agree.

	* check/Makefile.am: Update for the new test case.

	* include/lightning.h,  lib/lightning.c: Add the new
	jit_callee_save_p() call, that is intended to be used when
	writing complex code using lightning, so that one does not
	need to verify what backend is being used, or have access to
	private data, to query if a register is callee save or not;
	on several backends the scratch registers are actually callee
	save.

	* include/lightning/jit_aarch64.h, include/lightning/jit_arm.h,
	include/lightning/jit_hppa.h, include/lightning/jit_mips.h,
	include/lightning/jit_ppc.h, include/lightning/jit_sparc.h,
	include/lightning/jit_x86.h: Add an explicit definition for
	JIT_R3-JIT_Rn, JIT_V3-JIT_Vn and JIT_F6-JIT_Fn when applicable.
	This allows one to write code based on "#if defined(JIT_XN)"
	and therefore, not need to check what is the current backend
	or have access to private data structures. This is particularly
	useful when writing virtual machines with several specialized,
	global registers.

	* lib/jit_ia64.c: Properly flag the callee save general
	purpose registers as such, so that jit_callee_save_p() works
	as intended.
2013-09-10 21:41:49 -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
b5763c42aa Correct license to properly advertise LGPLv3 and not GPLv3. 2013-08-11 18:08:52 -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
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
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
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
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