BPFSubtarget.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //===-- BPFSubtarget.h - Define Subtarget for the 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 TargetSubtargetInfo.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef LLVM_LIB_TARGET_BPF_BPFSUBTARGET_H
  13. #define LLVM_LIB_TARGET_BPF_BPFSUBTARGET_H
  14. #include "BPFFrameLowering.h"
  15. #include "BPFISelLowering.h"
  16. #include "BPFInstrInfo.h"
  17. #include "BPFSelectionDAGInfo.h"
  18. #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
  19. #include "llvm/CodeGen/TargetSubtargetInfo.h"
  20. #include "llvm/IR/DataLayout.h"
  21. #include "llvm/Target/TargetMachine.h"
  22. #define GET_SUBTARGETINFO_HEADER
  23. #include "BPFGenSubtargetInfo.inc"
  24. namespace llvm {
  25. class StringRef;
  26. class BPFSubtarget : public BPFGenSubtargetInfo {
  27. virtual void anchor();
  28. BPFInstrInfo InstrInfo;
  29. BPFFrameLowering FrameLowering;
  30. BPFTargetLowering TLInfo;
  31. BPFSelectionDAGInfo TSInfo;
  32. private:
  33. void initializeEnvironment();
  34. void initSubtargetFeatures(StringRef CPU, StringRef FS);
  35. bool probeJmpExt();
  36. protected:
  37. // unused
  38. bool isDummyMode;
  39. // whether the cpu supports jmp ext
  40. bool HasJmpExt;
  41. // whether the cpu supports jmp32 ext.
  42. // NOTE: jmp32 is not enabled when alu32 enabled.
  43. bool HasJmp32;
  44. // whether the cpu supports alu32 instructions.
  45. bool HasAlu32;
  46. // whether we should enable MCAsmInfo DwarfUsesRelocationsAcrossSections
  47. bool UseDwarfRIS;
  48. public:
  49. // This constructor initializes the data members to match that
  50. // of the specified triple.
  51. BPFSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
  52. const TargetMachine &TM);
  53. BPFSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
  54. // ParseSubtargetFeatures - Parses features string setting specified
  55. // subtarget options. Definition of function is auto generated by tblgen.
  56. void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
  57. bool getHasJmpExt() const { return HasJmpExt; }
  58. bool getHasJmp32() const { return HasJmp32; }
  59. bool getHasAlu32() const { return HasAlu32; }
  60. bool getUseDwarfRIS() const { return UseDwarfRIS; }
  61. const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; }
  62. const BPFFrameLowering *getFrameLowering() const override {
  63. return &FrameLowering;
  64. }
  65. const BPFTargetLowering *getTargetLowering() const override {
  66. return &TLInfo;
  67. }
  68. const BPFSelectionDAGInfo *getSelectionDAGInfo() const override {
  69. return &TSInfo;
  70. }
  71. const TargetRegisterInfo *getRegisterInfo() const override {
  72. return &InstrInfo.getRegisterInfo();
  73. }
  74. };
  75. } // End llvm namespace
  76. #endif