xref: /freebsd/contrib/llvm-project/llvm/lib/Target/BPF/BPFCORE.h (revision 5f757f3ff9144b609b3c433dfd370cc6bdc191ad)
10b57cec5SDimitry Andric //===- BPFCORE.h - Common info for Compile-Once Run-EveryWhere  -*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric 
90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_BPF_BPFCORE_H
100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_BPF_BPFCORE_H
110b57cec5SDimitry Andric 
125ffd83dbSDimitry Andric #include "llvm/ADT/StringRef.h"
13*5f757f3fSDimitry Andric #include "llvm/IR/Instructions.h"
145ffd83dbSDimitry Andric 
150b57cec5SDimitry Andric namespace llvm {
160b57cec5SDimitry Andric 
17e8d8bef9SDimitry Andric class BasicBlock;
18e8d8bef9SDimitry Andric class Instruction;
19e8d8bef9SDimitry Andric class Module;
20e8d8bef9SDimitry Andric 
210b57cec5SDimitry Andric class BPFCoreSharedInfo {
220b57cec5SDimitry Andric public:
235ffd83dbSDimitry Andric   enum BTFTypeIdFlag : uint32_t {
245ffd83dbSDimitry Andric     BTF_TYPE_ID_LOCAL_RELOC = 0,
255ffd83dbSDimitry Andric     BTF_TYPE_ID_REMOTE_RELOC,
265ffd83dbSDimitry Andric 
275ffd83dbSDimitry Andric     MAX_BTF_TYPE_ID_FLAG,
285ffd83dbSDimitry Andric   };
295ffd83dbSDimitry Andric 
30e8d8bef9SDimitry Andric   enum PreserveTypeInfo : uint32_t {
31e8d8bef9SDimitry Andric     PRESERVE_TYPE_INFO_EXISTENCE = 0,
32e8d8bef9SDimitry Andric     PRESERVE_TYPE_INFO_SIZE,
3381ad6265SDimitry Andric     PRESERVE_TYPE_INFO_MATCH,
34e8d8bef9SDimitry Andric 
35e8d8bef9SDimitry Andric     MAX_PRESERVE_TYPE_INFO_FLAG,
36e8d8bef9SDimitry Andric   };
37e8d8bef9SDimitry Andric 
38e8d8bef9SDimitry Andric   enum PreserveEnumValue : uint32_t {
39e8d8bef9SDimitry Andric     PRESERVE_ENUM_VALUE_EXISTENCE = 0,
40e8d8bef9SDimitry Andric     PRESERVE_ENUM_VALUE,
41e8d8bef9SDimitry Andric 
42e8d8bef9SDimitry Andric     MAX_PRESERVE_ENUM_VALUE_FLAG,
43e8d8bef9SDimitry Andric   };
44e8d8bef9SDimitry Andric 
458bcb0991SDimitry Andric   /// The attribute attached to globals representing a field access
465ffd83dbSDimitry Andric   static constexpr StringRef AmaAttr = "btf_ama";
475ffd83dbSDimitry Andric   /// The attribute attached to globals representing a type id
485ffd83dbSDimitry Andric   static constexpr StringRef TypeIdAttr = "btf_type_id";
49e8d8bef9SDimitry Andric 
50e8d8bef9SDimitry Andric   /// llvm.bpf.passthrough builtin seq number
51e8d8bef9SDimitry Andric   static uint32_t SeqNum;
52e8d8bef9SDimitry Andric 
53e8d8bef9SDimitry Andric   /// Insert a bpf passthrough builtin function.
54e8d8bef9SDimitry Andric   static Instruction *insertPassThrough(Module *M, BasicBlock *BB,
55e8d8bef9SDimitry Andric                                         Instruction *Input,
56e8d8bef9SDimitry Andric                                         Instruction *Before);
57*5f757f3fSDimitry Andric   static void removeArrayAccessCall(CallInst *Call);
58*5f757f3fSDimitry Andric   static void removeStructAccessCall(CallInst *Call);
59*5f757f3fSDimitry Andric   static void removeUnionAccessCall(CallInst *Call);
600b57cec5SDimitry Andric };
610b57cec5SDimitry Andric 
620b57cec5SDimitry Andric } // namespace llvm
630b57cec5SDimitry Andric 
640b57cec5SDimitry Andric #endif
65