LLVM API Documentation

MSP430MCTargetDesc.cpp
Go to the documentation of this file.
00001 //===-- MSP430MCTargetDesc.cpp - MSP430 Target Descriptions ---------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file provides MSP430 specific target descriptions.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "MSP430MCTargetDesc.h"
00015 #include "InstPrinter/MSP430InstPrinter.h"
00016 #include "MSP430MCAsmInfo.h"
00017 #include "llvm/MC/MCCodeGenInfo.h"
00018 #include "llvm/MC/MCInstrInfo.h"
00019 #include "llvm/MC/MCRegisterInfo.h"
00020 #include "llvm/MC/MCSubtargetInfo.h"
00021 #include "llvm/Support/TargetRegistry.h"
00022 
00023 using namespace llvm;
00024 
00025 #define GET_INSTRINFO_MC_DESC
00026 #include "MSP430GenInstrInfo.inc"
00027 
00028 #define GET_SUBTARGETINFO_MC_DESC
00029 #include "MSP430GenSubtargetInfo.inc"
00030 
00031 #define GET_REGINFO_MC_DESC
00032 #include "MSP430GenRegisterInfo.inc"
00033 
00034 static MCInstrInfo *createMSP430MCInstrInfo() {
00035   MCInstrInfo *X = new MCInstrInfo();
00036   InitMSP430MCInstrInfo(X);
00037   return X;
00038 }
00039 
00040 static MCRegisterInfo *createMSP430MCRegisterInfo(StringRef TT) {
00041   MCRegisterInfo *X = new MCRegisterInfo();
00042   InitMSP430MCRegisterInfo(X, MSP430::PC);
00043   return X;
00044 }
00045 
00046 static MCSubtargetInfo *createMSP430MCSubtargetInfo(StringRef TT, StringRef CPU,
00047                                                     StringRef FS) {
00048   MCSubtargetInfo *X = new MCSubtargetInfo();
00049   InitMSP430MCSubtargetInfo(X, TT, CPU, FS);
00050   return X;
00051 }
00052 
00053 static MCCodeGenInfo *createMSP430MCCodeGenInfo(StringRef TT, Reloc::Model RM,
00054                                                 CodeModel::Model CM,
00055                                                 CodeGenOpt::Level OL) {
00056   MCCodeGenInfo *X = new MCCodeGenInfo();
00057   X->InitMCCodeGenInfo(RM, CM, OL);
00058   return X;
00059 }
00060 
00061 static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
00062                                                 unsigned SyntaxVariant,
00063                                                 const MCAsmInfo &MAI,
00064                                                 const MCInstrInfo &MII,
00065                                                 const MCRegisterInfo &MRI,
00066                                                 const MCSubtargetInfo &STI) {
00067   if (SyntaxVariant == 0)
00068     return new MSP430InstPrinter(MAI, MII, MRI);
00069   return nullptr;
00070 }
00071 
00072 extern "C" void LLVMInitializeMSP430TargetMC() {
00073   // Register the MC asm info.
00074   RegisterMCAsmInfo<MSP430MCAsmInfo> X(TheMSP430Target);
00075 
00076   // Register the MC codegen info.
00077   TargetRegistry::RegisterMCCodeGenInfo(TheMSP430Target,
00078                                         createMSP430MCCodeGenInfo);
00079 
00080   // Register the MC instruction info.
00081   TargetRegistry::RegisterMCInstrInfo(TheMSP430Target, createMSP430MCInstrInfo);
00082 
00083   // Register the MC register info.
00084   TargetRegistry::RegisterMCRegInfo(TheMSP430Target,
00085                                     createMSP430MCRegisterInfo);
00086 
00087   // Register the MC subtarget info.
00088   TargetRegistry::RegisterMCSubtargetInfo(TheMSP430Target,
00089                                           createMSP430MCSubtargetInfo);
00090 
00091   // Register the MCInstPrinter.
00092   TargetRegistry::RegisterMCInstPrinter(TheMSP430Target,
00093                                         createMSP430MCInstPrinter);
00094 }