Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Enable the constraints checking for assembler by default if possible. #173

Conversation

Nelson1225
Copy link

I get the request recently that the assembler's constraints checking break hardware exception test cases. Therefore I have disabled the checking in assembler by default, and people don't get the constraints error when writing assembly code. But we should enable the checking for the code which the compiler emits.

Beside, GCC also checks whether the assembler supports the options used to enable and disable the constraints checking. The basic logic is shown as follows,

GAS support constraints options GAS doesn't support constraints options
GCC default Output .option checkconstraints Don't output the .option checkconstraints
GCC -mcheck-constraints Output .option checkconstraints Report error message that GAS doesn't support .option checkconstraints
GCC -mno-check-constraints Don't output the.option checkconstraints Don't output the.option checkconstraints

One more thing is that, the gcc_GAS_CHECK_FEATURE doesn't seem to work for checking the .option xxx. I think the reason may be that GAS report warning message rather than error when the .option xxx isn't supported. However, I have added both GAS options and .option directives for the
constraints checking, so I check them both in the gcc_GAS_CHECK_FEATURE.

gcc/
* config.in: Regenerated.
* configure: Likewise.
* configure.ac: Check whether GAS support constraints options.
* config/riscv/riscv.c (riscv_option_override): If user don't set the
`m[no-]check-constraints` option and GAS support the constraints
checking, then GCC should enable it by default. If user set the
`mcheck-constraints` options but the checking isn't supported in GAS,
then we should report error message.
(riscv_file_start): Emit `.option checkconstraints` if needed.
* config/riscv/riscv.opt (mcheck-constraints): New option.

gcc/testsuite/
* gcc.target/riscv/constraints-1.c: New.
* gcc.target/riscv/constraints-2.c: Likewise.

@Nelson1225
Copy link
Author

The related support in binutils riscvarchive/riscv-binutils-gdb#193

Copy link
Collaborator

@jim-wilson jim-wilson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can pass --fatal-warnings to GNU as to change warnings into errors. That might fix your configure patch problem.

gcc/config/riscv/riscv.c Outdated Show resolved Hide resolved
I get the request recently that the assembler's constraints checking break
hardware exception test cases.  Therefore I have disabled the checking in
assembler by default, and people don't get the constraints error when writing
assembly code.  But we should enable the checking for the code which the
compiler emits.

Beside, GCC also checks whether the assembler supports the options used to
enable and disable the constraints checking.  The basic logic is shown as
follows,

                  | GAS support              | GAS doesn't support
                  | constraints options      | constraints options
----------------------------------------------------------------------
 GCC default      | Output `.option          | Don't output the `.option
                  | checkconstraints`        | checkconstraints`
----------------------------------------------------------------------
 GCC `-mcheck-    | Output `.option          | Report error message that
 constraints`     | checkconstraints`        | GAS doesn't support `.option
                  |                          | checkconstraints`
----------------------------------------------------------------------
 GCC `-mno-check- | Don't output the`.option | Don't output the`.option
 constraints`     | checkconstraints`        | checkconstraints`

	gcc/
	* config.in: Regenerated.
	* configure: Likewise.
	* configure.ac: Check whether GAS support constraints .option directives.
	* config/riscv/riscv.c (riscv_option_override): If user don't set the
	`m[no-]check-constraints` option and GAS support the constraints
	checking, then GCC should enable it by default. If user set the
	`mcheck-constraints` options but the checking isn't supported in GAS,
	then we should report error message.
	(riscv_file_start): Emit `.option checkconstraints` if needed.
	* config/riscv/riscv.opt (mcheck-constraints): New option.

	gcc/testsuite/
	* gcc.target/riscv/constraints-1.c: New.
	* gcc.target/riscv/constraints-2.c: Likewise.
@Nelson1225 Nelson1225 force-pushed the riscv-gcc-9.2.0-rvv-constraints branch from e905515 to 4d6490f Compare February 19, 2020 06:27
@Nelson1225
Copy link
Author

You can pass --fatal-warnings to GNU as to change warnings into errors. That might fix your configure patch problem.

Thanks this works :)

@kito-cheng
Copy link
Collaborator

Verified on my side, I gonna merge this.

@kito-cheng kito-cheng merged commit 8b5d91c into riscvarchive:riscv-gcc-9.2.0-rvv Feb 19, 2020
@Nelson1225 Nelson1225 deleted the riscv-gcc-9.2.0-rvv-constraints branch February 20, 2020 01:09
@Nelson1225
Copy link
Author

Thanks for helps :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants