BPFTargetMachine.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. namespace llvm {
  17. class BPFTargetMachine : public LLVMTargetMachine {
  18. std::unique_ptr<TargetLoweringObjectFile> TLOF;
  19. BPFSubtarget Subtarget;
  20. public:
  21. BPFTargetMachine(const Target &T, const Triple &TT, StringRef CPU,
  22. StringRef FS, const TargetOptions &Options,
  23. Optional<Reloc::Model> RM, Optional<CodeModel::Model> CM,
  24. CodeGenOpt::Level OL, bool JIT);
  25. const BPFSubtarget *getSubtargetImpl() const { return &Subtarget; }
  26. const BPFSubtarget *getSubtargetImpl(const Function &) const override {
  27. return &Subtarget;
  28. }
  29. TargetPassConfig *createPassConfig(PassManagerBase &PM) override;
  30. TargetTransformInfo getTargetTransformInfo(const Function &F) override;
  31. TargetLoweringObjectFile *getObjFileLowering() const override {
  32. return TLOF.get();
  33. }
  34. void adjustPassManager(PassManagerBuilder &) override;
  35. void registerPassBuilderCallbacks(PassBuilder &PB) override;
  36. };
  37. }
  38. #endif