MSP430MCTargetDesc.cpp revision 226890
1//===-- MSP430MCTargetDesc.cpp - MSP430 Target Descriptions -----*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file provides MSP430 specific target descriptions.
11//
12//===----------------------------------------------------------------------===//
13
14#include "MSP430MCTargetDesc.h"
15#include "MSP430MCAsmInfo.h"
16#include "InstPrinter/MSP430InstPrinter.h"
17#include "llvm/MC/MCCodeGenInfo.h"
18#include "llvm/MC/MCInstrInfo.h"
19#include "llvm/MC/MCRegisterInfo.h"
20#include "llvm/MC/MCSubtargetInfo.h"
21#include "llvm/Support/TargetRegistry.h"
22
23#define GET_INSTRINFO_MC_DESC
24#include "MSP430GenInstrInfo.inc"
25
26#define GET_SUBTARGETINFO_MC_DESC
27#include "MSP430GenSubtargetInfo.inc"
28
29#define GET_REGINFO_MC_DESC
30#include "MSP430GenRegisterInfo.inc"
31
32using namespace llvm;
33
34static MCInstrInfo *createMSP430MCInstrInfo() {
35  MCInstrInfo *X = new MCInstrInfo();
36  InitMSP430MCInstrInfo(X);
37  return X;
38}
39
40static MCRegisterInfo *createMSP430MCRegisterInfo(StringRef TT) {
41  MCRegisterInfo *X = new MCRegisterInfo();
42  InitMSP430MCRegisterInfo(X, MSP430::PCW);
43  return X;
44}
45
46static MCSubtargetInfo *createMSP430MCSubtargetInfo(StringRef TT, StringRef CPU,
47                                                    StringRef FS) {
48  MCSubtargetInfo *X = new MCSubtargetInfo();
49  InitMSP430MCSubtargetInfo(X, TT, CPU, FS);
50  return X;
51}
52
53static MCCodeGenInfo *createMSP430MCCodeGenInfo(StringRef TT, Reloc::Model RM,
54                                                CodeModel::Model CM) {
55  MCCodeGenInfo *X = new MCCodeGenInfo();
56  X->InitMCCodeGenInfo(RM, CM);
57  return X;
58}
59
60static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
61                                                unsigned SyntaxVariant,
62                                                const MCAsmInfo &MAI,
63                                                const MCSubtargetInfo &STI) {
64  if (SyntaxVariant == 0)
65    return new MSP430InstPrinter(MAI);
66  return 0;
67}
68
69extern "C" void LLVMInitializeMSP430TargetMC() {
70  // Register the MC asm info.
71  RegisterMCAsmInfo<MSP430MCAsmInfo> X(TheMSP430Target);
72
73  // Register the MC codegen info.
74  TargetRegistry::RegisterMCCodeGenInfo(TheMSP430Target,
75                                        createMSP430MCCodeGenInfo);
76
77  // Register the MC instruction info.
78  TargetRegistry::RegisterMCInstrInfo(TheMSP430Target, createMSP430MCInstrInfo);
79
80  // Register the MC register info.
81  TargetRegistry::RegisterMCRegInfo(TheMSP430Target,
82                                    createMSP430MCRegisterInfo);
83
84  // Register the MC subtarget info.
85  TargetRegistry::RegisterMCSubtargetInfo(TheMSP430Target,
86                                          createMSP430MCSubtargetInfo);
87
88  // Register the MCInstPrinter.
89  TargetRegistry::RegisterMCInstPrinter(TheMSP430Target,
90                                        createMSP430MCInstPrinter);
91}
92