| 1 |
;; Predicate definitions for eBPF. |
| 2 |
;; Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 3 |
;; |
| 4 |
;; This file is part of GCC. |
| 5 |
;; |
| 6 |
;; GCC is free software; you can redistribute it and/or modify |
| 7 |
;; it under the terms of the GNU General Public License as published by |
| 8 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 9 |
;; any later version. |
| 10 |
;; |
| 11 |
;; GCC is distributed in the hope that it will be useful, |
| 12 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
;; GNU General Public License for more details. |
| 15 |
;; |
| 16 |
;; You should have received a copy of the GNU General Public License |
| 17 |
;; along with GCC; see the file COPYING3. If not see |
| 18 |
;; <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
(define_predicate "reg_or_imm_operand" |
| 21 |
(ior (and (match_code "const_int") |
| 22 |
(match_test "IN_RANGE (INTVAL (op), -1 - 0x7fffffff, 0x7fffffff)")) |
| 23 |
(match_operand 0 "register_operand"))) |
| 24 |
|
| 25 |
(define_predicate "imm32_operand" |
| 26 |
(ior (and (match_code "const_int") |
| 27 |
(match_test "IN_RANGE (INTVAL (op), 0, 0xffffffff)")) |
| 28 |
(match_code "symbol_ref,label_ref,const"))) |
| 29 |
|
| 30 |
(define_predicate "core_imm_operand" |
| 31 |
(and (match_code "unspec") |
| 32 |
(match_test "XINT (op, 1) == UNSPEC_CORE_RELOC"))) |
| 33 |
|
| 34 |
(define_predicate "lddw_operand" |
| 35 |
(match_code "symbol_ref,label_ref,const,const_double,const_int")) |
| 36 |
|
| 37 |
(define_predicate "call_operand" |
| 38 |
(match_code "reg,symbol_ref,const_int,const") |
| 39 |
{ |
| 40 |
if (GET_CODE (op) == CONST) |
| 41 |
{ |
| 42 |
op = XEXP (op, 0); |
| 43 |
|
| 44 |
switch (GET_CODE (op)) |
| 45 |
{ |
| 46 |
case SYMBOL_REF: |
| 47 |
case LABEL_REF: |
| 48 |
case CONST_INT: |
| 49 |
return true; |
| 50 |
break; |
| 51 |
default: |
| 52 |
break; |
| 53 |
} |
| 54 |
|
| 55 |
return false; |
| 56 |
} |
| 57 |
|
| 58 |
return true; |
| 59 |
}) |
| 60 |
|
| 61 |
(define_predicate "mov_src_operand" |
| 62 |
(ior (match_operand 0 "memory_operand") |
| 63 |
(match_operand 0 "reg_or_imm_operand") |
| 64 |
(match_operand 0 "lddw_operand") |
| 65 |
(match_operand 0 "core_imm_operand"))) |
| 66 |
|
| 67 |
(define_predicate "register_compare_operator" |
| 68 |
(match_code "eq,ne,geu,gtu,ge,gt")) |