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