From: Stafford Horne <shorne@gmail.com>
To: openrisc@lists.librecores.org
Subject: [OpenRISC] [PATCH v3 3/5] or1k: Add mrori option, fix option docs
Date: Tue, 9 Jul 2019 22:06:24 +0900 [thread overview]
Message-ID: <20190709130626.11226-4-shorne@gmail.com> (raw)
In-Reply-To: <20190709130626.11226-1-shorne@gmail.com>
gcc/ChangeLog:
* config.gcc (or1k*-*-*): Add mrori and mror to validation.
* doc/invoke.texi (OpenRISC Options): Add mrori option, rewrite all
documenation to be more clear.
* config/or1k/elf.opt (mboard=, mnewlib): Rewrite documentation to be
more clear.
* config/or1k/or1k.opt (mrori): New option.
(mhard-div, msoft-div, mhard-mul, msoft-mul, mcmov, mror, msext,
msfimm, mshftimm): Rewrite documentation to be more clear.
* config/or1k/predicates.md (ror_reg_or_u6_operand): New predicate.
* config/or1k/or1k.md (insn_support): Add ror and rori.
(enabled): Add conditions for ror and rori.
(rotrsi3): Replace condition for shftimm with ror and rori.
gcc/testsuite/ChangeLog:
* gcc.target/or1k/ror-4.c: New file.
* gcc.target/or1k/ror-5.c: New file.
* gcc.target/or1k/shftimm-1.c: Update test from rotate to shift
as the shftimm option no longer controls rotate.
---
Changes since v2:
- Fix issue with ror predicate pointed out by Segher.
- Added ror-5.c test to confirm/fix ICE.
gcc/config.gcc | 1 +
gcc/config/or1k/elf.opt | 6 +--
gcc/config/or1k/or1k.md | 14 ++++--
gcc/config/or1k/or1k.opt | 56 +++++++++++++----------
gcc/config/or1k/predicates.md | 7 +++
gcc/doc/invoke.texi | 56 +++++++++++++----------
gcc/testsuite/gcc.target/or1k/ror-4.c | 8 ++++
gcc/testsuite/gcc.target/or1k/ror-5.c | 9 ++++
gcc/testsuite/gcc.target/or1k/shftimm-1.c | 8 ++--
9 files changed, 104 insertions(+), 61 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/or1k/ror-4.c
create mode 100644 gcc/testsuite/gcc.target/or1k/ror-5.c
diff --git a/gcc/config.gcc b/gcc/config.gcc
index c281c418b28..aeab8b4544e 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -2578,6 +2578,7 @@ or1k*-*-*)
for or1k_multilib in ${or1k_multilibs}; do
case ${or1k_multilib} in
mcmov | msext | msfimm | \
+ mror | mrori | \
mhard-div | mhard-mul | \
msoft-div | msoft-mul )
TM_MULTILIB_CONFIG="${TM_MULTILIB_CONFIG},${or1k_multilib}"
diff --git a/gcc/config/or1k/elf.opt b/gcc/config/or1k/elf.opt
index 641b6ddd4be..2d4d1875d02 100644
--- a/gcc/config/or1k/elf.opt
+++ b/gcc/config/or1k/elf.opt
@@ -25,9 +25,9 @@
mboard=
Target RejectNegative Joined
-Configure board specific runtime.
+Configure the newlib board specific runtime. The default is or1ksim.
mnewlib
Target RejectNegative
-For compatibility, it's always newlib for elf now.
-
+This option is ignored; it is provided for compatibility purposes only. This
+used to select linker and preprocessor options for use with newlib.
diff --git a/gcc/config/or1k/or1k.md b/gcc/config/or1k/or1k.md
index 757d899c442..0faa0fa4c47 100644
--- a/gcc/config/or1k/or1k.md
+++ b/gcc/config/or1k/or1k.md
@@ -63,7 +63,7 @@
"alu,st,ld,control,multi"
(const_string "alu"))
-(define_attr "insn_support" "class1,sext,sfimm,shftimm" (const_string "class1"))
+(define_attr "insn_support" "class1,sext,sfimm,shftimm,ror,rori" (const_string "class1"))
(define_attr "enabled" ""
(cond [(eq_attr "insn_support" "class1") (const_int 1)
@@ -72,7 +72,11 @@
(and (eq_attr "insn_support" "sfimm")
(ne (symbol_ref "TARGET_SFIMM") (const_int 0))) (const_int 1)
(and (eq_attr "insn_support" "shftimm")
- (ne (symbol_ref "TARGET_SHFTIMM") (const_int 0))) (const_int 1)]
+ (ne (symbol_ref "TARGET_SHFTIMM") (const_int 0))) (const_int 1)
+ (and (eq_attr "insn_support" "ror")
+ (ne (symbol_ref "TARGET_ROR") (const_int 0))) (const_int 1)
+ (and (eq_attr "insn_support" "rori")
+ (ne (symbol_ref "TARGET_RORI") (const_int 0))) (const_int 1)]
(const_int 0)))
;; Describe a user's asm statement.
@@ -178,12 +182,12 @@
(define_insn "rotrsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(rotatert:SI (match_operand:SI 1 "register_operand" "r,r")
- (match_operand:SI 2 "reg_or_u6_operand" "r,n")))]
- "TARGET_ROR"
+ (match_operand:SI 2 "ror_reg_or_u6_operand" "r,n")))]
+ "TARGET_ROR || TARGET_RORI"
"@
l.ror\t%0, %1, %2
l.rori\t%0, %1, %2"
- [(set_attr "insn_support" "*,shftimm")])
+ [(set_attr "insn_support" "ror,rori")])
(define_insn "andsi3"
[(set (match_operand:SI 0 "register_operand" "=r,r")
diff --git a/gcc/config/or1k/or1k.opt b/gcc/config/or1k/or1k.opt
index 7bdbd842dd4..c2f64c5dd45 100644
--- a/gcc/config/or1k/or1k.opt
+++ b/gcc/config/or1k/or1k.opt
@@ -21,47 +21,55 @@
; See the GCC internals manual (options.texi) for a description of
; this file's format.
-; Please try to keep this file in ASCII collating order.
-
mhard-div
Target RejectNegative InverseMask(SOFT_DIV)
-Use hardware divide instructions, use -msoft-div for emulation.
+Enable generation of hardware divide (l.div, l.divu) instructions. This is the
+default; use -msoft-div to override.
+
+msoft-div
+Target RejectNegative Mask(SOFT_DIV)
+Enable generation of binaries which use functions from libgcc to perform divide
+operations. The default is -mhard-div.
mhard-mul
Target RejectNegative InverseMask(SOFT_MUL).
-Use hardware multiply instructions, use -msoft-mul for emulation.
+Enable generation of hardware multiply instructions (l.mul, l.muli) instructions.
+This is the default; use -msoft-mul to override.
+
+msoft-mul
+Target RejectNegative Mask(SOFT_MUL).
+Enable generation of binaries which use functions from libgcc to perform
+multiply operations. The default is -mhard-mul.
mcmov
Target RejectNegative Mask(CMOV)
-Allows generation of binaries which use the l.cmov instruction. If your target
-does not support this the compiler will generate the equivalent using set and
-branch.
+Enable generation of conditional move (l.cmov) instructions. By default the
+equivalent will be generated using using set and branch.
mror
Target RejectNegative Mask(ROR)
-Allows generation of binaries which use the l.rori instructions.
+Enable generation of rotate right (l.ror) instructions. By default functions
+from libgcc are used to perform rotate right operations.
+
+mrori
+Target RejectNegative Mask(RORI)
+Enable generation of rotate right with immediate (l.rori) instructions. By
+default functions from libgcc are used to perform rotate right with immediate
+operations.
msext
Target RejectNegative Mask(SEXT)
-Allows generation of binaries which use sign-extension instructions. If your
-target does not support this the compiler will use memory loads to perform sign
-extension.
+Enable generation of sign extension (l.ext*) instructions. By default memory
+loads are used to perform sign extension.
msfimm
Target RejectNegative Mask(SFIMM)
-Allows generation of binaries which use l.sf*i instructions. If your target
-does not support this the compiler will generate instructions to store the
-immediate to a register first.
+Enable generation of compare and set flag with immediate (l.sf*i) instructions.
+By default extra instructions will be generated to store the immediate to a
+register first.
mshftimm
Target RejectNegative Mask(SHFTIMM)
-Allows generation of binaries which support shifts and rotate instructions
-supporting immediate arguments, for example l.rori.
-
-msoft-div
-Target RejectNegative Mask(SOFT_DIV)
-Use divide emulation.
-
-msoft-mul
-Target RejectNegative Mask(SOFT_MUL).
-Use multiply emulation.
+Enable generation of shift with immediate (l.srai, l.srli, l.slli) instructions.
+By default extra instructions will be generated to store the immediate to a
+register first.
diff --git a/gcc/config/or1k/predicates.md b/gcc/config/or1k/predicates.md
index dad1c5d4be3..5e97bf48467 100644
--- a/gcc/config/or1k/predicates.md
+++ b/gcc/config/or1k/predicates.md
@@ -53,6 +53,13 @@
(match_test "INTVAL (op) >= -32768 && INTVAL (op) <= 32767")
(match_operand 0 "register_operand")))
+(define_predicate "ror_reg_or_u6_operand"
+ (if_then_else (match_code "const_int")
+ (and (match_test "INTVAL (op) >= 0 && INTVAL (op) <= 0x3f")
+ (match_test "TARGET_RORI"))
+ (and (match_operand 0 "register_operand")
+ (match_test "TARGET_ROR"))))
+
(define_predicate "call_insn_operand"
(ior (match_code "symbol_ref")
(match_operand 0 "register_operand")))
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 6382a840281..1f1f73672bd 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -1033,7 +1033,7 @@ Objective-C and Objective-C++ Dialects}.
@emph{OpenRISC Options}
@gccoptlist{-mboard=@var{name} -mnewlib -mhard-mul -mhard-div @gol
-msoft-mul -msoft-div @gol
--mcmov -mror -msext -msfimm -mshftimm}
+-mcmov -mror -mrori -msext -msfimm -mshftimm}
@emph{PDP-11 Options}
@gccoptlist{-mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 @gol
@@ -23632,50 +23632,56 @@ newlib board library linking. The default is @code{or1ksim}.
@item -mnewlib
@opindex mnewlib
-For compatibility, it's always newlib for elf now.
+This option is ignored; it is for compatibility purposes only. This used to
+select linker and preprocessor options for use with newlib.
- at item -mhard-div
+ at item -msoft-div
+ at itemx -mhard-div
+ at opindex msoft-div
@opindex mhard-div
-Generate code for hardware which supports divide instructions. This is the
-default.
+Select software or hardware divide (@code{l.div}, @code{l.divu}) instructions.
+This default is hardware divide.
- at item -mhard-mul
+ at item -msoft-mul
+ at itemx -mhard-mul
+ at opindex msoft-mul
@opindex mhard-mul
-Generate code for hardware which supports multiply instructions. This is the
-default.
+Select software or hardware multiply (@code{l.mul}, @code{l.muli}) instructions.
+This default is hardware multiply.
@item -mcmov
@opindex mcmov
-Generate code for hardware which supports the conditional move (@code{l.cmov})
-instruction.
+Enable generation of conditional move (@code{l.cmov}) instructions. By
+default the equivalent will be generated using using set and branch.
@item -mror
@opindex mror
-Generate code for hardware which supports rotate right instructions.
+Enable generation of rotate right (@code{l.ror}) instructions. By default
+functions from @file{libgcc} are used to perform rotate right operations.
+
+ at item -mrori
+ at opindex mrori
+Enable generation of rotate right with immediate (@code{l.rori}) instructions.
+By default functions from @file{libgcc} are used to perform rotate right with
+immediate operations.
@item -msext
@opindex msext
-Generate code for hardware which supports sign-extension instructions.
+Enable generation of sign extension (@code{l.ext*}) instructions. By default
+memory loads are used to perform sign extension.
@item -msfimm
@opindex msfimm
-Generate code for hardware which supports set flag immediate (@code{l.sf*i})
-instructions.
+Enable generation of compare and set flag with immediate (@code{l.sf*i})
+instructions. By default extra instructions will be generated to store the
+immediate to a register first.
@item -mshftimm
@opindex mshftimm
-Generate code for hardware which supports shift immediate related instructions
-(i.e. @code{l.srai}, @code{l.srli}, @code{l.slli}, @code{1.rori}). Note, to
-enable generation of the @code{l.rori} instruction the @option{-mror} flag must
-also be specified.
+Enable generation of shift with immediate (@code{l.srai}, @code{l.srli},
+ at code{l.slli}) instructions. By default extra instructions will be generated
+to store the immediate to a register first.
- at item -msoft-div
- at opindex msoft-div
-Generate code for hardware which requires divide instruction emulation.
-
- at item -msoft-mul
-@opindex msoft-mul
-Generate code for hardware which requires multiply instruction emulation.
@end table
diff --git a/gcc/testsuite/gcc.target/or1k/ror-4.c b/gcc/testsuite/gcc.target/or1k/ror-4.c
new file mode 100644
index 00000000000..7489ce5b6a2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/or1k/ror-4.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mrori -O2" } */
+
+unsigned int rotate6 (unsigned int a) {
+ return ( a >> 6 ) | ( a << ( 32 - 6 ) );
+}
+
+/* { dg-final { scan-assembler "l.rori" } } */
diff --git a/gcc/testsuite/gcc.target/or1k/ror-5.c b/gcc/testsuite/gcc.target/or1k/ror-5.c
new file mode 100644
index 00000000000..dd56accba60
--- /dev/null
+++ b/gcc/testsuite/gcc.target/or1k/ror-5.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-mrori -O2" } */
+/* { dg-skip-if "" { *-*-* } { "-mror" } { "" } } */
+
+unsigned int rotate (unsigned int a, int b) {
+ return ( a >> b ) | ( a << ( 32 - b ) );
+}
+
+/* { dg-final { scan-assembler-not "l.ror" } } */
diff --git a/gcc/testsuite/gcc.target/or1k/shftimm-1.c b/gcc/testsuite/gcc.target/or1k/shftimm-1.c
index be8d9e8b895..3a8dc06df79 100644
--- a/gcc/testsuite/gcc.target/or1k/shftimm-1.c
+++ b/gcc/testsuite/gcc.target/or1k/shftimm-1.c
@@ -1,8 +1,8 @@
/* { dg-do compile } */
-/* { dg-options "-mror -mshftimm -O2" } */
+/* { dg-options "-mshftimm -O2" } */
-unsigned int rotate6 (unsigned int a) {
- return ( a >> 6 ) | ( a << ( 32 - 6 ) );
+unsigned int shift6 (unsigned int a) {
+ return a << 6;
}
-/* { dg-final { scan-assembler "l.rori" } } */
+/* { dg-final { scan-assembler "l.slli" } } */
--
2.21.0
next prev parent reply other threads:[~2019-07-09 13:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-09 13:06 [OpenRISC] [PATCH v3 0/5] OpenRISC updates for 10 (fpu, fixes) Stafford Horne
2019-07-09 13:06 ` [OpenRISC] [PATCH v3 1/5] or1k: Fix code quality for volatile memory loads Stafford Horne
2019-07-09 13:06 ` [OpenRISC] [PATCH v3 2/5] or1k: Fix issues with msoft-div Stafford Horne
2019-07-09 13:06 ` Stafford Horne [this message]
2019-07-09 13:06 ` [OpenRISC] [PATCH v3 4/5] or1k: Initial support for FPU Stafford Horne
2019-07-09 13:06 ` [OpenRISC] [PATCH v3 5/5] or1k: only force reg for immediates Stafford Horne
2019-07-16 21:09 ` [OpenRISC] [PATCH v3 0/5] OpenRISC updates for 10 (fpu, fixes) Stafford Horne
2019-07-23 20:30 ` Stafford Horne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190709130626.11226-4-shorne@gmail.com \
--to=shorne@gmail.com \
--cc=openrisc@lists.librecores.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.