Skip to content

Commit e4954e4

Browse files
Claudiu Zissulescuartemiy-volkov
authored andcommitted
arc64: add unaligned access, improve addN patterns.
What is new: - add munaligned-access option (default off); - allow addN instruction to work with symbols when they are under 4G. - allow scalled addresses for store instructions. Signed-off-by: Claudiu Zissulescu <[email protected]>
1 parent ada1ca2 commit e4954e4

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

gcc/config/arc64/arc64.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,11 @@ arc64_legitimate_address_1_p (machine_mode mode,
590590
return true;
591591

592592
/* Scalled addresses. */
593-
if (load_p
594-
&& GET_CODE (x) == PLUS
593+
if (GET_CODE (x) == PLUS
595594
&& GET_CODE (XEXP (x, 0)) == MULT
596-
&& REG_P (XEXP (x, 1))
595+
&& ((load_p && REG_P (XEXP (x, 1)))
596+
|| (load_p && CONST_INT_P (XEXP (x, 1)))
597+
|| ARC64_CHECK_SMALL_IMMEDIATE (XEXP (x, 1), QImode))
597598
&& REG_P (XEXP (XEXP (x, 0), 0))
598599
&& CONST_INT_P (XEXP (XEXP (x, 0), 1)))
599600
switch (GET_MODE_SIZE (mode))
@@ -602,7 +603,7 @@ arc64_legitimate_address_1_p (machine_mode mode,
602603
case 4:
603604
case 8:
604605
if (INTVAL (XEXP (XEXP (x, 0), 1)) == GET_MODE_SIZE (mode))
605-
return true;;
606+
return true;
606607
break;
607608
default:
608609
break;

gcc/config/arc64/arc64.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,12 @@
8787

8888
/* Set this nonzero if move instructions will actually fail to work
8989
when given unaligned data. */
90-
#define STRICT_ALIGNMENT 1
90+
#define STRICT_ALIGNMENT (!unaligned_access)
91+
92+
/* Default unaligned accesses. */
93+
#ifndef UNALIGNED_ACCESS_DEFAULT
94+
#define UNALIGNED_ACCESS_DEFAULT 0
95+
#endif
9196

9297
/* Layout of Source Language Data Types. */
9398
#define SHORT_TYPE_SIZE 16

gcc/config/arc64/arc64.opt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,7 @@ Enable MPY64 multiplication instructions.
6767
mcpu=
6868
Target RejectNegative Joined
6969
-mcpu= Generate code for specific ARCv3 CPU variant.
70+
71+
munaligned-access
72+
Target Report Var(unaligned_access) Init(UNALIGNED_ACCESS_DEFAULT)
73+
Enable unaligned accesses to packed data.

gcc/config/arc64/arith.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@
461461
(plus:GPI
462462
(ashift:GPI (match_operand:GPI 1 "register_operand" "q,r,r,r")
463463
(match_operand:GPI 2 "_1_2_3_operand" ""))
464-
(match_operand:GPI 3 "arc64_nonmem_operand" "0,0,r,S32S0")))]
464+
(match_operand:GPI 3 "arc64_regsym_operand" "0,0,r,S32S0SymMV")))]
465465
""
466466
"add%2<sfxtab>%?\\t%0,%3,%1"
467467
[(set_attr "type" "add")
@@ -474,7 +474,7 @@
474474
(compare:CC_ZN
475475
(plus:GPI (ashift:GPI (match_operand:GPI 1 "register_operand" "r,r,r")
476476
(match_operand:GPI 2 "_1_2_3_operand" ""))
477-
(match_operand:GPI 3 "arc64_nonmem_operand" "0,r,S32S0"))
477+
(match_operand:GPI 3 "arc64_regsym_operand" "0,r,S32S0SymMV"))
478478
(const_int 0)))
479479
(set (match_operand:GPI 0 "register_operand" "=r,r,r")
480480
(plus:GPI (ashift:GPI (match_dup 1) (match_dup 2))
@@ -490,7 +490,7 @@
490490
(compare:CC_ZN
491491
(plus:GPI (ashift:GPI (match_operand:GPI 0 "register_operand" "r,r,r")
492492
(match_operand:GPI 1 "_1_2_3_operand" ""))
493-
(match_operand:GPI 2 "arc64_nonmem_operand" "0,r,S32S0"))
493+
(match_operand:GPI 2 "arc64_regsym_operand" "0,r,S32S0SymMV"))
494494
(const_int 0)))]
495495
""
496496
"add%1<sfxtab>%?.f\\t0,%2,%1"
@@ -500,7 +500,7 @@
500500

501501
(define_insn "*sub<mode>_shift"
502502
[(set (match_operand:GPI 0 "register_operand" "=r,r,r")
503-
(minus:GPI (match_operand:GPI 1 "arc64_nonmem_operand" "0,r,S32S0")
503+
(minus:GPI (match_operand:GPI 1 "arc64_regsym_operand" "0,r,S32S0SymMV")
504504
(ashift:GPI (match_operand:GPI 2 "register_operand" "r,r,r")
505505
(match_operand:GPI 3 "_1_2_3_operand" ""))))]
506506
""

gcc/config/arc64/predicates.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@
3333
(ior (match_test "UNSIGNED_INT32 (INTVAL (op))")
3434
(match_test "SIGNED_INT32 (INTVAL (op))"))))))
3535

36+
;; A restricted version of the above, still accepting symbols and label refs.
37+
(define_predicate "arc64_regsym_operand"
38+
(ior (match_operand 0 "register_operand")
39+
(and (ior (match_code "label_ref")
40+
(match_code "symbol_ref"))
41+
(match_test "arc64_allow_direct_access_p (op)"))
42+
(and (match_code "const_int")
43+
(ior (match_test "UNSIGNED_INT32 (INTVAL (op))")
44+
(match_test "SIGNED_INT32 (INTVAL (op))")))))
45+
3646
(define_predicate "arc64_nonmem_operand"
3747
(ior (match_operand 0 "register_operand")
3848
(and (match_code "const_int")

0 commit comments

Comments
 (0)