1 //===-- MSP430MCTargetDesc.cpp - MSP430 Target Descriptions ---------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file provides MSP430 specific target descriptions.
11 //===----------------------------------------------------------------------===//
13 #include "MSP430MCTargetDesc.h"
14 #include "MSP430InstPrinter.h"
15 #include "MSP430MCAsmInfo.h"
16 #include "TargetInfo/MSP430TargetInfo.h"
17 #include "llvm/MC/MCDwarf.h"
18 #include "llvm/MC/MCInstrInfo.h"
19 #include "llvm/MC/MCRegisterInfo.h"
20 #include "llvm/MC/MCSubtargetInfo.h"
21 #include "llvm/MC/TargetRegistry.h"
25 #define GET_INSTRINFO_MC_DESC
26 #define ENABLE_INSTR_PREDICATE_VERIFIER
27 #include "MSP430GenInstrInfo.inc"
29 #define GET_SUBTARGETINFO_MC_DESC
30 #include "MSP430GenSubtargetInfo.inc"
32 #define GET_REGINFO_MC_DESC
33 #include "MSP430GenRegisterInfo.inc"
35 static MCInstrInfo
*createMSP430MCInstrInfo() {
36 MCInstrInfo
*X
= new MCInstrInfo();
37 InitMSP430MCInstrInfo(X
);
41 static MCRegisterInfo
*createMSP430MCRegisterInfo(const Triple
&TT
) {
42 MCRegisterInfo
*X
= new MCRegisterInfo();
43 InitMSP430MCRegisterInfo(X
, MSP430::PC
);
47 static MCAsmInfo
*createMSP430MCAsmInfo(const MCRegisterInfo
&MRI
,
49 const MCTargetOptions
&Options
) {
50 MCAsmInfo
*MAI
= new MSP430MCAsmInfo(TT
);
52 // Initialize initial frame state.
55 // Initial state of the frame pointer is sp+ptr_size.
56 MCCFIInstruction Inst
= MCCFIInstruction::cfiDefCfa(
57 nullptr, MRI
.getDwarfRegNum(MSP430::SP
, true), -stackGrowth
);
58 MAI
->addInitialFrameState(Inst
);
60 // Add return address to move list
61 MCCFIInstruction Inst2
= MCCFIInstruction::createOffset(
62 nullptr, MRI
.getDwarfRegNum(MSP430::PC
, true), stackGrowth
);
63 MAI
->addInitialFrameState(Inst2
);
68 static MCSubtargetInfo
*
69 createMSP430MCSubtargetInfo(const Triple
&TT
, StringRef CPU
, StringRef FS
) {
70 return createMSP430MCSubtargetInfoImpl(TT
, CPU
, /*TuneCPU*/ CPU
, FS
);
73 static MCInstPrinter
*createMSP430MCInstPrinter(const Triple
&T
,
74 unsigned SyntaxVariant
,
76 const MCInstrInfo
&MII
,
77 const MCRegisterInfo
&MRI
) {
78 if (SyntaxVariant
== 0)
79 return new MSP430InstPrinter(MAI
, MII
, MRI
);
83 extern "C" LLVM_EXTERNAL_VISIBILITY
void LLVMInitializeMSP430TargetMC() {
84 Target
&T
= getTheMSP430Target();
86 TargetRegistry::RegisterMCAsmInfo(T
, createMSP430MCAsmInfo
);
87 TargetRegistry::RegisterMCInstrInfo(T
, createMSP430MCInstrInfo
);
88 TargetRegistry::RegisterMCRegInfo(T
, createMSP430MCRegisterInfo
);
89 TargetRegistry::RegisterMCSubtargetInfo(T
, createMSP430MCSubtargetInfo
);
90 TargetRegistry::RegisterMCInstPrinter(T
, createMSP430MCInstPrinter
);
91 TargetRegistry::RegisterMCCodeEmitter(T
, createMSP430MCCodeEmitter
);
92 TargetRegistry::RegisterMCAsmBackend(T
, createMSP430MCAsmBackend
);
93 TargetRegistry::RegisterObjectTargetStreamer(
94 T
, createMSP430ObjectTargetStreamer
);