1 //===-- CSKYSubtarget.h - Define Subtarget for the CSKY----------*- 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 CSKY specific subclass of TargetSubtargetInfo. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #ifndef LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H 14 #define LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H 15 16 #include "CSKYFrameLowering.h" 17 #include "CSKYISelLowering.h" 18 #include "CSKYInstrInfo.h" 19 #include "CSKYRegisterInfo.h" 20 #include "llvm/CodeGen/SelectionDAGTargetInfo.h" 21 #include "llvm/CodeGen/TargetSubtargetInfo.h" 22 #include "llvm/Target/TargetMachine.h" 23 24 #define GET_SUBTARGETINFO_HEADER 25 #include "CSKYGenSubtargetInfo.inc" 26 27 namespace llvm { 28 class StringRef; 29 30 class CSKYSubtarget : public CSKYGenSubtargetInfo { 31 virtual void anchor(); 32 33 CSKYFrameLowering FrameLowering; 34 CSKYInstrInfo InstrInfo; 35 CSKYRegisterInfo RegInfo; 36 CSKYTargetLowering TLInfo; 37 SelectionDAGTargetInfo TSInfo; 38 39 bool UseHardFloat; 40 bool UseHardFloatABI; 41 bool HasFPUv2SingleFloat; 42 bool HasFPUv2DoubleFloat; 43 bool HasFPUv3SingleFloat; 44 bool HasFPUv3DoubleFloat; 45 46 bool HasExtendLrw; 47 bool HasDoloop; 48 bool HasHighRegisters; 49 50 bool HasE1; 51 bool HasE2; 52 bool Has2E3; 53 bool HasMP; 54 bool Has3E3r1; 55 bool Has3r1E3r2; 56 bool Has3r2E3r3; 57 bool Has3E7; 58 bool HasMP1E2; 59 bool Has7E10; 60 bool Has10E60; 61 62 public: 63 CSKYSubtarget(const Triple &TT, StringRef CPU, StringRef TuneCPU, 64 StringRef FS, const TargetMachine &TM); 65 66 const CSKYFrameLowering *getFrameLowering() const override { 67 return &FrameLowering; 68 } 69 const CSKYInstrInfo *getInstrInfo() const override { return &InstrInfo; } 70 const CSKYRegisterInfo *getRegisterInfo() const override { return &RegInfo; } 71 const CSKYTargetLowering *getTargetLowering() const override { 72 return &TLInfo; 73 } 74 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override { 75 return &TSInfo; 76 } 77 78 /// Initializes using the passed in CPU and feature strings so that we can 79 /// use initializer lists for subtarget initialization. 80 CSKYSubtarget &initializeSubtargetDependencies(const Triple &TT, 81 StringRef CPU, 82 StringRef TuneCPU, 83 StringRef FS); 84 85 // Generated by inc file 86 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); 87 88 bool useHardFloatABI() const; 89 bool useHardFloat() const { return UseHardFloat; } 90 bool hasFPUv2SingleFloat() const { return HasFPUv2SingleFloat; } 91 bool hasFPUv2DoubleFloat() const { return HasFPUv2DoubleFloat; } 92 bool hasFPUv2() const { return HasFPUv2SingleFloat || HasFPUv2DoubleFloat; } 93 bool hasFPUv3SingleFloat() const { return HasFPUv3SingleFloat; } 94 bool hasFPUv3DoubleFloat() const { return HasFPUv3DoubleFloat; } 95 bool hasFPUv3() const { return HasFPUv3SingleFloat || HasFPUv3DoubleFloat; } 96 bool hasAnyFloatExt() const { return hasFPUv2() || hasFPUv3(); }; 97 98 bool hasExtendLrw() const { return HasExtendLrw; } 99 bool hasDoloop() const { return HasDoloop; } 100 bool hasHighRegisters() const { return HasHighRegisters; } 101 102 bool hasE1() const { return HasE1; } 103 bool hasE2() const { return HasE2; } 104 bool has2E3() const { return Has2E3; } 105 bool has3r1E3r2() const { return Has3r1E3r2; } 106 bool has3r2E3r3() const { return Has3r2E3r3; } 107 bool has3E3r1() const { return Has3E3r1; } 108 bool has3E7() const { return Has3E7; } 109 bool hasMP() const { return HasMP; } 110 bool hasMP1E2() const { return HasMP1E2; } 111 bool has7E10() const { return Has7E10; } 112 bool has10E60() const { return Has10E60; } 113 }; 114 } // namespace llvm 115 116 #endif // LLVM_LIB_TARGET_CSKY_CSKYSUBTARGET_H 117