| 1 | //===-- MSP430Subtarget.h - Define Subtarget for the MSP430 ----*- 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 MSP430 specific subclass of TargetSubtargetInfo. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #ifndef LLVM_LIB_TARGET_MSP430_MSP430SUBTARGET_H |
| 14 | #define LLVM_LIB_TARGET_MSP430_MSP430SUBTARGET_H |
| 15 | |
| 16 | #include "MSP430FrameLowering.h" |
| 17 | #include "MSP430ISelLowering.h" |
| 18 | #include "MSP430InstrInfo.h" |
| 19 | #include "MSP430RegisterInfo.h" |
| 20 | #include "llvm/CodeGen/TargetSubtargetInfo.h" |
| 21 | #include "llvm/IR/DataLayout.h" |
| 22 | #include <string> |
| 23 | |
| 24 | namespace llvm::MSP430 { |
| 25 | enum class HWMult { None, HW16, HW32, F5 }; |
| 26 | } // namespace llvm::MSP430 |
| 27 | |
| 28 | #define OPTIONS_STRUCT_DECL |
| 29 | #include "MSP430Options.inc" |
| 30 | |
| 31 | #define |
| 32 | #include "MSP430GenSubtargetInfo.inc" |
| 33 | |
| 34 | namespace llvm { |
| 35 | class MSP430TargetMachine; |
| 36 | class StringRef; |
| 37 | |
| 38 | class MSP430Subtarget : public MSP430GenSubtargetInfo { |
| 39 | const MSP430Options &CLOpts; |
| 40 | virtual void anchor(); |
| 41 | bool ExtendedInsts = false; |
| 42 | MSP430::HWMult HWMultMode = MSP430::HWMult::None; |
| 43 | MSP430InstrInfo InstrInfo; |
| 44 | MSP430TargetLowering TLInfo; |
| 45 | std::unique_ptr<const SelectionDAGTargetInfo> TSInfo; |
| 46 | MSP430FrameLowering FrameLowering; |
| 47 | |
| 48 | public: |
| 49 | /// This constructor initializes the data members to match that |
| 50 | /// of the specified triple. |
| 51 | /// |
| 52 | MSP430Subtarget(const Triple &TT, const std::string &CPU, |
| 53 | const std::string &FS, const MSP430TargetMachine &TM); |
| 54 | |
| 55 | ~MSP430Subtarget() override; |
| 56 | |
| 57 | const MSP430Options &getCLOpts() const { return CLOpts; } |
| 58 | |
| 59 | MSP430Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS); |
| 60 | |
| 61 | /// ParseSubtargetFeatures - Parses features string setting specified |
| 62 | /// subtarget options. Definition of function is auto generated by tblgen. |
| 63 | void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS); |
| 64 | |
| 65 | bool hasHWMult16() const { return HWMultMode == MSP430::HWMult::HW16; } |
| 66 | bool hasHWMult32() const { return HWMultMode == MSP430::HWMult::HW32; } |
| 67 | bool hasHWMultF5() const { return HWMultMode == MSP430::HWMult::F5; } |
| 68 | |
| 69 | const TargetFrameLowering *getFrameLowering() const override { |
| 70 | return &FrameLowering; |
| 71 | } |
| 72 | const MSP430InstrInfo *getInstrInfo() const override { return &InstrInfo; } |
| 73 | const MSP430RegisterInfo *getRegisterInfo() const override { |
| 74 | return &getInstrInfo()->getRegisterInfo(); |
| 75 | } |
| 76 | |
| 77 | const MSP430TargetLowering *getTargetLowering() const override { |
| 78 | return &TLInfo; |
| 79 | } |
| 80 | |
| 81 | const SelectionDAGTargetInfo *getSelectionDAGInfo() const override; |
| 82 | |
| 83 | void initLibcallLoweringInfo(LibcallLoweringInfo &Info) const override; |
| 84 | }; |
| 85 | } // End llvm namespace |
| 86 | |
| 87 | #endif // LLVM_TARGET_MSP430_SUBTARGET_H |
| 88 | |