brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · b90542c Raw
112 lines · c
1//===- LoongArchSubtarget.h - Define Subtarget for the LoongArch -*- 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 LoongArch specific subclass of TargetSubtargetInfo.10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H14#define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H15 16#include "LoongArchFrameLowering.h"17#include "LoongArchISelLowering.h"18#include "LoongArchInstrInfo.h"19#include "LoongArchRegisterInfo.h"20#include "MCTargetDesc/LoongArchBaseInfo.h"21#include "llvm/CodeGen/TargetSubtargetInfo.h"22#include "llvm/IR/DataLayout.h"23#include "llvm/Target/TargetMachine.h"24 25#define GET_SUBTARGETINFO_HEADER26#include "LoongArchGenSubtargetInfo.inc"27 28namespace llvm {29class StringRef;30 31class LoongArchSubtarget : public LoongArchGenSubtargetInfo {32  virtual void anchor();33 34#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER)                    \35  bool ATTRIBUTE = DEFAULT;36#include "LoongArchGenSubtargetInfo.inc"37 38  unsigned GRLen = 32;39  // TODO: The default value is empirical and conservative. Override the40  // default in initializeProperties once we support optimizing for more41  // uarches.42  uint8_t MaxInterleaveFactor = 2;43  MVT GRLenVT = MVT::i32;44  LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown;45  LoongArchFrameLowering FrameLowering;46  LoongArchInstrInfo InstrInfo;47  LoongArchTargetLowering TLInfo;48  std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;49 50  Align PrefFunctionAlignment;51  Align PrefLoopAlignment;52  unsigned MaxBytesForAlignment;53 54  /// Initializes using the passed in CPU and feature strings so that we can55  /// use initializer lists for subtarget initialization.56  LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT,57                                                      StringRef CPU,58                                                      StringRef TuneCPU,59                                                      StringRef FS,60                                                      StringRef ABIName);61 62  /// Initialize properties based on the selected processor family.63  void initializeProperties(StringRef TuneCPU);64 65public:66  // Initializes the data members to match that of the specified triple.67  LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,68                     StringRef FS, StringRef ABIName, const TargetMachine &TM);69 70  ~LoongArchSubtarget() override;71 72  // Parses features string setting specified subtarget options. The73  // definition of this function is auto-generated by tblgen.74  void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);75 76  const LoongArchFrameLowering *getFrameLowering() const override {77    return &FrameLowering;78  }79  const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; }80  const LoongArchRegisterInfo *getRegisterInfo() const override {81    return &InstrInfo.getRegisterInfo();82  }83  const LoongArchTargetLowering *getTargetLowering() const override {84    return &TLInfo;85  }86 87  const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;88 89#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER)                    \90  bool GETTER() const { return ATTRIBUTE; }91#include "LoongArchGenSubtargetInfo.inc"92 93  bool is64Bit() const { return HasLA64; }94  MVT getGRLenVT() const { return GRLenVT; }95  unsigned getGRLen() const { return GRLen; }96  LoongArchABI::ABI getTargetABI() const { return TargetABI; }97  bool isSoftFPABI() const {98    return TargetABI == LoongArchABI::ABI_LP64S ||99           TargetABI == LoongArchABI::ABI_ILP32S;100  }101  bool isXRaySupported() const override { return is64Bit(); }102  Align getPrefFunctionAlignment() const { return PrefFunctionAlignment; }103  Align getPrefLoopAlignment() const { return PrefLoopAlignment; }104  unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }105  unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }106  bool enableMachineScheduler() const override { return true; }107  bool useAA() const override;108};109} // end namespace llvm110 111#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H112