Commit graph

1329 commits

Author SHA1 Message Date
Quentin Carbonneaux
a9a70e30a8 add new target-specific abi0 pass
The general idea is to give abis a
chance to talk before we've done all
the optimizations. Currently, all
targets eliminate {par,arg,ret}{sb,ub,...}
during this pass. The forthcoming
arm64_apple will, however, insert
proper extensions during abi0.

Moving forward abis can, for example,
lower small-aggregates passing there
so that memory optimizations can
interact better with function calls.
2022-10-03 10:41:03 +02:00
Quentin Carbonneaux
0b26cd4f5e parse sb,ub,sh,uh abi types 2022-10-03 10:41:03 +02:00
Ember Sawady
bdaf8d374e Fix parsing of multiple globals in datadef
Eg. data $a = { w $b $c }
2022-09-15 09:09:30 +02:00
Quentin Carbonneaux
0715a395df capitalize a label 2022-09-01 19:09:15 +02:00
Quentin Carbonneaux
fb76791b97 remove two unsigned
We have a uint alias that we use
everywhere else. I also added a
todo about unhandled large offsets
in arm64/emit.
2022-09-01 19:08:38 +02:00
Quentin Carbonneaux
f135a0b1fd use direct bl calls on arm64
This generates tidier code and is pic
friendly because it lets the linker
trampoline calls to dynlinked libs.
2022-09-01 19:03:53 +02:00
Quentin Carbonneaux
8dddb971d9 drop -G flag and add target amd64_apple
apple support is more than assembly syntax
in case of arm64 machines, and apple syntax
is currently useless in all cases but amd64;
rather than having a -G option that only
makes sense with amd64, we add a new target
amd64_apple
2022-08-31 21:42:49 +02:00
Quentin Carbonneaux
5490268683 flag the default target in "qbe -h" 2022-08-31 17:16:29 +02:00
Quentin Carbonneaux
9ebb54c568 fix some variadic calls in test/abi8.ssa 2022-08-31 17:16:29 +02:00
Quentin Carbonneaux
f5ad580886 regenerate test/vararg2.ssa
- update the test generation script to
  match some manual changes
- fix some variadic calls to printf
- add a test case where an odd number of
  slots is used on the stack before varargs
2022-08-31 17:16:29 +02:00
Roberto E. Vargas Caballero
c8cd2824ea Reject multiple section definition for a symbol 2022-07-01 13:20:45 +02:00
Roberto E. Vargas Caballero
d9935ac14a Add qbe identifier in error strings
When qbe is used with other tools is a bit hard to identify
what is the tool that is generating the error. Adding an
identifier at the beginning of the line makes much easier
to identify the tool generating the error.
2022-07-01 13:19:33 +02:00
Roberto E. Vargas Caballero
9b4bb8d224 Makefile: Avoid double macro expansion in targets
POSIX specification stays:

        string1 = [string2]
        ...
        Macro expansions in string1 of macro definition lines shall
        be evaluated when read. Macro expansions in string2 of macro
        definition lines shall be performed when the macro identified
        by string1 is expanded in a rule or command.

It means that recursive macro expansion is not guaranteed to work in
a portable Make. Also, as make is a declarative language makes more
sense to declare your targets as a primary concern instead of
derivating them from a informational macro like SRC that is only
used in a rule command.
2022-07-01 13:17:09 +02:00
Simon Heath
790aedb8fe Fix minor typos in IL doc 2022-06-29 22:55:16 +02:00
Quentin Carbonneaux
cd778b44ba install with install -m755 2022-06-16 09:49:09 +02:00
Haelwenn (lanodan) Monnier
2b451a28d8 tools/test.sh: Without a TARGET, use $CC if defined
cc can be absent in Gentoo to make sure the right compiler is picked,
for example when clang is preferred or when cross-compiling.
2022-06-14 18:46:38 +02:00
illiliti
6cd5f70286 Makefile: POSIXify
Makefile now compatible with gmake, bmake, smake and pdpmake.
2022-06-14 13:58:01 +02:00
Quentin Carbonneaux
740bf867b3 do not fold cnst+cnst in amd64's isel
This may cause invalid assembly to be generated
and is not all that useful anyway after constant
folding has run.
2022-06-14 13:49:50 +02:00
Alexey Yerin
1162359a19 rv64: implement Oswap for floating-point types 2022-06-14 09:12:19 +02:00
Quentin Carbonneaux
c9f04db881 refine assertion in liveness analysis
We were redundantly checking cardinality in a
way that prevented fp regs from ever being
globally live.  We now check that the live
regs after a return are exactly the globally
live ones.
2022-06-14 09:11:44 +02:00
Quentin Carbonneaux
9a3e131cf7 install in /usr/local by default 2022-05-12 11:36:25 +02:00
Quentin Carbonneaux
ee6c272416 tighten function definition spec 2022-05-12 09:24:23 +02:00
Quentin Carbonneaux
2c8697696d use an alias for \n in the il spec 2022-05-12 09:18:37 +02:00
Quentin Carbonneaux
ef68ab4066 avoid folding overflowing divisions
Thanks to Paul Ouellette for reporting.
2022-05-11 18:11:00 +02:00
Quentin Carbonneaux
fb742ec0e4 document spacing in il reference 2022-05-11 10:33:32 +02:00
Quentin Carbonneaux
6cd9797573 add installation notes 2022-05-10 12:02:36 +02:00
Michael Forney
4ac7d770d6 arm64: fix maximum immediate size for small loads/stores
The maximum immediate size for 1, 2, 4, and 8 byte loads/stores is
4095, 8190, 16380, and 32760 respectively[0][1][2].

