* [PATCH] Make muser-mode the default for LEON3
@ 2015-06-23 14:29 Daniel Cederman
2015-06-26 7:59 ` Eric Botcazou
0 siblings, 1 reply; 10+ messages in thread
From: Daniel Cederman @ 2015-06-23 14:29 UTC (permalink / raw)
To: gcc-patches; +Cc: daniel, cederman, ebotcazou, jakub, sebastian.huber
The muser-mode flag causes the CASA instruction for LEON3 to use the
user mode ASI. This is the correct behavior for almost all LEON3 targets.
For this reason it makes sense to make user mode the default.
gcc/ChangeLog:
2015-06-23 Daniel Cederman <cederman@gaisler.com>
* config/sparc/sparc.opt: Rename mask from USER_MODE to SV_MODE
and make it inverse to change default
* config/sparc/sync.md: Only use supervisor ASI for CASA when in
supervisor mode
* doc/invoke.texi: Document change of default
---
gcc/config/sparc/sparc.opt | 4 ++--
gcc/config/sparc/sync.md | 6 +++---
gcc/doc/invoke.texi | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/gcc/config/sparc/sparc.opt b/gcc/config/sparc/sparc.opt
index 93d24a6..85bf0bd 100644
--- a/gcc/config/sparc/sparc.opt
+++ b/gcc/config/sparc/sparc.opt
@@ -114,8 +114,8 @@ Target
Optimize tail call instructions in assembler and linker
muser-mode
-Target Report Mask(USER_MODE)
-Do not generate code that can only run in supervisor mode
+Target Report InverseMask(SV_MODE)
+Do not generate code that can only run in supervisor mode (default)
mcpu=
Target RejectNegative Joined Var(sparc_cpu_and_features) Enum(sparc_processor_type) Init(PROCESSOR_V7)
diff --git a/gcc/config/sparc/sync.md b/gcc/config/sparc/sync.md
index 7d00b10..2fabff5 100644
--- a/gcc/config/sparc/sync.md
+++ b/gcc/config/sparc/sync.md
@@ -222,10 +222,10 @@
UNSPECV_CAS))]
"TARGET_LEON3"
{
- if (TARGET_USER_MODE)
- return "casa\t%1 0xa, %2, %0"; /* ASI for user data space. */
- else
+ if (TARGET_SV_MODE)
return "casa\t%1 0xb, %2, %0"; /* ASI for supervisor data space. */
+ else
+ return "casa\t%1 0xa, %2, %0"; /* ASI for user data space. */
}
[(set_attr "type" "multi")])
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b99ab1c..86b2a73 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -21305,8 +21305,8 @@ in a performance loss, especially for floating-point code.
@opindex muser-mode
@opindex mno-user-mode
Do not generate code that can only run in supervisor mode. This is relevant
-only for the @code{casa} instruction emitted for the LEON3 processor. The
-default is @option{-mno-user-mode}.
+only for the @code{casa} instruction emitted for the LEON3 processor. This
+is the default.
@item -mno-faster-structs
@itemx -mfaster-structs
--
2.4.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-23 14:29 [PATCH] Make muser-mode the default for LEON3 Daniel Cederman
@ 2015-06-26 7:59 ` Eric Botcazou
2015-06-26 12:06 ` Daniel Cederman
0 siblings, 1 reply; 10+ messages in thread
From: Eric Botcazou @ 2015-06-26 7:59 UTC (permalink / raw)
To: Daniel Cederman; +Cc: gcc-patches, daniel, jakub, sebastian.huber
> The muser-mode flag causes the CASA instruction for LEON3 to use the
> user mode ASI. This is the correct behavior for almost all LEON3 targets.
Do they lack the CASA instruction with supervisor-mode ASI? What happens when
the CASA instruction with user-mode ASI is executed in supervisor mode?
--
Eric Botcazou
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-26 7:59 ` Eric Botcazou
@ 2015-06-26 12:06 ` Daniel Cederman
2015-06-30 9:50 ` Eric Botcazou
0 siblings, 1 reply; 10+ messages in thread
From: Daniel Cederman @ 2015-06-26 12:06 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches, daniel, jakub, sebastian.huber
>
> Do they lack the CASA instruction with supervisor-mode ASI? What happens when
> the CASA instruction with user-mode ASI is executed in supervisor mode?
>
For all LEON3 (with CASA support) the CASA instruction works in
supervisor-mode regardless of ASI used. In user-mode CASA only works
with the user-mode ASI. So CASA with user-mode ASI works for both
user-mode and supervisor-mode. By having user-mode ASI as default, one
would not need to change flag when compiling user or kernel code.
On a few old LEON3 systems the CASA instruction only works in supervisor
mode. Using the CASA instruction with the user-mode ASI on these systems
is not legal and will cause a trap.
--
Daniel Cederman
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-26 12:06 ` Daniel Cederman
@ 2015-06-30 9:50 ` Eric Botcazou
0 siblings, 0 replies; 10+ messages in thread
From: Eric Botcazou @ 2015-06-30 9:50 UTC (permalink / raw)
To: Daniel Cederman; +Cc: gcc-patches, daniel, jakub, sebastian.huber
> For all LEON3 (with CASA support) the CASA instruction works in
> supervisor-mode regardless of ASI used. In user-mode CASA only works
> with the user-mode ASI. So CASA with user-mode ASI works for both
> user-mode and supervisor-mode. By having user-mode ASI as default, one
> would not need to change flag when compiling user or kernel code.
Thanks, OK for mainline, 5 branch and 4.9 branch.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] Add mask to specify which LEON3 targets support CASA
@ 2015-06-23 12:22 Daniel Cederman
2015-06-23 12:22 ` [PATCH] Make muser-mode the default for LEON3 Daniel Cederman
0 siblings, 1 reply; 10+ messages in thread
From: Daniel Cederman @ 2015-06-23 12:22 UTC (permalink / raw)
To: gcc-patches; +Cc: daniel, cederman, ebotcazou
Not all LEON3 support the CASA instruction. This patch provides a mask
that can be used to specify which LEON3 targets that support CASA.
gcc/ChangeLog:
2015-06-22 Daniel Cederman <cederman@gaisler.com>
* config/sparc/sparc.c (sparc_option_override): Mark CPU targets
leon3 and leon3v7 as supporting the CASA instruction
* config/sparc/sparc.opt: Add mask specifying that the LEON3
supports the CASA instruction (MASK_LEON3_CASA)
* config/sparc/sync.md: Only generate CASA for V9 and targets
with the MASK_LEON3_CASA mask
---
gcc/config/sparc/sparc.c | 4 ++--
gcc/config/sparc/sparc.opt | 3 +++
gcc/config/sparc/sync.md | 6 +++---
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 995a769..205e3cb 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -1280,8 +1280,8 @@ sparc_option_override (void)
{ "supersparc", MASK_ISA, MASK_V8 },
{ "hypersparc", MASK_ISA, MASK_V8|MASK_FPU },
{ "leon", MASK_ISA, MASK_V8|MASK_LEON|MASK_FPU },
- { "leon3", MASK_ISA, MASK_V8|MASK_LEON3|MASK_FPU },
- { "leon3v7", MASK_ISA, MASK_LEON3|MASK_FPU },
+ { "leon3", MASK_ISA, MASK_V8|MASK_LEON3|MASK_FPU|MASK_LEON_CASA },
+ { "leon3v7", MASK_ISA, MASK_LEON3|MASK_FPU|MASK_LEON_CASA },
{ "sparclite", MASK_ISA, MASK_SPARCLITE },
/* The Fujitsu MB86930 is the original sparclite chip, with no FPU. */
{ "f930", MASK_ISA|MASK_FPU, MASK_SPARCLITE },
diff --git a/gcc/config/sparc/sparc.opt b/gcc/config/sparc/sparc.opt
index 5c7f546..e6caa95 100644
--- a/gcc/config/sparc/sparc.opt
+++ b/gcc/config/sparc/sparc.opt
@@ -228,6 +228,9 @@ Mask(LEON)
Mask(LEON3)
;; Generate code for LEON3
+Mask(LEON_CASA)
+;; Generate CAS instruction for LEON
+
Mask(SPARCLITE)
;; Generate code for SPARClite
diff --git a/gcc/config/sparc/sync.md b/gcc/config/sparc/sync.md
index 2fabff5..8e1baee 100644
--- a/gcc/config/sparc/sync.md
+++ b/gcc/config/sparc/sync.md
@@ -181,7 +181,7 @@
(match_operand:SI 5 "const_int_operand" "") ;; is_weak
(match_operand:SI 6 "const_int_operand" "") ;; mod_s
(match_operand:SI 7 "const_int_operand" "")] ;; mod_f
- "(TARGET_V9 || TARGET_LEON3)
+ "(TARGET_V9 || TARGET_LEON_CASA)
&& (<MODE>mode != DImode || TARGET_ARCH64 || TARGET_V8PLUS)"
{
sparc_expand_compare_and_swap (operands);
@@ -197,7 +197,7 @@
[(match_operand:I48MODE 2 "register_operand" "")
(match_operand:I48MODE 3 "register_operand" "")]
UNSPECV_CAS))])]
- "TARGET_V9 || TARGET_LEON3"
+ "TARGET_V9 || TARGET_LEON_CASA"
"")
(define_insn "*atomic_compare_and_swap<mode>_1"
@@ -220,7 +220,7 @@
[(match_operand:SI 2 "register_operand" "r")
(match_operand:SI 3 "register_operand" "0")]
UNSPECV_CAS))]
- "TARGET_LEON3"
+ "TARGET_LEON_CASA"
{
if (TARGET_SV_MODE)
return "casa\t%1 0xb, %2, %0"; /* ASI for supervisor data space. */
--
2.4.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] Make muser-mode the default for LEON3
2015-06-23 12:22 [PATCH 1/2] Add mask to specify which LEON3 targets support CASA Daniel Cederman
@ 2015-06-23 12:22 ` Daniel Cederman
2015-06-23 12:34 ` Sebastian Huber
2015-06-23 12:38 ` Jakub Jelinek
0 siblings, 2 replies; 10+ messages in thread
From: Daniel Cederman @ 2015-06-23 12:22 UTC (permalink / raw)
To: gcc-patches; +Cc: daniel, cederman, ebotcazou
The muser-mode flag causes the CASA instruction for LEON3 to use the
user mode ASI. This is the correct behavior for almost all LEON3 targets.
For this reason it makes sense to make user mode the default. This patch
adds a flag for supervisor mode that can be used on the very few LEON3 targets
that requires CASA to use the supervisor ASI.
gcc/ChangeLog:
2015-06-22 Daniel Cederman <cederman@gaisler.com>
* config/sparc/sparc.opt: Add supervisor mode flag (-msv-mode) and
make user mode the default
* config/sparc/sync.md: Only use supervisor ASI for CASA when in
supervisor mode
* doc/invoke.texi: Document msv-mode flag
---
gcc/config/sparc/sparc.opt | 8 ++++++--
gcc/config/sparc/sync.md | 6 +++---
gcc/doc/invoke.texi | 13 ++++++++-----
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/gcc/config/sparc/sparc.opt b/gcc/config/sparc/sparc.opt
index 93d24a6..5c7f546 100644
--- a/gcc/config/sparc/sparc.opt
+++ b/gcc/config/sparc/sparc.opt
@@ -113,9 +113,13 @@ mrelax
Target
Optimize tail call instructions in assembler and linker
+msv-mode
+Target RejectNegative Report Mask(SV_MODE)
+Generate code that can only run in supervisor mode
+
muser-mode
-Target Report Mask(USER_MODE)
-Do not generate code that can only run in supervisor mode
+Target RejectNegative Report InverseMask(SV_MODE)
+Do not generate code that can only run in supervisor mode (default)
mcpu=
Target RejectNegative Joined Var(sparc_cpu_and_features) Enum(sparc_processor_type) Init(PROCESSOR_V7)
diff --git a/gcc/config/sparc/sync.md b/gcc/config/sparc/sync.md
index 7d00b10..2fabff5 100644
--- a/gcc/config/sparc/sync.md
+++ b/gcc/config/sparc/sync.md
@@ -222,10 +222,10 @@
UNSPECV_CAS))]
"TARGET_LEON3"
{
- if (TARGET_USER_MODE)
- return "casa\t%1 0xa, %2, %0"; /* ASI for user data space. */
- else
+ if (TARGET_SV_MODE)
return "casa\t%1 0xb, %2, %0"; /* ASI for supervisor data space. */
+ else
+ return "casa\t%1 0xa, %2, %0"; /* ASI for user data space. */
}
[(set_attr "type" "multi")])
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b99ab1c..211e8e9 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1008,7 +1008,7 @@ See RS/6000 and PowerPC Options.
-mhard-quad-float -msoft-quad-float @gol
-mstack-bias -mno-stack-bias @gol
-munaligned-doubles -mno-unaligned-doubles @gol
--muser-mode -mno-user-mode @gol
+-muser-mode -msv-mode @gol
-mv8plus -mno-v8plus -mvis -mno-vis @gol
-mvis2 -mno-vis2 -mvis3 -mno-vis3 @gol
-mcbcond -mno-cbcond @gol
@@ -21300,13 +21300,16 @@ Specifying this option avoids some rare compatibility problems with code
generated by other compilers. It is not the default because it results
in a performance loss, especially for floating-point code.
+@item -msv-mode
+@opindex msv-mode
+Generate code that can only run in supervisor mode. This is relevant
+only for the @code{casa} instruction emitted for the LEON3 processor.
+
@item -muser-mode
-@itemx -mno-user-mode
@opindex muser-mode
-@opindex mno-user-mode
Do not generate code that can only run in supervisor mode. This is relevant
-only for the @code{casa} instruction emitted for the LEON3 processor. The
-default is @option{-mno-user-mode}.
+only for the @code{casa} instruction emitted for the LEON3 processor. This
+is the default.
@item -mno-faster-structs
@itemx -mfaster-structs
--
2.4.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-23 12:22 ` [PATCH] Make muser-mode the default for LEON3 Daniel Cederman
@ 2015-06-23 12:34 ` Sebastian Huber
2015-06-23 12:38 ` Jakub Jelinek
1 sibling, 0 replies; 10+ messages in thread
From: Sebastian Huber @ 2015-06-23 12:34 UTC (permalink / raw)
To: Daniel Cederman, gcc-patches; +Cc: daniel, ebotcazou
Instead of introducing a new option which may conflict with an existing
one, is it not possible to simply use -mno-user-mode?
On 23/06/15 14:22, Daniel Cederman wrote:
> The muser-mode flag causes the CASA instruction for LEON3 to use the
> user mode ASI. This is the correct behavior for almost all LEON3 targets.
> For this reason it makes sense to make user mode the default. This patch
> adds a flag for supervisor mode that can be used on the very few LEON3 targets
> that requires CASA to use the supervisor ASI.
>
> gcc/ChangeLog:
>
> 2015-06-22 Daniel Cederman <cederman@gaisler.com>
>
> * config/sparc/sparc.opt: Add supervisor mode flag (-msv-mode) and
> make user mode the default
> * config/sparc/sync.md: Only use supervisor ASI for CASA when in
> supervisor mode
> * doc/invoke.texi: Document msv-mode flag
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-23 12:22 ` [PATCH] Make muser-mode the default for LEON3 Daniel Cederman
2015-06-23 12:34 ` Sebastian Huber
@ 2015-06-23 12:38 ` Jakub Jelinek
2015-06-23 12:55 ` Daniel Cederman
1 sibling, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2015-06-23 12:38 UTC (permalink / raw)
To: Daniel Cederman; +Cc: gcc-patches, daniel, ebotcazou
On Tue, Jun 23, 2015 at 02:22:34PM +0200, Daniel Cederman wrote:
> The muser-mode flag causes the CASA instruction for LEON3 to use the
> user mode ASI. This is the correct behavior for almost all LEON3 targets.
> For this reason it makes sense to make user mode the default. This patch
> adds a flag for supervisor mode that can be used on the very few LEON3 targets
> that requires CASA to use the supervisor ASI.
Why are you adding a new option and without deprecation removing a
previously accepted (at least since 4.8) option?
For just changing the default, you really don't need to add a new option
or remove -mno-user-mode, just change the default, which can be done
e.g. by checking if the bit has been explicitly set and if not, use the
desired default, or if you want to change the Mask() name, just
make it InverseMask, but keep the options as they are.
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-23 12:38 ` Jakub Jelinek
@ 2015-06-23 12:55 ` Daniel Cederman
2015-06-23 13:07 ` Jakub Jelinek
0 siblings, 1 reply; 10+ messages in thread
From: Daniel Cederman @ 2015-06-23 12:55 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, daniel, ebotcazou, Sebastian Huber
On 2015-06-23 14:34, Jakub Jelinek wrote:
> On Tue, Jun 23, 2015 at 02:22:34PM +0200, Daniel Cederman wrote:
>> The muser-mode flag causes the CASA instruction for LEON3 to use the
>> user mode ASI. This is the correct behavior for almost all LEON3 targets.
>> For this reason it makes sense to make user mode the default. This patch
>> adds a flag for supervisor mode that can be used on the very few LEON3 targets
>> that requires CASA to use the supervisor ASI.
>
> Why are you adding a new option and without deprecation removing a
> previously accepted (at least since 4.8) option?
> For just changing the default, you really don't need to add a new option
> or remove -mno-user-mode, just change the default, which can be done
> e.g. by checking if the bit has been explicitly set and if not, use the
> desired default, or if you want to change the Mask() name, just
> make it InverseMask, but keep the options as they are.
>
> Jakub
>
How does one check if the bit has been explicitly set? It was not
obvious to me, which is why I took a similar approach to a patch I found
for another CPU target. If it is possible to change the default without
adding another flag then that is obviously better and I will update my
patch.
Best regards,
Daniel Cederman
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-23 12:55 ` Daniel Cederman
@ 2015-06-23 13:07 ` Jakub Jelinek
2015-06-23 14:10 ` Daniel Cederman
0 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2015-06-23 13:07 UTC (permalink / raw)
To: Daniel Cederman; +Cc: gcc-patches, daniel, ebotcazou, Sebastian Huber
On Tue, Jun 23, 2015 at 02:48:45PM +0200, Daniel Cederman wrote:
> How does one check if the bit has been explicitly set? It was not obvious to
if (TARGET_USER_MODE_P (target_flags_explicit))
> me, which is why I took a similar approach to a patch I found for another
> CPU target. If it is possible to change the default without adding another
> flag then that is obviously better and I will update my patch.
Or you can just change the default target_flags, supposedly with
TargetVariable
int target_flags = MASK_USER_MODE
in the opt file, there are really many possibilities.
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Make muser-mode the default for LEON3
2015-06-23 13:07 ` Jakub Jelinek
@ 2015-06-23 14:10 ` Daniel Cederman
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Cederman @ 2015-06-23 14:10 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, daniel, ebotcazou, Sebastian Huber
On 2015-06-23 14:58, Jakub Jelinek wrote:
> On Tue, Jun 23, 2015 at 02:48:45PM +0200, Daniel Cederman wrote:
>> How does one check if the bit has been explicitly set? It was not obvious to
>
> if (TARGET_USER_MODE_P (target_flags_explicit))
>
>> me, which is why I took a similar approach to a patch I found for another
>> CPU target. If it is possible to change the default without adding another
>> flag then that is obviously better and I will update my patch.
>
> Or you can just change the default target_flags, supposedly with
> TargetVariable
> int target_flags = MASK_USER_MODE
> in the opt file, there are really many possibilities.
>
> Jakub
>
Thanks! I went with your suggestion in the previous mail and removed the
new -msv-mode option and inversed the user mode mask.
Best regards,
Daniel Cederman
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-06-30 9:36 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-23 14:29 [PATCH] Make muser-mode the default for LEON3 Daniel Cederman
2015-06-26 7:59 ` Eric Botcazou
2015-06-26 12:06 ` Daniel Cederman
2015-06-30 9:50 ` Eric Botcazou
-- strict thread matches above, loose matches on Subject: below --
2015-06-23 12:22 [PATCH 1/2] Add mask to specify which LEON3 targets support CASA Daniel Cederman
2015-06-23 12:22 ` [PATCH] Make muser-mode the default for LEON3 Daniel Cederman
2015-06-23 12:34 ` Sebastian Huber
2015-06-23 12:38 ` Jakub Jelinek
2015-06-23 12:55 ` Daniel Cederman
2015-06-23 13:07 ` Jakub Jelinek
2015-06-23 14:10 ` Daniel Cederman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).