diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2023-11-21 15:39:11 +0000 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2023-11-21 15:39:11 +0000 |
commit | 32ce90c60154c21789225ed36faae59af8416cb4 (patch) | |
tree | 55ba738f76d62516d472bd370b22d28b88603d3d | |
parent | ef4e6e2c04141f1654e0d7bc8e5674dad9cc3452 (diff) | |
download | gcc-32ce90c60154c21789225ed36faae59af8416cb4.zip gcc-32ce90c60154c21789225ed36faae59af8416cb4.tar.gz gcc-32ce90c60154c21789225ed36faae59af8416cb4.tar.bz2 |
Add an aligned_register_operand predicate
This patch adds a target-independent aligned_register_operand
predicate, for use with register constraints that use filters
to impose an alignment. The definition deliberately jetisons
some of the historical baggage in general_operand.
gcc/
* common.md (aligned_register_operand): New predicate.
-rw-r--r-- | gcc/common.md | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gcc/common.md b/gcc/common.md index 51ecd79..91a72bd 100644 --- a/gcc/common.md +++ b/gcc/common.md @@ -17,6 +17,34 @@ ;; along with GCC; see the file COPYING3. If not see ;; <http://www.gnu.org/licenses/>. */ +;; This predicate is intended to be paired with register constraints that use +;; register filters to impose an alignment. Operands that are aligned via +;; TARGET_HARD_REGNO_MODE_OK should use normal register_operands instead. +(define_predicate "aligned_register_operand" + (match_code "reg,subreg") +{ + /* Require the offset in a non-paradoxical subreg to be naturally aligned. + For example, if we have a subreg of something that is double the size of + this operand, the offset must select the first or second half of it. */ + if (SUBREG_P (op) + && multiple_p (SUBREG_BYTE (op), GET_MODE_SIZE (GET_MODE (op)))) + op = SUBREG_REG (op); + if (!REG_P (op)) + return false; + + if (HARD_REGISTER_P (op)) + { + if (!in_hard_reg_set_p (operand_reg_set, GET_MODE (op), REGNO (op))) + return false; + + /* Reject hard registers that would need reloading, so that the reload + is visible to IRA and to pre-RA optimizers. */ + if (REGNO (op) % REG_NREGS (op) != 0) + return false; + } + return true; +}) + (define_register_constraint "r" "GENERAL_REGS" "Matches any general register.") |