brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 24eff86 Raw
129 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8//9// This file declares the BPF specific subclass of TargetSubtargetInfo.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_BPF_BPFSUBTARGET_H14#define LLVM_LIB_TARGET_BPF_BPFSUBTARGET_H15 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_HEADER31#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  // unused49  bool isDummyMode;50 51  bool IsLittleEndian;52 53  // whether the cpu supports jmp ext54  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 DwarfUsesRelocationsAcrossSections64  bool UseDwarfRIS;65 66  // whether we allows misaligned memory access67  bool AllowsMisalignedMemAccess;68 69  // whether cpu v4 insns are enabled.70  bool HasLdsx, HasMovsx, HasBswap, HasSdivSmod, HasGotol, HasStoreImm,71      HasLoadAcqStoreRel, HasGotox;72 73  std::unique_ptr<CallLowering> CallLoweringInfo;74  std::unique_ptr<InstructionSelector> InstSelector;75  std::unique_ptr<LegalizerInfo> Legalizer;76  std::unique_ptr<RegisterBankInfo> RegBankInfo;77 78public:79  // This constructor initializes the data members to match that80  // of the specified triple.81  BPFSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS,82               const TargetMachine &TM);83 84  BPFSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);85 86  // ParseSubtargetFeatures - Parses features string setting specified87  // subtarget options.  Definition of function is auto generated by tblgen.88  void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);89  bool getHasJmpExt() const { return HasJmpExt; }90  bool getHasJmp32() const { return HasJmp32; }91  bool getHasAlu32() const { return HasAlu32; }92  bool getUseDwarfRIS() const { return UseDwarfRIS; }93  bool getAllowsMisalignedMemAccess() const {94    return AllowsMisalignedMemAccess;95  }96  bool hasLdsx() const { return HasLdsx; }97  bool hasMovsx() const { return HasMovsx; }98  bool hasBswap() const { return HasBswap; }99  bool hasSdivSmod() const { return HasSdivSmod; }100  bool hasGotol() const { return HasGotol; }101  bool hasStoreImm() const { return HasStoreImm; }102  bool hasLoadAcqStoreRel() const { return HasLoadAcqStoreRel; }103  bool hasGotox() const { return HasGotox; }104 105  bool isLittleEndian() const { return IsLittleEndian; }106 107  const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; }108  const BPFFrameLowering *getFrameLowering() const override {109    return &FrameLowering;110  }111  const BPFTargetLowering *getTargetLowering() const override {112    return &TLInfo;113  }114  const BPFSelectionDAGInfo *getSelectionDAGInfo() const override {115    return &TSInfo;116  }117  const BPFRegisterInfo *getRegisterInfo() const override {118    return &InstrInfo.getRegisterInfo();119  }120 121  const CallLowering *getCallLowering() const override;122  InstructionSelector *getInstructionSelector() const override;123  const LegalizerInfo *getLegalizerInfo() const override;124  const RegisterBankInfo *getRegBankInfo() const override;125};126} // End llvm namespace127 128#endif129