| 1 |
;; Machine description for NVPTX. |
| 2 |
;; Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 3 |
;; Contributed by Bernd Schmidt <[email protected]> |
| 4 |
;; |
| 5 |
;; This file is part of GCC. |
| 6 |
;; |
| 7 |
;; GCC is free software; you can redistribute it and/or modify |
| 8 |
;; it under the terms of the GNU General Public License as published by |
| 9 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 10 |
;; any later version. |
| 11 |
;; |
| 12 |
;; GCC is distributed in the hope that it will be useful, |
| 13 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
;; GNU General Public License for more details. |
| 16 |
;; |
| 17 |
;; You should have received a copy of the GNU General Public License |
| 18 |
;; along with GCC; see the file COPYING3. If not see |
| 19 |
;; <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
(define_c_enum "unspec" [ |
| 22 |
UNSPEC_ARG_REG |
| 23 |
|
| 24 |
UNSPEC_COPYSIGN |
| 25 |
UNSPEC_LOG2 |
| 26 |
UNSPEC_EXP2 |
| 27 |
UNSPEC_SIN |
| 28 |
UNSPEC_COS |
| 29 |
UNSPEC_TANH |
| 30 |
UNSPEC_ISINF |
| 31 |
|
| 32 |
UNSPEC_FPINT_FLOOR |
| 33 |
UNSPEC_FPINT_BTRUNC |
| 34 |
UNSPEC_FPINT_CEIL |
| 35 |
UNSPEC_FPINT_NEARBYINT |
| 36 |
|
| 37 |
UNSPEC_ALLOCA |
| 38 |
UNSPEC_SET_SOFTSTACK |
| 39 |
UNSPEC_STACKSAVE |
| 40 |
UNSPEC_STACKRESTORE |
| 41 |
|
| 42 |
UNSPEC_DIM_SIZE |
| 43 |
|
| 44 |
UNSPEC_BIT_CONV |
| 45 |
|
| 46 |
UNSPEC_VOTE_BALLOT |
| 47 |
|
| 48 |
UNSPEC_LANEID |
| 49 |
|
| 50 |
UNSPEC_SHUFFLE |
| 51 |
UNSPEC_BR_UNIFIED |
| 52 |
]) |
| 53 |
|
| 54 |
(define_c_enum "unspecv" [ |
| 55 |
UNSPECV_LOCK |
| 56 |
UNSPECV_CAS |
| 57 |
UNSPECV_CAS_LOCAL |
| 58 |
UNSPECV_XCHG |
| 59 |
UNSPECV_ST |
| 60 |
UNSPECV_BARRED_AND |
| 61 |
UNSPECV_BARRED_OR |
| 62 |
UNSPECV_BARRED_POPC |
| 63 |
UNSPECV_BARSYNC |
| 64 |
UNSPECV_WARPSYNC |
| 65 |
UNSPECV_UNIFORM_WARP_CHECK |
| 66 |
UNSPECV_MEMBAR |
| 67 |
UNSPECV_MEMBAR_CTA |
| 68 |
UNSPECV_MEMBAR_GL |
| 69 |
UNSPECV_DIM_POS |
| 70 |
|
| 71 |
UNSPECV_FORK |
| 72 |
UNSPECV_FORKED |
| 73 |
UNSPECV_JOINING |
| 74 |
UNSPECV_JOIN |
| 75 |
|
| 76 |
UNSPECV_NOUNROLL |
| 77 |
|
| 78 |
UNSPECV_SIMT_ENTER |
| 79 |
UNSPECV_SIMT_EXIT |
| 80 |
|
| 81 |
UNSPECV_RED_PART |
| 82 |
]) |
| 83 |
|
| 84 |
(define_attr "subregs_ok" "false,true" |
| 85 |
(const_string "false")) |
| 86 |
|
| 87 |
(define_attr "atomic" "false,true" |
| 88 |
(const_string "false")) |
| 89 |
|
| 90 |
;; The nvptx operand predicates, in general, don't permit subregs and |
| 91 |
;; only literal constants, which differ from the generic ones, which |
| 92 |
;; permit subregs and symbolc constants (as appropriate) |
| 93 |
(define_predicate "nvptx_register_operand" |
| 94 |
(match_code "reg") |
| 95 |
{ |
| 96 |
return register_operand (op, mode); |
| 97 |
}) |
| 98 |
|
| 99 |
(define_predicate "nvptx_register_or_complex_di_df_register_operand" |
| 100 |
(ior (match_code "reg") |
| 101 |
(match_code "concat")) |
| 102 |
{ |
| 103 |
if (GET_CODE (op) == CONCAT) |
| 104 |
return ((GET_MODE (op) == DCmode || GET_MODE (op) == CDImode) |
| 105 |
&& nvptx_register_operand (XEXP (op, 0), mode) |
| 106 |
&& nvptx_register_operand (XEXP (op, 1), mode)); |
| 107 |
|
| 108 |
return nvptx_register_operand (op, mode); |
| 109 |
}) |
| 110 |
|
| 111 |
(define_predicate "nvptx_nonimmediate_operand" |
| 112 |
(match_code "mem,reg") |
| 113 |
{ |
| 114 |
return (REG_P (op) ? register_operand (op, mode) |
| 115 |
: memory_operand (op, mode)); |
| 116 |
}) |
| 117 |
|
| 118 |
(define_predicate "nvptx_nonmemory_operand" |
| 119 |
(match_code "reg,const_int,const_double") |
| 120 |
{ |
| 121 |
return (REG_P (op) ? register_operand (op, mode) |
| 122 |
: immediate_operand (op, mode)); |
| 123 |
}) |
| 124 |
|
| 125 |
(define_predicate "const0_operand" |
| 126 |
(and (match_code "const_int") |
| 127 |
(match_test "op == const0_rtx"))) |
| 128 |
|
| 129 |
;; True if this operator is valid for predication. |
| 130 |
(define_predicate "predicate_operator" |
| 131 |
(match_code "eq,ne")) |
| 132 |
|
| 133 |
(define_predicate "ne_operator" |
| 134 |
(match_code "ne")) |
| 135 |
|
| 136 |
(define_predicate "nvptx_comparison_operator" |
| 137 |
(match_code "eq,ne,le,ge,lt,gt,leu,geu,ltu,gtu")) |
| 138 |
|
| 139 |
(define_predicate "nvptx_float_comparison_operator" |
| 140 |
(match_code "eq,ne,le,ge,lt,gt,uneq,unle,unge,unlt,ungt,unordered,ordered")) |
| 141 |
|
| 142 |
(define_predicate "nvptx_vector_index_operand" |
| 143 |
(and (match_code "const_int") |
| 144 |
(match_test "UINTVAL (op) < 4"))) |
| 145 |
|
| 146 |
;; Test for a valid operand for a call instruction. |
| 147 |
(define_predicate "call_insn_operand" |
| 148 |
(match_code "symbol_ref,reg") |
| 149 |
{ |
| 150 |
return REG_P (op) || SYMBOL_REF_FUNCTION_P (op); |
| 151 |
}) |
| 152 |
|
| 153 |
;; Return true if OP is a call with parallel USEs of the argument |
| 154 |
;; pseudos. |
| 155 |
(define_predicate "call_operation" |
| 156 |
(match_code "parallel") |
| 157 |
{ |
| 158 |
int arg_end = XVECLEN (op, 0); |
| 159 |
|
| 160 |
for (int i = 1; i < arg_end; i++) |
| 161 |
{ |
| 162 |
rtx elt = XVECEXP (op, 0, i); |
| 163 |
|
| 164 |
if (GET_CODE (elt) != USE || !REG_P (XEXP (elt, 0))) |
| 165 |
return false; |
| 166 |
} |
| 167 |
return true; |
| 168 |
}) |
| 169 |
|
| 170 |
;; Test for a function symbol ref operand |
| 171 |
(define_predicate "symbol_ref_function_operand" |
| 172 |
(match_code "symbol_ref") |
| 173 |
{ |
| 174 |
return SYMBOL_REF_FUNCTION_P (op); |
| 175 |
}) |
| 176 |
|
| 177 |
(define_attr "predicable" "no,yes" |
| 178 |
(const_string "yes")) |
| 179 |
|
| 180 |
(define_cond_exec |
| 181 |
[(match_operator 0 "predicate_operator" |
| 182 |
[(match_operand:BI 1 "nvptx_register_operand" "") |
| 183 |
(match_operand:BI 2 "const0_operand" "")])] |
| 184 |
"" |
| 185 |
"" |
| 186 |
) |
| 187 |
|
| 188 |
(define_constraint "P0" |
| 189 |
"An integer with the value 0." |
| 190 |
(and (match_code "const_int") |
| 191 |
(match_test "ival == 0"))) |
| 192 |
|
| 193 |
(define_constraint "P1" |
| 194 |
"An integer with the value 1." |
| 195 |
(and (match_code "const_int") |
| 196 |
(match_test "ival == 1"))) |
| 197 |
|
| 198 |
(define_constraint "Pn" |
| 199 |
"An integer with the value -1." |
| 200 |
(and (match_code "const_int") |
| 201 |
(match_test "ival == -1"))) |
| 202 |
|
| 203 |
(define_constraint "R" |
| 204 |
"A pseudo register." |
| 205 |
(match_code "reg")) |
| 206 |
|
| 207 |
(define_constraint "Ia" |
| 208 |
"Any integer constant." |
| 209 |
(and (match_code "const_int") (match_test "true"))) |
| 210 |
|
| 211 |
(define_mode_iterator QHSDISDFM [QI HI SI DI SF DF]) |
| 212 |
(define_mode_iterator QHSDIM [QI HI SI DI]) |
| 213 |
(define_mode_iterator HSDIM [HI SI DI]) |
| 214 |
(define_mode_iterator BHSDIM [BI HI SI DI]) |
| 215 |
(define_mode_iterator SDIM [SI DI]) |
| 216 |
(define_mode_iterator SDISDFM [SI DI SF DF]) |
| 217 |
(define_mode_iterator QHIM [QI HI]) |
| 218 |
(define_mode_iterator QHSIM [QI HI SI]) |
| 219 |
(define_mode_iterator SDFM [SF DF]) |
| 220 |
(define_mode_iterator HSFM [HF SF]) |
| 221 |
(define_mode_iterator SDCM [SC DC]) |
| 222 |
(define_mode_iterator BITS [SI SF]) |
| 223 |
(define_mode_iterator BITD [DI DF]) |
| 224 |
(define_mode_iterator VECIM [V2SI V2DI]) |
| 225 |
|
| 226 |
;; This mode iterator allows :P to be used for patterns that operate on |
| 227 |
;; pointer-sized quantities. Exactly one of the two alternatives will match. |
| 228 |
(define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")]) |
| 229 |
|
| 230 |
;; Define element mode for each vector mode. |
| 231 |
(define_mode_attr VECELEM [(V2SI "SI") (V2DI "DI")]) |
| 232 |
(define_mode_attr Vecelem [(V2SI "si") (V2DI "di")]) |
| 233 |
|
| 234 |
;; We should get away with not defining memory alternatives, since we don't |
| 235 |
;; get variables in this mode and pseudos are never spilled. |
| 236 |
(define_insn "movbi" |
| 237 |
[(set (match_operand:BI 0 "nvptx_register_operand" "=R,R,R") |
| 238 |
(match_operand:BI 1 "nvptx_nonmemory_operand" "R,P0,P1"))] |
| 239 |
"" |
| 240 |
"@ |
| 241 |
%.\\tmov%t0\\t%0, %1; |
| 242 |
%.\\tsetp.eq.u32\\t%0, 1, 0; |
| 243 |
%.\\tsetp.eq.u32\\t%0, 1, 1;") |
| 244 |
|
| 245 |
(define_insn "*mov<mode>_insn" |
| 246 |
[(set (match_operand:VECIM 0 "nonimmediate_operand" "=R,R,m") |
| 247 |
(match_operand:VECIM 1 "general_operand" "Ri,m,R"))] |
| 248 |
"!MEM_P (operands[0]) || REG_P (operands[1])" |
| 249 |
{ |
| 250 |
if (which_alternative == 1) |
| 251 |
return "%.\\tld%A1%u1\\t%0, %1;"; |
| 252 |
if (which_alternative == 2) |
| 253 |
return "%.\\tst%A0%u0\\t%0, %1;"; |
| 254 |
|
| 255 |
return nvptx_output_mov_insn (operands[0], operands[1]); |
| 256 |
} |
| 257 |
[(set_attr "subregs_ok" "true")]) |
| 258 |
|
| 259 |
(define_insn "*mov<mode>_insn" |
| 260 |
[(set (match_operand:QHSDIM 0 "nonimmediate_operand" "=R,R,m") |
| 261 |
(match_operand:QHSDIM 1 "general_operand" "Ri,m,R"))] |
| 262 |
"!MEM_P (operands[0]) || REG_P (operands[1])" |
| 263 |
{ |
| 264 |
if (which_alternative == 1) |
| 265 |
return "%.\\tld%A1%u1\\t%0, %1;"; |
| 266 |
if (which_alternative == 2) |
| 267 |
return "%.\\tst%A0%u0\\t%0, %1;"; |
| 268 |
|
| 269 |
return nvptx_output_mov_insn (operands[0], operands[1]); |
| 270 |
} |
| 271 |
[(set_attr "subregs_ok" "true")]) |
| 272 |
|
| 273 |
;; ptxas segfaults on 'mov.u64 %r24,bar+4096', so break it up. |
| 274 |
(define_split |
| 275 |
[(set (match_operand:DI 0 "nvptx_register_operand") |
| 276 |
(const:DI (plus:DI (match_operand:DI 1 "symbol_ref_function_operand") |
| 277 |
(match_operand 2 "const_int_operand"))))] |
| 278 |
"" |
| 279 |
[(set (match_dup 0) (match_dup 1)) |
| 280 |
(set (match_dup 0) (plus:DI (match_dup 0) (match_dup 2))) |
| 281 |
] |
| 282 |
"") |
| 283 |
|
| 284 |
(define_insn "*mov<mode>_insn" |
| 285 |
[(set (match_operand:SDFM 0 "nonimmediate_operand" "=R,R,m") |
| 286 |
(match_operand:SDFM 1 "general_operand" "RF,m,R"))] |
| 287 |
"!MEM_P (operands[0]) || REG_P (operands[1])" |
| 288 |
{ |
| 289 |
if (which_alternative == 1) |
| 290 |
return "%.\\tld%A1%u0\\t%0, %1;"; |
| 291 |
if (which_alternative == 2) |
| 292 |
return "%.\\tst%A0%u1\\t%0, %1;"; |
| 293 |
|
| 294 |
return nvptx_output_mov_insn (operands[0], operands[1]); |
| 295 |
} |
| 296 |
[(set_attr "subregs_ok" "true")]) |
| 297 |
|
| 298 |
(define_insn "*movhf_insn" |
| 299 |
[(set (match_operand:HF 0 "nonimmediate_operand" "=R,R,m") |
| 300 |
(match_operand:HF 1 "nonimmediate_operand" "R,m,R"))] |
| 301 |
"!MEM_P (operands[0]) || REG_P (operands[1])" |
| 302 |
"@ |
| 303 |
%.\\tmov.b16\\t%0, %1; |
| 304 |
%.\\tld.b16\\t%0, %1; |
| 305 |
%.\\tst.b16\\t%0, %1;" |
| 306 |
[(set_attr "subregs_ok" "true")]) |
| 307 |
|
| 308 |
(define_expand "movhf" |
| 309 |
[(set (match_operand:HF 0 "nonimmediate_operand" "") |
| 310 |
(match_operand:HF 1 "nonimmediate_operand" ""))] |
| 311 |
"" |
| 312 |
{ |
| 313 |
/* Load HFmode constants as SFmode with an explicit FLOAT_TRUNCATE. */ |
| 314 |
if (CONST_DOUBLE_P (operands[1])) |
| 315 |
{ |
| 316 |
rtx tmp1 = gen_reg_rtx (SFmode); |
| 317 |
REAL_VALUE_TYPE d = *CONST_DOUBLE_REAL_VALUE (operands[1]); |
| 318 |
real_convert (&d, SFmode, &d); |
| 319 |
emit_move_insn (tmp1, const_double_from_real_value (d, SFmode)); |
| 320 |
|
| 321 |
if (!REG_P (operands[0])) |
| 322 |
{ |
| 323 |
rtx tmp2 = gen_reg_rtx (HFmode); |
| 324 |
emit_insn (gen_truncsfhf2 (tmp2, tmp1)); |
| 325 |
emit_move_insn (operands[0], tmp2); |
| 326 |
} |
| 327 |
else |
| 328 |
emit_insn (gen_truncsfhf2 (operands[0], tmp1)); |
| 329 |
DONE; |
| 330 |
} |
| 331 |
|
| 332 |
if (MEM_P (operands[0]) && !REG_P (operands[1])) |
| 333 |
{ |
| 334 |
rtx tmp = gen_reg_rtx (HFmode); |
| 335 |
emit_move_insn (tmp, operands[1]); |
| 336 |
emit_move_insn (operands[0], tmp); |
| 337 |
DONE; |
| 338 |
} |
| 339 |
}) |
| 340 |
|
| 341 |
(define_insn "load_arg_reg<mode>" |
| 342 |
[(set (match_operand:QHIM 0 "nvptx_register_operand" "=R") |
| 343 |
(unspec:QHIM [(match_operand 1 "const_int_operand" "n")] |
| 344 |
UNSPEC_ARG_REG))] |
| 345 |
"" |
| 346 |
"%.\\tcvt%t0.u32\\t%0, %%ar%1;") |
| 347 |
|
| 348 |
(define_insn "load_arg_reg<mode>" |
| 349 |
[(set (match_operand:SDISDFM 0 "nvptx_register_operand" "=R") |
| 350 |
(unspec:SDISDFM [(match_operand 1 "const_int_operand" "n")] |
| 351 |
UNSPEC_ARG_REG))] |
| 352 |
"" |
| 353 |
"%.\\tmov%t0\\t%0, %%ar%1;") |
| 354 |
|
| 355 |
(define_expand "mov<mode>" |
| 356 |
[(set (match_operand:VECIM 0 "nonimmediate_operand" "") |
| 357 |
(match_operand:VECIM 1 "general_operand" ""))] |
| 358 |
"" |
| 359 |
{ |
| 360 |
if (MEM_P (operands[0]) && !REG_P (operands[1])) |
| 361 |
{ |
| 362 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 363 |
emit_move_insn (tmp, operands[1]); |
| 364 |
emit_move_insn (operands[0], tmp); |
| 365 |
DONE; |
| 366 |
} |
| 367 |
}) |
| 368 |
|
| 369 |
(define_expand "mov<mode>" |
| 370 |
[(set (match_operand:QHSDISDFM 0 "nonimmediate_operand" "") |
| 371 |
(match_operand:QHSDISDFM 1 "general_operand" ""))] |
| 372 |
"" |
| 373 |
{ |
| 374 |
if (MEM_P (operands[0]) && !REG_P (operands[1])) |
| 375 |
{ |
| 376 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 377 |
emit_move_insn (tmp, operands[1]); |
| 378 |
emit_move_insn (operands[0], tmp); |
| 379 |
DONE; |
| 380 |
} |
| 381 |
|
| 382 |
if (GET_CODE (operands[1]) == LABEL_REF) |
| 383 |
sorry ("target cannot support label values"); |
| 384 |
}) |
| 385 |
|
| 386 |
(define_insn "zero_extendqihi2" |
| 387 |
[(set (match_operand:HI 0 "nvptx_register_operand" "=R,R") |
| 388 |
(zero_extend:HI (match_operand:QI 1 "nvptx_nonimmediate_operand" "R,m")))] |
| 389 |
"" |
| 390 |
"@ |
| 391 |
%.\\tcvt.u16.u%T1\\t%0, %1; |
| 392 |
%.\\tld%A1.u8\\t%0, %1;" |
| 393 |
[(set_attr "subregs_ok" "true")]) |
| 394 |
|
| 395 |
(define_insn "zero_extend<mode>si2" |
| 396 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R,R") |
| 397 |
(zero_extend:SI (match_operand:QHIM 1 "nvptx_nonimmediate_operand" "R,m")))] |
| 398 |
"" |
| 399 |
"@ |
| 400 |
%.\\tcvt.u32.u%T1\\t%0, %1; |
| 401 |
%.\\tld%A1.u%T1\\t%0, %1;" |
| 402 |
[(set_attr "subregs_ok" "true")]) |
| 403 |
|
| 404 |
(define_insn "zero_extend<mode>di2" |
| 405 |
[(set (match_operand:DI 0 "nvptx_register_operand" "=R,R") |
| 406 |
(zero_extend:DI (match_operand:QHSIM 1 "nvptx_nonimmediate_operand" "R,m")))] |
| 407 |
"" |
| 408 |
"@ |
| 409 |
%.\\tcvt.u64.u%T1\\t%0, %1; |
| 410 |
%.\\tld%A1%u1\\t%0, %1;" |
| 411 |
[(set_attr "subregs_ok" "true")]) |
| 412 |
|
| 413 |
(define_insn "extendqihi2" |
| 414 |
[(set (match_operand:HI 0 "nvptx_register_operand" "=R") |
| 415 |
(sign_extend:HI (match_operand:QI 1 "nvptx_register_operand" "R")))] |
| 416 |
"" |
| 417 |
"%.\\tcvt.s16.s8\\t%0, %1;" |
| 418 |
[(set_attr "subregs_ok" "true")]) |
| 419 |
|
| 420 |
(define_insn "extend<mode>si2" |
| 421 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R,R") |
| 422 |
(sign_extend:SI (match_operand:QHIM 1 "nvptx_nonimmediate_operand" "R,m")))] |
| 423 |
"" |
| 424 |
"@ |
| 425 |
%.\\tcvt.s32.s%T1\\t%0, %1; |
| 426 |
%.\\tld%A1.s%T1\\t%0, %1;" |
| 427 |
[(set_attr "subregs_ok" "true")]) |
| 428 |
|
| 429 |
(define_insn "extend<mode>di2" |
| 430 |
[(set (match_operand:DI 0 "nvptx_register_operand" "=R,R") |
| 431 |
(sign_extend:DI (match_operand:QHSIM 1 "nvptx_nonimmediate_operand" "R,m")))] |
| 432 |
"" |
| 433 |
"@ |
| 434 |
%.\\tcvt.s64.s%T1\\t%0, %1; |
| 435 |
%.\\tld%A1.s%T1\\t%0, %1;" |
| 436 |
[(set_attr "subregs_ok" "true")]) |
| 437 |
|
| 438 |
(define_insn "trunchiqi2" |
| 439 |
[(set (match_operand:QI 0 "nvptx_nonimmediate_operand" "=R,m") |
| 440 |
(truncate:QI (match_operand:HI 1 "nvptx_register_operand" "R,R")))] |
| 441 |
"" |
| 442 |
"@ |
| 443 |
%.\\tcvt%t0.u16\\t%0, %1; |
| 444 |
%.\\tst%A0.u8\\t%0, %1;" |
| 445 |
[(set_attr "subregs_ok" "true")]) |
| 446 |
|
| 447 |
(define_insn "truncsi<mode>2" |
| 448 |
[(set (match_operand:QHIM 0 "nvptx_nonimmediate_operand" "=R,m") |
| 449 |
(truncate:QHIM (match_operand:SI 1 "nvptx_register_operand" "R,R")))] |
| 450 |
"" |
| 451 |
{ |
| 452 |
if (which_alternative == 1) |
| 453 |
return "%.\\tst%A0.u%T0\\t%0, %1;"; |
| 454 |
if (GET_MODE (operands[0]) == QImode) |
| 455 |
return "%.\\tmov%t0\\t%0, %1;"; |
| 456 |
return "%.\\tcvt%t0.u32\\t%0, %1;"; |
| 457 |
} |
| 458 |
[(set_attr "subregs_ok" "true")]) |
| 459 |
|
| 460 |
(define_insn "truncdi<mode>2" |
| 461 |
[(set (match_operand:QHSIM 0 "nvptx_nonimmediate_operand" "=R,m") |
| 462 |
(truncate:QHSIM (match_operand:DI 1 "nvptx_register_operand" "R,R")))] |
| 463 |
"" |
| 464 |
"@ |
| 465 |
%.\\tcvt%t0.u64\\t%0, %1; |
| 466 |
%.\\tst%A0.u%T0\\t%0, %1;" |
| 467 |
[(set_attr "subregs_ok" "true")]) |
| 468 |
|
| 469 |
;; Sign-extensions of truncations |
| 470 |
|
| 471 |
(define_insn "*extend_trunc_<mode>2_qi" |
| 472 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 473 |
(sign_extend:HSDIM |
| 474 |
(truncate:QI (match_operand:HSDIM 1 "nvptx_register_operand" "R"))))] |
| 475 |
"" |
| 476 |
"%.\\tcvt.s%T0.s8\\t%0, %1;" |
| 477 |
[(set_attr "subregs_ok" "true")]) |
| 478 |
|
| 479 |
(define_insn "*extend_trunc_<mode>2_hi" |
| 480 |
[(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") |
| 481 |
(sign_extend:SDIM |
| 482 |
(truncate:HI (match_operand:SDIM 1 "nvptx_register_operand" "R"))))] |
| 483 |
"" |
| 484 |
"%.\\tcvt.s%T0.s16\\t%0, %1;" |
| 485 |
[(set_attr "subregs_ok" "true")]) |
| 486 |
|
| 487 |
(define_insn "*extend_trunc_di2_si" |
| 488 |
[(set (match_operand:DI 0 "nvptx_register_operand" "=R") |
| 489 |
(sign_extend:DI |
| 490 |
(truncate:SI (match_operand:DI 1 "nvptx_register_operand" "R"))))] |
| 491 |
"" |
| 492 |
"%.\\tcvt.s64.s32\\t%0, %1;" |
| 493 |
[(set_attr "subregs_ok" "true")]) |
| 494 |
|
| 495 |
;; Integer arithmetic |
| 496 |
|
| 497 |
(define_insn "add<mode>3" |
| 498 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 499 |
(plus:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 500 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 501 |
"" |
| 502 |
"%.\\tadd%t0\\t%0, %1, %2;") |
| 503 |
|
| 504 |
(define_insn "*vadd_addsi4" |
| 505 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 506 |
(plus:SI (plus:SI (match_operand:SI 1 "nvptx_register_operand" "R") |
| 507 |
(match_operand:SI 2 "nvptx_register_operand" "R")) |
| 508 |
(match_operand:SI 3 "nvptx_register_operand" "R")))] |
| 509 |
"" |
| 510 |
"%.\\tvadd%t0%t1%t2.add\\t%0, %1, %2, %3;") |
| 511 |
|
| 512 |
(define_insn "*vsub_addsi4" |
| 513 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 514 |
(plus:SI (minus:SI (match_operand:SI 1 "nvptx_register_operand" "R") |
| 515 |
(match_operand:SI 2 "nvptx_register_operand" "R")) |
| 516 |
(match_operand:SI 3 "nvptx_register_operand" "R")))] |
| 517 |
"" |
| 518 |
"%.\\tvsub%t0%t1%t2.add\\t%0, %1, %2, %3;") |
| 519 |
|
| 520 |
(define_insn "sub<mode>3" |
| 521 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 522 |
(minus:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 523 |
(match_operand:HSDIM 2 "nvptx_register_operand" "R")))] |
| 524 |
"" |
| 525 |
{ |
| 526 |
if (GET_MODE (operands[0]) == HImode) |
| 527 |
/* Workaround https://developer.nvidia.com/nvidia_bug/3527713. |
| 528 |
See PR97005. */ |
| 529 |
return "%.\\tsub.s16\\t%0, %1, %2;"; |
| 530 |
|
| 531 |
return "%.\\tsub%t0\\t%0, %1, %2;"; |
| 532 |
}) |
| 533 |
|
| 534 |
(define_insn "mul<mode>3" |
| 535 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 536 |
(mult:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 537 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 538 |
"" |
| 539 |
"%.\\tmul.lo%t0\\t%0, %1, %2;") |
| 540 |
|
| 541 |
(define_insn "*mad<mode>3" |
| 542 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 543 |
(plus:HSDIM (mult:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 544 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")) |
| 545 |
(match_operand:HSDIM 3 "nvptx_nonmemory_operand" "Ri")))] |
| 546 |
"" |
| 547 |
"%.\\tmad.lo%t0\\t%0, %1, %2, %3;") |
| 548 |
|
| 549 |
(define_insn "div<mode>3" |
| 550 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 551 |
(div:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 552 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 553 |
"" |
| 554 |
"%.\\tdiv.s%T0\\t%0, %1, %2;") |
| 555 |
|
| 556 |
(define_insn "udiv<mode>3" |
| 557 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 558 |
(udiv:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 559 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 560 |
"" |
| 561 |
"%.\\tdiv.u%T0\\t%0, %1, %2;") |
| 562 |
|
| 563 |
(define_insn "mod<mode>3" |
| 564 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 565 |
(mod:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "Ri") |
| 566 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 567 |
"" |
| 568 |
"%.\\trem.s%T0\\t%0, %1, %2;") |
| 569 |
|
| 570 |
(define_insn "umod<mode>3" |
| 571 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 572 |
(umod:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "Ri") |
| 573 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 574 |
"" |
| 575 |
"%.\\trem.u%T0\\t%0, %1, %2;") |
| 576 |
|
| 577 |
(define_insn "smin<mode>3" |
| 578 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 579 |
(smin:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 580 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 581 |
"" |
| 582 |
"%.\\tmin.s%T0\\t%0, %1, %2;") |
| 583 |
|
| 584 |
(define_insn "umin<mode>3" |
| 585 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 586 |
(umin:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 587 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 588 |
"" |
| 589 |
"%.\\tmin.u%T0\\t%0, %1, %2;") |
| 590 |
|
| 591 |
(define_insn "smax<mode>3" |
| 592 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 593 |
(smax:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 594 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 595 |
"" |
| 596 |
"%.\\tmax.s%T0\\t%0, %1, %2;") |
| 597 |
|
| 598 |
(define_insn "umax<mode>3" |
| 599 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 600 |
(umax:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 601 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 602 |
"" |
| 603 |
"%.\\tmax.u%T0\\t%0, %1, %2;") |
| 604 |
|
| 605 |
(define_insn "abs<mode>2" |
| 606 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 607 |
(abs:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R")))] |
| 608 |
"" |
| 609 |
"%.\\tabs.s%T0\\t%0, %1;") |
| 610 |
|
| 611 |
(define_insn "neg<mode>2" |
| 612 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 613 |
(neg:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R")))] |
| 614 |
"" |
| 615 |
"%.\\tneg.s%T0\\t%0, %1;") |
| 616 |
|
| 617 |
(define_insn "one_cmpl<mode>2" |
| 618 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 619 |
(not:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R")))] |
| 620 |
"" |
| 621 |
"%.\\tnot.b%T0\\t%0, %1;") |
| 622 |
|
| 623 |
(define_insn "one_cmplbi2" |
| 624 |
[(set (match_operand:BI 0 "nvptx_register_operand" "=R") |
| 625 |
(not:BI (match_operand:BI 1 "nvptx_register_operand" "R")))] |
| 626 |
"" |
| 627 |
"%.\\tnot.pred\\t%0, %1;") |
| 628 |
|
| 629 |
(define_insn "*cnot<mode>2" |
| 630 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 631 |
(eq:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 632 |
(const_int 0)))] |
| 633 |
"" |
| 634 |
"%.\\tcnot.b%T0\\t%0, %1;") |
| 635 |
|
| 636 |
(define_insn "bitrev<mode>2" |
| 637 |
[(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") |
| 638 |
(bitreverse:SDIM (match_operand:SDIM 1 "nvptx_register_operand" "R")))] |
| 639 |
"" |
| 640 |
"%.\\tbrev.b%T0\\t%0, %1;") |
| 641 |
|
| 642 |
(define_insn "clz<mode>2" |
| 643 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 644 |
(clz:SI (match_operand:SDIM 1 "nvptx_register_operand" "R")))] |
| 645 |
"" |
| 646 |
"%.\\tclz.b%T1\\t%0, %1;") |
| 647 |
|
| 648 |
(define_expand "ctz<mode>2" |
| 649 |
[(set (match_operand:SI 0 "nvptx_register_operand" "") |
| 650 |
(ctz:SI (match_operand:SDIM 1 "nvptx_register_operand" "")))] |
| 651 |
"" |
| 652 |
{ |
| 653 |
rtx tmpreg = gen_reg_rtx (<MODE>mode); |
| 654 |
emit_insn (gen_bitrev<mode>2 (tmpreg, operands[1])); |
| 655 |
emit_insn (gen_clz<mode>2 (operands[0], tmpreg)); |
| 656 |
DONE; |
| 657 |
}) |
| 658 |
|
| 659 |
(define_insn "popcountsi2" |
| 660 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 661 |
(popcount:SI (match_operand:SI 1 "nvptx_register_operand" "R")))] |
| 662 |
"" |
| 663 |
"%.\\tpopc.b32\\t%0, %1;") |
| 664 |
|
| 665 |
(define_insn "popcountdi2" |
| 666 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 667 |
(truncate:SI |
| 668 |
(popcount:DI (match_operand:DI 1 "nvptx_register_operand" "R"))))] |
| 669 |
"" |
| 670 |
"%.\\tpopc.b64\\t%0, %1;") |
| 671 |
|
| 672 |
;; Multiplication variants |
| 673 |
|
| 674 |
(define_insn "mulhisi3" |
| 675 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 676 |
(mult:SI (sign_extend:SI |
| 677 |
(match_operand:HI 1 "nvptx_register_operand" "R")) |
| 678 |
(sign_extend:SI |
| 679 |
(match_operand:HI 2 "nvptx_register_operand" "R"))))] |
| 680 |
"" |
| 681 |
"%.\\tmul.wide.s16\\t%0, %1, %2;") |
| 682 |
|
| 683 |
(define_insn "mulsidi3" |
| 684 |
[(set (match_operand:DI 0 "nvptx_register_operand" "=R") |
| 685 |
(mult:DI (sign_extend:DI |
| 686 |
(match_operand:SI 1 "nvptx_register_operand" "R")) |
| 687 |
(sign_extend:DI |
| 688 |
(match_operand:SI 2 "nvptx_register_operand" "R"))))] |
| 689 |
"" |
| 690 |
"%.\\tmul.wide.s32\\t%0, %1, %2;") |
| 691 |
|
| 692 |
(define_insn "umulhisi3" |
| 693 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 694 |
(mult:SI (zero_extend:SI |
| 695 |
(match_operand:HI 1 "nvptx_register_operand" "R")) |
| 696 |
(zero_extend:SI |
| 697 |
(match_operand:HI 2 "nvptx_register_operand" "R"))))] |
| 698 |
"" |
| 699 |
"%.\\tmul.wide.u16\\t%0, %1, %2;") |
| 700 |
|
| 701 |
(define_insn "umulsidi3" |
| 702 |
[(set (match_operand:DI 0 "nvptx_register_operand" "=R") |
| 703 |
(mult:DI (zero_extend:DI |
| 704 |
(match_operand:SI 1 "nvptx_register_operand" "R")) |
| 705 |
(zero_extend:DI |
| 706 |
(match_operand:SI 2 "nvptx_register_operand" "R"))))] |
| 707 |
"" |
| 708 |
"%.\\tmul.wide.u32\\t%0, %1, %2;") |
| 709 |
|
| 710 |
(define_expand "mulditi3" |
| 711 |
[(set (match_operand:TI 0 "nvptx_register_operand") |
| 712 |
(mult:TI (sign_extend:TI |
| 713 |
(match_operand:DI 1 "nvptx_register_operand")) |
| 714 |
(sign_extend:DI |
| 715 |
(match_operand:DI 2 "nvptx_nonmemory_operand"))))] |
| 716 |
"" |
| 717 |
{ |
| 718 |
rtx hi = gen_reg_rtx (DImode); |
| 719 |
rtx lo = gen_reg_rtx (DImode); |
| 720 |
emit_insn (gen_smuldi3_highpart (hi, operands[1], operands[2])); |
| 721 |
emit_insn (gen_muldi3 (lo, operands[1], operands[2])); |
| 722 |
emit_move_insn (gen_highpart (DImode, operands[0]), hi); |
| 723 |
emit_move_insn (gen_lowpart (DImode, operands[0]), lo); |
| 724 |
DONE; |
| 725 |
}) |
| 726 |
|
| 727 |
(define_expand "umulditi3" |
| 728 |
[(set (match_operand:TI 0 "nvptx_register_operand") |
| 729 |
(mult:TI (zero_extend:TI |
| 730 |
(match_operand:DI 1 "nvptx_register_operand")) |
| 731 |
(zero_extend:DI |
| 732 |
(match_operand:DI 2 "nvptx_nonmemory_operand"))))] |
| 733 |
"" |
| 734 |
{ |
| 735 |
rtx hi = gen_reg_rtx (DImode); |
| 736 |
rtx lo = gen_reg_rtx (DImode); |
| 737 |
emit_insn (gen_umuldi3_highpart (hi, operands[1], operands[2])); |
| 738 |
emit_insn (gen_muldi3 (lo, operands[1], operands[2])); |
| 739 |
emit_move_insn (gen_highpart (DImode, operands[0]), hi); |
| 740 |
emit_move_insn (gen_lowpart (DImode, operands[0]), lo); |
| 741 |
DONE; |
| 742 |
}) |
| 743 |
|
| 744 |
(define_insn "smul<mode>3_highpart" |
| 745 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 746 |
(smul_highpart:HSDIM |
| 747 |
(match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 748 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 749 |
"" |
| 750 |
"%.\\tmul.hi.s%T0\\t%0, %1, %2;") |
| 751 |
|
| 752 |
(define_insn "umul<mode>3_highpart" |
| 753 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 754 |
(umul_highpart:HSDIM |
| 755 |
(match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 756 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 757 |
"" |
| 758 |
"%.\\tmul.hi.u%T0\\t%0, %1, %2;") |
| 759 |
|
| 760 |
(define_insn "*smulhi3_highpart_2" |
| 761 |
[(set (match_operand:HI 0 "nvptx_register_operand" "=R") |
| 762 |
(truncate:HI |
| 763 |
(lshiftrt:SI |
| 764 |
(mult:SI (sign_extend:SI |
| 765 |
(match_operand:HI 1 "nvptx_register_operand" "R")) |
| 766 |
(sign_extend:SI |
| 767 |
(match_operand:HI 2 "nvptx_register_operand" "R"))) |
| 768 |
(const_int 16))))] |
| 769 |
"" |
| 770 |
"%.\\tmul.hi.s16\\t%0, %1, %2;") |
| 771 |
|
| 772 |
(define_insn "*smulsi3_highpart_2" |
| 773 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 774 |
(truncate:SI |
| 775 |
(lshiftrt:DI |
| 776 |
(mult:DI (sign_extend:DI |
| 777 |
(match_operand:SI 1 "nvptx_register_operand" "R")) |
| 778 |
(sign_extend:DI |
| 779 |
(match_operand:SI 2 "nvptx_register_operand" "R"))) |
| 780 |
(const_int 32))))] |
| 781 |
"" |
| 782 |
"%.\\tmul.hi.s32\\t%0, %1, %2;") |
| 783 |
|
| 784 |
(define_insn "*umulhi3_highpart_2" |
| 785 |
[(set (match_operand:HI 0 "nvptx_register_operand" "=R") |
| 786 |
(truncate:HI |
| 787 |
(lshiftrt:SI |
| 788 |
(mult:SI (zero_extend:SI |
| 789 |
(match_operand:HI 1 "nvptx_register_operand" "R")) |
| 790 |
(zero_extend:SI |
| 791 |
(match_operand:HI 2 "nvptx_register_operand" "R"))) |
| 792 |
(const_int 16))))] |
| 793 |
"" |
| 794 |
"%.\\tmul.hi.u16\\t%0, %1, %2;") |
| 795 |
|
| 796 |
(define_insn "*umulsi3_highpart_2" |
| 797 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 798 |
(truncate:SI |
| 799 |
(lshiftrt:DI |
| 800 |
(mult:DI (zero_extend:DI |
| 801 |
(match_operand:SI 1 "nvptx_register_operand" "R")) |
| 802 |
(zero_extend:DI |
| 803 |
(match_operand:SI 2 "nvptx_register_operand" "R"))) |
| 804 |
(const_int 32))))] |
| 805 |
"" |
| 806 |
"%.\\tmul.hi.u32\\t%0, %1, %2;") |
| 807 |
|
| 808 |
;; Shifts |
| 809 |
|
| 810 |
(define_insn "ashl<mode>3" |
| 811 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 812 |
(ashift:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 813 |
(match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")))] |
| 814 |
"" |
| 815 |
"%.\\tshl.b%T0\\t%0, %1, %2;") |
| 816 |
|
| 817 |
(define_insn "ashr<mode>3" |
| 818 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 819 |
(ashiftrt:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 820 |
(match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")))] |
| 821 |
"" |
| 822 |
"%.\\tshr.s%T0\\t%0, %1, %2;") |
| 823 |
|
| 824 |
(define_insn "lshr<mode>3" |
| 825 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 826 |
(lshiftrt:HSDIM (match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 827 |
(match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")))] |
| 828 |
"" |
| 829 |
"%.\\tshr.u%T0\\t%0, %1, %2;") |
| 830 |
|
| 831 |
(define_insn "rotlsi3" |
| 832 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 833 |
(rotate:SI (match_operand:SI 1 "nvptx_register_operand" "R") |
| 834 |
(and:SI (match_operand:SI 2 "nvptx_nonmemory_operand" "Ri") |
| 835 |
(const_int 31))))] |
| 836 |
"TARGET_SM35" |
| 837 |
"%.\\tshf.l.wrap.b32\\t%0, %1, %1, %2;") |
| 838 |
|
| 839 |
(define_insn "rotrsi3" |
| 840 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 841 |
(rotatert:SI (match_operand:SI 1 "nvptx_register_operand" "R") |
| 842 |
(and:SI (match_operand:SI 2 "nvptx_nonmemory_operand" "Ri") |
| 843 |
(const_int 31))))] |
| 844 |
"TARGET_SM35" |
| 845 |
"%.\\tshf.r.wrap.b32\\t%0, %1, %1, %2;") |
| 846 |
|
| 847 |
;; Logical operations |
| 848 |
|
| 849 |
(define_code_iterator any_logic [and ior xor]) |
| 850 |
(define_code_attr logic [(and "and") (ior "or") (xor "xor")]) |
| 851 |
(define_code_attr ilogic [(and "and") (ior "ior") (xor "xor")]) |
| 852 |
|
| 853 |
(define_insn "<ilogic><mode>3" |
| 854 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 855 |
(any_logic:HSDIM |
| 856 |
(match_operand:HSDIM 1 "nvptx_register_operand" "R") |
| 857 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri")))] |
| 858 |
"" |
| 859 |
"%.\\t<logic>.b%T0\\t%0, %1, %2;") |
| 860 |
|
| 861 |
(define_insn "<ilogic>bi3" |
| 862 |
[(set (match_operand:BI 0 "nvptx_register_operand" "=R") |
| 863 |
(any_logic:BI (match_operand:BI 1 "nvptx_register_operand" "R") |
| 864 |
(match_operand:BI 2 "nvptx_register_operand" "R")))] |
| 865 |
"" |
| 866 |
"%.\\t<logic>.pred\\t%0, %1, %2;") |
| 867 |
|
| 868 |
(define_split |
| 869 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand") |
| 870 |
(any_logic:HSDIM |
| 871 |
(ne:HSDIM (match_operand:BI 1 "nvptx_register_operand") |
| 872 |
(const_int 0)) |
| 873 |
(ne:HSDIM (match_operand:BI 2 "nvptx_register_operand") |
| 874 |
(const_int 0))))] |
| 875 |
"can_create_pseudo_p ()" |
| 876 |
[(set (match_dup 3) (any_logic:BI (match_dup 1) (match_dup 2))) |
| 877 |
(set (match_dup 0) (ne:HSDIM (match_dup 3) (const_int 0)))] |
| 878 |
{ |
| 879 |
operands[3] = gen_reg_rtx (BImode); |
| 880 |
}) |
| 881 |
|
| 882 |
;; Comparisons and branches |
| 883 |
|
| 884 |
(define_insn "cmp<mode>" |
| 885 |
[(set (match_operand:BI 0 "nvptx_register_operand" "=R") |
| 886 |
(match_operator:BI 1 "nvptx_comparison_operator" |
| 887 |
[(match_operand:HSDIM 2 "nvptx_register_operand" "R") |
| 888 |
(match_operand:HSDIM 3 "nvptx_nonmemory_operand" "Ri")]))] |
| 889 |
"" |
| 890 |
"%.\\tsetp%c1\\t%0, %2, %3;") |
| 891 |
|
| 892 |
(define_insn "*cmp<mode>" |
| 893 |
[(set (match_operand:BI 0 "nvptx_register_operand" "=R") |
| 894 |
(match_operator:BI 1 "nvptx_float_comparison_operator" |
| 895 |
[(match_operand:SDFM 2 "nvptx_register_operand" "R") |
| 896 |
(match_operand:SDFM 3 "nvptx_nonmemory_operand" "RF")]))] |
| 897 |
"" |
| 898 |
"%.\\tsetp%c1\\t%0, %2, %3;") |
| 899 |
|
| 900 |
(define_insn "*cmphf" |
| 901 |
[(set (match_operand:BI 0 "nvptx_register_operand" "=R") |
| 902 |
(match_operator:BI 1 "nvptx_float_comparison_operator" |
| 903 |
[(match_operand:HF 2 "nvptx_register_operand" "R") |
| 904 |
(match_operand:HF 3 "nvptx_nonmemory_operand" "RF")]))] |
| 905 |
"TARGET_SM53" |
| 906 |
"%.\\tsetp%c1\\t%0, %2, %3;") |
| 907 |
|
| 908 |
(define_insn "jump" |
| 909 |
[(set (pc) |
| 910 |
(label_ref (match_operand 0 "" "")))] |
| 911 |
"" |
| 912 |
"%.\\tbra\\t%l0;") |
| 913 |
|
| 914 |
(define_insn "br_true" |
| 915 |
[(set (pc) |
| 916 |
(if_then_else (ne (match_operand:BI 0 "nvptx_register_operand" "R") |
| 917 |
(const_int 0)) |
| 918 |
(label_ref (match_operand 1 "" "")) |
| 919 |
(pc)))] |
| 920 |
"" |
| 921 |
"%j0\\tbra\\t%l1;" |
| 922 |
[(set_attr "predicable" "no")]) |
| 923 |
|
| 924 |
(define_insn "br_false" |
| 925 |
[(set (pc) |
| 926 |
(if_then_else (eq (match_operand:BI 0 "nvptx_register_operand" "R") |
| 927 |
(const_int 0)) |
| 928 |
(label_ref (match_operand 1 "" "")) |
| 929 |
(pc)))] |
| 930 |
"" |
| 931 |
"%J0\\tbra\\t%l1;" |
| 932 |
[(set_attr "predicable" "no")]) |
| 933 |
|
| 934 |
;; unified conditional branch |
| 935 |
(define_insn "br_true_uni" |
| 936 |
[(set (pc) (if_then_else |
| 937 |
(ne (unspec:BI [(match_operand:BI 0 "nvptx_register_operand" "R")] |
| 938 |
UNSPEC_BR_UNIFIED) (const_int 0)) |
| 939 |
(label_ref (match_operand 1 "" "")) (pc)))] |
| 940 |
"" |
| 941 |
"%j0\\tbra.uni\\t%l1;" |
| 942 |
[(set_attr "predicable" "no")]) |
| 943 |
|
| 944 |
(define_insn "br_false_uni" |
| 945 |
[(set (pc) (if_then_else |
| 946 |
(eq (unspec:BI [(match_operand:BI 0 "nvptx_register_operand" "R")] |
| 947 |
UNSPEC_BR_UNIFIED) (const_int 0)) |
| 948 |
(label_ref (match_operand 1 "" "")) (pc)))] |
| 949 |
"" |
| 950 |
"%J0\\tbra.uni\\t%l1;" |
| 951 |
[(set_attr "predicable" "no")]) |
| 952 |
|
| 953 |
(define_expand "cbranch<mode>4" |
| 954 |
[(set (pc) |
| 955 |
(if_then_else (match_operator 0 "nvptx_comparison_operator" |
| 956 |
[(match_operand:HSDIM 1 "nvptx_register_operand" "") |
| 957 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "")]) |
| 958 |
(label_ref (match_operand 3 "" "")) |
| 959 |
(pc)))] |
| 960 |
"" |
| 961 |
{ |
| 962 |
rtx t = nvptx_expand_compare (operands[0]); |
| 963 |
operands[0] = t; |
| 964 |
operands[1] = XEXP (t, 0); |
| 965 |
operands[2] = XEXP (t, 1); |
| 966 |
}) |
| 967 |
|
| 968 |
(define_expand "cbranch<mode>4" |
| 969 |
[(set (pc) |
| 970 |
(if_then_else (match_operator 0 "nvptx_float_comparison_operator" |
| 971 |
[(match_operand:SDFM 1 "nvptx_register_operand" "") |
| 972 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "")]) |
| 973 |
(label_ref (match_operand 3 "" "")) |
| 974 |
(pc)))] |
| 975 |
"" |
| 976 |
{ |
| 977 |
rtx t = nvptx_expand_compare (operands[0]); |
| 978 |
operands[0] = t; |
| 979 |
operands[1] = XEXP (t, 0); |
| 980 |
operands[2] = XEXP (t, 1); |
| 981 |
}) |
| 982 |
|
| 983 |
(define_expand "cbranchbi4" |
| 984 |
[(set (pc) |
| 985 |
(if_then_else (match_operator 0 "predicate_operator" |
| 986 |
[(match_operand:BI 1 "nvptx_register_operand" "") |
| 987 |
(match_operand:BI 2 "const0_operand" "")]) |
| 988 |
(label_ref (match_operand 3 "" "")) |
| 989 |
(pc)))] |
| 990 |
"" |
| 991 |
"") |
| 992 |
|
| 993 |
;; Conditional stores |
| 994 |
|
| 995 |
(define_insn "setcc<mode>_from_bi" |
| 996 |
[(set (match_operand:QHSDIM 0 "nvptx_register_operand" "=R") |
| 997 |
(ne:QHSDIM (match_operand:BI 1 "nvptx_register_operand" "R") |
| 998 |
(const_int 0)))] |
| 999 |
"" |
| 1000 |
"%.\\tselp%t0\\t%0, 1, 0, %1;") |
| 1001 |
|
| 1002 |
(define_insn "*setcc<mode>_from_not_bi" |
| 1003 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 1004 |
(eq:HSDIM (match_operand:BI 1 "nvptx_register_operand" "R") |
| 1005 |
(const_int 0)))] |
| 1006 |
"" |
| 1007 |
"%.\\tselp%t0\\t%0, 0, 1, %1;") |
| 1008 |
|
| 1009 |
(define_insn "extendbi<mode>2" |
| 1010 |
[(set (match_operand:QHSDIM 0 "nvptx_register_operand" "=R") |
| 1011 |
(sign_extend:QHSDIM |
| 1012 |
(match_operand:BI 1 "nvptx_register_operand" "R")))] |
| 1013 |
"" |
| 1014 |
"%.\\tselp%t0\\t%0, -1, 0, %1;") |
| 1015 |
|
| 1016 |
(define_insn "zero_extendbi<mode>2" |
| 1017 |
[(set (match_operand:QHSDIM 0 "nvptx_register_operand" "=R") |
| 1018 |
(zero_extend:QHSDIM |
| 1019 |
(match_operand:BI 1 "nvptx_register_operand" "R")))] |
| 1020 |
"" |
| 1021 |
"%.\\tselp%t0\\t%0, 1, 0, %1;") |
| 1022 |
|
| 1023 |
(define_insn "sel_true<mode>" |
| 1024 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 1025 |
(if_then_else:HSDIM |
| 1026 |
(ne (match_operand:BI 1 "nvptx_register_operand" "R") (const_int 0)) |
| 1027 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri") |
| 1028 |
(match_operand:HSDIM 3 "nvptx_nonmemory_operand" "Ri")))] |
| 1029 |
"" |
| 1030 |
"%.\\tselp%t0\\t%0, %2, %3, %1;") |
| 1031 |
|
| 1032 |
(define_insn "sel_true<mode>" |
| 1033 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1034 |
(if_then_else:SDFM |
| 1035 |
(ne (match_operand:BI 1 "nvptx_register_operand" "R") (const_int 0)) |
| 1036 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF") |
| 1037 |
(match_operand:SDFM 3 "nvptx_nonmemory_operand" "RF")))] |
| 1038 |
"" |
| 1039 |
"%.\\tselp%t0\\t%0, %2, %3, %1;") |
| 1040 |
|
| 1041 |
(define_insn "sel_false<mode>" |
| 1042 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 1043 |
(if_then_else:HSDIM |
| 1044 |
(eq (match_operand:BI 1 "nvptx_register_operand" "R") (const_int 0)) |
| 1045 |
(match_operand:HSDIM 2 "nvptx_nonmemory_operand" "Ri") |
| 1046 |
(match_operand:HSDIM 3 "nvptx_nonmemory_operand" "Ri")))] |
| 1047 |
"" |
| 1048 |
"%.\\tselp%t0\\t%0, %3, %2, %1;") |
| 1049 |
|
| 1050 |
(define_insn "sel_false<mode>" |
| 1051 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1052 |
(if_then_else:SDFM |
| 1053 |
(eq (match_operand:BI 1 "nvptx_register_operand" "R") (const_int 0)) |
| 1054 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF") |
| 1055 |
(match_operand:SDFM 3 "nvptx_nonmemory_operand" "RF")))] |
| 1056 |
"" |
| 1057 |
"%.\\tselp%t0\\t%0, %3, %2, %1;") |
| 1058 |
|
| 1059 |
(define_code_iterator eqne [eq ne]) |
| 1060 |
|
| 1061 |
;; Split negation of a predicate into a conditional move. |
| 1062 |
(define_insn_and_split "*selp<mode>_neg_<code>" |
| 1063 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 1064 |
(neg:HSDIM (eqne:HSDIM |
| 1065 |
(match_operand:BI 1 "nvptx_register_operand" "R") |
| 1066 |
(const_int 0))))] |
| 1067 |
"" |
| 1068 |
"#" |
| 1069 |
"&& 1" |
| 1070 |
[(set (match_dup 0) |
| 1071 |
(if_then_else:HSDIM |
| 1072 |
(eqne (match_dup 1) (const_int 0)) |
| 1073 |
(const_int -1) |
| 1074 |
(const_int 0)))]) |
| 1075 |
|
| 1076 |
;; Split bitwise not of a predicate into a conditional move. |
| 1077 |
(define_insn_and_split "*selp<mode>_not_<code>" |
| 1078 |
[(set (match_operand:HSDIM 0 "nvptx_register_operand" "=R") |
| 1079 |
(not:HSDIM (eqne:HSDIM |
| 1080 |
(match_operand:BI 1 "nvptx_register_operand" "R") |
| 1081 |
(const_int 0))))] |
| 1082 |
"" |
| 1083 |
"#" |
| 1084 |
"&& 1" |
| 1085 |
[(set (match_dup 0) |
| 1086 |
(if_then_else:HSDIM |
| 1087 |
(eqne (match_dup 1) (const_int 0)) |
| 1088 |
(const_int -2) |
| 1089 |
(const_int -1)))]) |
| 1090 |
|
| 1091 |
(define_insn "*setcc_int<mode>" |
| 1092 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 1093 |
(neg:SI |
| 1094 |
(match_operator:SI 1 "nvptx_comparison_operator" |
| 1095 |
[(match_operand:HSDIM 2 "nvptx_register_operand" "R") |
| 1096 |
(match_operand:HSDIM 3 "nvptx_nonmemory_operand" "Ri")])))] |
| 1097 |
"" |
| 1098 |
"%.\\tset%t0%c1\\t%0, %2, %3;") |
| 1099 |
|
| 1100 |
(define_insn "*setcc_int<mode>" |
| 1101 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 1102 |
(neg:SI |
| 1103 |
(match_operator:SI 1 "nvptx_float_comparison_operator" |
| 1104 |
[(match_operand:SDFM 2 "nvptx_register_operand" "R") |
| 1105 |
(match_operand:SDFM 3 "nvptx_nonmemory_operand" "RF")])))] |
| 1106 |
"" |
| 1107 |
"%.\\tset%t0%c1\\t%0, %2, %3;") |
| 1108 |
|
| 1109 |
(define_insn "setcc_float<mode>" |
| 1110 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1111 |
(match_operator:SF 1 "nvptx_comparison_operator" |
| 1112 |
[(match_operand:HSDIM 2 "nvptx_register_operand" "R") |
| 1113 |
(match_operand:HSDIM 3 "nvptx_nonmemory_operand" "Ri")]))] |
| 1114 |
"" |
| 1115 |
"%.\\tset%t0%c1\\t%0, %2, %3;") |
| 1116 |
|
| 1117 |
(define_insn "setcc_float<mode>" |
| 1118 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1119 |
(match_operator:SF 1 "nvptx_float_comparison_operator" |
| 1120 |
[(match_operand:SDFM 2 "nvptx_register_operand" "R") |
| 1121 |
(match_operand:SDFM 3 "nvptx_nonmemory_operand" "RF")]))] |
| 1122 |
"" |
| 1123 |
"%.\\tset%t0%c1\\t%0, %2, %3;") |
| 1124 |
|
| 1125 |
(define_expand "cstore<mode>4" |
| 1126 |
[(set (match_operand:SI 0 "nvptx_register_operand") |
| 1127 |
(match_operator:SI 1 "nvptx_comparison_operator" |
| 1128 |
[(match_operand:HSDIM 2 "nvptx_register_operand") |
| 1129 |
(match_operand:HSDIM 3 "nvptx_nonmemory_operand")]))] |
| 1130 |
"" |
| 1131 |
{ |
| 1132 |
rtx reg = gen_reg_rtx (BImode); |
| 1133 |
rtx cmp = gen_rtx_fmt_ee (GET_CODE (operands[1]), BImode, |
| 1134 |
operands[2], operands[3]); |
| 1135 |
emit_move_insn (reg, cmp); |
| 1136 |
emit_insn (gen_setccsi_from_bi (operands[0], reg)); |
| 1137 |
DONE; |
| 1138 |
}) |
| 1139 |
|
| 1140 |
(define_expand "cstore<mode>4" |
| 1141 |
[(set (match_operand:SI 0 "nvptx_register_operand") |
| 1142 |
(match_operator:SI 1 "nvptx_float_comparison_operator" |
| 1143 |
[(match_operand:SDFM 2 "nvptx_register_operand") |
| 1144 |
(match_operand:SDFM 3 "nvptx_nonmemory_operand")]))] |
| 1145 |
"" |
| 1146 |
{ |
| 1147 |
rtx reg = gen_reg_rtx (BImode); |
| 1148 |
rtx cmp = gen_rtx_fmt_ee (GET_CODE (operands[1]), BImode, |
| 1149 |
operands[2], operands[3]); |
| 1150 |
emit_move_insn (reg, cmp); |
| 1151 |
emit_insn (gen_setccsi_from_bi (operands[0], reg)); |
| 1152 |
DONE; |
| 1153 |
}) |
| 1154 |
|
| 1155 |
(define_expand "cstorehf4" |
| 1156 |
[(set (match_operand:SI 0 "nvptx_register_operand") |
| 1157 |
(match_operator:SI 1 "nvptx_float_comparison_operator" |
| 1158 |
[(match_operand:HF 2 "nvptx_register_operand") |
| 1159 |
(match_operand:HF 3 "nvptx_nonmemory_operand")]))] |
| 1160 |
"TARGET_SM53" |
| 1161 |
{ |
| 1162 |
rtx reg = gen_reg_rtx (BImode); |
| 1163 |
rtx cmp = gen_rtx_fmt_ee (GET_CODE (operands[1]), BImode, |
| 1164 |
operands[2], operands[3]); |
| 1165 |
emit_move_insn (reg, cmp); |
| 1166 |
emit_insn (gen_setccsi_from_bi (operands[0], reg)); |
| 1167 |
DONE; |
| 1168 |
}) |
| 1169 |
|
| 1170 |
;; Calls |
| 1171 |
|
| 1172 |
(define_insn "call_insn_<mode>" |
| 1173 |
[(match_parallel 2 "call_operation" |
| 1174 |
[(call (mem:QI (match_operand:P 0 "call_insn_operand" "Rs")) |
| 1175 |
(match_operand 1))])] |
| 1176 |
"" |
| 1177 |
{ |
| 1178 |
return nvptx_output_call_insn (insn, NULL_RTX, operands[0]); |
| 1179 |
}) |
| 1180 |
|
| 1181 |
(define_insn "call_value_insn_<mode>" |
| 1182 |
[(match_parallel 3 "call_operation" |
| 1183 |
[(set (match_operand 0 "nvptx_register_operand" "=R") |
| 1184 |
(call (mem:QI (match_operand:P 1 "call_insn_operand" "Rs")) |
| 1185 |
(match_operand 2)))])] |
| 1186 |
"" |
| 1187 |
{ |
| 1188 |
return nvptx_output_call_insn (insn, operands[0], operands[1]); |
| 1189 |
}) |
| 1190 |
|
| 1191 |
(define_expand "call" |
| 1192 |
[(match_operand 0 "" "")] |
| 1193 |
"" |
| 1194 |
{ |
| 1195 |
nvptx_expand_call (NULL_RTX, operands[0]); |
| 1196 |
DONE; |
| 1197 |
}) |
| 1198 |
|
| 1199 |
(define_expand "call_value" |
| 1200 |
[(match_operand 0 "" "") |
| 1201 |
(match_operand 1 "" "")] |
| 1202 |
"" |
| 1203 |
{ |
| 1204 |
nvptx_expand_call (operands[0], operands[1]); |
| 1205 |
DONE; |
| 1206 |
}) |
| 1207 |
|
| 1208 |
;; Floating point arithmetic. |
| 1209 |
|
| 1210 |
(define_insn "add<mode>3" |
| 1211 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1212 |
(plus:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R") |
| 1213 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")))] |
| 1214 |
"" |
| 1215 |
"%.\\tadd%t0\\t%0, %1, %2;") |
| 1216 |
|
| 1217 |
(define_insn "sub<mode>3" |
| 1218 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1219 |
(minus:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R") |
| 1220 |
(match_operand:SDFM 2 "nvptx_register_operand" "R")))] |
| 1221 |
"" |
| 1222 |
"%.\\tsub%t0\\t%0, %1, %2;") |
| 1223 |
|
| 1224 |
(define_insn "mul<mode>3" |
| 1225 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1226 |
(mult:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R") |
| 1227 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")))] |
| 1228 |
"" |
| 1229 |
"%.\\tmul%t0\\t%0, %1, %2;") |
| 1230 |
|
| 1231 |
(define_insn "fma<mode>4" |
| 1232 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1233 |
(fma:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R") |
| 1234 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF") |
| 1235 |
(match_operand:SDFM 3 "nvptx_nonmemory_operand" "RF")))] |
| 1236 |
"" |
| 1237 |
"%.\\tfma%#%t0\\t%0, %1, %2, %3;") |
| 1238 |
|
| 1239 |
(define_insn "*recip<mode>2" |
| 1240 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1241 |
(div:SDFM |
| 1242 |
(match_operand:SDFM 2 "const_double_operand" "F") |
| 1243 |
(match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1244 |
"CONST_DOUBLE_P (operands[2]) |
| 1245 |
&& real_identical (CONST_DOUBLE_REAL_VALUE (operands[2]), &dconst1)" |
| 1246 |
"%.\\trcp%#%t0\\t%0, %1;") |
| 1247 |
|
| 1248 |
(define_insn "div<mode>3" |
| 1249 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1250 |
(div:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R") |
| 1251 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")))] |
| 1252 |
"" |
| 1253 |
"%.\\tdiv%#%t0\\t%0, %1, %2;") |
| 1254 |
|
| 1255 |
(define_insn "copysign<mode>3" |
| 1256 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1257 |
(unspec:SDFM [(match_operand:SDFM 1 "nvptx_nonmemory_operand" "RF") |
| 1258 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")] |
| 1259 |
UNSPEC_COPYSIGN))] |
| 1260 |
"" |
| 1261 |
"%.\\tcopysign%t0\\t%0, %2, %1;") |
| 1262 |
|
| 1263 |
(define_insn "smin<mode>3" |
| 1264 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1265 |
(smin:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R") |
| 1266 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")))] |
| 1267 |
"" |
| 1268 |
"%.\\tmin%t0\\t%0, %1, %2;") |
| 1269 |
|
| 1270 |
(define_insn "smax<mode>3" |
| 1271 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1272 |
(smax:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R") |
| 1273 |
(match_operand:SDFM 2 "nvptx_nonmemory_operand" "RF")))] |
| 1274 |
"" |
| 1275 |
"%.\\tmax%t0\\t%0, %1, %2;") |
| 1276 |
|
| 1277 |
(define_insn "abs<mode>2" |
| 1278 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1279 |
(abs:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1280 |
"" |
| 1281 |
"%.\\tabs%t0\\t%0, %1;") |
| 1282 |
|
| 1283 |
(define_insn "neg<mode>2" |
| 1284 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1285 |
(neg:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1286 |
"" |
| 1287 |
"%.\\tneg%t0\\t%0, %1;") |
| 1288 |
|
| 1289 |
(define_insn "sqrt<mode>2" |
| 1290 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1291 |
(sqrt:SDFM (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1292 |
"" |
| 1293 |
"%.\\tsqrt%#%t0\\t%0, %1;") |
| 1294 |
|
| 1295 |
(define_expand "sincossf3" |
| 1296 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1297 |
(unspec:SF [(match_operand:SF 2 "nvptx_register_operand" "R")] |
| 1298 |
UNSPEC_COS)) |
| 1299 |
(set (match_operand:SF 1 "nvptx_register_operand" "=R") |
| 1300 |
(unspec:SF [(match_dup 2)] UNSPEC_SIN))] |
| 1301 |
"flag_unsafe_math_optimizations" |
| 1302 |
{ |
| 1303 |
operands[2] = make_safe_from (operands[2], operands[0]); |
| 1304 |
}) |
| 1305 |
|
| 1306 |
(define_insn "sinsf2" |
| 1307 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1308 |
(unspec:SF [(match_operand:SF 1 "nvptx_register_operand" "R")] |
| 1309 |
UNSPEC_SIN))] |
| 1310 |
"flag_unsafe_math_optimizations" |
| 1311 |
"%.\\tsin.approx%t0\\t%0, %1;") |
| 1312 |
|
| 1313 |
(define_insn "cossf2" |
| 1314 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1315 |
(unspec:SF [(match_operand:SF 1 "nvptx_register_operand" "R")] |
| 1316 |
UNSPEC_COS))] |
| 1317 |
"flag_unsafe_math_optimizations" |
| 1318 |
"%.\\tcos.approx%t0\\t%0, %1;") |
| 1319 |
|
| 1320 |
(define_insn "log2sf2" |
| 1321 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1322 |
(unspec:SF [(match_operand:SF 1 "nvptx_register_operand" "R")] |
| 1323 |
UNSPEC_LOG2))] |
| 1324 |
"flag_unsafe_math_optimizations" |
| 1325 |
"%.\\tlg2.approx%t0\\t%0, %1;") |
| 1326 |
|
| 1327 |
(define_insn "exp2sf2" |
| 1328 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1329 |
(unspec:SF [(match_operand:SF 1 "nvptx_register_operand" "R")] |
| 1330 |
UNSPEC_EXP2))] |
| 1331 |
"flag_unsafe_math_optimizations" |
| 1332 |
"%.\\tex2.approx%t0\\t%0, %1;") |
| 1333 |
|
| 1334 |
(define_insn "setcc_isinf<mode>" |
| 1335 |
[(set (match_operand:BI 0 "nvptx_register_operand" "=R") |
| 1336 |
(unspec:BI [(match_operand:SDFM 1 "nvptx_register_operand" "R")] |
| 1337 |
UNSPEC_ISINF))] |
| 1338 |
"" |
| 1339 |
"%.\\ttestp.infinite%t1\\t%0, %1;") |
| 1340 |
|
| 1341 |
(define_expand "isinf<mode>2" |
| 1342 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 1343 |
(unspec:SI [(match_operand:SDFM 1 "nvptx_register_operand" "R")] |
| 1344 |
UNSPEC_ISINF))] |
| 1345 |
"" |
| 1346 |
{ |
| 1347 |
rtx pred = gen_reg_rtx (BImode); |
| 1348 |
emit_insn (gen_setcc_isinf<mode> (pred, operands[1])); |
| 1349 |
emit_insn (gen_setccsi_from_bi (operands[0], pred)); |
| 1350 |
DONE; |
| 1351 |
}) |
| 1352 |
|
| 1353 |
;; HFmode floating point arithmetic. |
| 1354 |
|
| 1355 |
(define_insn "addhf3" |
| 1356 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1357 |
(plus:HF (match_operand:HF 1 "nvptx_register_operand" "R") |
| 1358 |
(match_operand:HF 2 "nvptx_register_operand" "R")))] |
| 1359 |
"TARGET_SM53" |
| 1360 |
"%.\\tadd.f16\\t%0, %1, %2;") |
| 1361 |
|
| 1362 |
(define_insn "subhf3" |
| 1363 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1364 |
(minus:HF (match_operand:HF 1 "nvptx_register_operand" "R") |
| 1365 |
(match_operand:HF 2 "nvptx_register_operand" "R")))] |
| 1366 |
"TARGET_SM53" |
| 1367 |
"%.\\tsub.f16\\t%0, %1, %2;") |
| 1368 |
|
| 1369 |
(define_insn "mulhf3" |
| 1370 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1371 |
(mult:HF (match_operand:HF 1 "nvptx_register_operand" "R") |
| 1372 |
(match_operand:HF 2 "nvptx_register_operand" "R")))] |
| 1373 |
"TARGET_SM53" |
| 1374 |
"%.\\tmul.f16\\t%0, %1, %2;") |
| 1375 |
|
| 1376 |
(define_insn "fmahf4" |
| 1377 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1378 |
(fma:HF (match_operand:HF 1 "nvptx_register_operand" "R") |
| 1379 |
(match_operand:HF 2 "nvptx_nonmemory_operand" "RF") |
| 1380 |
(match_operand:HF 3 "nvptx_nonmemory_operand" "RF")))] |
| 1381 |
"TARGET_SM53" |
| 1382 |
"%.\\tfma%#.f16\\t%0, %1, %2, %3;") |
| 1383 |
|
| 1384 |
(define_insn "neghf2" |
| 1385 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1386 |
(neg:HF (match_operand:HF 1 "nvptx_register_operand" "R")))] |
| 1387 |
"" |
| 1388 |
"%.\\txor.b16\\t%0, %1, -32768;") |
| 1389 |
|
| 1390 |
(define_insn "abshf2" |
| 1391 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1392 |
(abs:HF (match_operand:HF 1 "nvptx_register_operand" "R")))] |
| 1393 |
"" |
| 1394 |
"%.\\tand.b16\\t%0, %1, 32767;") |
| 1395 |
|
| 1396 |
(define_insn "exp2hf2" |
| 1397 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1398 |
(unspec:HF [(match_operand:HF 1 "nvptx_register_operand" "R")] |
| 1399 |
UNSPEC_EXP2))] |
| 1400 |
"TARGET_SM75 && flag_unsafe_math_optimizations" |
| 1401 |
"%.\\tex2.approx.f16\\t%0, %1;") |
| 1402 |
|
| 1403 |
(define_insn "tanh<mode>2" |
| 1404 |
[(set (match_operand:HSFM 0 "nvptx_register_operand" "=R") |
| 1405 |
(unspec:HSFM [(match_operand:HSFM 1 "nvptx_register_operand" "R")] |
| 1406 |
UNSPEC_TANH))] |
| 1407 |
"TARGET_SM75 && flag_unsafe_math_optimizations" |
| 1408 |
"%.\\ttanh.approx%t0\\t%0, %1;") |
| 1409 |
|
| 1410 |
;; HFmode floating point arithmetic. |
| 1411 |
|
| 1412 |
(define_insn "sminhf3" |
| 1413 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1414 |
(smin:HF (match_operand:HF 1 "nvptx_register_operand" "R") |
| 1415 |
(match_operand:HF 2 "nvptx_register_operand" "R")))] |
| 1416 |
"TARGET_SM80" |
| 1417 |
"%.\\tmin.f16\\t%0, %1, %2;") |
| 1418 |
|
| 1419 |
(define_insn "smaxhf3" |
| 1420 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1421 |
(smax:HF (match_operand:HF 1 "nvptx_register_operand" "R") |
| 1422 |
(match_operand:HF 2 "nvptx_register_operand" "R")))] |
| 1423 |
"TARGET_SM80" |
| 1424 |
"%.\\tmax.f16\\t%0, %1, %2;") |
| 1425 |
|
| 1426 |
;; Conversions involving floating point |
| 1427 |
|
| 1428 |
(define_insn "extendsfdf2" |
| 1429 |
[(set (match_operand:DF 0 "nvptx_register_operand" "=R") |
| 1430 |
(float_extend:DF (match_operand:SF 1 "nvptx_register_operand" "R")))] |
| 1431 |
"" |
| 1432 |
"%.\\tcvt%t0%t1\\t%0, %1;") |
| 1433 |
|
| 1434 |
(define_insn "truncdfsf2" |
| 1435 |
[(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 1436 |
(float_truncate:SF (match_operand:DF 1 "nvptx_register_operand" "R")))] |
| 1437 |
"" |
| 1438 |
"%.\\tcvt%#%t0%t1\\t%0, %1;") |
| 1439 |
|
| 1440 |
(define_insn "floatunssi<mode>2" |
| 1441 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1442 |
(unsigned_float:SDFM (match_operand:SI 1 "nvptx_register_operand" "R")))] |
| 1443 |
"" |
| 1444 |
"%.\\tcvt%#%t0.u%T1\\t%0, %1;") |
| 1445 |
|
| 1446 |
(define_insn "floatsi<mode>2" |
| 1447 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1448 |
(float:SDFM (match_operand:SI 1 "nvptx_register_operand" "R")))] |
| 1449 |
"" |
| 1450 |
"%.\\tcvt%#%t0.s%T1\\t%0, %1;") |
| 1451 |
|
| 1452 |
(define_insn "floatunsdi<mode>2" |
| 1453 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1454 |
(unsigned_float:SDFM (match_operand:DI 1 "nvptx_register_operand" "R")))] |
| 1455 |
"" |
| 1456 |
"%.\\tcvt%#%t0.u%T1\\t%0, %1;") |
| 1457 |
|
| 1458 |
(define_insn "floatdi<mode>2" |
| 1459 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1460 |
(float:SDFM (match_operand:DI 1 "nvptx_register_operand" "R")))] |
| 1461 |
"" |
| 1462 |
"%.\\tcvt%#%t0.s%T1\\t%0, %1;") |
| 1463 |
|
| 1464 |
(define_insn "fixuns_trunc<mode>si2" |
| 1465 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 1466 |
(unsigned_fix:SI (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1467 |
"" |
| 1468 |
"%.\\tcvt.rzi.u%T0%t1\\t%0, %1;") |
| 1469 |
|
| 1470 |
(define_insn "fix_trunc<mode>si2" |
| 1471 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 1472 |
(fix:SI (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1473 |
"" |
| 1474 |
"%.\\tcvt.rzi.s%T0%t1\\t%0, %1;") |
| 1475 |
|
| 1476 |
(define_insn "fixuns_trunc<mode>di2" |
| 1477 |
[(set (match_operand:DI 0 "nvptx_register_operand" "=R") |
| 1478 |
(unsigned_fix:DI (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1479 |
"" |
| 1480 |
"%.\\tcvt.rzi.u%T0%t1\\t%0, %1;") |
| 1481 |
|
| 1482 |
(define_insn "fix_trunc<mode>di2" |
| 1483 |
[(set (match_operand:DI 0 "nvptx_register_operand" "=R") |
| 1484 |
(fix:DI (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1485 |
"" |
| 1486 |
"%.\\tcvt.rzi.s%T0%t1\\t%0, %1;") |
| 1487 |
|
| 1488 |
(define_int_iterator FPINT [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_BTRUNC |
| 1489 |
UNSPEC_FPINT_CEIL UNSPEC_FPINT_NEARBYINT]) |
| 1490 |
(define_int_attr fpint_name [(UNSPEC_FPINT_FLOOR "floor") |
| 1491 |
(UNSPEC_FPINT_BTRUNC "btrunc") |
| 1492 |
(UNSPEC_FPINT_CEIL "ceil") |
| 1493 |
(UNSPEC_FPINT_NEARBYINT "nearbyint")]) |
| 1494 |
(define_int_attr fpint_roundingmode [(UNSPEC_FPINT_FLOOR ".rmi") |
| 1495 |
(UNSPEC_FPINT_BTRUNC ".rzi") |
| 1496 |
(UNSPEC_FPINT_CEIL ".rpi") |
| 1497 |
(UNSPEC_FPINT_NEARBYINT "%#i")]) |
| 1498 |
|
| 1499 |
(define_insn "<FPINT:fpint_name><SDFM:mode>2" |
| 1500 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1501 |
(unspec:SDFM [(match_operand:SDFM 1 "nvptx_register_operand" "R")] |
| 1502 |
FPINT))] |
| 1503 |
"" |
| 1504 |
"%.\\tcvt<FPINT:fpint_roundingmode>%t0%t1\\t%0, %1;") |
| 1505 |
|
| 1506 |
(define_int_iterator FPINT2 [UNSPEC_FPINT_FLOOR UNSPEC_FPINT_CEIL]) |
| 1507 |
(define_int_attr fpint2_name [(UNSPEC_FPINT_FLOOR "lfloor") |
| 1508 |
(UNSPEC_FPINT_CEIL "lceil")]) |
| 1509 |
(define_int_attr fpint2_roundingmode [(UNSPEC_FPINT_FLOOR ".rmi") |
| 1510 |
(UNSPEC_FPINT_CEIL ".rpi")]) |
| 1511 |
|
| 1512 |
(define_insn "<FPINT2:fpint2_name><SDFM:mode><SDIM:mode>2" |
| 1513 |
[(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") |
| 1514 |
(unspec:SDIM [(match_operand:SDFM 1 "nvptx_register_operand" "R")] |
| 1515 |
FPINT2))] |
| 1516 |
"" |
| 1517 |
"%.\\tcvt<FPINT2:fpint2_roundingmode>.s%T0%t1\\t%0, %1;") |
| 1518 |
|
| 1519 |
(define_insn "extendhf<mode>2" |
| 1520 |
[(set (match_operand:SDFM 0 "nvptx_register_operand" "=R") |
| 1521 |
(float_extend:SDFM (match_operand:HF 1 "nvptx_register_operand" "R")))] |
| 1522 |
"TARGET_SM53" |
| 1523 |
"%.\\tcvt%t0%t1\\t%0, %1;") |
| 1524 |
|
| 1525 |
(define_insn "trunc<mode>hf2" |
| 1526 |
[(set (match_operand:HF 0 "nvptx_register_operand" "=R") |
| 1527 |
(float_truncate:HF (match_operand:SDFM 1 "nvptx_register_operand" "R")))] |
| 1528 |
"TARGET_SM53" |
| 1529 |
"%.\\tcvt%#%t0%t1\\t%0, %1;") |
| 1530 |
|
| 1531 |
;; Vector operations |
| 1532 |
|
| 1533 |
(define_insn "*vec_set<mode>_0" |
| 1534 |
[(set (match_operand:VECIM 0 "nvptx_register_operand" "=R") |
| 1535 |
(vec_merge:VECIM |
| 1536 |
(vec_duplicate:VECIM |
| 1537 |
(match_operand:<VECELEM> 1 "nvptx_register_operand" "R")) |
| 1538 |
(match_dup 0) |
| 1539 |
(const_int 1)))] |
| 1540 |
"" |
| 1541 |
"%.\\tmov%t1\\t%0.x, %1;") |
| 1542 |
|
| 1543 |
(define_insn "*vec_set<mode>_1" |
| 1544 |
[(set (match_operand:VECIM 0 "nvptx_register_operand" "=R") |
| 1545 |
(vec_merge:VECIM |
| 1546 |
(vec_duplicate:VECIM |
| 1547 |
(match_operand:<VECELEM> 1 "nvptx_register_operand" "R")) |
| 1548 |
(match_dup 0) |
| 1549 |
(const_int 2)))] |
| 1550 |
"" |
| 1551 |
"%.\\tmov%t1\\t%0.y, %1;") |
| 1552 |
|
| 1553 |
(define_insn "*vec_set<mode>_2" |
| 1554 |
[(set (match_operand:VECIM 0 "nvptx_register_operand" "=R") |
| 1555 |
(vec_merge:VECIM |
| 1556 |
(vec_duplicate:VECIM |
| 1557 |
(match_operand:<VECELEM> 1 "nvptx_register_operand" "R")) |
| 1558 |
(match_dup 0) |
| 1559 |
(const_int 4)))] |
| 1560 |
"" |
| 1561 |
"%.\\tmov%t1\\t%0.z, %1;") |
| 1562 |
|
| 1563 |
(define_insn "*vec_set<mode>_3" |
| 1564 |
[(set (match_operand:VECIM 0 "nvptx_register_operand" "=R") |
| 1565 |
(vec_merge:VECIM |
| 1566 |
(vec_duplicate:VECIM |
| 1567 |
(match_operand:<VECELEM> 1 "nvptx_register_operand" "R")) |
| 1568 |
(match_dup 0) |
| 1569 |
(const_int 8)))] |
| 1570 |
"" |
| 1571 |
"%.\\tmov%t1\\t%0.w, %1;") |
| 1572 |
|
| 1573 |
(define_expand "vec_set<mode>" |
| 1574 |
[(match_operand:VECIM 0 "nvptx_register_operand") |
| 1575 |
(match_operand:<VECELEM> 1 "nvptx_register_operand") |
| 1576 |
(match_operand:SI 2 "nvptx_vector_index_operand")] |
| 1577 |
"" |
| 1578 |
{ |
| 1579 |
enum machine_mode mode = GET_MODE (operands[0]); |
| 1580 |
int mask = 1 << INTVAL (operands[2]); |
| 1581 |
rtx tmp = gen_rtx_VEC_DUPLICATE (mode, operands[1]); |
| 1582 |
tmp = gen_rtx_VEC_MERGE (mode, tmp, operands[0], GEN_INT (mask)); |
| 1583 |
emit_insn (gen_rtx_SET (operands[0], tmp)); |
| 1584 |
DONE; |
| 1585 |
}) |
| 1586 |
|
| 1587 |
(define_insn "vec_extract<mode><Vecelem>" |
| 1588 |
[(set (match_operand:<VECELEM> 0 "nvptx_register_operand" "=R") |
| 1589 |
(vec_select:<VECELEM> |
| 1590 |
(match_operand:VECIM 1 "nvptx_register_operand" "R") |
| 1591 |
(parallel [(match_operand:SI 2 "nvptx_vector_index_operand" "")])))] |
| 1592 |
"" |
| 1593 |
{ |
| 1594 |
static const char *const asms[4] = { |
| 1595 |
"%.\\tmov%t0\\t%0, %1.x;", |
| 1596 |
"%.\\tmov%t0\\t%0, %1.y;", |
| 1597 |
"%.\\tmov%t0\\t%0, %1.z;", |
| 1598 |
"%.\\tmov%t0\\t%0, %1.w;" |
| 1599 |
}; |
| 1600 |
return asms[INTVAL (operands[2])]; |
| 1601 |
}) |
| 1602 |
|
| 1603 |
;; Miscellaneous |
| 1604 |
|
| 1605 |
(define_insn "nop" |
| 1606 |
[(const_int 0)] |
| 1607 |
"" |
| 1608 |
"") |
| 1609 |
|
| 1610 |
(define_insn "exit" |
| 1611 |
[(const_int 1)] |
| 1612 |
"" |
| 1613 |
"exit;") |
| 1614 |
|
| 1615 |
(define_insn "fake_nop" |
| 1616 |
[(const_int 2)] |
| 1617 |
"" |
| 1618 |
"{ |
| 1619 |
.reg .u32 %%nop_src; |
| 1620 |
.reg .u32 %%nop_dst; |
| 1621 |
mov.u32 %%nop_dst, %%nop_src; |
| 1622 |
}") |
| 1623 |
|
| 1624 |
(define_insn "return" |
| 1625 |
[(return)] |
| 1626 |
"" |
| 1627 |
{ |
| 1628 |
return nvptx_output_return (); |
| 1629 |
} |
| 1630 |
[(set_attr "predicable" "no")]) |
| 1631 |
|
| 1632 |
(define_expand "epilogue" |
| 1633 |
[(clobber (const_int 0))] |
| 1634 |
"" |
| 1635 |
{ |
| 1636 |
if (TARGET_SOFT_STACK) |
| 1637 |
emit_insn (gen_set_softstack (Pmode, gen_rtx_REG (Pmode, |
| 1638 |
SOFTSTACK_PREV_REGNUM))); |
| 1639 |
emit_jump_insn (gen_return ()); |
| 1640 |
DONE; |
| 1641 |
}) |
| 1642 |
|
| 1643 |
(define_expand "exception_receiver" |
| 1644 |
[(const_int 0)] |
| 1645 |
"" |
| 1646 |
{ |
| 1647 |
if (!fake_exceptions) |
| 1648 |
sorry ("exception handling not supported"); |
| 1649 |
DONE; |
| 1650 |
}) |
| 1651 |
|
| 1652 |
(define_expand "nonlocal_goto" |
| 1653 |
[(match_operand 0 "" "") |
| 1654 |
(match_operand 1 "" "") |
| 1655 |
(match_operand 2 "" "") |
| 1656 |
(match_operand 3 "" "")] |
| 1657 |
"" |
| 1658 |
{ |
| 1659 |
sorry ("target cannot support nonlocal goto"); |
| 1660 |
emit_insn (gen_nop ()); |
| 1661 |
DONE; |
| 1662 |
}) |
| 1663 |
|
| 1664 |
(define_expand "nonlocal_goto_receiver" |
| 1665 |
[(const_int 0)] |
| 1666 |
"" |
| 1667 |
{ |
| 1668 |
sorry ("target cannot support nonlocal goto"); |
| 1669 |
}) |
| 1670 |
|
| 1671 |
(define_expand "allocate_stack" |
| 1672 |
[(match_operand 0 "nvptx_register_operand") |
| 1673 |
(match_operand 1 "nvptx_register_operand")] |
| 1674 |
"" |
| 1675 |
{ |
| 1676 |
if (!TARGET_SOFT_STACK) |
| 1677 |
emit_insn (gen_nvptx_alloca (Pmode, operands[0], operands[1])); |
| 1678 |
else if (TARGET_SOFT_STACK) |
| 1679 |
{ |
| 1680 |
emit_move_insn (stack_pointer_rtx, |
| 1681 |
gen_rtx_MINUS (Pmode, stack_pointer_rtx, operands[1])); |
| 1682 |
emit_insn (gen_set_softstack (Pmode, stack_pointer_rtx)); |
| 1683 |
emit_move_insn (operands[0], virtual_stack_dynamic_rtx); |
| 1684 |
} |
| 1685 |
else |
| 1686 |
gcc_unreachable (); |
| 1687 |
DONE; |
| 1688 |
}) |
| 1689 |
|
| 1690 |
(define_insn "@nvptx_alloca_<mode>" |
| 1691 |
[(set (match_operand:P 0 "nvptx_register_operand" "=R") |
| 1692 |
(unspec:P [(match_operand:P 1 "nvptx_nonmemory_operand" "Ri")] |
| 1693 |
UNSPEC_ALLOCA))] |
| 1694 |
"" |
| 1695 |
{ |
| 1696 |
if (TARGET_PTX_7_3 |
| 1697 |
&& TARGET_SM52) |
| 1698 |
{ |
| 1699 |
/* Convert the address from '.local' state space to generic. That way, |
| 1700 |
we don't have to use 'st.local', 'ld.local', and can easily pass the |
| 1701 |
address to other "generic functions". |
| 1702 |
TODO 'gcc.target/nvptx/alloca-5.c' */ |
| 1703 |
output_asm_insn ("{", NULL); |
| 1704 |
output_asm_insn ("\\t.reg%t0\\t%0_local;", operands); |
| 1705 |
output_asm_insn ("\\talloca%u0\\t%0_local, %1;", operands); |
| 1706 |
output_asm_insn ("\\tcvta.local%u0\\t%0, %0_local;", operands); |
| 1707 |
output_asm_insn ("}", NULL); |
| 1708 |
return ""; |
| 1709 |
} |
| 1710 |
else if (nvptx_fake_ptx_alloca) |
| 1711 |
return nvptx_output_fake_ptx_alloca (); |
| 1712 |
else |
| 1713 |
{ |
| 1714 |
sorry_at (INSN_LOCATION (insn), |
| 1715 |
"dynamic stack allocation not supported"); |
| 1716 |
return ""; |
| 1717 |
} |
| 1718 |
} |
| 1719 |
[(set_attr "predicable" "no")]) |
| 1720 |
|
| 1721 |
(define_insn "@set_softstack_<mode>" |
| 1722 |
[(unspec [(match_operand:P 0 "nvptx_register_operand" "R")] |
| 1723 |
UNSPEC_SET_SOFTSTACK)] |
| 1724 |
"TARGET_SOFT_STACK" |
| 1725 |
{ |
| 1726 |
return nvptx_output_set_softstack (REGNO (operands[0])); |
| 1727 |
}) |
| 1728 |
|
| 1729 |
(define_expand "save_stack_block" |
| 1730 |
[(match_operand 0 "register_operand" "") |
| 1731 |
(match_operand 1 "register_operand" "")] |
| 1732 |
"!TARGET_SOFT_STACK" |
| 1733 |
{ |
| 1734 |
if (TARGET_PTX_7_3 |
| 1735 |
&& TARGET_SM52) |
| 1736 |
{ |
| 1737 |
gcc_checking_assert (REG_P (operands[0])); |
| 1738 |
emit_insn (gen_nvptx_stacksave (Pmode, operands[0], operands[1])); |
| 1739 |
} |
| 1740 |
/* We don't bother to special-case '-mfake-ptx-alloca' here. */ |
| 1741 |
else |
| 1742 |
{ |
| 1743 |
/* The concept of a '%stack' pointer doesn't apply like this. |
| 1744 |
GCC however occasionally synthesizes '__builtin_stack_save ()', |
| 1745 |
'__builtin_stack_restore ()', and isn't able to optimize them all |
| 1746 |
away. Just submit a dummy -- user code shouldn't be able to observe |
| 1747 |
this. */ |
| 1748 |
emit_move_insn (operands[0], GEN_INT (0xdeadbeef)); |
| 1749 |
} |
| 1750 |
DONE; |
| 1751 |
}) |
| 1752 |
|
| 1753 |
(define_insn "@nvptx_stacksave_<mode>" |
| 1754 |
[(set (match_operand:P 0 "nvptx_register_operand" "=R") |
| 1755 |
(unspec:P [(match_operand:P 1 "register_operand" "R")] |
| 1756 |
UNSPEC_STACKSAVE))] |
| 1757 |
"TARGET_PTX_7_3 |
| 1758 |
&& TARGET_SM52" |
| 1759 |
"%.\\tstacksave%u0\\t%0;") |
| 1760 |
|
| 1761 |
(define_expand "restore_stack_block" |
| 1762 |
[(match_operand 0 "register_operand" "") |
| 1763 |
(match_operand 1 "register_operand" "")] |
| 1764 |
"" |
| 1765 |
{ |
| 1766 |
if (!TARGET_SOFT_STACK |
| 1767 |
&& TARGET_PTX_7_3 |
| 1768 |
&& TARGET_SM52) |
| 1769 |
{ |
| 1770 |
operands[1] = force_reg (Pmode, operands[1]); |
| 1771 |
emit_insn (gen_nvptx_stackrestore (Pmode, operands[0], operands[1])); |
| 1772 |
} |
| 1773 |
/* We don't bother to special-case '-mfake-ptx-alloca' here. */ |
| 1774 |
else if (!TARGET_SOFT_STACK) |
| 1775 |
; /* See 'save_stack_block'. */ |
| 1776 |
else if (TARGET_SOFT_STACK) |
| 1777 |
{ |
| 1778 |
emit_move_insn (operands[0], operands[1]); |
| 1779 |
emit_insn (gen_set_softstack (Pmode, operands[0])); |
| 1780 |
} |
| 1781 |
else |
| 1782 |
gcc_unreachable (); |
| 1783 |
DONE; |
| 1784 |
}) |
| 1785 |
|
| 1786 |
(define_insn "@nvptx_stackrestore_<mode>" |
| 1787 |
[(set (match_operand:P 0 "nvptx_register_operand" "=R") |
| 1788 |
(unspec:P [(match_operand:P 1 "nvptx_register_operand" "R")] |
| 1789 |
UNSPEC_STACKRESTORE))] |
| 1790 |
"TARGET_PTX_7_3 |
| 1791 |
&& TARGET_SM52" |
| 1792 |
"%.\\tstackrestore%u1\\t%1;") |
| 1793 |
|
| 1794 |
(define_expand "save_stack_function" |
| 1795 |
[(match_operand 0 "register_operand" "") |
| 1796 |
(match_operand 1 "register_operand" "")] |
| 1797 |
"!TARGET_SOFT_STACK" |
| 1798 |
{ |
| 1799 |
/* See 'STACK_SAVEAREA_MODE'. */ |
| 1800 |
gcc_checking_assert (operands[0] == 0); |
| 1801 |
DONE; |
| 1802 |
}) |
| 1803 |
|
| 1804 |
(define_expand "restore_stack_function" |
| 1805 |
[(match_operand 0 "register_operand" "") |
| 1806 |
(match_operand 1 "register_operand" "")] |
| 1807 |
"" |
| 1808 |
{ |
| 1809 |
if (!TARGET_SOFT_STACK) |
| 1810 |
/* See 'STACK_SAVEAREA_MODE'. */ |
| 1811 |
gcc_checking_assert (operands[1] == 0); |
| 1812 |
DONE; |
| 1813 |
}) |
| 1814 |
|
| 1815 |
(define_insn "trap" |
| 1816 |
[(trap_if (const_int 1) (const_int 0))] |
| 1817 |
"" |
| 1818 |
"trap; exit;") |
| 1819 |
|
| 1820 |
(define_insn "trap_if_true" |
| 1821 |
[(trap_if (ne (match_operand:BI 0 "nvptx_register_operand" "R") |
| 1822 |
(const_int 0)) |
| 1823 |
(const_int 0))] |
| 1824 |
"" |
| 1825 |
"%j0 trap; %j0 exit;" |
| 1826 |
[(set_attr "predicable" "no")]) |
| 1827 |
|
| 1828 |
(define_insn "trap_if_false" |
| 1829 |
[(trap_if (eq (match_operand:BI 0 "nvptx_register_operand" "R") |
| 1830 |
(const_int 0)) |
| 1831 |
(const_int 0))] |
| 1832 |
"" |
| 1833 |
"%J0 trap; %J0 exit;" |
| 1834 |
[(set_attr "predicable" "no")]) |
| 1835 |
|
| 1836 |
(define_expand "ctrap<mode>4" |
| 1837 |
[(trap_if (match_operator 0 "nvptx_comparison_operator" |
| 1838 |
[(match_operand:SDIM 1 "nvptx_register_operand") |
| 1839 |
(match_operand:SDIM 2 "nvptx_nonmemory_operand")]) |
| 1840 |
(match_operand 3 "const0_operand"))] |
| 1841 |
"" |
| 1842 |
{ |
| 1843 |
rtx t = nvptx_expand_compare (operands[0]); |
| 1844 |
emit_insn (gen_trap_if_true (t)); |
| 1845 |
DONE; |
| 1846 |
}) |
| 1847 |
|
| 1848 |
(define_insn "oacc_dim_size" |
| 1849 |
[(set (match_operand:SI 0 "nvptx_register_operand" "") |
| 1850 |
(unspec:SI [(match_operand:SI 1 "const_int_operand" "")] |
| 1851 |
UNSPEC_DIM_SIZE))] |
| 1852 |
"" |
| 1853 |
{ |
| 1854 |
static const char *const asms[] = |
| 1855 |
{ /* Must match oacc_loop_levels ordering. */ |
| 1856 |
"%.\\tmov.u32\\t%0, %%nctaid.x;", /* gang */ |
| 1857 |
"%.\\tmov.u32\\t%0, %%ntid.y;", /* worker */ |
| 1858 |
"%.\\tmov.u32\\t%0, %%ntid.x;", /* vector */ |
| 1859 |
}; |
| 1860 |
return asms[INTVAL (operands[1])]; |
| 1861 |
}) |
| 1862 |
|
| 1863 |
(define_insn "oacc_dim_pos" |
| 1864 |
[(set (match_operand:SI 0 "nvptx_register_operand" "") |
| 1865 |
(unspec_volatile:SI [(match_operand:SI 1 "const_int_operand" "")] |
| 1866 |
UNSPECV_DIM_POS))] |
| 1867 |
"" |
| 1868 |
{ |
| 1869 |
static const char *const asms[] = |
| 1870 |
{ /* Must match oacc_loop_levels ordering. */ |
| 1871 |
"%.\\tmov.u32\\t%0, %%ctaid.x;", /* gang */ |
| 1872 |
"%.\\tmov.u32\\t%0, %%tid.y;", /* worker */ |
| 1873 |
"%.\\tmov.u32\\t%0, %%tid.x;", /* vector */ |
| 1874 |
}; |
| 1875 |
return asms[INTVAL (operands[1])]; |
| 1876 |
}) |
| 1877 |
|
| 1878 |
(define_insn "nvptx_fork" |
| 1879 |
[(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")] |
| 1880 |
UNSPECV_FORK)] |
| 1881 |
"" |
| 1882 |
"// fork %0;" |
| 1883 |
[(set_attr "predicable" "no")]) |
| 1884 |
|
| 1885 |
(define_insn "nvptx_forked" |
| 1886 |
[(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")] |
| 1887 |
UNSPECV_FORKED)] |
| 1888 |
"" |
| 1889 |
"// forked %0;" |
| 1890 |
[(set_attr "predicable" "no")]) |
| 1891 |
|
| 1892 |
(define_insn "nvptx_joining" |
| 1893 |
[(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")] |
| 1894 |
UNSPECV_JOINING)] |
| 1895 |
"" |
| 1896 |
"// joining %0;" |
| 1897 |
[(set_attr "predicable" "no")]) |
| 1898 |
|
| 1899 |
(define_insn "nvptx_join" |
| 1900 |
[(unspec_volatile:SI [(match_operand:SI 0 "const_int_operand" "")] |
| 1901 |
UNSPECV_JOIN)] |
| 1902 |
"" |
| 1903 |
"// join %0;" |
| 1904 |
[(set_attr "predicable" "no")]) |
| 1905 |
|
| 1906 |
(define_expand "oacc_fork" |
| 1907 |
[(set (match_operand:SI 0 "nvptx_nonmemory_operand" "") |
| 1908 |
(match_operand:SI 1 "general_operand" "")) |
| 1909 |
(unspec_volatile:SI [(match_operand:SI 2 "const_int_operand" "")] |
| 1910 |
UNSPECV_FORKED)] |
| 1911 |
"" |
| 1912 |
{ |
| 1913 |
if (operands[0] != const0_rtx) |
| 1914 |
emit_move_insn (operands[0], operands[1]); |
| 1915 |
nvptx_expand_oacc_fork (INTVAL (operands[2])); |
| 1916 |
DONE; |
| 1917 |
}) |
| 1918 |
|
| 1919 |
(define_expand "oacc_join" |
| 1920 |
[(set (match_operand:SI 0 "nvptx_nonmemory_operand" "") |
| 1921 |
(match_operand:SI 1 "general_operand" "")) |
| 1922 |
(unspec_volatile:SI [(match_operand:SI 2 "const_int_operand" "")] |
| 1923 |
UNSPECV_JOIN)] |
| 1924 |
"" |
| 1925 |
{ |
| 1926 |
if (operands[0] != const0_rtx) |
| 1927 |
emit_move_insn (operands[0], operands[1]); |
| 1928 |
nvptx_expand_oacc_join (INTVAL (operands[2])); |
| 1929 |
DONE; |
| 1930 |
}) |
| 1931 |
|
| 1932 |
;; only 32-bit shuffles exist. |
| 1933 |
(define_insn "nvptx_shuffle<mode>" |
| 1934 |
[(set (match_operand:BITS 0 "nvptx_register_operand" "=R") |
| 1935 |
(unspec:BITS |
| 1936 |
[(match_operand:BITS 1 "nvptx_register_operand" "R") |
| 1937 |
(match_operand:SI 2 "nvptx_nonmemory_operand" "Ri") |
| 1938 |
(match_operand:SI 3 "const_int_operand" "n")] |
| 1939 |
UNSPEC_SHUFFLE))] |
| 1940 |
"" |
| 1941 |
{ |
| 1942 |
if (TARGET_PTX_6_0) |
| 1943 |
return "%.\\tshfl.sync%S3.b32\\t%0, %1, %2, 31, 0xffffffff;"; |
| 1944 |
else |
| 1945 |
return "%.\\tshfl%S3.b32\\t%0, %1, %2, 31;"; |
| 1946 |
}) |
| 1947 |
|
| 1948 |
(define_insn "nvptx_vote_ballot" |
| 1949 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 1950 |
(unspec:SI [(match_operand:BI 1 "nvptx_register_operand" "R")] |
| 1951 |
UNSPEC_VOTE_BALLOT))] |
| 1952 |
"" |
| 1953 |
{ |
| 1954 |
if (TARGET_PTX_6_0) |
| 1955 |
return "%.\\tvote.sync.ballot.b32\\t%0, %1, 0xffffffff;"; |
| 1956 |
else |
| 1957 |
return "%.\\tvote.ballot.b32\\t%0, %1;"; |
| 1958 |
}) |
| 1959 |
|
| 1960 |
;; Patterns for OpenMP SIMD-via-SIMT lowering |
| 1961 |
|
| 1962 |
(define_insn "@omp_simt_enter_<mode>" |
| 1963 |
[(set (match_operand:P 0 "nvptx_register_operand" "=R") |
| 1964 |
(unspec_volatile:P [(match_operand:P 1 "nvptx_nonmemory_operand" "Ri") |
| 1965 |
(match_operand:P 2 "nvptx_nonmemory_operand" "Ri")] |
| 1966 |
UNSPECV_SIMT_ENTER))] |
| 1967 |
"" |
| 1968 |
{ |
| 1969 |
return nvptx_output_simt_enter (operands[0], operands[1], operands[2]); |
| 1970 |
}) |
| 1971 |
|
| 1972 |
(define_expand "omp_simt_enter" |
| 1973 |
[(match_operand 0 "nvptx_register_operand" "=R") |
| 1974 |
(match_operand 1 "nvptx_nonmemory_operand" "Ri") |
| 1975 |
(match_operand 2 "const_int_operand" "n")] |
| 1976 |
"" |
| 1977 |
{ |
| 1978 |
if (!CONST_INT_P (operands[1])) |
| 1979 |
cfun->machine->simt_stack_size = HOST_WIDE_INT_M1U; |
| 1980 |
else |
| 1981 |
cfun->machine->simt_stack_size = MAX (UINTVAL (operands[1]), |
| 1982 |
cfun->machine->simt_stack_size); |
| 1983 |
cfun->machine->simt_stack_align = MAX (UINTVAL (operands[2]), |
| 1984 |
cfun->machine->simt_stack_align); |
| 1985 |
cfun->machine->has_simtreg = true; |
| 1986 |
emit_insn (gen_omp_simt_enter (Pmode, operands[0], operands[1], operands[2])); |
| 1987 |
DONE; |
| 1988 |
}) |
| 1989 |
|
| 1990 |
(define_expand "omp_simt_exit" |
| 1991 |
[(match_operand 0 "nvptx_register_operand" "R")] |
| 1992 |
"" |
| 1993 |
{ |
| 1994 |
emit_insn (gen_omp_simt_exit (Pmode, operands[0])); |
| 1995 |
if (TARGET_PTX_6_0) |
| 1996 |
emit_insn (gen_nvptx_warpsync ()); |
| 1997 |
else |
| 1998 |
emit_insn (gen_nvptx_uniform_warp_check ()); |
| 1999 |
DONE; |
| 2000 |
}) |
| 2001 |
|
| 2002 |
(define_insn "@omp_simt_exit_<mode>" |
| 2003 |
[(unspec_volatile [(match_operand:P 0 "nvptx_register_operand" "R")] |
| 2004 |
UNSPECV_SIMT_EXIT)] |
| 2005 |
"" |
| 2006 |
{ |
| 2007 |
return nvptx_output_simt_exit (operands[0]); |
| 2008 |
}) |
| 2009 |
|
| 2010 |
;; Implement IFN_GOMP_SIMT_LANE: set operand 0 to lane index |
| 2011 |
(define_insn "omp_simt_lane" |
| 2012 |
[(set (match_operand:SI 0 "nvptx_register_operand" "") |
| 2013 |
(unspec:SI [(const_int 0)] UNSPEC_LANEID))] |
| 2014 |
"" |
| 2015 |
"%.\\tmov.u32\\t%0, %%laneid;") |
| 2016 |
|
| 2017 |
;; Implement IFN_GOMP_SIMT_ORDERED: copy operand 1 to operand 0 and |
| 2018 |
;; place a compiler barrier to disallow unrolling/peeling the containing loop |
| 2019 |
(define_expand "omp_simt_ordered" |
| 2020 |
[(match_operand:SI 0 "nvptx_register_operand" "=R") |
| 2021 |
(match_operand:SI 1 "nvptx_register_operand" "R")] |
| 2022 |
"" |
| 2023 |
{ |
| 2024 |
emit_move_insn (operands[0], operands[1]); |
| 2025 |
emit_insn (gen_nvptx_nounroll ()); |
| 2026 |
DONE; |
| 2027 |
}) |
| 2028 |
|
| 2029 |
;; Implement IFN_GOMP_SIMT_XCHG_BFLY: perform a "butterfly" exchange |
| 2030 |
;; across lanes |
| 2031 |
(define_expand "omp_simt_xchg_bfly" |
| 2032 |
[(match_operand 0 "nvptx_register_or_complex_di_df_register_operand" "=R") |
| 2033 |
(match_operand 1 "nvptx_register_or_complex_di_df_register_operand" "R") |
| 2034 |
(match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")] |
| 2035 |
"" |
| 2036 |
{ |
| 2037 |
emit_insn (nvptx_gen_shuffle (operands[0], operands[1], operands[2], |
| 2038 |
SHUFFLE_BFLY)); |
| 2039 |
DONE; |
| 2040 |
}) |
| 2041 |
|
| 2042 |
;; Implement IFN_GOMP_SIMT_XCHG_IDX: broadcast value in operand 1 |
| 2043 |
;; from lane given by index in operand 2 to operand 0 in all lanes |
| 2044 |
(define_expand "omp_simt_xchg_idx" |
| 2045 |
[(match_operand 0 "nvptx_register_or_complex_di_df_register_operand" "=R") |
| 2046 |
(match_operand 1 "nvptx_register_or_complex_di_df_register_operand" "R") |
| 2047 |
(match_operand:SI 2 "nvptx_nonmemory_operand" "Ri")] |
| 2048 |
"" |
| 2049 |
{ |
| 2050 |
emit_insn (nvptx_gen_shuffle (operands[0], operands[1], operands[2], |
| 2051 |
SHUFFLE_IDX)); |
| 2052 |
DONE; |
| 2053 |
}) |
| 2054 |
|
| 2055 |
;; Implement IFN_GOMP_SIMT_VOTE_ANY: |
| 2056 |
;; set operand 0 to zero iff all lanes supply zero in operand 1 |
| 2057 |
(define_expand "omp_simt_vote_any" |
| 2058 |
[(match_operand:SI 0 "nvptx_register_operand" "=R") |
| 2059 |
(match_operand:SI 1 "nvptx_register_operand" "R")] |
| 2060 |
"" |
| 2061 |
{ |
| 2062 |
rtx pred = gen_reg_rtx (BImode); |
| 2063 |
emit_move_insn (pred, gen_rtx_NE (BImode, operands[1], const0_rtx)); |
| 2064 |
emit_insn (gen_nvptx_vote_ballot (operands[0], pred)); |
| 2065 |
DONE; |
| 2066 |
}) |
| 2067 |
|
| 2068 |
;; Implement IFN_GOMP_SIMT_LAST_LANE: |
| 2069 |
;; set operand 0 to the lowest lane index that passed non-zero in operand 1 |
| 2070 |
(define_expand "omp_simt_last_lane" |
| 2071 |
[(match_operand:SI 0 "nvptx_register_operand" "=R") |
| 2072 |
(match_operand:SI 1 "nvptx_register_operand" "R")] |
| 2073 |
"" |
| 2074 |
{ |
| 2075 |
rtx pred = gen_reg_rtx (BImode); |
| 2076 |
rtx tmp = gen_reg_rtx (SImode); |
| 2077 |
emit_move_insn (pred, gen_rtx_NE (BImode, operands[1], const0_rtx)); |
| 2078 |
emit_insn (gen_nvptx_vote_ballot (tmp, pred)); |
| 2079 |
emit_insn (gen_ctzsi2 (operands[0], tmp)); |
| 2080 |
DONE; |
| 2081 |
}) |
| 2082 |
|
| 2083 |
;; extract parts of a 64 bit object into 2 32-bit ints |
| 2084 |
(define_insn "unpack<mode>si2" |
| 2085 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 2086 |
(unspec:SI [(match_operand:BITD 2 "nvptx_register_operand" "R") |
| 2087 |
(const_int 0)] UNSPEC_BIT_CONV)) |
| 2088 |
(set (match_operand:SI 1 "nvptx_register_operand" "=R") |
| 2089 |
(unspec:SI [(match_dup 2) (const_int 1)] UNSPEC_BIT_CONV))] |
| 2090 |
"" |
| 2091 |
"%.\\tmov.b64\\t{%0,%1}, %2;") |
| 2092 |
|
| 2093 |
;; pack 2 32-bit ints into a 64 bit object |
| 2094 |
(define_insn "packsi<mode>2" |
| 2095 |
[(set (match_operand:BITD 0 "nvptx_register_operand" "=R") |
| 2096 |
(unspec:BITD [(match_operand:SI 1 "nvptx_register_operand" "R") |
| 2097 |
(match_operand:SI 2 "nvptx_register_operand" "R")] |
| 2098 |
UNSPEC_BIT_CONV))] |
| 2099 |
"" |
| 2100 |
"%.\\tmov.b64\\t%0, {%1,%2};") |
| 2101 |
|
| 2102 |
;; Atomic insns. |
| 2103 |
|
| 2104 |
(define_expand "atomic_compare_and_swap<mode>" |
| 2105 |
[(match_operand:SI 0 "nvptx_register_operand") ;; bool success output |
| 2106 |
(match_operand:SDIM 1 "nvptx_register_operand") ;; oldval output |
| 2107 |
(match_operand:SDIM 2 "memory_operand") ;; memory |
| 2108 |
(match_operand:SDIM 3 "nvptx_register_operand") ;; expected input |
| 2109 |
(match_operand:SDIM 4 "nvptx_register_operand") ;; newval input |
| 2110 |
(match_operand:SI 5 "const_int_operand") ;; is_weak |
| 2111 |
(match_operand:SI 6 "const_int_operand") ;; success model |
| 2112 |
(match_operand:SI 7 "const_int_operand")] ;; failure model |
| 2113 |
"" |
| 2114 |
{ |
| 2115 |
if (nvptx_mem_local_p (operands[2])) |
| 2116 |
emit_insn (gen_atomic_compare_and_swap<mode>_1_local |
| 2117 |
(operands[1], operands[2], operands[3], operands[4], |
| 2118 |
operands[6])); |
| 2119 |
else |
| 2120 |
emit_insn (gen_atomic_compare_and_swap<mode>_1 |
| 2121 |
(operands[1], operands[2], operands[3], operands[4], |
| 2122 |
operands[6])); |
| 2123 |
|
| 2124 |
rtx cond = gen_reg_rtx (BImode); |
| 2125 |
emit_move_insn (cond, gen_rtx_EQ (BImode, operands[1], operands[3])); |
| 2126 |
emit_insn (gen_sel_truesi (operands[0], cond, GEN_INT (1), GEN_INT (0))); |
| 2127 |
DONE; |
| 2128 |
}) |
| 2129 |
|
| 2130 |
(define_insn "atomic_compare_and_swap<mode>_1_local" |
| 2131 |
[(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") |
| 2132 |
(unspec_volatile:SDIM |
| 2133 |
[(match_operand:SDIM 1 "memory_operand" "+m") |
| 2134 |
(match_operand:SDIM 2 "nvptx_nonmemory_operand" "Ri") |
| 2135 |
(match_operand:SDIM 3 "nvptx_nonmemory_operand" "Ri") |
| 2136 |
(match_operand:SI 4 "const_int_operand")] |
| 2137 |
UNSPECV_CAS_LOCAL)) |
| 2138 |
(set (match_dup 1) |
| 2139 |
(unspec_volatile:SDIM [(const_int 0)] UNSPECV_CAS_LOCAL))] |
| 2140 |
"" |
| 2141 |
{ |
| 2142 |
output_asm_insn ("{", NULL); |
| 2143 |
output_asm_insn ("\\t" ".reg.pred" "\\t" "%%eq_p;", NULL); |
| 2144 |
output_asm_insn ("\\t" ".reg%t0" "\\t" "%%val;", operands); |
| 2145 |
output_asm_insn ("\\t" "ld%A1%t0" "\\t" "%%val,%1;", operands); |
| 2146 |
output_asm_insn ("\\t" "setp.eq%t0" "\\t" "%%eq_p, %%val, %2;", |
| 2147 |
operands); |
| 2148 |
output_asm_insn ("@%%eq_p\\t" "st%A1%t0" "\\t" "%1,%3;", operands); |
| 2149 |
output_asm_insn ("\\t" "mov%t0" "\\t" "%0,%%val;", operands); |
| 2150 |
output_asm_insn ("}", NULL); |
| 2151 |
return ""; |
| 2152 |
} |
| 2153 |
[(set_attr "predicable" "no")]) |
| 2154 |
|
| 2155 |
(define_insn "atomic_compare_and_swap<mode>_1" |
| 2156 |
[(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") |
| 2157 |
(unspec_volatile:SDIM |
| 2158 |
[(match_operand:SDIM 1 "memory_operand" "+m") |
| 2159 |
(match_operand:SDIM 2 "nvptx_nonmemory_operand" "Ri") |
| 2160 |
(match_operand:SDIM 3 "nvptx_nonmemory_operand" "Ri") |
| 2161 |
(match_operand:SI 4 "const_int_operand")] |
| 2162 |
UNSPECV_CAS)) |
| 2163 |
(set (match_dup 1) |
| 2164 |
(unspec_volatile:SDIM [(const_int 0)] UNSPECV_CAS))] |
| 2165 |
"" |
| 2166 |
{ |
| 2167 |
const char *t |
| 2168 |
= "%.\\tatom%A1.cas.b%T0\\t%x0, %1, %2, %3;"; |
| 2169 |
return nvptx_output_atomic_insn (t, operands, 1, 4); |
| 2170 |
} |
| 2171 |
[(set_attr "atomic" "true")]) |
| 2172 |
|
| 2173 |
(define_insn "atomic_exchange<mode>" |
| 2174 |
[(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") ;; output |
| 2175 |
(unspec_volatile:SDIM |
| 2176 |
[(match_operand:SDIM 1 "memory_operand" "+m") ;; memory |
| 2177 |
(match_operand:SI 3 "const_int_operand")] ;; model |
| 2178 |
UNSPECV_XCHG)) |
| 2179 |
(set (match_dup 1) |
| 2180 |
(match_operand:SDIM 2 "nvptx_nonmemory_operand" "Ri"))] ;; input |
| 2181 |
"" |
| 2182 |
{ |
| 2183 |
if (nvptx_mem_local_p (operands[1])) |
| 2184 |
{ |
| 2185 |
output_asm_insn ("{", NULL); |
| 2186 |
output_asm_insn ("\\t" ".reg%t0" "\\t" "%%val;", operands); |
| 2187 |
output_asm_insn ("%.\\t" "ld%A1%t0" "\\t" "%%val,%1;", operands); |
| 2188 |
output_asm_insn ("%.\\t" "st%A1%t0" "\\t" "%1,%2;", operands); |
| 2189 |
output_asm_insn ("%.\\t" "mov%t0" "\\t" "%0,%%val;", operands); |
| 2190 |
output_asm_insn ("}", NULL); |
| 2191 |
return ""; |
| 2192 |
} |
| 2193 |
const char *t |
| 2194 |
= "%.\tatom%A1.exch.b%T0\t%x0, %1, %2;"; |
| 2195 |
return nvptx_output_atomic_insn (t, operands, 1, 3); |
| 2196 |
} |
| 2197 |
[(set_attr "atomic" "true")]) |
| 2198 |
|
| 2199 |
(define_expand "atomic_store<mode>" |
| 2200 |
[(match_operand:SDIM 0 "memory_operand" "=m") ;; memory |
| 2201 |
(match_operand:SDIM 1 "nvptx_nonmemory_operand" "Ri") ;; input |
| 2202 |
(match_operand:SI 2 "const_int_operand")] ;; model |
| 2203 |
"" |
| 2204 |
{ |
| 2205 |
struct address_info info; |
| 2206 |
decompose_mem_address (&info, operands[0]); |
| 2207 |
if (info.base != NULL && REG_P (*info.base) |
| 2208 |
&& REGNO_PTR_FRAME_P (REGNO (*info.base))) |
| 2209 |
{ |
| 2210 |
emit_insn (gen_mov<mode> (operands[0], operands[1])); |
| 2211 |
DONE; |
| 2212 |
} |
| 2213 |
|
| 2214 |
if (TARGET_SM70) |
| 2215 |
{ |
| 2216 |
emit_insn (gen_nvptx_atomic_store_sm70<mode> (operands[0], operands[1], |
| 2217 |
operands[2])); |
| 2218 |
DONE; |
| 2219 |
} |
| 2220 |
|
| 2221 |
bool maybe_shared_p = nvptx_mem_maybe_shared_p (operands[0]); |
| 2222 |
if (!maybe_shared_p) |
| 2223 |
/* Fall back to expand_atomic_store. */ |
| 2224 |
FAIL; |
| 2225 |
|
| 2226 |
emit_insn (gen_nvptx_atomic_store<mode> (operands[0], operands[1], |
| 2227 |
operands[2])); |
| 2228 |
DONE; |
| 2229 |
}) |
| 2230 |
|
| 2231 |
(define_insn "nvptx_atomic_store_sm70<mode>" |
| 2232 |
[(set (match_operand:SDIM 0 "memory_operand" "+m") ;; memory |
| 2233 |
(unspec_volatile:SDIM |
| 2234 |
[(match_operand:SDIM 1 "nvptx_nonmemory_operand" "Ri") ;; input |
| 2235 |
(match_operand:SI 2 "const_int_operand")] ;; model |
| 2236 |
UNSPECV_ST))] |
| 2237 |
"TARGET_SM70" |
| 2238 |
{ |
| 2239 |
const char *t |
| 2240 |
= "%.\tst%A0.b%T0\t%0, %1;"; |
| 2241 |
return nvptx_output_atomic_insn (t, operands, 0, 2); |
| 2242 |
} |
| 2243 |
[(set_attr "atomic" "false")]) ;; Note: st is not an atomic insn. |
| 2244 |
|
| 2245 |
(define_insn "nvptx_atomic_store<mode>" |
| 2246 |
[(set (match_operand:SDIM 0 "memory_operand" "+m") ;; memory |
| 2247 |
(unspec_volatile:SDIM |
| 2248 |
[(match_operand:SDIM 1 "nvptx_nonmemory_operand" "Ri") ;; input |
| 2249 |
(match_operand:SI 2 "const_int_operand")] ;; model |
| 2250 |
UNSPECV_ST))] |
| 2251 |
"!TARGET_SM70" |
| 2252 |
{ |
| 2253 |
const char *t |
| 2254 |
= "%.\tatom%A0.exch.b%T0\t_, %0, %1;"; |
| 2255 |
return nvptx_output_atomic_insn (t, operands, 0, 2); |
| 2256 |
} |
| 2257 |
[(set_attr "atomic" "true")]) |
| 2258 |
|
| 2259 |
(define_insn "atomic_fetch_add<mode>" |
| 2260 |
[(set (match_operand:SDIM 1 "memory_operand" "+m") |
| 2261 |
(unspec_volatile:SDIM |
| 2262 |
[(plus:SDIM (match_dup 1) |
| 2263 |
(match_operand:SDIM 2 "nvptx_nonmemory_operand" "Ri")) |
| 2264 |
(match_operand:SI 3 "const_int_operand")] ;; model |
| 2265 |
UNSPECV_LOCK)) |
| 2266 |
(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") |
| 2267 |
(match_dup 1))] |
| 2268 |
"" |
| 2269 |
{ |
| 2270 |
if (nvptx_mem_local_p (operands[1])) |
| 2271 |
{ |
| 2272 |
output_asm_insn ("{", NULL); |
| 2273 |
output_asm_insn ("\\t" ".reg%t0" "\\t" "%%val;", operands); |
| 2274 |
output_asm_insn ("\\t" ".reg%t0" "\\t" "%%update;", operands); |
| 2275 |
output_asm_insn ("%.\\t" "ld%A1%t0" "\\t" "%%val,%1;", operands); |
| 2276 |
output_asm_insn ("%.\\t" "add%t0" "\\t" "%%update,%%val,%2;", |
| 2277 |
operands); |
| 2278 |
output_asm_insn ("%.\\t" "st%A1%t0" "\\t" "%1,%%update;", operands); |
| 2279 |
output_asm_insn ("%.\\t" "mov%t0" "\\t" "%0,%%val;", operands); |
| 2280 |
output_asm_insn ("}", NULL); |
| 2281 |
return ""; |
| 2282 |
} |
| 2283 |
const char *t |
| 2284 |
= "%.\\tatom%A1.add%t0\\t%x0, %1, %2;"; |
| 2285 |
return nvptx_output_atomic_insn (t, operands, 1, 3); |
| 2286 |
} |
| 2287 |
[(set_attr "atomic" "true")]) |
| 2288 |
|
| 2289 |
(define_insn "atomic_fetch_addsf" |
| 2290 |
[(set (match_operand:SF 1 "memory_operand" "+m") |
| 2291 |
(unspec_volatile:SF |
| 2292 |
[(plus:SF (match_dup 1) |
| 2293 |
(match_operand:SF 2 "nvptx_nonmemory_operand" "RF")) |
| 2294 |
(match_operand:SI 3 "const_int_operand")] ;; model |
| 2295 |
UNSPECV_LOCK)) |
| 2296 |
(set (match_operand:SF 0 "nvptx_register_operand" "=R") |
| 2297 |
(match_dup 1))] |
| 2298 |
"" |
| 2299 |
{ |
| 2300 |
if (nvptx_mem_local_p (operands[1])) |
| 2301 |
{ |
| 2302 |
output_asm_insn ("{", NULL); |
| 2303 |
output_asm_insn ("\\t" ".reg%t0" "\\t" "%%val;", operands); |
| 2304 |
output_asm_insn ("\\t" ".reg%t0" "\\t" "%%update;", operands); |
| 2305 |
output_asm_insn ("%.\\t" "ld%A1%t0" "\\t" "%%val,%1;", operands); |
| 2306 |
output_asm_insn ("%.\\t" "add%t0" "\\t" "%%update,%%val,%2;", |
| 2307 |
operands); |
| 2308 |
output_asm_insn ("%.\\t" "st%A1%t0" "\\t" "%1,%%update;", operands); |
| 2309 |
output_asm_insn ("%.\\t" "mov%t0" "\\t" "%0,%%val;", operands); |
| 2310 |
output_asm_insn ("}", NULL); |
| 2311 |
return ""; |
| 2312 |
} |
| 2313 |
const char *t |
| 2314 |
= "%.\\tatom%A1.add%t0\\t%x0, %1, %2;"; |
| 2315 |
return nvptx_output_atomic_insn (t, operands, 1, 3); |
| 2316 |
} |
| 2317 |
[(set_attr "atomic" "true")]) |
| 2318 |
|
| 2319 |
(define_insn "atomic_fetch_<logic><mode>" |
| 2320 |
[(set (match_operand:SDIM 1 "memory_operand" "+m") |
| 2321 |
(unspec_volatile:SDIM |
| 2322 |
[(any_logic:SDIM (match_dup 1) |
| 2323 |
(match_operand:SDIM 2 "nvptx_nonmemory_operand" "Ri")) |
| 2324 |
(match_operand:SI 3 "const_int_operand")] ;; model |
| 2325 |
UNSPECV_LOCK)) |
| 2326 |
(set (match_operand:SDIM 0 "nvptx_register_operand" "=R") |
| 2327 |
(match_dup 1))] |
| 2328 |
"<MODE>mode == SImode || TARGET_SM35" |
| 2329 |
{ |
| 2330 |
if (nvptx_mem_local_p (operands[1])) |
| 2331 |
{ |
| 2332 |
output_asm_insn ("{", NULL); |
| 2333 |
output_asm_insn ("\\t" ".reg.b%T0" "\\t" "%%val;", operands); |
| 2334 |
output_asm_insn ("\\t" ".reg.b%T0" "\\t" "%%update;", operands); |
| 2335 |
output_asm_insn ("%.\\t" "ld%A1%t0" "\\t" "%%val,%1;", operands); |
| 2336 |
output_asm_insn ("%.\\t" "<logic>.b%T0" "\\t" "%%update,%%val,%2;", |
| 2337 |
operands); |
| 2338 |
output_asm_insn ("%.\\t" "st%A1%t0" "\\t" "%1,%%update;", operands); |
| 2339 |
output_asm_insn ("%.\\t" "mov%t0" "\\t" "%0,%%val;", operands); |
| 2340 |
output_asm_insn ("}", NULL); |
| 2341 |
return ""; |
| 2342 |
} |
| 2343 |
const char *t |
| 2344 |
= "%.\\tatom%A1.<logic>.b%T0\\t%x0, %1, %2;"; |
| 2345 |
return nvptx_output_atomic_insn (t, operands, 1, 3); |
| 2346 |
} |
| 2347 |
|
| 2348 |
[(set_attr "atomic" "true")]) |
| 2349 |
|
| 2350 |
(define_expand "atomic_test_and_set" |
| 2351 |
[(match_operand:SI 0 "nvptx_register_operand") ;; bool success output |
| 2352 |
(match_operand:QI 1 "memory_operand") ;; memory |
| 2353 |
(match_operand:SI 2 "const_int_operand")] ;; model |
| 2354 |
"" |
| 2355 |
{ |
| 2356 |
rtx libfunc; |
| 2357 |
rtx addr; |
| 2358 |
libfunc = init_one_libfunc ("__atomic_test_and_set_1"); |
| 2359 |
addr = convert_memory_address (ptr_mode, XEXP (operands[1], 0)); |
| 2360 |
emit_library_call_value (libfunc, operands[0], LCT_NORMAL, SImode, |
| 2361 |
addr, ptr_mode, |
| 2362 |
operands[2], SImode); |
| 2363 |
DONE; |
| 2364 |
}) |
| 2365 |
|
| 2366 |
(define_insn "nvptx_barsync" |
| 2367 |
[(unspec_volatile [(match_operand:SI 0 "nvptx_nonmemory_operand" "Ri") |
| 2368 |
(match_operand:SI 1 "const_int_operand")] |
| 2369 |
UNSPECV_BARSYNC)] |
| 2370 |
"" |
| 2371 |
{ |
| 2372 |
if (INTVAL (operands[1]) == 0) |
| 2373 |
return (TARGET_PTX_6_0 |
| 2374 |
? "\\tbarrier.sync.aligned\\t%0;" |
| 2375 |
: "\\tbar.sync\\t%0;"); |
| 2376 |
else |
| 2377 |
return (TARGET_PTX_6_0 |
| 2378 |
? "\\tbarrier.sync\\t%0, %1;" |
| 2379 |
: "\\tbar.sync\\t%0, %1;"); |
| 2380 |
} |
| 2381 |
[(set_attr "predicable" "no")]) |
| 2382 |
|
| 2383 |
(define_insn "nvptx_warpsync" |
| 2384 |
[(unspec_volatile [(const_int 0)] UNSPECV_WARPSYNC)] |
| 2385 |
"TARGET_PTX_6_0" |
| 2386 |
"%.\\tbar.warp.sync\\t0xffffffff;") |
| 2387 |
|
| 2388 |
(define_int_iterator BARRED |
| 2389 |
[UNSPECV_BARRED_AND |
| 2390 |
UNSPECV_BARRED_OR |
| 2391 |
UNSPECV_BARRED_POPC]) |
| 2392 |
(define_int_attr barred_op |
| 2393 |
[(UNSPECV_BARRED_AND "and") |
| 2394 |
(UNSPECV_BARRED_OR "or") |
| 2395 |
(UNSPECV_BARRED_POPC "popc")]) |
| 2396 |
(define_int_attr barred_mode |
| 2397 |
[(UNSPECV_BARRED_AND "BI") |
| 2398 |
(UNSPECV_BARRED_OR "BI") |
| 2399 |
(UNSPECV_BARRED_POPC "SI")]) |
| 2400 |
(define_int_attr barred_ptxtype |
| 2401 |
[(UNSPECV_BARRED_AND "pred") |
| 2402 |
(UNSPECV_BARRED_OR "pred") |
| 2403 |
(UNSPECV_BARRED_POPC "u32")]) |
| 2404 |
|
| 2405 |
(define_insn "nvptx_barred_<barred_op>" |
| 2406 |
[(set (match_operand:<barred_mode> 0 "nvptx_register_operand" "=R") |
| 2407 |
(unspec_volatile |
| 2408 |
[(match_operand:SI 1 "nvptx_nonmemory_operand" "Ri") |
| 2409 |
(match_operand:SI 2 "nvptx_nonmemory_operand" "Ri") |
| 2410 |
(match_operand:SI 3 "const_int_operand" "i") |
| 2411 |
(match_operand:BI 4 "nvptx_register_operand" "R")] |
| 2412 |
BARRED))] |
| 2413 |
"" |
| 2414 |
"\\tbar.red.<barred_op>.<barred_ptxtype> \\t%0, %1, %2, %p3%4;";" |
| 2415 |
[(set_attr "predicable" "no")]) |
| 2416 |
|
| 2417 |
(define_insn "nvptx_uniform_warp_check" |
| 2418 |
[(unspec_volatile [(const_int 0)] UNSPECV_UNIFORM_WARP_CHECK)] |
| 2419 |
"" |
| 2420 |
{ |
| 2421 |
const char *insns[] = { |
| 2422 |
"{", |
| 2423 |
"\\t" ".reg.pred" "\\t" "%%r_sync;", |
| 2424 |
"\\t" "mov.pred" "\\t" "%%r_sync, 1;", |
| 2425 |
"%.\\t" "vote.all.pred" "\\t" "%%r_sync, 1;", |
| 2426 |
"@!%%r_sync\\t" "trap;", |
| 2427 |
"@!%%r_sync\\t" "exit;", |
| 2428 |
"}", |
| 2429 |
NULL |
| 2430 |
}; |
| 2431 |
for (const char **p = &insns[0]; *p != NULL; p++) |
| 2432 |
output_asm_insn (*p, NULL); |
| 2433 |
return ""; |
| 2434 |
}) |
| 2435 |
|
| 2436 |
(define_expand "memory_barrier" |
| 2437 |
[(set (match_dup 0) |
| 2438 |
(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR))] |
| 2439 |
"" |
| 2440 |
{ |
| 2441 |
operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode)); |
| 2442 |
MEM_VOLATILE_P (operands[0]) = 1; |
| 2443 |
}) |
| 2444 |
|
| 2445 |
;; Ptx defines the memory barriers membar.cta, membar.gl and membar.sys |
| 2446 |
;; (corresponding to cuda functions threadfence_block, threadfence and |
| 2447 |
;; threadfence_system). For the insn memory_barrier we use membar.sys. This |
| 2448 |
;; may be overconservative, but before using membar.gl instead we'll need to |
| 2449 |
;; explain in detail why it's safe to use. For now, use membar.sys. |
| 2450 |
(define_insn "*memory_barrier" |
| 2451 |
[(set (match_operand:BLK 0 "" "") |
| 2452 |
(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR))] |
| 2453 |
"" |
| 2454 |
"\\tmembar.sys;" |
| 2455 |
[(set_attr "predicable" "no")]) |
| 2456 |
|
| 2457 |
(define_expand "nvptx_membar_cta" |
| 2458 |
[(set (match_dup 0) |
| 2459 |
(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR_CTA))] |
| 2460 |
"" |
| 2461 |
{ |
| 2462 |
operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode)); |
| 2463 |
MEM_VOLATILE_P (operands[0]) = 1; |
| 2464 |
}) |
| 2465 |
|
| 2466 |
(define_insn "*nvptx_membar_cta" |
| 2467 |
[(set (match_operand:BLK 0 "" "") |
| 2468 |
(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR_CTA))] |
| 2469 |
"" |
| 2470 |
"\\tmembar.cta;" |
| 2471 |
[(set_attr "predicable" "no")]) |
| 2472 |
|
| 2473 |
(define_expand "nvptx_membar_gl" |
| 2474 |
[(set (match_dup 0) |
| 2475 |
(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR_GL))] |
| 2476 |
"" |
| 2477 |
{ |
| 2478 |
operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode)); |
| 2479 |
MEM_VOLATILE_P (operands[0]) = 1; |
| 2480 |
}) |
| 2481 |
|
| 2482 |
(define_insn "*nvptx_membar_gl" |
| 2483 |
[(set (match_operand:BLK 0 "" "") |
| 2484 |
(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR_GL))] |
| 2485 |
"" |
| 2486 |
"\\tmembar.gl;" |
| 2487 |
[(set_attr "predicable" "no")]) |
| 2488 |
|
| 2489 |
(define_insn "nvptx_nounroll" |
| 2490 |
[(unspec_volatile [(const_int 0)] UNSPECV_NOUNROLL)] |
| 2491 |
"" |
| 2492 |
"\\t.pragma \\\"nounroll\\\";" |
| 2493 |
[(set_attr "predicable" "no")]) |
| 2494 |
|
| 2495 |
(define_insn "nvptx_red_partition" |
| 2496 |
[(set (match_operand:DI 0 "nonimmediate_operand" "=R") |
| 2497 |
(unspec_volatile:DI [(match_operand:DI 1 "const_int_operand")] |
| 2498 |
UNSPECV_RED_PART))] |
| 2499 |
"" |
| 2500 |
{ |
| 2501 |
return nvptx_output_red_partition (operands[0], operands[1]); |
| 2502 |
} |
| 2503 |
[(set_attr "predicable" "no")]) |
| 2504 |
|
| 2505 |
;; Expand QI mode operations using SI mode instructions. |
| 2506 |
(define_code_iterator any_sbinary [plus minus smin smax]) |
| 2507 |
(define_code_attr sbinary [(plus "add") (minus "sub") (smin "smin") (smax "smax")]) |
| 2508 |
|
| 2509 |
(define_code_iterator any_ubinary [and ior xor umin umax]) |
| 2510 |
(define_code_attr ubinary [(and "and") (ior "ior") (xor "xor") (umin "umin") |
| 2511 |
(umax "umax")]) |
| 2512 |
|
| 2513 |
(define_code_iterator any_sunary [neg abs]) |
| 2514 |
(define_code_attr sunary [(neg "neg") (abs "abs")]) |
| 2515 |
|
| 2516 |
(define_code_iterator any_uunary [not]) |
| 2517 |
(define_code_attr uunary [(not "one_cmpl")]) |
| 2518 |
|
| 2519 |
(define_expand "<sbinary>qi3" |
| 2520 |
[(set (match_operand:QI 0 "nvptx_register_operand") |
| 2521 |
(any_sbinary:QI (match_operand:QI 1 "nvptx_nonmemory_operand") |
| 2522 |
(match_operand:QI 2 "nvptx_nonmemory_operand")))] |
| 2523 |
"" |
| 2524 |
{ |
| 2525 |
rtx reg = gen_reg_rtx (SImode); |
| 2526 |
rtx op0 = convert_modes (SImode, QImode, operands[1], 0); |
| 2527 |
rtx op1 = convert_modes (SImode, QImode, operands[2], 0); |
| 2528 |
if (<CODE> == MINUS) |
| 2529 |
op0 = force_reg (SImode, op0); |
| 2530 |
emit_insn (gen_<sbinary>si3 (reg, op0, op1)); |
| 2531 |
emit_insn (gen_truncsiqi2 (operands[0], reg)); |
| 2532 |
DONE; |
| 2533 |
}) |
| 2534 |
|
| 2535 |
(define_expand "<ubinary>qi3" |
| 2536 |
[(set (match_operand:QI 0 "nvptx_register_operand") |
| 2537 |
(any_ubinary:QI (match_operand:QI 1 "nvptx_nonmemory_operand") |
| 2538 |
(match_operand:QI 2 "nvptx_nonmemory_operand")))] |
| 2539 |
"" |
| 2540 |
{ |
| 2541 |
rtx reg = gen_reg_rtx (SImode); |
| 2542 |
rtx op0 = convert_modes (SImode, QImode, operands[1], 1); |
| 2543 |
rtx op1 = convert_modes (SImode, QImode, operands[2], 1); |
| 2544 |
emit_insn (gen_<ubinary>si3 (reg, op0, op1)); |
| 2545 |
emit_insn (gen_truncsiqi2 (operands[0], reg)); |
| 2546 |
DONE; |
| 2547 |
}) |
| 2548 |
|
| 2549 |
(define_expand "<sunary>qi2" |
| 2550 |
[(set (match_operand:QI 0 "nvptx_register_operand") |
| 2551 |
(any_sunary:QI (match_operand:QI 1 "nvptx_nonmemory_operand")))] |
| 2552 |
"" |
| 2553 |
{ |
| 2554 |
rtx reg = gen_reg_rtx (SImode); |
| 2555 |
rtx op0 = convert_modes (SImode, QImode, operands[1], 0); |
| 2556 |
emit_insn (gen_<sunary>si2 (reg, op0)); |
| 2557 |
emit_insn (gen_truncsiqi2 (operands[0], reg)); |
| 2558 |
DONE; |
| 2559 |
}) |
| 2560 |
|
| 2561 |
(define_expand "<uunary>qi2" |
| 2562 |
[(set (match_operand:QI 0 "nvptx_register_operand") |
| 2563 |
(any_uunary:QI (match_operand:QI 1 "nvptx_nonmemory_operand")))] |
| 2564 |
"" |
| 2565 |
{ |
| 2566 |
rtx reg = gen_reg_rtx (SImode); |
| 2567 |
rtx op0 = convert_modes (SImode, QImode, operands[1], 1); |
| 2568 |
emit_insn (gen_<uunary>si2 (reg, op0)); |
| 2569 |
emit_insn (gen_truncsiqi2 (operands[0], reg)); |
| 2570 |
DONE; |
| 2571 |
}) |
| 2572 |
|
| 2573 |
(define_expand "cstoreqi4" |
| 2574 |
[(set (match_operand:SI 0 "nvptx_register_operand") |
| 2575 |
(match_operator:SI 1 "nvptx_comparison_operator" |
| 2576 |
[(match_operand:QI 2 "nvptx_nonmemory_operand") |
| 2577 |
(match_operand:QI 3 "nvptx_nonmemory_operand")]))] |
| 2578 |
"" |
| 2579 |
{ |
| 2580 |
rtx reg = gen_reg_rtx (BImode); |
| 2581 |
enum rtx_code code = GET_CODE (operands[1]); |
| 2582 |
int unsignedp = unsigned_condition_p (code); |
| 2583 |
rtx op2 = convert_modes (SImode, QImode, operands[2], unsignedp); |
| 2584 |
rtx op3 = convert_modes (SImode, QImode, operands[3], unsignedp); |
| 2585 |
rtx cmp = gen_rtx_fmt_ee (code, SImode, op2, op3); |
| 2586 |
emit_insn (gen_cmpsi (reg, cmp, op2, op3)); |
| 2587 |
emit_insn (gen_setccsi_from_bi (operands[0], reg)); |
| 2588 |
DONE; |
| 2589 |
}) |
| 2590 |
|
| 2591 |
(define_insn "*ext_truncsi2_qi" |
| 2592 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 2593 |
(sign_extend:SI |
| 2594 |
(truncate:QI (match_operand:SI 1 "nvptx_register_operand" "R"))))] |
| 2595 |
"" |
| 2596 |
"%.\\tcvt.s32.s8\\t%0, %1;") |
| 2597 |
|
| 2598 |
(define_insn "*zext_truncsi2_qi" |
| 2599 |
[(set (match_operand:SI 0 "nvptx_register_operand" "=R") |
| 2600 |
(zero_extend:SI |
| 2601 |
(truncate:QI (match_operand:SI 1 "nvptx_register_operand" "R"))))] |
| 2602 |
"" |
| 2603 |
"%.\\tcvt.u32.u8\\t%0, %1;") |