xref: /freebsd/contrib/llvm-project/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp (revision d9a42747950146bf03cda7f6e25d219253f8a57a)
1 //===-- MSP430MCTargetDesc.cpp - MSP430 Target Descriptions ---------------===//
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 provides MSP430 specific target descriptions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "MSP430MCTargetDesc.h"
14 #include "MSP430InstPrinter.h"
15 #include "MSP430MCAsmInfo.h"
16 #include "TargetInfo/MSP430TargetInfo.h"
17 #include "llvm/MC/MCInstrInfo.h"
18 #include "llvm/MC/MCRegisterInfo.h"
19 #include "llvm/MC/MCSubtargetInfo.h"
20 #include "llvm/MC/TargetRegistry.h"
21 
22 using namespace llvm;
23 
24 #define GET_INSTRINFO_MC_DESC
25 #define ENABLE_INSTR_PREDICATE_VERIFIER
26 #include "MSP430GenInstrInfo.inc"
27 
28 #define GET_SUBTARGETINFO_MC_DESC
29 #include "MSP430GenSubtargetInfo.inc"
30 
31 #define GET_REGINFO_MC_DESC
32 #include "MSP430GenRegisterInfo.inc"
33 
34 static MCInstrInfo *createMSP430MCInstrInfo() {
35   MCInstrInfo *X = new MCInstrInfo();
36   InitMSP430MCInstrInfo(X);
37   return X;
38 }
39 
40 static MCRegisterInfo *createMSP430MCRegisterInfo(const Triple &TT) {
41   MCRegisterInfo *X = new MCRegisterInfo();
42   InitMSP430MCRegisterInfo(X, MSP430::PC);
43   return X;
44 }
45 
46 static MCSubtargetInfo *
47 createMSP430MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
48   return createMSP430MCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
49 }
50 
51 static MCInstPrinter *createMSP430MCInstPrinter(const Triple &T,
52                                                 unsigned SyntaxVariant,
53                                                 const MCAsmInfo &MAI,
54                                                 const MCInstrInfo &MII,
55                                                 const MCRegisterInfo &MRI) {
56   if (SyntaxVariant == 0)
57     return new MSP430InstPrinter(MAI, MII, MRI);
58   return nullptr;
59 }
60 
61 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430TargetMC() {
62   Target &T = getTheMSP430Target();
63 
64   RegisterMCAsmInfo<MSP430MCAsmInfo> X(T);
65   TargetRegistry::RegisterMCInstrInfo(T, createMSP430MCInstrInfo);
66   TargetRegistry::RegisterMCRegInfo(T, createMSP430MCRegisterInfo);
67   TargetRegistry::RegisterMCSubtargetInfo(T, createMSP430MCSubtargetInfo);
68   TargetRegistry::RegisterMCInstPrinter(T, createMSP430MCInstPrinter);
69   TargetRegistry::RegisterMCCodeEmitter(T, createMSP430MCCodeEmitter);
70   TargetRegistry::RegisterMCAsmBackend(T, createMSP430MCAsmBackend);
71   TargetRegistry::RegisterObjectTargetStreamer(
72       T, createMSP430ObjectTargetStreamer);
73 }
74