[0] https://developer.arm.com/documentation/dui0802/a/A64-Data-Transfer-Instructions/LDRB--immediate-
[1] https://developer.arm.com/documentation/dui0802/a/A64-Data-Transfer-Instructions/LDRH--immediate-
[2] https://developer.arm.com/documentation/dui0802/a/A64-Data-Transfer-Instructions/LDR--immediate-
2022-05-10 11:51:47 +02:00
Quentin Carbonneaux
2caa26e388 move nx stack annotation to gas.c 2022-04-11 14:57:50 +02:00
Daniel Xu
3c5cd9fdd0 Close input file after done reading
Leaks resources to not close.

Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
2022-04-11 14:39:01 +02:00
Quentin Carbonneaux
5f4b42abc7 do not leak type fields
Thanks to Daniel Xu for reporting.
2022-04-11 14:36:36 +02:00
Michael Forney
c6b41eb8c8 amd64: restore previous name of amd64_sysv target 2022-03-17 13:24:52 +01:00
Quentin Carbonneaux
bf2a90ef7c fix return for big aggregates
The recent changes in arm and riscv
typclass() set ngp to 1 when a struct
is returned via a caller-provided
buffer.  This interacts bogusly with
selret() that ends up declaring a gp
register live when none is set in
the returning sequence.

The fix is simply to set cty to zero
(all registers dead) in case a caller-
provided buffer is used.
2022-03-17 10:57:09 +01:00
Quentin Carbonneaux
cec9855fa0 detect target in tests 2022-03-15 22:34:03 +01:00
Quentin Carbonneaux
2416d29141 new -t? flag to print default target 2022-03-15 22:30:34 +01:00
Quentin Carbonneaux
da36b211ab homogenize riscv and arm abis 2022-03-15 14:18:31 +01:00
Quentin Carbonneaux
01142fa059 support env calls on arm64
The x9 register is used for
the env parameter.
2022-03-15 14:18:31 +01:00
Quentin Carbonneaux
c656c48f04 fix register count in riscv argregs 2022-03-15 14:18:23 +01:00
Quentin Carbonneaux
c5769f62b4 dynamic stack allocs for arm64
I also moved some isel logic
that would have been repeated
a third time in util.c.
2022-03-14 23:14:48 +01:00
Quentin Carbonneaux
329a18a30b add rv64/ to README 2022-03-14 15:32:46 +01:00
Quentin Carbonneaux
6ca9399ed6 output symbol type and size
That is not available on osx
so I tweaked the gas.c api
a little to conditionally
output the two directives.
2022-03-14 15:32:27 +01:00
Quentin Carbonneaux
7a7a5f4803 improve consistency in abis 2022-03-14 10:40:30 +01:00
Quentin Carbonneaux
905e9cef30 arm64/abi: fix big aggregates passed on the stack
The riscv test abi8.ssa caught a bug
in the arm backend. It turns out we
were using the wrong class when loading
pointers to aggregates from the stack.

The fix is simple and mirrors what is
done in the riscv abi.
2022-03-14 10:04:24 +01:00
Quentin Carbonneaux
c7842d84da dust off antique .tag 2022-03-11 13:38:46 +01:00
Quentin Carbonneaux
a9e4fa9715 rv64: plug holes in the abi
Many things got fixed, but the most
notable change is the proper support
of floating point types in aggregates.

Minor fixes:
- selpar() did not deal correctly
  with Cfpint
- typclass() was reading out of
  bounds in the gp/fp arrays
- support for env calls
2022-03-10 22:52:20 +01:00
Quentin Carbonneaux
e6debbbb02 two new tests in abi5.ssa
They are meant to exercise the
hardware floating-point calling
convention of the risc-v target.
2022-03-10 22:46:57 +01:00
Quentin Carbonneaux
7f7e34cd1f new abi stress test 2022-03-10 16:01:50 +01:00
Quentin Carbonneaux
9060981c10 flag types defined as unions
The risc-v abi needs to know if a
type is defined as a union or not.

We cannot use nunion to obtain this
information because the risc-v abi
made the unfortunate decision of
treating

	union { int i; }

differently from

	int i;

So, instead, I introduce a single
bit flag 'isunion'.
2022-03-08 15:57:06 +01:00
Quentin Carbonneaux
349794f3e4 cosmetics 2022-03-08 15:36:26 +01:00
lincoln auster [they/them]
3d294346ab doc: export function main in hello world example
This enables the example to be compiled and run as-is, without any
additional modification.
2022-03-07 15:34:28 +01:00
Quentin Carbonneaux
457e568ce9 rv64: formatting and bug fix in epilogue 2022-02-27 11:27:55 +01:00