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

664 commits

Author SHA1 Message Date
Ekaitz Zarraga
019cd02410 riscv: movi: sign extend hi 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
741af987a3 riscv: fix load size for ldxi instructions 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
33eddc7b62 riscv: simplify load from pool 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
8c7990d4a1 riscv: fix literal pool guard jump address calc 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
fb527804f9 riscv: add get_callr_temp 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
c6008fd0ab riscv: fix the B and J type size check 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
93380fc377 riscv: clean patch jumps 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
f6f2a757c3 riscv: don't pack veneers, use padding 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
76549a674a riscv: Pack the veneer struct 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
775d11b21e riscv: Add fence 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
3edd48b046 Fix CI 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
797fe5067c Add RISCV to CI and makefile 2025-01-29 14:28:13 +01:00
Ekaitz Zarraga
cbd72e71a7 RISC-V Support 2025-01-29 14:01:52 +01:00
Ekaitz Zarraga
23c4e36dca Makefile: RISCV support and optional vars
Optional variables are needed because the structure of the makefile
is prepared to run on Guix but Guix doesn't support RISCV yet, so it's
better to set them as optional and let the user decide how do they want
to compile this thing.
2025-01-29 14:01:52 +01:00
Andy Wingo
41a2a60fa1 Merge branch 'reinterpret' into 'main'
Add movr_f_i, movr_i_f, movr_d_l, movr_l_d

See merge request wingo/lightening!27
2025-01-29 11:17:25 +00:00
Andy Wingo
11918685e1 Add movr_f_i, movr_i_f, movr_d_l, movr_l_d
These move values verbatim between FPRs and GPRs.
2025-01-29 12:14:59 +01:00
Andy Wingo
434fe2b4aa Merge branch 'callr-fix3' into 'main'
Fix some problems with callr and calli.

See merge request wingo/lightening!19
2024-06-03 13:43:19 +00:00
Andy Wingo
436a8b278b aarch64: Fix duplicate declaration 2024-04-22 15:14:13 +02:00
Andy Wingo
43262c0962 aarch64: Add support for LSE atomics
* lightening/aarch64-cpu.c (SWPAL, CASAL): New instructions.
(swap_atomic, cas_atomic): Use better instructions if we have LSE.
* lightening/aarch64.c (get_hwcap, jit_get_cpu): Arrange to detect LSE
availability on GNU/Linux and Darwin.

Based on a patch by Tony Garnock-Jones.  Thanks!
2024-04-22 15:03:01 +02:00
Tony Garnock-Jones
2c0126e3ef aarch64: Fix swap_atomic retry
* lightening/aarch64-cpu.c (swap_atomic): If the swap fails, and the dst
register was the same as the val, we would stomple val during the retry.
Fixes https://github.com/wingo/fibers/issues/83#issuecomment-2068847127.
2024-04-22 15:03:01 +02:00
Andy Wingo
d759faa27a Fix CI 2024-04-22 15:03:01 +02:00
Helmut Eller
f31fb0044d Fix some problems with callr and calli.
The problem with callr is that the register that contains the
function to be called, can be overwritten by the logic that moves
the values into argument registers.  To fix this, I added a
get_callr_temp function that should return a platform specific
register that is not used to pass arguments.  For Aarch64/Arm the
link registers seems to work; for Amd64/i686 the RAX register.
The function/tmp pair becomes an additional argument to the
parallel assigment; this way the original function register is not
accidentally overwritten.

The problem with calli is that it may not have enough temp
registers to move arguments.  The windmill paper says that at most
one temporary register is needed for the parallel assignment.
However, we also need a temp register for mem-to-mem moves.  So it
seems that we need a second temporary.  For Amd64/i686 we have
only one temporary GPR and one temporary FPR.  To fix this, I
modified the algorithm from the paper a bit: we perform the
mem-to-mem moves before the other moves.  Later when we need the
temp to break cycles, there shouldn't be any mem-to-mem moves
left.  So we should never need two temps at the same time.

* lightening/lightening.c: (get_callr_temp): New function; need
for each platform.
(prepare_call_args): Include the function/callr_temp pair in the
arguments for the parallel assignment.

