xref: /freebsd/contrib/llvm-project/llvm/include/llvm/IR/IntrinsicsBPF.td (revision 6c4b055cfb6bf549e9145dde6454cc6b178c35e4)
1//===- IntrinsicsBPF.td - Defines BPF intrinsics -----------*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines all of the BPF-specific intrinsics.
10//
11//===----------------------------------------------------------------------===//
12
13// Specialized loads from packet
14let TargetPrefix = "bpf" in {  // All intrinsics start with "llvm.bpf."
15  def int_bpf_load_byte : ClangBuiltin<"__builtin_bpf_load_byte">,
16              DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], [IntrReadMem]>;
17  def int_bpf_load_half : ClangBuiltin<"__builtin_bpf_load_half">,
18              DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], [IntrReadMem]>;
19  def int_bpf_load_word : ClangBuiltin<"__builtin_bpf_load_word">,
20              DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_ptr_ty, llvm_i64_ty], [IntrReadMem]>;
21  def int_bpf_pseudo : ClangBuiltin<"__builtin_bpf_pseudo">,
22              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty]>;
23  def int_bpf_preserve_field_info : ClangBuiltin<"__builtin_bpf_preserve_field_info">,
24              Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty, llvm_i64_ty],
25              [IntrNoMem, ImmArg<ArgIndex<1>>]>;
26  def int_bpf_btf_type_id : ClangBuiltin<"__builtin_bpf_btf_type_id">,
27              Intrinsic<[llvm_i64_ty], [llvm_i32_ty, llvm_i64_ty],
28              [IntrNoMem]>;
29  def int_bpf_preserve_type_info : ClangBuiltin<"__builtin_bpf_preserve_type_info">,
30              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i64_ty],
31              [IntrNoMem]>;
32  def int_bpf_preserve_enum_value : ClangBuiltin<"__builtin_bpf_preserve_enum_value">,
33              Intrinsic<[llvm_i64_ty], [llvm_i32_ty, llvm_ptr_ty, llvm_i64_ty],
34              [IntrNoMem]>;
35  def int_bpf_passthrough : ClangBuiltin<"__builtin_bpf_passthrough">,
36              Intrinsic<[llvm_any_ty], [llvm_i32_ty, llvm_any_ty], [IntrNoMem]>;
37  def int_bpf_compare : ClangBuiltin<"__builtin_bpf_compare">,
38              Intrinsic<[llvm_i1_ty], [llvm_i32_ty, llvm_anyint_ty, llvm_anyint_ty],
39              [IntrNoMem]>;
40  def int_bpf_getelementptr_and_load : ClangBuiltin<"__builtin_bpf_getelementptr_and_load">,
41              Intrinsic<[llvm_any_ty],
42                        [llvm_ptr_ty,     // base ptr for getelementptr
43                         llvm_i1_ty,      // volatile
44                         llvm_i8_ty,      // atomic order
45                         llvm_i8_ty,      // synscope id
46                         llvm_i8_ty,      // alignment
47                         llvm_i1_ty,      // inbounds
48                         llvm_vararg_ty], // indices for getelementptr insn
49                        [IntrNoCallback,
50                         IntrNoFree,
51                         IntrWillReturn,
52                         NoCapture <ArgIndex<0>>,
53                         ImmArg    <ArgIndex<1>>, // volatile
54                         ImmArg    <ArgIndex<2>>, // atomic order
55                         ImmArg    <ArgIndex<3>>, // synscope id
56                         ImmArg    <ArgIndex<4>>, // alignment
57                         ImmArg    <ArgIndex<5>>, // inbounds
58                        ]>;
59  def int_bpf_getelementptr_and_store : ClangBuiltin<"__builtin_bpf_getelementptr_and_store">,
60              Intrinsic<[],
61                        [llvm_any_ty,     // value to store
62                         llvm_ptr_ty,     // base ptr for getelementptr
63                         llvm_i1_ty,      // volatile
64                         llvm_i8_ty,      // atomic order
65                         llvm_i8_ty,      // syncscope id
66                         llvm_i8_ty,      // alignment
67                         llvm_i1_ty,      // inbounds
68                         llvm_vararg_ty], // indexes for getelementptr insn
69                        [IntrNoCallback,
70                         IntrNoFree,
71                         IntrWillReturn,
72                         NoCapture <ArgIndex<1>>,
73                         ImmArg    <ArgIndex<2>>, // volatile
74                         ImmArg    <ArgIndex<3>>, // atomic order
75                         ImmArg    <ArgIndex<4>>, // syncscope id
76                         ImmArg    <ArgIndex<5>>, // alignment
77                         ImmArg    <ArgIndex<6>>, // inbounds
78                        ]>;
79}
80