Skip to content

Commit 0910c1b

Browse files
author
Claudiu Zissulescu
committed
Safer usage of 5bit register class
1 parent 81ba6fb commit 0910c1b

File tree

5 files changed

+42
-24
lines changed

5 files changed

+42
-24
lines changed

gcc/ChangeLog.ARC

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2013-05-22 Claudiu Zissulescu <[email protected]>
2+
3+
* config/arc/arc.c (arc_conditional_register_usage): Make sure
4+
r30 is fix for the time being.
5+
* config/arc/arc.h (AC16_H_REGS): New Register class.
6+
* config/arc/arc.md :Use 'h' instead of 'W' for 5bit register
7+
class.
8+
* config/arc/constraints.md ('h'): New register constraint letter.
9+
110
2013-05-16 Claudiu Zissulescu <[email protected]>
211

312
* config/arc/arc.c (arc_expand_movmem): Fix computation on

gcc/config/arc/arc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,12 +1342,13 @@ arc_conditional_register_usage (void)
13421342
int i;
13431343
int fix_start = 60, fix_end = 55;
13441344

1345-
/* For ARCv2 the core register set is changed.*/
13461345
if (TARGET_V2)
13471346
{
1347+
/* For ARCv2 the core register set is changed.*/
13481348
strcpy(rname29, "ilink");
13491349
strcpy(rname30, "r30");
1350-
}
1350+
fixed_regs[30] = call_used_regs[30] = 1;
1351+
}
13511352
if (TARGET_MUL64_SET)
13521353
{
13531354
fix_start = 57;

gcc/config/arc/arc.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ if (GET_MODE_CLASS (MODE) == MODE_INT \
535535
27 - frame pointer
536536
28 - stack pointer
537537
29 - ilink1
538-
30 - ilink2
538+
30 - ilink2 (general purpose register ARCv2)
539539
31 - return address register
540540
541541
By default, the extension registers are not available. */
@@ -601,7 +601,7 @@ if (GET_MODE_CLASS (MODE) == MODE_INT \
601601
/* If defined, an initializer for a vector of integers, containing the
602602
numbers of hard registers in the order in which GCC should
603603
prefer to use them (from most preferred to least). */
604-
#define REG_ALLOC_ORDER \
604+
#define REG_ALLOC_ORDER \
605605
{ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, \
606606
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, \
607607
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, \
@@ -631,7 +631,7 @@ extern unsigned int arc_mode_class[];
631631
MODE2)' must be zero. */
632632

633633
/* Tie QI/HI/SI modes together. */
634-
#define MODES_TIEABLE_P(MODE1, MODE2) \
634+
#define MODES_TIEABLE_P(MODE1, MODE2) \
635635
(GET_MODE_CLASS (MODE1) == MODE_INT \
636636
&& GET_MODE_CLASS (MODE2) == MODE_INT \
637637
&& GET_MODE_SIZE (MODE1) <= UNITS_PER_WORD \
@@ -694,6 +694,7 @@ enum reg_class
694694
ALL_CORE_REGS, /* 'Rac' */
695695
R0R3_CODE_DENSITY_REGS, /* 'Rcd' */
696696
R0R1_CODE_DENSITY_REGS, /* 'Rsd' */
697+
AC16_H_REGS, /* 'h' */
697698
ALL_REGS,
698699
LIM_REG_CLASSES
699700
};
@@ -722,6 +723,7 @@ enum reg_class
722723
"CHEAP_CORE_REGS", \
723724
"R0R3_CODE_DENSITY_REGS", \
724725
"R0R1_CODE_DENSITY_REGS", \
726+
"AC16_H_REGS", \
725727
"ALL_CORE_REGS", \
726728
"ALL_REGS" \
727729
}
@@ -756,6 +758,7 @@ enum reg_class
756758
{0xffffffff, 0xdfffffff, 0x00000000, 0x00000000, 0x00000000}, /* 'Rac', r0-r60, ap, pcl */ \
757759
{0x0000000f, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'Rcd', r0-r3 */ \
758760
{0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'Rsd', r0-r1 */ \
761+
{0x9fffffff, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, /* 'h', r0-28, r30 */ \
759762
{0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, 0x0003ffff} /* All Registers */ \
760763
}
761764

@@ -794,9 +797,9 @@ extern enum reg_class arc_regno_reg_class[];
794797
or a pseudo reg currently allocated to a suitable hard reg.
795798
Since they use reg_renumber, they are safe only once reg_renumber
796799
has been allocated, which happens in local-alloc.c. */
797-
#define REGNO_OK_FOR_BASE_P(REGNO) \
798-
((REGNO) < 29 || ((REGNO) == ARG_POINTER_REGNUM) || ((REGNO) == 63) ||\
799-
(unsigned) reg_renumber[REGNO] < 29)
800+
#define REGNO_OK_FOR_BASE_P(REGNO) \
801+
((REGNO) < 29 || ((REGNO) == ARG_POINTER_REGNUM) || ((REGNO) == 63) || \
802+
(unsigned) reg_renumber[REGNO] < 29)
800803

801804
#define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P(REGNO)
802805

@@ -805,17 +808,17 @@ extern enum reg_class arc_regno_reg_class[];
805808
In general this is just CLASS; but on some machines
806809
in some cases it is preferable to use a more restrictive class. */
807810

808-
#define PREFERRED_RELOAD_CLASS(X, CLASS) \
811+
#define PREFERRED_RELOAD_CLASS(X, CLASS) \
809812
arc_preferred_reload_class((X), (CLASS))
810813

811814
extern enum reg_class arc_preferred_reload_class (rtx, enum reg_class);
812815

813816
/* Return the maximum number of consecutive registers
814817
needed to represent mode MODE in a register of class CLASS. */
815818

816-
#define CLASS_MAX_NREGS(CLASS, MODE) \
817-
(( GET_MODE_SIZE (MODE) == 16 && CLASS == SIMD_VR_REGS) ? 1: \
818-
((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
819+
#define CLASS_MAX_NREGS(CLASS, MODE) \
820+
(( GET_MODE_SIZE (MODE) == 16 && CLASS == SIMD_VR_REGS) ? 1: \
821+
((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD))
819822

820823
#define SMALL_INT(X) ((unsigned) ((X) + 0x100) < 0x200)
821824
#define SMALL_INT_RANGE(X, OFFSET, SHIFT) \

gcc/config/arc/arc.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,8 @@
593593
; The iscompact attribute allows the epilogue expander to know for which
594594
; insns it should lengthen the return insn.
595595
(define_insn "*movqi_insn"
596-
[(set (match_operand:QI 0 "move_dest_operand" "=Rcq,Rcq#q, w, W, w, w,???w, w,Rcq, S,!*x,r,m,???m")
597-
(match_operand:QI 1 "move_src_operand" " cL, cP,Rcq#q,WCm1,cL, I,?Rac,?i, T,Rcq,Usd,m,c,?Rac"))]
596+
[(set (match_operand:QI 0 "move_dest_operand" "=Rcq,Rcq#q, w, h, w, w,???w, w,Rcq, S,!*x,r,m,???m")
597+
(match_operand:QI 1 "move_src_operand" " cL, cP,Rcq#q,hCm1,cL, I,?Rac,?i, T,Rcq,Usd,m,c,?Rac"))]
598598
"register_operand (operands[0], QImode)
599599
|| register_operand (operands[1], QImode)"
600600
"@
@@ -624,8 +624,8 @@
624624
"if (prepare_move_operands (operands, HImode)) DONE;")
625625

626626
(define_insn "*movhi_insn"
627-
[(set (match_operand:HI 0 "move_dest_operand" "=Rcq,Rcq#q, w, W, w,w,???w,Rcq#q, w,Rcq, S,r,m,???m,VUsc,VUsc")
628-
(match_operand:HI 1 "move_src_operand" "cL, cP,Rcq#q,WCm1,cL,I,?Rac, ?i,?i, T,Rcq,m,c,?Rac, Cm3, i"))]
627+
[(set (match_operand:HI 0 "move_dest_operand" "=Rcq,Rcq#q, w, h, w,w,???w,Rcq#q, w,Rcq, S,r,m,???m,VUsc,VUsc")
628+
(match_operand:HI 1 "move_src_operand" "cL, cP,Rcq#q,hCm1,cL,I,?Rac, ?i,?i, T,Rcq,m,c,?Rac, Cm3, i"))]
629629
"register_operand (operands[0], HImode)
630630
|| register_operand (operands[1], HImode)
631631
|| (CONSTANT_P (operands[1])
@@ -670,8 +670,8 @@
670670
; insns it should lengthen the return insn.
671671
; N.B. operand 1 of alternative 7 expands into pcl,symbol@gotpc .
672672
(define_insn "*movsi_insn" ; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
673-
[(set (match_operand:SI 0 "move_dest_operand" "=Rcq,Rcq#q, w, W, w,w, w,???w, ?w, w,Rcq#q, w,Rcq, S, Us<,RcqRck,!*x,!*Rsd,!*Rcd, r,Usd, m,???m,VUsc,VUsc")
674-
(match_operand:SI 1 "move_src_operand" "cL, cP,Rcq#q,WCm1,cL,I,Crr,?Rac,Cpc,Clb, ?Cal,?Cal,Uts,Rcq,RcqRck, Us>,Usd, Usd, Ucd, m,!*x, c,?Rac, Cm3, C32"))]
673+
[(set (match_operand:SI 0 "move_dest_operand" "=Rcq,Rcq#q, w, h, w,w, w,???w, ?w, w,Rcq#q, w,Rcq, S, Us<,RcqRck,!*x,!*Rsd,!*Rcd, r,Usd, m,???m,VUsc,VUsc")
674+
(match_operand:SI 1 "move_src_operand" "cL, cP,Rcq#q,hCm1,cL,I,Crr,?Rac,Cpc,Clb, ?Cal,?Cal,Uts,Rcq,RcqRck, Us>,Usd, Usd, Ucd, m,!*x, c,?Rac, Cm3, C32"))]
675675
"register_operand (operands[0], SImode)
676676
|| register_operand (operands[1], SImode)
677677
|| (CONSTANT_P (operands[1])
@@ -1046,8 +1046,8 @@
10461046
"if (prepare_move_operands (operands, SFmode)) DONE;")
10471047

10481048
(define_insn "*movsf_insn"
1049-
[(set (match_operand:SF 0 "move_dest_operand" "= W,w,w,r,m")
1050-
(match_operand:SF 1 "move_src_operand" "WCm1,c,E,m,c"))]
1049+
[(set (match_operand:SF 0 "move_dest_operand" "= h,w,w,r,m")
1050+
(match_operand:SF 1 "move_src_operand" "hCm1,c,E,m,c"))]
10511051
"(register_operand (operands[0], SFmode)
10521052
|| register_operand (operands[1], SFmode))
10531053
&& !(register_operand (operands[1], SFmode) && REGNO(operands[1]) == 58)"
@@ -1650,7 +1650,7 @@
16501650
; register class 'W' instead of 'w'.
16511651
(define_insn_and_split "*addsi3_mixed"
16521652
;; 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12
1653-
[(set (match_operand:SI 0 "dest_reg_operand" "=Rcq#q,Rcq, W,!*Rsd,Rcq,Rcb,Rcq, Rcqq,Rcqq,Rcw,Rcw, Rcw, W, W,W, W,Rcqq,Rcw, W")
1653+
[(set (match_operand:SI 0 "dest_reg_operand" "=Rcq#q,Rcq, h,!*Rsd,Rcq,Rcb,Rcq, Rcqq,Rcqq,Rcw,Rcw, Rcw, W, W,W, W,Rcqq,Rcw, W")
16541654
(plus:SI (match_operand:SI 1 "register_operand" "%0, c, 0, Rcqq, 0, 0,Rcb, Rcqq, 0, 0, c, 0, c, c,0, 0, 0, 0, c")
16551655
(match_operand:SI 2 "nonmemory_operand" "cL, 0, Cm1, L,CL2,Csp,CM4,RcqqK, cO, cL, 0,cCca,cLCmL,Cca,I,C2a, Cal,Cal,Cal")))]
16561656
""
@@ -3319,7 +3319,7 @@
33193319
;; modifed cc user if second, but not first operand is a compact register.
33203320
(define_insn "cmpsi_cc_insn_mixed"
33213321
[(set (reg:CC CC_REG)
3322-
(compare:CC (match_operand:SI 0 "register_operand" "Rcq#q, W, c, c, qRcq, c")
3322+
(compare:CC (match_operand:SI 0 "register_operand" "Rcq#q, h, c, c, qRcq, c")
33233323
(match_operand:SI 1 "nonmemory_operand" " cO,Cm1,cI,cL, Cal, Cal")))]
33243324
""
33253325
"cmp%? %0,%B1%&"
@@ -3405,7 +3405,7 @@
34053405

34063406
(define_insn "*cmpsi_cc_c_insn"
34073407
[(set (reg:CC_C CC_REG)
3408-
(compare:CC_C (match_operand:SI 0 "register_operand" "Rcqq, W, c,Rcqq, c")
3408+
(compare:CC_C (match_operand:SI 0 "register_operand" "Rcqq, h, c,Rcqq, c")
34093409
(match_operand:SI 1 "nonmemory_operand" " cO,Cm1,cI, Cal,Cal")))]
34103410
""
34113411
"cmp%? %0,%S1%&"
@@ -3502,7 +3502,7 @@
35023502
[(cond_exec
35033503
(ne (match_operand:CC_Z 2 "cc_use_register" "Rcc, Rcc, Rcc,Rcc, Rcc,Rcc") (const_int 0))
35043504
(set (match_operand:SI 0 "dest_reg_operand" "=Rcq#q,Rcq#q,Rcq#q, w,???w,w")
3505-
(match_operand:SI 1 "nonmemory_operand" "C_0, W, ?Cal, Lc,?Rac,?Cal")))]
3505+
(match_operand:SI 1 "nonmemory_operand" "C_0, h, ?Cal, Lc,?Rac,?Cal")))]
35063506
""
35073507
"@
35083508
* current_insn_predicate = 0; return \"sub%?.ne %0,%0,%0%&\";

gcc/config/arc/constraints.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,3 +459,8 @@
459459
(define_register_constraint "Rsd" "R0R1_CODE_DENSITY_REGS"
460460
"@internal
461461
core register @code{r0}-@code{r1}")
462+
463+
(define_register_constraint "h" "AC16_H_REGS"
464+
"5-bit h register set except @code{r30} and @code{r29}: @code{r0}-@code{r31}, nonfixed core register")
465+
466+

0 commit comments

Comments
 (0)