* lightening/x86.c, lightening/arm.c, lightening/aarch64.c
(get_callr_temp): Implementation for each platform.

* lightening/arm.c (next_abi_arg): Fix the stack size for doubles.

* tests/call_10_2.c, tests/callr_10.c: New tests.
* tests/regarrays.inc: New file. Common code between the above two
tests that would be tedious to duplicate.
2022-06-08 16:20:42 +02:00
Andy Wingo
636f43bc54 Merge branch 'topic/fix-reset-literal-pool' into 'main'
replace use of uninitialized variable size in reset_literal_pool

See merge request wingo/lightening!15
2022-01-11 20:43:06 +00:00
Luke Nihlen
3f495cc5d6 set size to known value before init 2022-01-11 09:02:30 -05:00
Luke Nihlen
6cdea3995a replace use of uninitialized variable size in reset_literal_pool 2022-01-10 20:32:00 -05:00
Andy Wingo
bfba596dda Merge branch 'fix-shortening' into 'master'
Fix jmp-shortening on x86 when target within instruction.

See merge request wingo/lightening!12
2021-01-07 10:05:57 +00:00
Andy Wingo
35cd7fac8b Fix jmp-shortening on x64 when target within instruction.
* lightening/x86.c (jit_try_shorten): If the address is within the
  last instruction, don't shorten.  If the intstruction is a jump, we
  could elide it entirely in some cases, but we don't know if the user
  captured the PC before calling jit_patch_here.  Better to leave this
  to the user.

Thanks to Helmut Eller for the bug report and test case in
https://gitlab.com/wingo/lightening/-/issues/17.
2021-01-07 11:04:17 +01:00
Andy Wingo
8b37b783ea Merge branch 'word-spills' into 'master'
Spill whole words to stack, even for uint8_t args

Closes #15

See merge request wingo/lightening!11
2020-07-30 12:34:20 +00:00
Andy Wingo
2784bee8e5 Spill whole words to stack, even for uint8_t args
* lightening/lightening.c (abi_gpr_to_mem): Write whole words when
  spilling GPRs to the stack.  Always correct given that all Lightening
  operations that write GPRs write the whole register, and the current
  ABI targets allow writing the extra words.  Closes #15.
2020-07-30 14:26:37 +02:00
Andy Wingo
ca35ac9a4b Merge branch 'word-align-literal-pools' into 'master'
Literal pools have word-alignment, not u64-alignment

See merge request wingo/lightening!10
2020-07-30 12:09:24 +00:00
Andy Wingo
ca1cc01cdf Literal pools have word-alignment, not u64-alignment
Prevents useless over-alignment for ARM.

* lightening/lightening.c (struct jit_literal_pool_entry): Value is a
  uintptr_t.
  (emit_uintptr): New helper.
  (emit_abs_reloc): Use new helper.
  (patch_pending_literal): Value is a uintptr_t.
  (emit_literal_pool): Adapt to literal entry being uintptr_t.
2020-07-30 14:04:47 +02:00
Andy Wingo
a6fc30d810 Merge branch 'size-data' into 'master'
Allow jit_begin_data to declare max data size

See merge request wingo/lightening!9
2020-07-30 11:44:44 +00:00
Andy Wingo
44b07aef4b Allow jit_begin_data to declare max data size
* lightening.h:
* lightening/lightening.c (jit_begin_data): Add max data size
  parameter.  If nonzero, can allow the JIT to avoid prematurely
  emitting a constant pool.
  (jit_end_data): Allow pending literals.
* tests/jmp_table.c (run_test): Use new API.
2020-07-30 13:41:02 +02:00
Andy Wingo
644ee3a37f Merge branch 'table-switch' into 'master'
Add support for emitting inline data and table switches

See merge request wingo/lightening!6
2020-07-30 11:06:08 +00:00
Andy Wingo
91c1591e41 Add support for emitting inline data and table switches
* lightening.h:
* lightening/lightening.c (jit_begin_data, jit_end_data)
  (jit_emit_u8, jit_emit_u16, jit_emit_u32, jit_emit_u64): Add new raw
  data-emitting primitives, bracketed by begin/end so that we can flush
  constant pools first, if needed.
