aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/bpf/predicates.md
blob: 568156f56e3a86f0061f3a99ecfabd660783609b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
;; Predicate definitions for eBPF.
;; Copyright (C) 2019-2024 Free Software Foundation, Inc.
;;
;; This file is part of GCC.
;;
;; GCC is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; GCC is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GCC; see the file COPYING3.  If not see
;; <http://www.gnu.org/licenses/>.

(define_predicate "reg_or_imm_operand"
  (ior (and (match_code "const_int")
            (match_test "IN_RANGE (INTVAL (op), -1 - 0x7fffffff, 0x7fffffff)"))
       (match_operand 0 "register_operand")))

(define_predicate "imm32_operand"
  (ior (and (match_code "const_int")
            (match_test "IN_RANGE (INTVAL (op), 0, 0xffffffff)"))
       (match_code "symbol_ref,label_ref,const")))

(define_predicate "core_imm_operand"
  (and (match_code "unspec")
       (match_test "XINT (op, 1) == UNSPEC_CORE_RELOC")))

(define_predicate "lddw_operand"
  (match_code "symbol_ref,label_ref,const,const_double,const_int"))

(define_predicate "call_operand"
  (match_code "reg,symbol_ref,const_int,const")
{
  if (GET_CODE (op) == CONST)
    {
      op = XEXP (op, 0);

      switch (GET_CODE (op))
	{
	case SYMBOL_REF:
	case LABEL_REF:
	case CONST_INT:
	  return true;
	  break;
	default:
	  break;
	}

      return false;
    }

  return true;
})

(define_predicate "mov_src_operand"
  (ior (match_operand 0 "memory_operand")
       (match_operand 0 "reg_or_imm_operand")
       (match_operand 0 "lddw_operand")
       (match_operand 0 "core_imm_operand")))

(define_predicate "register_compare_operator"
  (match_code "eq,ne,geu,gtu,ge,gt"))