BPFTargetMachine.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //===-- BPFTargetMachine.h - Define TargetMachine for BPF --- 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. //
  9. // This file declares the BPF specific subclass of TargetMachine.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_BPF_BPFTARGETMACHINE_H
  13. #define LLVM_LIB_TARGET_BPF_BPFTARGETMACHINE_H
  14. #include "BPFSubtarget.h"
  15. #include "llvm/Target/TargetMachine.h"
  16. #include <optional>
  17. namespace llvm {
  18. class BPFTargetMachine : public LLVMTargetMachine {
  19. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  20. BPFSubtarget Subtarget;
  21. public:
  22. BPFTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  23. StringRef FS, const TargetOptions &Options,
  24. std::optional<Reloc::Model> RM,
  25. std::optional<CodeModel::Model> CM, CodeGenOpt::Level OL,
  26. bool JIT);
  27. const BPFSubtarget *getSubtargetImpl() const { return &Subtarget; }
  28. const BPFSubtarget *getSubtargetImpl(const Function &) const override {
  29. return &Subtarget;
  30. }
  31. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  32. TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
  33. TargetLoweringObjectFile *getObjFileLowering() const override {
  34. return TLOF.get();
  35. }
  36. void registerPassBuilderCallbacks(PassBuilder &PB) override;
  37. };
  38. }
  39. #endif