* lightening/lightening.c (struct jit_state): Add new emitting_data
  flag.
  (jit_begin, jit_reset, jit_end): Handle the new flag.
  (emit_abs_reloc): Move here, from x86.c.
* lightening/x86.c (emit_abs_reloc): Remove.
  (jit_try_shorten): Don't shorten if loc == start; could be raw data.
* tests/jmp_table.c: New test.
2020-07-30 13:02:46 +02:00
Andy Wingo
7b4840d7df Merge branch 'fix-tail-call-test' into 'master'
Ensure tail caller and callee in jmpi test have compatible ABI

See merge request wingo/lightening!8
2020-07-30 10:01:28 +00:00
Andy Wingo
6c7813a05f Ensure tail caller and callee in jmpi test have compatible ABI
* tests/jmpi.c: Emit the tail callee using the JIT, to ensure that it
  saves and restores registers in the same way as the caller.  Fixes
  #16.
2020-07-30 11:52:57 +02:00
Andy Wingo
56d92850c6 Merge branch 'fix-aarch64-veneers' into 'master'
Fix patch_veneer on aarch64

See merge request wingo/lightening!7
2020-07-30 09:19:39 +00:00
Andy Wingo
b2ef1d5fba Fix patch_veneer on aarch64
* lightening/aarch64.c (patch_veneer): Fix absolutely bogus patch_veneer
  implementation.
2020-07-30 11:17:46 +02:00
Dale P. Smith
24ef197b12 Add 'movi' test.
This is a followup to 1bb909a44d.  It
reproduces the bug that 1bb909a44d fixes
on ARMv7.

* tests/movi.c: New file.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
2020-06-20 16:34:37 +02:00
Ludovic Courtès
e20ca01d9b tests: Remove 'glibc' from the 'guix environment' command line.
* tests/Makefile (CC_IA32, CC_AARCH64, CC_ARMv7): Remove 'glibc' from
the 'guix environment' command line since it's redundant with
'gcc-toolchain'.
2020-06-20 16:14:10 +02:00
Ludovic Courtès
e3d9bdf03f tests: Make 'TARGETS' overridable.
This allows users to run "make TARGETS=armv7", for instance.

* tests/Makefile (TARGETS): Make it overridable.
2020-06-20 16:13:16 +02:00
Andrew Gierth
1bb909a44d Fix ARMv7 THUMB encoding for immediates.
* lightening/arm-cpu.c (encode_thumb_immediate): Fix return value in
third case.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2020-06-20 15:57:06 +02:00
Andy Wingo
2c0fdb045e Fix unused variable warning for no-literal-pool targets
* lightening/lightening.c (jit_patch_there): Conditionally define
  flags.
2020-06-19 16:30:12 +02:00
Andy Wingo
6e317e70dd Merge branch 'fix-literal-pool-reset' into 'master'
Fix zeroing of literal pool entries

See merge request wingo/lightening!5
2020-06-19 14:25:36 +00:00
Andy Wingo
97212e87bd Fix zeroing of literal pool entries
* lightening/lightening.c (reset_literal_pool): Zero before setting size
  to 0.  Thanks to Dale Smith for pointing this out!
2020-06-19 16:23:36 +02:00
Andy Wingo
921f13a03b Merge branch 'fix-rotate-by-zero' into 'master'
Fix undefined behavior in ARMv7 assembler

See merge request wingo/lightening!4
2020-06-19 14:18:14 +00:00
Andy Wingo
ffba9b08c4 Fix undefined behavior in ARMv7 assembler
* lightening/arm-cpu.c (rotate_left): Fix the case of rotating by zero,
  which produced undefined behavior.  Many thanks to Andrew
  Gierth (andrew at tao11 riddles org uk) for the debugging and the
  fix.
2020-06-19 16:14:52 +02:00
Andy Wingo
3260f7deeb Merge branch 'arm-fix' into 'master'
Fix armv7 with the ARM instruction set

Closes #12

See merge request wingo/lightening!3
2020-06-11 16:11:24 +00:00
Icecream95
2a4ed4b776
Add CI jobs for ARM in both instruction sets 2020-04-09 22:34:21 +12:00