While testing something else, I noticed a couple compilation errors like:
/tmp/ccCxOOoN.s: Assembler messages:
/tmp/ccCxOOoN.s:164: Error: r31 cannot be used with jmp; use ret instead
The assembler is correct in rejecting this code, since this is a
documented restriction of the JMP instruction. We need to introduce a
new register class that excludes r31. Fortunately, Chung-Lin already
had a patch for this on our internal development branch; I've committed
it to mainline after testing to make sure it fixes the problem.
-Sandra
2015-05-12 Chung-Lin Tang <clt...@codesourcery.com>
Sandra Loosemore <san...@codesourcery.com>
gcc/
* config/nios2/nios2.h (enum reg_class): Add IJMP_REGS enum
value.
(REG_CLASS_NAMES): Add "IJMP_REGS".
(REG_CLASS_CONTENTS): Add new entry for IJMP_REGS.
* config/nios2/nios2.md (indirect_jump,*tablejump): Adjust to
use new "c" register constraint.
* config/nios2/constraint.md (c): New register constraint
corresponding to IJMP_REGS.
Index: gcc/config/nios2/nios2.h
===================================================================
--- gcc/config/nios2/nios2.h (revision 223017)
+++ gcc/config/nios2/nios2.h (working copy)
@@ -173,6 +173,7 @@ enum reg_class
{
NO_REGS,
SIB_REGS,
+ IJMP_REGS,
GP_REGS,
ALL_REGS,
LIM_REG_CLASSES
@@ -183,6 +184,7 @@ enum reg_class
#define REG_CLASS_NAMES \
{ "NO_REGS", \
"SIB_REGS", \
+ "IJMP_REGS", \
"GP_REGS", \
"ALL_REGS" }
@@ -190,10 +192,11 @@ enum reg_class
#define REG_CLASS_CONTENTS \
{ \
- /* NO_REGS */ { 0, 0}, \
- /* SIB_REGS */ { 0xfe0c, 0}, \
- /* GP_REGS */ {~0, 0}, \
- /* ALL_REGS */ {~0,~0} \
+ /* NO_REGS */ { 0, 0}, \
+ /* SIB_REGS */ { 0xfe0c, 0}, \
+ /* IJMP_REGS */ { 0x7fffffff, 0}, \
+ /* GP_REGS */ {~0, 0}, \
+ /* ALL_REGS */ {~0,~0} \
}
Index: gcc/config/nios2/nios2.md
===================================================================
--- gcc/config/nios2/nios2.md (revision 223017)
+++ gcc/config/nios2/nios2.md (working copy)
@@ -697,7 +697,7 @@
; check or adjust for overflow.
(define_insn "indirect_jump"
- [(set (pc) (match_operand:SI 0 "register_operand" "r"))]
+ [(set (pc) (match_operand:SI 0 "register_operand" "c"))]
""
"jmp\\t%0"
[(set_attr "type" "control")])
@@ -811,7 +811,7 @@
(define_insn "*tablejump"
[(set (pc)
- (match_operand:SI 0 "register_operand" "r"))
+ (match_operand:SI 0 "register_operand" "c"))
(use (label_ref (match_operand 1 "" "")))]
""
"jmp\\t%0"
Index: gcc/config/nios2/constraints.md
===================================================================
--- gcc/config/nios2/constraints.md (revision 223017)
+++ gcc/config/nios2/constraints.md (working copy)
@@ -39,6 +39,9 @@
;; Register constraints
+(define_register_constraint "c" "IJMP_REGS"
+ "A register suitable for an indirect jump.")
+
(define_register_constraint "j" "SIB_REGS"
"A register suitable for an indirect sibcall.")