Skip to content

Conversation

@a4lg
Copy link
Owner

@a4lg a4lg commented Jul 26, 2023

@a4lg a4lg force-pushed the riscv-ext-imply-complex branch 5 times, most recently from 78b97d4 to d738708 Compare August 1, 2023 03:40
@a4lg a4lg force-pushed the riscv-ext-imply-complex branch from d738708 to 1874da7 Compare August 3, 2023 00:07
@a4lg a4lg added bug Something isn't working enhancement New feature or request labels Aug 3, 2023
@a4lg a4lg force-pushed the riscv-ext-imply-complex branch 7 times, most recently from 3a66e57 to 9a869a7 Compare August 8, 2023 04:11
@a4lg a4lg force-pushed the riscv-ext-imply-complex branch 3 times, most recently from 961b24a to 0927141 Compare August 15, 2023 06:37
@a4lg a4lg force-pushed the riscv-ext-imply-complex branch from 0927141 to 5e9f6a2 Compare August 15, 2023 07:27
@a4lg a4lg force-pushed the riscv-ext-imply-complex branch 4 times, most recently from 5d1cddf to 981ef2b Compare September 7, 2023 09:35
@a4lg a4lg force-pushed the riscv-ext-imply-complex branch 3 times, most recently from e3d6f58 to 2334ee6 Compare October 19, 2023 03:17
a4lg added 3 commits October 19, 2023 06:58
Thanks to the commit 48558a5 ("RISC-V: Allow nested implications for
extensions"), we can write complex extension implications in theory.
However, to actually do that, we need to pass more information to
check_func.

For example, we want to imply 'Zcf' from 'F' if and only if the 'Zce'
extension is also enabled and XLEN is 32.  Passing rps is a way to
enable this.

This commit prepares for such complex extension implications.

bfd/ChangeLog:

	* elfxx-riscv.c (struct riscv_implicit_subset): Move around and
	change check_func function prototype.
	(check_implicit_always): New arguments.
	(check_implicit_for_i): Likewise.
	(riscv_implicit_subsets): Add comment for this variable.
	(riscv_parse_add_implicit_subsets): Call check_func with
	new arguments.
The 'C' extension and its subsets have complex relations, depending on
the implemented floating point extensions.

They are the expansions related in this context:

'C'             == 'Zca'
'C' + 'F'       == 'Zca' + 'Zcf'         + 'F' (RV32)
'C' + 'F'       == 'Zca'                 + 'F' (RV64)
'C' + 'F' + 'D' == 'Zca' + 'Zcf' + 'Zcd' + 'F' + 'D' (RV32)
'C' + 'F' + 'D' == 'Zca'         + 'Zcd' + 'F' + 'D' (RV64)
[they exclude dependencies from 'F' and 'D']

This commit implements those implications.

Note that some test cases are modified to reflect new compressed
instruction extensions:

1.  Test cases that use ".option arch, -c" to turn off RVC
    (at least the 'Zca' extension must be also turned off).
2.  Test cases that test RISC-V attributes and/or mapping symbols
    when the 'C' extension is enabled.

bfd/ChangeLog:

	* elfxx-riscv.c (check_implicit_for_d_c): New.
	(check_implicit_for_f_c): New.
	(riscv_implicit_subsets): Add unconditional implication,
	'C' -> 'Zca'.  Add conditional implications, 'D' -> 'Zcd'
	and 'F' -> 'Zcf'.

gas/ChangeLog:

	* testsuite/gas/riscv/march-imply-c.d: Test implied
	extensions from 'C' alone.
	* testsuite/gas/riscv/march-imply-c-d-32.d: New to test implied
	extensions from 'C' and 'D' on RV32.
	* testsuite/gas/riscv/march-imply-c-d-64.d: New to test implied
	extensions from 'C' and 'D' on RV64.
	* testsuite/gas/riscv/attribute-10.d: Reflect reorganization of
	compressed instruction extensions.
	* testsuite/gas/riscv/dis-addr-overflow-32.d: Likewise.
	* testsuite/gas/riscv/dis-addr-overflow-64.d: Likewise.
	* testsuite/gas/riscv/dis-addr-overflow.s: Likewise.
	* testsuite/gas/riscv/mapping-symbols.d: Likewise.
	* testsuite/gas/riscv/mapping.s: Likewise.
	* testsuite/gas/riscv/march-ok-reorder.d: Likewise.
	* testsuite/gas/riscv/option-arch-01.s: Likewise.
	* testsuite/gas/riscv/option-arch-01b.d: Likewise.
	* testsuite/gas/riscv/option-arch-02.d: Likewise.
	* testsuite/gas/riscv/option-arch-02.s: Likewise.
	* testsuite/gas/riscv/option-arch-03.d: Likewise.
	* testsuite/gas/riscv/option-arch-03.s: Likewise.
Despite its deprecation, ".option norvc" may used to turn off the 'C'
extension.  This commit also disables its subsets, 'Zca', 'Zcf' and 'Zcd'
and clarifies that it won't completely do the job if other enabled
extensions depend on 'C' or 'Zc*'.

Note that, even if it does not "completely" work, we cannot emit any
compressed instructions after the ".option norvc" directive since it
disables RVC and prevents any 2-byte instructions from assembling.

gas/ChangeLog:

	* config/tc-riscv.c (s_riscv_option): Also turn off 'Zca', 'Zcf'
	and 'Zcd'.  Clarify the limitation of this directive.
@a4lg a4lg force-pushed the riscv-ext-imply-complex branch from 2334ee6 to a4e2990 Compare October 19, 2023 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants