BPFCORE.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. MAX_FIELD_RELOC_KIND,
  31. };
  32. enum BTFTypeIdFlag : uint32_t {
  33. BTF_TYPE_ID_LOCAL_RELOC = 0,
  34. BTF_TYPE_ID_REMOTE_RELOC,
  35. MAX_BTF_TYPE_ID_FLAG,
  36. };
  37. enum PreserveTypeInfo : uint32_t {
  38. PRESERVE_TYPE_INFO_EXISTENCE = 0,
  39. PRESERVE_TYPE_INFO_SIZE,
  40. MAX_PRESERVE_TYPE_INFO_FLAG,
  41. };
  42. enum PreserveEnumValue : uint32_t {
  43. PRESERVE_ENUM_VALUE_EXISTENCE = 0,
  44. PRESERVE_ENUM_VALUE,
  45. MAX_PRESERVE_ENUM_VALUE_FLAG,
  46. };
  47. /// The attribute attached to globals representing a field access
  48. static constexpr StringRef AmaAttr = "btf_ama";
  49. /// The attribute attached to globals representing a type id
  50. static constexpr StringRef TypeIdAttr = "btf_type_id";
  51. /// llvm.bpf.passthrough builtin seq number
  52. static uint32_t SeqNum;
  53. /// Insert a bpf passthrough builtin function.
  54. static Instruction *insertPassThrough(Module *M, BasicBlock *BB,
  55. Instruction *Input,
  56. Instruction *Before);
  57. };
  58. } // namespace llvm
  59. #endif