xref: /freebsd/contrib/llvm-project/llvm/lib/Target/BPF/BPFSubtarget.h (revision 0ad011ececb978e22a9bff2acf76633b094f1ff6)
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 "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"
24 
25 #define GET_SUBTARGETINFO_HEADER
26 #include "BPFGenSubtargetInfo.inc"
27 
28 namespace llvm {
29 class StringRef;
30 
31 class BPFSubtarget : public BPFGenSubtargetInfo {
32   virtual void anchor();
33   BPFInstrInfo InstrInfo;
34   BPFFrameLowering FrameLowering;
35   BPFTargetLowering TLInfo;
36   BPFSelectionDAGInfo TSInfo;
37 
38 private:
39   void initializeEnvironment();
40   void initSubtargetFeatures(StringRef CPU, StringRef FS);
41 
42 protected:
43   // unused
44   bool isDummyMode;
45 
46   // whether the cpu supports jmp ext
47   bool HasJmpExt;
48 
49   // whether the cpu supports jmp32 ext.
50   // NOTE: jmp32 is not enabled when alu32 enabled.
51   bool HasJmp32;
52 
53   // whether the cpu supports alu32 instructions.
54   bool HasAlu32;
55 
56   // whether we should enable MCAsmInfo DwarfUsesRelocationsAcrossSections
57   bool UseDwarfRIS;
58 
59 public:
60   // This constructor initializes the data members to match that
61   // of the specified triple.
62   BPFSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
63                const TargetMachine &TM);
64 
65   BPFSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
66 
67   // ParseSubtargetFeatures - Parses features string setting specified
68   // subtarget options.  Definition of function is auto generated by tblgen.
69   void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
70   bool getHasJmpExt() const { return HasJmpExt; }
71   bool getHasJmp32() const { return HasJmp32; }
72   bool getHasAlu32() const { return HasAlu32; }
73   bool getUseDwarfRIS() const { return UseDwarfRIS; }
74 
75   const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; }
76   const BPFFrameLowering *getFrameLowering() const override {
77     return &FrameLowering;
78   }
79   const BPFTargetLowering *getTargetLowering() const override {
80     return &TLInfo;
81   }
82   const BPFSelectionDAGInfo *getSelectionDAGInfo() const override {
83     return &TSInfo;
84   }
85   const TargetRegisterInfo *getRegisterInfo() const override {
86     return &InstrInfo.getRegisterInfo();
87   }
88 };
89 } // End llvm namespace
90 
91 #endif
92