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

18 commits

Author SHA1 Message Date
pcpa
e6a14a61eb Finish sparc port.
* check/lightning.c: Remove state flag to work with partial
	sparc port, by just disassembling if there was incomplete
	code generation.

	* jit_sparc-cpu.c: Correct wrong range check for immediate
	integer constants (off by one bit shift).
	  Correct macro implementing equivalent "rd %y, rd" assembly.
	  Implement qmul* and qdiv*.

	* jit_sparc.c: Update for qmul* and qdiv* and remove logic
	to handle incomplete code generation during sparc port.
2013-02-19 17:28:38 -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
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
8f020fe044 Add code to release all memory used by the jit state.
* include/lightning.h, lib/lightning.c: Implement the new
	jit_clear_state and jit_destroy_state calls. jit_clear_state
	releases all memory not required during jit_execution; that
	is, leaves only the mmap'ed data and code buffers allocated.
	jit_destroy_state releases the mmap'ed buffers as well as
	the jit_state_t object itself, that holds pointers to the
	code and data buffers, as well as annotation pointers (for
	disassembly or backtrace) in the data buffer.

	* lib/jit_note.c: Correct invalid vector offset access.

	* check/ccall.c, check/lightning.c, doc/ifib.c, doc/incr.c,
	doc/printf.c, doc/rfib.c, doc/rpn.c: Use the new jit_clear_state
	and jit_destroy_state calls, to demonstrate the new code to
	release all jit memory.

	* doc/body.texi: Add basic documentation and usage description
	of jit_clear_state and jit_destroy_state.
2013-02-11 15:51:55 -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
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
c5421a8c76 Make JIT_RET, JIT_FRET and JIT_SP private.
* check/add.tst, check/allocai.tst, check/bp.tst, check/divi.tst,
	check/fib.tst, check/lightning.c, 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:
	Make JIT_RET, JIT_FRET and JIT_SP private. These should not be
	used in any operations due to frequently having special
	constraints (usually JIT_FRET). JIT_FP must be made available
	because it must be used as the base register to access stack
	space allocated with jit_allocai.
2013-01-17 16:13:29 -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
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
3ee09ecc64 Add simple test case to test argument and return values.
* check/call.ok, check/call.tst: New test cases to validate
	simple typed argument and return values in function calls.

	* check/lightning.c: Properly handle jit_movi of labels for
	backward and forward code labels.

	* check/Makefile.am: Update for new test case.
2012-12-23 20:28:05 -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
b43ea1f908 Add two extra test cases for float operations.
* check/fop_abs.ok, check/fop_abs.tst, check/fop_sqrt.ok,
	check/fop_sqrt.tst: New files implementing simple test cases
	for the extra float operations.

	* check/Makefile.am: Update for new test cases.

	* check/alu.inc: Add an extra macro to check for unordered
	equality on tests where it is expected to use NaN as an
	argument.

	* check/lightning.c: Minor change for proper/common argument
	syntax handling ommiting arguments to options.
2012-12-17 17:55:38 -02:00
pcpa
d05538bff6 Add support to test different/alternate code generation setups.
* check/lightning.c: Remove the ".cpu name value" syntax,
	as it was not able to do proper changes before the jit
	internal data structure was initialized. Now it supports
	several getopt options to force using different jit
	generation options, effectively replacing the previous
	syntax.

	* check/run-test: Add simple extra logic to handle differently
	named test scripts, used to test things like x87 coprocessor
	in ix86, and arm instruction set or software float in armv7l.

	* configure.ac: Add some AC_RUN_IFELSE calls to figure at
	compile time if can test different code generation options,
	and update Makefile generation accordingly.

	* check/Makefile.am, lib/jit_arm.c, lib/jit_x86.c: Update to
	properly work with the test tool updating the jit_cpu global
	information.

	* check/check.arm.sh, check/check.swf.sh, check/check.x87.sh:
	New wrapper files passing -mthumb=0, mvfp=0 and -mx87=1 to
	the test tool, if applicable, so that it can validate alternate
	code generation options on test hosts that support them.
2012-12-14 22:40:08 -02:00
pcpa
074056499f Remove most type casts and compile test tool silently with -Wall 2012-12-14 14:15:25 -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
d1c0bc8e98 Add new test case for int/float to/from conversion.
* check/Makefile.am, check/cvt.ok, check/cvt.tst: Add new
	"cvt" test case to test conversion from/to int/float types.

	* check/lightning.c: Only define truncr_{f,d}_l in 64 bit mode.

	* include/lightning.h: Correct typo that caused it to define
	jit_truncr_{f,d}_l in 32 bit mode.

	* lib/jit_arm-cpu.c: Avoid assertion failure in the signed/unsigned
	extend opcodes generation as it shares an interface for 3 argument
	opcode generation.

	* lib/jit_x86-cpu.c: Correct wrong argument passed to
	jit_unget_reg in the andi implementation and wrong byte
	unsigned extend code generation.

	* lib/jit_x86-sse.c: Correct conversion from "word" to float or
	double as is dependent on wordsize.
2012-12-06 15:16:23 -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
7a1c455237 Big merge with new lightning semantics aiming for lightning 2.0.
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.
2012-12-02 19:44:36 -02:00