1 1.1 mrg ;; Constraint definitions for LoongArch. 2 1.1 mrg ;; Copyright (C) 2021-2022 Free Software Foundation, Inc. 3 1.1 mrg ;; Contributed by Loongson Ltd. 4 1.1 mrg ;; 5 1.1 mrg ;; This file is part of GCC. 6 1.1 mrg ;; 7 1.1 mrg ;; GCC is free software; you can redistribute it and/or modify 8 1.1 mrg ;; it under the terms of the GNU General Public License as published by 9 1.1 mrg ;; the Free Software Foundation; either version 3, or (at your option) 10 1.1 mrg ;; any later version. 11 1.1 mrg ;; 12 1.1 mrg ;; GCC is distributed in the hope that it will be useful, 13 1.1 mrg ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 1.1 mrg ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 1.1 mrg ;; GNU General Public License for more details. 16 1.1 mrg ;; 17 1.1 mrg ;; You should have received a copy of the GNU General Public License 18 1.1 mrg ;; along with GCC; see the file COPYING3. If not see 19 1.1 mrg ;; <http://www.gnu.org/licenses/>. 20 1.1 mrg 21 1.1 mrg ;; Register constraints 22 1.1 mrg 23 1.1 mrg ;; "a" "A constant call global and noplt address." 24 1.1 mrg ;; "b" <-----unused 25 1.1 mrg ;; "c" "A constant call local address." 26 1.1 mrg ;; "d" <-----unused 27 1.1 mrg ;; "e" JIRL_REGS 28 1.1 mrg ;; "f" FP_REGS 29 1.1 mrg ;; "g" <-----unused 30 1.1 mrg ;; "h" "A constant call plt address." 31 1.1 mrg ;; "i" "Matches a general integer constant." (Global non-architectural) 32 1.1 mrg ;; "j" SIBCALL_REGS 33 1.1 mrg ;; "k" "A memory operand whose address is formed by a base register and 34 1.1 mrg ;; (optionally scaled) index register." 35 1.1 mrg ;; "l" "A signed 16-bit constant." 36 1.1 mrg ;; "m" "A memory operand whose address is formed by a base register and offset 37 1.1 mrg ;; that is suitable for use in instructions with the same addressing mode 38 1.1 mrg ;; as @code{st.w} and @code{ld.w}." 39 1.1 mrg ;; "n" "Matches a non-symbolic integer constant." (Global non-architectural) 40 1.1 mrg ;; "o" "Matches an offsettable memory reference." (Global non-architectural) 41 1.1 mrg ;; "p" "Matches a general address." (Global non-architectural) 42 1.1 mrg ;; "q" CSR_REGS 43 1.1 mrg ;; "r" GENERAL_REGS (Global non-architectural) 44 1.1 mrg ;; "s" "Matches a symbolic integer constant." (Global non-architectural) 45 1.1 mrg ;; "t" "A constant call weak address" 46 1.1 mrg ;; "u" "A signed 52bit constant and low 32-bit is zero (for logic instructions)" 47 1.1 mrg ;; "v" "A signed 64-bit constant and low 44-bit is zero (for logic instructions)." 48 1.1 mrg ;; "w" "Matches any valid memory." 49 1.1 mrg ;; "x" <-----unused 50 1.1 mrg ;; "y" <-----unused 51 1.1 mrg ;; "z" FCC_REGS 52 1.1 mrg ;; "A" <-----unused 53 1.1 mrg ;; "B" <-----unused 54 1.1 mrg ;; "C" <-----unused 55 1.1 mrg ;; "D" <-----unused 56 1.1 mrg ;; "E" "Matches a floating-point constant." (Global non-architectural) 57 1.1 mrg ;; "F" "Matches a floating-point constant." (Global non-architectural) 58 1.1 mrg ;; "G" "Floating-point zero." 59 1.1 mrg ;; "H" <-----unused 60 1.1 mrg ;; "I" "A signed 12-bit constant (for arithmetic instructions)." 61 1.1 mrg ;; "J" "Integer zero." 62 1.1 mrg ;; "K" "An unsigned 12-bit constant (for logic instructions)." 63 1.1 mrg ;; "L" <-----unused 64 1.1 mrg ;; "M" <-----unused 65 1.1 mrg ;; "N" <-----unused 66 1.1 mrg ;; "O" <-----unused 67 1.1 mrg ;; "P" <-----unused 68 1.1 mrg ;; "Q" <-----unused 69 1.1 mrg ;; "R" <-----unused 70 1.1 mrg ;; "S" <-----unused 71 1.1 mrg ;; "T" <-----unused 72 1.1 mrg ;; "U" <-----unused 73 1.1 mrg ;; "V" "Matches a non-offsettable memory reference." (Global non-architectural) 74 1.1 mrg ;; "W" <-----unused 75 1.1 mrg ;; "X" "Matches anything." (Global non-architectural) 76 1.1 mrg ;; "Y" - 77 1.1 mrg ;; "Yd" 78 1.1 mrg ;; "A constant @code{move_operand} that can be safely loaded using 79 1.1 mrg ;; @code{la}." 80 1.1 mrg ;; "Yx" 81 1.1 mrg ;; "Z" - 82 1.1 mrg ;; "ZC" 83 1.1 mrg ;; "A memory operand whose address is formed by a base register and offset 84 1.1 mrg ;; that is suitable for use in instructions with the same addressing mode 85 1.1 mrg ;; as @code{ll.w} and @code{sc.w}." 86 1.1 mrg ;; "ZB" 87 1.1 mrg ;; "An address that is held in a general-purpose register. 88 1.1 mrg ;; The offset is zero" 89 1.1 mrg ;; "<" "Matches a pre-dec or post-dec operand." (Global non-architectural) 90 1.1 mrg ;; ">" "Matches a pre-inc or post-inc operand." (Global non-architectural) 91 1.1 mrg 92 1.1 mrg (define_constraint "a" 93 1.1 mrg "@internal 94 1.1 mrg A constant call global and noplt address." 95 1.1 mrg (match_operand 0 "is_const_call_global_noplt_symbol")) 96 1.1 mrg 97 1.1 mrg (define_constraint "c" 98 1.1 mrg "@internal 99 1.1 mrg A constant call local address." 100 1.1 mrg (match_operand 0 "is_const_call_local_symbol")) 101 1.1 mrg 102 1.1 mrg (define_register_constraint "e" "JIRL_REGS" 103 1.1 mrg "@internal") 104 1.1 mrg 105 1.1 mrg (define_register_constraint "f" "TARGET_HARD_FLOAT ? FP_REGS : NO_REGS" 106 1.1 mrg "A floating-point register (if available).") 107 1.1 mrg 108 1.1 mrg (define_constraint "h" 109 1.1 mrg "@internal 110 1.1 mrg A constant call plt address." 111 1.1 mrg (match_operand 0 "is_const_call_plt_symbol")) 112 1.1 mrg 113 1.1 mrg (define_register_constraint "j" "SIBCALL_REGS" 114 1.1 mrg "@internal") 115 1.1 mrg 116 1.1 mrg (define_memory_constraint "k" 117 1.1 mrg "A memory operand whose address is formed by a base register and (optionally scaled) 118 1.1 mrg index register." 119 1.1 mrg (and (match_code "mem") 120 1.1 mrg (match_test "loongarch_base_index_address_p (XEXP (op, 0), mode)"))) 121 1.1 mrg 122 1.1 mrg (define_constraint "l" 123 1.1 mrg "A signed 16-bit constant." 124 1.1 mrg (and (match_code "const_int") 125 1.1 mrg (match_test "IMM16_OPERAND (ival)"))) 126 1.1 mrg 127 1.1 mrg (define_memory_constraint "m" 128 1.1 mrg "A memory operand whose address is formed by a base register and offset 129 1.1 mrg that is suitable for use in instructions with the same addressing mode 130 1.1 mrg as @code{st.w} and @code{ld.w}." 131 1.1 mrg (and (match_code "mem") 132 1.1 mrg (match_test "loongarch_12bit_offset_address_p (XEXP (op, 0), mode)"))) 133 1.1 mrg 134 1.1 mrg (define_register_constraint "q" "CSR_REGS" 135 1.1 mrg "A general-purpose register except for $r0 and $r1 for lcsr.") 136 1.1 mrg 137 1.1 mrg (define_constraint "t" 138 1.1 mrg "@internal 139 1.1 mrg A constant call weak address." 140 1.1 mrg (match_operand 0 "is_const_call_weak_symbol")) 141 1.1 mrg 142 1.1 mrg (define_constraint "u" 143 1.1 mrg "A signed 52bit constant and low 32-bit is zero (for logic instructions)." 144 1.1 mrg (and (match_code "const_int") 145 1.1 mrg (match_test "LU32I_OPERAND (ival)"))) 146 1.1 mrg 147 1.1 mrg (define_constraint "v" 148 1.1 mrg "A signed 64-bit constant and low 44-bit is zero (for logic instructions)." 149 1.1 mrg (and (match_code "const_int") 150 1.1 mrg (match_test "LU52I_OPERAND (ival)"))) 151 1.1 mrg 152 1.1 mrg (define_register_constraint "z" "FCC_REGS" 153 1.1 mrg "A floating-point condition code register.") 154 1.1 mrg 155 1.1 mrg ;; Floating-point constraints 156 1.1 mrg 157 1.1 mrg (define_constraint "G" 158 1.1 mrg "Floating-point zero." 159 1.1 mrg (and (match_code "const_double") 160 1.1 mrg (match_test "op == CONST0_RTX (mode)"))) 161 1.1 mrg 162 1.1 mrg ;; Integer constraints 163 1.1 mrg 164 1.1 mrg (define_constraint "I" 165 1.1 mrg "A signed 12-bit constant (for arithmetic instructions)." 166 1.1 mrg (and (match_code "const_int") 167 1.1 mrg (match_test "IMM12_OPERAND (ival)"))) 168 1.1 mrg 169 1.1 mrg (define_constraint "J" 170 1.1 mrg "Integer zero." 171 1.1 mrg (and (match_code "const_int") 172 1.1 mrg (match_test "ival == 0"))) 173 1.1 mrg 174 1.1 mrg (define_constraint "K" 175 1.1 mrg "An unsigned 12-bit constant (for logic instructions)." 176 1.1 mrg (and (match_code "const_int") 177 1.1 mrg (match_test "IMM12_OPERAND_UNSIGNED (ival)"))) 178 1.1 mrg 179 1.1 mrg (define_constraint "Yd" 180 1.1 mrg "@internal 181 1.1 mrg A constant @code{move_operand} that can be safely loaded using 182 1.1 mrg @code{la}." 183 1.1 mrg (and (match_operand 0 "move_operand") 184 1.1 mrg (match_test "CONSTANT_P (op)"))) 185 1.1 mrg 186 1.1 mrg (define_constraint "Yx" 187 1.1 mrg "@internal" 188 1.1 mrg (match_operand 0 "low_bitmask_operand")) 189 1.1 mrg 190 1.1 mrg (define_memory_constraint "ZC" 191 1.1 mrg "A memory operand whose address is formed by a base register and offset 192 1.1 mrg that is suitable for use in instructions with the same addressing mode 193 1.1 mrg as @code{ll.w} and @code{sc.w}." 194 1.1 mrg (and (match_code "mem") 195 1.1 mrg (match_test "loongarch_14bit_shifted_offset_address_p (XEXP (op, 0), mode)"))) 196 1.1 mrg 197 1.1 mrg (define_memory_constraint "ZB" 198 1.1 mrg "@internal 199 1.1 mrg An address that is held in a general-purpose register. 200 1.1 mrg The offset is zero" 201 1.1 mrg (and (match_code "mem") 202 1.1 mrg (match_test "REG_P (XEXP (op, 0))"))) 203