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#define GET_SUBTARGETINFO_HEADER
25#include "MSP430GenSubtargetInfo.inc"
26
27namespace llvm {
28class StringRef;
29
30class MSP430Subtarget : public MSP430GenSubtargetInfo {
31public:
32 enum HWMultEnum {
33 NoHWMult, HWMult16, HWMult32, HWMultF5
34 };
35
36private:
37 virtual void anchor();
38 bool ExtendedInsts = false;
39 HWMultEnum HWMultMode = NoHWMult;
40 MSP430InstrInfo InstrInfo;
41 MSP430TargetLowering TLInfo;
42 std::unique_ptr<const SelectionDAGTargetInfo> TSInfo;
43 MSP430FrameLowering FrameLowering;
44
45public:
46 /// This constructor initializes the data members to match that
47 /// of the specified triple.
48 ///
49 MSP430Subtarget(const Triple &TT, const std::string &CPU,
50 const std::string &FS, const TargetMachine &TM);
51
52 ~MSP430Subtarget() override;
53
54 MSP430Subtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
55
56 /// ParseSubtargetFeatures - Parses features string setting specified
57 /// subtarget options. Definition of function is auto generated by tblgen.
58 void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
59
60 bool hasHWMult16() const { return HWMultMode == HWMult16; }
61 bool hasHWMult32() const { return HWMultMode == HWMult32; }
62 bool hasHWMultF5() const { return HWMultMode == HWMultF5; }
63
64 const TargetFrameLowering *getFrameLowering() const override {
65 return &FrameLowering;
66 }
67 const MSP430InstrInfo *getInstrInfo() const override { return &InstrInfo; }
68 const MSP430RegisterInfo *getRegisterInfo() const override {
69 return &getInstrInfo()->getRegisterInfo();
70 }
71
72 const MSP430TargetLowering *getTargetLowering() const override {
73 return &TLInfo;
74 }
75
76 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override;
77};
78} // End llvm namespace
79
80#endif // LLVM_TARGET_MSP430_SUBTARGET_H
81