1 //===- BPFCORE.h - Common info for Compile-Once Run-EveryWhere -*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_LIB_TARGET_BPF_BPFCORE_H
10 #define LLVM_LIB_TARGET_BPF_BPFCORE_H
12 #include "llvm/ADT/StringRef.h"
20 class BPFCoreSharedInfo
{
22 enum PatchableRelocKind
: uint32_t {
23 FIELD_BYTE_OFFSET
= 0,
39 enum BTFTypeIdFlag
: uint32_t {
40 BTF_TYPE_ID_LOCAL_RELOC
= 0,
41 BTF_TYPE_ID_REMOTE_RELOC
,
46 enum PreserveTypeInfo
: uint32_t {
47 PRESERVE_TYPE_INFO_EXISTENCE
= 0,
48 PRESERVE_TYPE_INFO_SIZE
,
50 MAX_PRESERVE_TYPE_INFO_FLAG
,
53 enum PreserveEnumValue
: uint32_t {
54 PRESERVE_ENUM_VALUE_EXISTENCE
= 0,
57 MAX_PRESERVE_ENUM_VALUE_FLAG
,
60 /// The attribute attached to globals representing a field access
61 static constexpr StringRef AmaAttr
= "btf_ama";
62 /// The attribute attached to globals representing a type id
63 static constexpr StringRef TypeIdAttr
= "btf_type_id";
65 /// llvm.bpf.passthrough builtin seq number
66 static uint32_t SeqNum
;
68 /// Insert a bpf passthrough builtin function.
69 static Instruction
*insertPassThrough(Module
*M
, BasicBlock
*BB
,