1 ;; Constraint definitions for eBPF.
2 ;; Copyright (C) 2019-2024 Free Software Foundation, Inc.
4 ;; This file is part of GCC.
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)
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.
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/>.
20 (define_constraint "I"
21 "A 32-bit signed immediate."
22 (and (match_code "const_int")
23 (match_test "IN_RANGE (ival, -1 - 0x7fffffff, 0x7fffffff)")))
25 (define_constraint "B"
26 "A constant argument for LDDW."
27 (match_code "const,symbol_ref,label_ref,const_double,const_int"))
29 (define_constraint "S"
30 "A constant call address."
31 (match_code "const,symbol_ref,label_ref,const_int"))
33 (define_register_constraint "t" "R0"
37 ;; BPF CO-RE immediate constraints.
38 ;; This constraints are used to match with the immediate operand that is
39 ;; represented with an UNSPEC_CORE_RELOC. This unspec is the result of using the
40 ;; BPF CO-RE infrastructure.
41 ;; It differentiates from a normal immediate constraints, as the instruction
42 ;; will also emit a BTF based specific relocation, i.e. a CO-RE relocation.
45 (define_constraint "c"
46 "A 32-bit CO-RE signed immediate."
47 (and (match_code "unspec")
48 (match_test "XINT (op, 1) == UNSPEC_CORE_RELOC")
49 (match_test "IN_RANGE (XVECEXP (op, 0, 0), -1 - 0x7fffffff, 0x7fffffff)")))
51 (define_constraint "C"
52 "For 64-bit CO-RE signed immediate."
53 (and (match_code "unspec")
54 (match_test "XINT (op, 1) == UNSPEC_CORE_RELOC")))
57 ;; Memory constraints.
60 ; Just like 'm' but disallows const_int.
61 ; Used for ldx[b,h,w,dw] and stx[b,h,w,dw] instructions.
62 (define_memory_constraint "q"
63 "Memory reference which is not a constant integer."
64 (and (match_code "mem")
65 (match_test "GET_CODE(XEXP(op, 0)) != CONST_INT")))