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 GET_SUBTARGETINFO_HEADER
31#include "BPFGenSubtargetInfo.inc"
32
33namespace llvm {
34class StringRef;
35
36class BPFSubtarget : public BPFGenSubtargetInfo {
37 virtual void anchor();
38 BPFInstrInfo InstrInfo;
39 BPFFrameLowering FrameLowering;
40 BPFTargetLowering TLInfo;
41 BPFSelectionDAGInfo TSInfo;
42
43private:
44 void initializeEnvironment();
45 void initSubtargetFeatures(StringRef CPU, StringRef FS);
46
47protected:
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
69 std::unique_ptr<CallLowering> CallLoweringInfo;
70 std::unique_ptr<InstructionSelector> InstSelector;
71 std::unique_ptr<LegalizerInfo> Legalizer;
72 std::unique_ptr<RegisterBankInfo> RegBankInfo;
73
74public:
75 // This constructor initializes the data members to match that
76 // of the specified triple.
77 BPFSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,
78 const TargetMachine &TM);
79
80 BPFSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
81
82 // ParseSubtargetFeatures - Parses features string setting specified
83 // subtarget options. Definition of function is auto generated by tblgen.
84 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
85 bool getHasJmpExt() const { return HasJmpExt; }
86 bool getHasJmp32() const { return HasJmp32; }
87 bool getHasAlu32() const { return HasAlu32; }
88 bool getUseDwarfRIS() const { return UseDwarfRIS; }
89 bool hasLdsx() const { return HasLdsx; }
90 bool hasMovsx() const { return HasMovsx; }
91 bool hasBswap() const { return HasBswap; }
92 bool hasSdivSmod() const { return HasSdivSmod; }
93 bool hasGotol() const { return HasGotol; }
94 bool hasStoreImm() const { return HasStoreImm; }
95
96 bool isLittleEndian() const { return IsLittleEndian; }
97
98 const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; }
99 const BPFFrameLowering *getFrameLowering() const override {
100 return &FrameLowering;
101 }
102 const BPFTargetLowering *getTargetLowering() const override {
103 return &TLInfo;
104 }
105 const BPFSelectionDAGInfo *getSelectionDAGInfo() const override {
106 return &TSInfo;
107 }
108 const BPFRegisterInfo *getRegisterInfo() const override {
109 return &InstrInfo.getRegisterInfo();
110 }
111
112 const CallLowering *getCallLowering() const override;
113 InstructionSelector *getInstructionSelector() const override;
114 const LegalizerInfo *getLegalizerInfo() const override;
115 const RegisterBankInfo *getRegBankInfo() const override;
116};
117} // End llvm namespace
118
119#endif
120

source code of llvm/lib/Target/BPF/BPFSubtarget.h