Home | History | Annotate | Download | only in MCTargetDesc
      1 //===-- XCoreMCTargetDesc.cpp - XCore 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 XCore specific target descriptions.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include "XCoreMCTargetDesc.h"
     15 #include "XCoreMCAsmInfo.h"
     16 #include "llvm/MC/MCCodeGenInfo.h"
     17 #include "llvm/MC/MCInstrInfo.h"
     18 #include "llvm/MC/MCRegisterInfo.h"
     19 #include "llvm/MC/MCSubtargetInfo.h"
     20 #include "llvm/Support/TargetRegistry.h"
     21 
     22 #define GET_INSTRINFO_MC_DESC
     23 #include "XCoreGenInstrInfo.inc"
     24 
     25 #define GET_SUBTARGETINFO_MC_DESC
     26 #include "XCoreGenSubtargetInfo.inc"
     27 
     28 #define GET_REGINFO_MC_DESC
     29 #include "XCoreGenRegisterInfo.inc"
     30 
     31 using namespace llvm;
     32 
     33 static MCInstrInfo *createXCoreMCInstrInfo() {
     34   MCInstrInfo *X = new MCInstrInfo();
     35   InitXCoreMCInstrInfo(X);
     36   return X;
     37 }
     38 
     39 static MCRegisterInfo *createXCoreMCRegisterInfo(StringRef TT) {
     40   MCRegisterInfo *X = new MCRegisterInfo();
     41   InitXCoreMCRegisterInfo(X, XCore::LR);
     42   return X;
     43 }
     44 
     45 static MCSubtargetInfo *createXCoreMCSubtargetInfo(StringRef TT, StringRef CPU,
     46                                                    StringRef FS) {
     47   MCSubtargetInfo *X = new MCSubtargetInfo();
     48   InitXCoreMCSubtargetInfo(X, TT, CPU, FS);
     49   return X;
     50 }
     51 
     52 static MCAsmInfo *createXCoreMCAsmInfo(const Target &T, StringRef TT) {
     53   MCAsmInfo *MAI = new XCoreMCAsmInfo(T, TT);
     54 
     55   // Initial state of the frame pointer is SP.
     56   MachineLocation Dst(MachineLocation::VirtualFP);
     57   MachineLocation Src(XCore::SP, 0);
     58   MAI->addInitialFrameState(0, Dst, Src);
     59 
     60   return MAI;
     61 }
     62 
     63 static MCCodeGenInfo *createXCoreMCCodeGenInfo(StringRef TT, Reloc::Model RM,
     64                                                CodeModel::Model CM) {
     65   MCCodeGenInfo *X = new MCCodeGenInfo();
     66   X->InitMCCodeGenInfo(RM, CM);
     67   return X;
     68 }
     69 
     70 // Force static initialization.
     71 extern "C" void LLVMInitializeXCoreTargetMC() {
     72   // Register the MC asm info.
     73   RegisterMCAsmInfoFn X(TheXCoreTarget, createXCoreMCAsmInfo);
     74 
     75   // Register the MC codegen info.
     76   TargetRegistry::RegisterMCCodeGenInfo(TheXCoreTarget,
     77                                         createXCoreMCCodeGenInfo);
     78 
     79   // Register the MC instruction info.
     80   TargetRegistry::RegisterMCInstrInfo(TheXCoreTarget, createXCoreMCInstrInfo);
     81 
     82   // Register the MC register info.
     83   TargetRegistry::RegisterMCRegInfo(TheXCoreTarget, createXCoreMCRegisterInfo);
     84 
     85   // Register the MC subtarget info.
     86   TargetRegistry::RegisterMCSubtargetInfo(TheXCoreTarget,
     87                                           createXCoreMCSubtargetInfo);
     88 }
     89