Path: blob/main/contrib/llvm-project/llvm/lib/Target/LoongArch/LoongArchSubtarget.h
35269 views
//===- LoongArchSubtarget.h - Define Subtarget for the LoongArch -*- C++ -*-==//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file declares the LoongArch specific subclass of TargetSubtargetInfo.9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H13#define LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H1415#include "LoongArchFrameLowering.h"16#include "LoongArchISelLowering.h"17#include "LoongArchInstrInfo.h"18#include "LoongArchRegisterInfo.h"19#include "MCTargetDesc/LoongArchBaseInfo.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"2425#define GET_SUBTARGETINFO_HEADER26#include "LoongArchGenSubtargetInfo.inc"2728namespace llvm {29class StringRef;3031class LoongArchSubtarget : public LoongArchGenSubtargetInfo {32virtual void anchor();3334#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \35bool ATTRIBUTE = DEFAULT;36#include "LoongArchGenSubtargetInfo.inc"3738unsigned GRLen = 32;39// TODO: The default value is empirical and conservative. Override the40// default in initializeProperties once we support optimizing for more41// uarches.42uint8_t MaxInterleaveFactor = 2;43MVT GRLenVT = MVT::i32;44LoongArchABI::ABI TargetABI = LoongArchABI::ABI_Unknown;45LoongArchFrameLowering FrameLowering;46LoongArchInstrInfo InstrInfo;47LoongArchRegisterInfo RegInfo;48LoongArchTargetLowering TLInfo;49SelectionDAGTargetInfo TSInfo;5051Align PrefFunctionAlignment;52Align PrefLoopAlignment;53unsigned MaxBytesForAlignment;5455/// Initializes using the passed in CPU and feature strings so that we can56/// use initializer lists for subtarget initialization.57LoongArchSubtarget &initializeSubtargetDependencies(const Triple &TT,58StringRef CPU,59StringRef TuneCPU,60StringRef FS,61StringRef ABIName);6263/// Initialize properties based on the selected processor family.64void initializeProperties(StringRef TuneCPU);6566public:67// Initializes the data members to match that of the specified triple.68LoongArchSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU,69StringRef FS, StringRef ABIName, const TargetMachine &TM);7071// Parses features string setting specified subtarget options. The72// definition of this function is auto-generated by tblgen.73void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);7475const LoongArchFrameLowering *getFrameLowering() const override {76return &FrameLowering;77}78const LoongArchInstrInfo *getInstrInfo() const override { return &InstrInfo; }79const LoongArchRegisterInfo *getRegisterInfo() const override {80return &RegInfo;81}82const LoongArchTargetLowering *getTargetLowering() const override {83return &TLInfo;84}85const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {86return &TSInfo;87}8889#define GET_SUBTARGETINFO_MACRO(ATTRIBUTE, DEFAULT, GETTER) \90bool GETTER() const { return ATTRIBUTE; }91#include "LoongArchGenSubtargetInfo.inc"9293bool is64Bit() const { return HasLA64; }94MVT getGRLenVT() const { return GRLenVT; }95unsigned getGRLen() const { return GRLen; }96LoongArchABI::ABI getTargetABI() const { return TargetABI; }97bool isSoftFPABI() const {98return TargetABI == LoongArchABI::ABI_LP64S ||99TargetABI == LoongArchABI::ABI_ILP32S;100}101bool isXRaySupported() const override { return is64Bit(); }102Align getPrefFunctionAlignment() const { return PrefFunctionAlignment; }103Align getPrefLoopAlignment() const { return PrefLoopAlignment; }104unsigned getMaxBytesForAlignment() const { return MaxBytesForAlignment; }105unsigned getMaxInterleaveFactor() const { return MaxInterleaveFactor; }106bool enableMachineScheduler() const override { return true; }107};108} // end namespace llvm109110#endif // LLVM_LIB_TARGET_LOONGARCH_LOONGARCHSUBTARGET_H111112113