aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Meakin <karl.meakin@arm.com>2025-07-03 12:48:29 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2025-07-03 12:48:29 +0100
commit70905bad8ea7e9e5f807b54ad3fe183f643cdbf2 (patch)
tree1a8a7a54c4e4c99e7d93f793d10d9686d608cae0
parent2cc9b03a84601b7951e5e0a24f5174387f564f27 (diff)
downloadgcc-70905bad8ea7e9e5f807b54ad3fe183f643cdbf2.zip
gcc-70905bad8ea7e9e5f807b54ad3fe183f643cdbf2.tar.gz
gcc-70905bad8ea7e9e5f807b54ad3fe183f643cdbf2.tar.bz2
AArch64: add constants for branch displacements
Extract the hardcoded values for the minimum PC-relative displacements into named constants and document them. gcc/ChangeLog: * config/aarch64/aarch64.md (BRANCH_LEN_P_1MiB): New constant. (BRANCH_LEN_N_1MiB): Likewise. (BRANCH_LEN_P_32KiB): Likewise. (BRANCH_LEN_N_32KiB): Likewise.
-rw-r--r--gcc/config/aarch64/aarch64.md60
1 files changed, 44 insertions, 16 deletions
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 8ce991e..3f37ea6 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -704,7 +704,19 @@
[(set_attr "type" "branch")]
)
+;; Maximum PC-relative positive/negative displacements for various branching
+;; instructions.
+(define_constants
+ [
+ ;; +/- 1MiB. Used by B.<cond>, CBZ, CBNZ.
+ (BRANCH_LEN_P_1MiB 1048572)
+ (BRANCH_LEN_N_1MiB -1048576)
+ ;; +/- 32KiB. Used by TBZ, TBNZ.
+ (BRANCH_LEN_P_32KiB 32764)
+ (BRANCH_LEN_N_32KiB -32768)
+ ]
+)
;; -------------------------------------------------------------------
;; Conditional jumps
@@ -769,13 +781,17 @@
}
[(set_attr "type" "branch")
(set (attr "length")
- (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
- (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
+ (if_then_else (and (ge (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_N_1MiB))
+ (lt (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_P_1MiB)))
(const_int 4)
(const_int 8)))
(set (attr "far_branch")
- (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
- (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
+ (if_then_else (and (ge (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_N_1MiB))
+ (lt (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_P_1MiB)))
(const_int 0)
(const_int 1)))]
)
@@ -830,13 +846,17 @@
}
[(set_attr "type" "branch")
(set (attr "length")
- (if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -1048576))
- (lt (minus (match_dup 1) (pc)) (const_int 1048572)))
+ (if_then_else (and (ge (minus (match_dup 1) (pc))
+ (const_int BRANCH_LEN_N_1MiB))
+ (lt (minus (match_dup 1) (pc))
+ (const_int BRANCH_LEN_P_1MiB)))
(const_int 4)
(const_int 8)))
(set (attr "far_branch")
- (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
- (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
+ (if_then_else (and (ge (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_N_1MiB))
+ (lt (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_P_1MiB)))
(const_int 0)
(const_int 1)))]
)
@@ -870,13 +890,17 @@
}
[(set_attr "type" "branch")
(set (attr "length")
- (if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -32768))
- (lt (minus (match_dup 1) (pc)) (const_int 32764)))
+ (if_then_else (and (ge (minus (match_dup 1) (pc))
+ (const_int BRANCH_LEN_N_32KiB))
+ (lt (minus (match_dup 1) (pc))
+ (const_int BRANCH_LEN_P_32KiB)))
(const_int 4)
(const_int 8)))
(set (attr "far_branch")
- (if_then_else (and (ge (minus (match_dup 1) (pc)) (const_int -1048576))
- (lt (minus (match_dup 1) (pc)) (const_int 1048572)))
+ (if_then_else (and (ge (minus (match_dup 1) (pc))
+ (const_int BRANCH_LEN_N_1MiB))
+ (lt (minus (match_dup 1) (pc))
+ (const_int BRANCH_LEN_P_1MiB)))
(const_int 0)
(const_int 1)))]
)
@@ -931,13 +955,17 @@
}
[(set_attr "type" "branch")
(set (attr "length")
- (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -32768))
- (lt (minus (match_dup 2) (pc)) (const_int 32764)))
+ (if_then_else (and (ge (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_N_32KiB))
+ (lt (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_P_32KiB)))
(const_int 4)
(const_int 8)))
(set (attr "far_branch")
- (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576))
- (lt (minus (match_dup 2) (pc)) (const_int 1048572)))
+ (if_then_else (and (ge (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_N_1MiB))
+ (lt (minus (match_dup 2) (pc))
+ (const_int BRANCH_LEN_P_1MiB)))
(const_int 0)
(const_int 1)))]