BPFCORE.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //===- BPFCORE.h - Common info for Compile-Once Run-EveryWhere -*- C++ -*-===//
  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. #ifndef LLVM_LIB_TARGET_BPF_BPFCORE_H
  9. #define LLVM_LIB_TARGET_BPF_BPFCORE_H
  10. #include "llvm/ADT/StringRef.h"
  11. namespace llvm {
  12. class BasicBlock;
  13. class Instruction;
  14. class Module;
  15. class BPFCoreSharedInfo {
  16. public:
  17. enum PatchableRelocKind : uint32_t {
  18. FIELD_BYTE_OFFSET = 0,
  19. FIELD_BYTE_SIZE,
  20. FIELD_EXISTENCE,
  21. FIELD_SIGNEDNESS,
  22. FIELD_LSHIFT_U64,
  23. FIELD_RSHIFT_U64,
  24. BTF_TYPE_ID_LOCAL,
  25. BTF_TYPE_ID_REMOTE,
  26. TYPE_EXISTENCE,
  27. TYPE_SIZE,
  28. ENUM_VALUE_EXISTENCE,
  29. ENUM_VALUE,
  30. TYPE_MATCH,
  31. MAX_FIELD_RELOC_KIND,
  32. };
  33. enum BTFTypeIdFlag : uint32_t {
  34. BTF_TYPE_ID_LOCAL_RELOC = 0,
  35. BTF_TYPE_ID_REMOTE_RELOC,
  36. MAX_BTF_TYPE_ID_FLAG,
  37. };
  38. enum PreserveTypeInfo : uint32_t {
  39. PRESERVE_TYPE_INFO_EXISTENCE = 0,
  40. PRESERVE_TYPE_INFO_SIZE,
  41. PRESERVE_TYPE_INFO_MATCH,
  42. MAX_PRESERVE_TYPE_INFO_FLAG,
  43. };
  44. enum PreserveEnumValue : uint32_t {
  45. PRESERVE_ENUM_VALUE_EXISTENCE = 0,
  46. PRESERVE_ENUM_VALUE,
  47. MAX_PRESERVE_ENUM_VALUE_FLAG,
  48. };
  49. /// The attribute attached to globals representing a field access
  50. static constexpr StringRef AmaAttr = "btf_ama";
  51. /// The attribute attached to globals representing a type id
  52. static constexpr StringRef TypeIdAttr = "btf_type_id";
  53. /// llvm.bpf.passthrough builtin seq number
  54. static uint32_t SeqNum;
  55. /// Insert a bpf passthrough builtin function.
  56. static Instruction *insertPassThrough(Module *M, BasicBlock *BB,
  57. Instruction *Input,
  58. Instruction *Before);
  59. };
  60. } // namespace llvm
  61. #endif