| 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 | |
| 13 | #ifndef LLVM_LIB_TARGET_BPF_BPFSUBTARGET_H |
| 14 | #define LLVM_LIB_TARGET_BPF_BPFSUBTARGET_H |
| 15 | |
| 16 | #include "BPFFrameLowering.h" |
| 17 | #include "BPFISelLowering.h" |
| 18 | #include "BPFInstrInfo.h" |
| 19 | #include "BPFRegisterInfo.h" |
| 20 | #include "BPFSelectionDAGInfo.h" |
| 21 | #include "llvm/CodeGen/GlobalISel/CallLowering.h" |
| 22 | #include "llvm/CodeGen/GlobalISel/InstructionSelector.h" |
| 23 | #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" |
| 24 | #include "llvm/CodeGen/RegisterBankInfo.h" |
| 25 | #include "llvm/CodeGen/SelectionDAGTargetInfo.h" |
| 26 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
| 27 | #include "llvm/IR/DataLayout.h" |
| 28 | #include "llvm/Target/TargetMachine.h" |
| 29 | |
| 30 | #define |
| 31 | #include "BPFGenSubtargetInfo.inc" |
| 32 | |
| 33 | namespace llvm { |
| 34 | class StringRef; |
| 35 | |
| 36 | class BPFSubtarget : public BPFGenSubtargetInfo { |
| 37 | virtual void anchor(); |
| 38 | BPFInstrInfo InstrInfo; |
| 39 | BPFFrameLowering FrameLowering; |
| 40 | BPFTargetLowering TLInfo; |
| 41 | BPFSelectionDAGInfo TSInfo; |
| 42 | |
| 43 | private: |
| 44 | void initializeEnvironment(); |
| 45 | void initSubtargetFeatures(StringRef CPU, StringRef FS); |
| 46 | |
| 47 | protected: |
| 48 | // unused |
| 49 | bool isDummyMode; |
| 50 | |
| 51 | bool IsLittleEndian; |
| 52 | |
| 53 | // whether the cpu supports jmp ext |
| 54 | bool HasJmpExt; |
| 55 | |
| 56 | // whether the cpu supports jmp32 ext. |
| 57 | // NOTE: jmp32 is not enabled when alu32 enabled. |
| 58 | bool HasJmp32; |
| 59 | |
| 60 | // whether the cpu supports alu32 instructions. |
| 61 | bool HasAlu32; |
| 62 | |
| 63 | // whether we should enable MCAsmInfo DwarfUsesRelocationsAcrossSections |
| 64 | bool UseDwarfRIS; |
| 65 | |
| 66 | // whether cpu v4 insns are enabled. |
| 67 | bool HasLdsx, HasMovsx, HasBswap, HasSdivSmod, HasGotol, HasStoreImm, |
| 68 | HasLoadAcqStoreRel; |
| 69 | |
| 70 | std::unique_ptr<CallLowering> CallLoweringInfo; |
| 71 | std::unique_ptr<InstructionSelector> InstSelector; |
| 72 | std::unique_ptr<LegalizerInfo> Legalizer; |
| 73 | std::unique_ptr<RegisterBankInfo> RegBankInfo; |
| 74 | |
| 75 | public: |
| 76 | // This constructor initializes the data members to match that |
| 77 | // of the specified triple. |
| 78 | BPFSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, |
| 79 | const TargetMachine &TM); |
| 80 | |
| 81 | BPFSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); |
| 82 | |
| 83 | // ParseSubtargetFeatures - Parses features string setting specified |
| 84 | // subtarget options. Definition of function is auto generated by tblgen. |
| 85 | void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); |
| 86 | bool getHasJmpExt() const { return HasJmpExt; } |
| 87 | bool getHasJmp32() const { return HasJmp32; } |
| 88 | bool getHasAlu32() const { return HasAlu32; } |
| 89 | bool getUseDwarfRIS() const { return UseDwarfRIS; } |
| 90 | bool hasLdsx() const { return HasLdsx; } |
| 91 | bool hasMovsx() const { return HasMovsx; } |
| 92 | bool hasBswap() const { return HasBswap; } |
| 93 | bool hasSdivSmod() const { return HasSdivSmod; } |
| 94 | bool hasGotol() const { return HasGotol; } |
| 95 | bool hasStoreImm() const { return HasStoreImm; } |
| 96 | bool hasLoadAcqStoreRel() const { return HasLoadAcqStoreRel; } |
| 97 | |
| 98 | bool isLittleEndian() const { return IsLittleEndian; } |
| 99 | |
| 100 | const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; } |
| 101 | const BPFFrameLowering *getFrameLowering() const override { |
| 102 | return &FrameLowering; |
| 103 | } |
| 104 | const BPFTargetLowering *getTargetLowering() const override { |
| 105 | return &TLInfo; |
| 106 | } |
| 107 | const BPFSelectionDAGInfo *getSelectionDAGInfo() const override { |
| 108 | return &TSInfo; |
| 109 | } |
| 110 | const BPFRegisterInfo *getRegisterInfo() const override { |
| 111 | return &InstrInfo.getRegisterInfo(); |
| 112 | } |
| 113 | |
| 114 | const CallLowering *getCallLowering() const override; |
| 115 | InstructionSelector *getInstructionSelector() const override; |
| 116 | const LegalizerInfo *getLegalizerInfo() const override; |
| 117 | const RegisterBankInfo *getRegBankInfo() const override; |
| 118 | }; |
| 119 | } // End llvm namespace |
| 120 | |
| 121 | #endif |
| 122 | |