Home | History | Annotate | Download | only in MCTargetDesc
      1 //===-- NVPTXMCTargetDesc.cpp - NVPTX 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 NVPTX specific target descriptions.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include "NVPTXMCTargetDesc.h"
     15 #include "InstPrinter/NVPTXInstPrinter.h"
     16 #include "NVPTXMCAsmInfo.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 using namespace llvm;
     23 
     24 #define GET_INSTRINFO_MC_DESC
     25 #include "NVPTXGenInstrInfo.inc"
     26 
     27 #define GET_SUBTARGETINFO_MC_DESC
     28 #include "NVPTXGenSubtargetInfo.inc"
     29 
     30 #define GET_REGINFO_MC_DESC
     31 #include "NVPTXGenRegisterInfo.inc"
     32 
     33 static MCInstrInfo *createNVPTXMCInstrInfo() {
     34   MCInstrInfo *X = new MCInstrInfo();
     35   InitNVPTXMCInstrInfo(X);
     36   return X;
     37 }
     38 
     39 static MCRegisterInfo *createNVPTXMCRegisterInfo(const Triple &TT) {
     40   MCRegisterInfo *X = new MCRegisterInfo();
     41   // PTX does not have a return address register.
     42   InitNVPTXMCRegisterInfo(X, 0);
     43   return X;
     44 }
     45 
     46 static MCSubtargetInfo *
     47 createNVPTXMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
     48   return createNVPTXMCSubtargetInfoImpl(TT, CPU, FS);
     49 }
     50 
     51 static MCInstPrinter *createNVPTXMCInstPrinter(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 NVPTXInstPrinter(MAI, MII, MRI);
     58   return nullptr;
     59 }
     60 
     61 // Force static initialization.
     62 extern "C" void LLVMInitializeNVPTXTargetMC() {
     63   for (Target *T : {&TheNVPTXTarget32, &TheNVPTXTarget64}) {
     64     // Register the MC asm info.
     65     RegisterMCAsmInfo<NVPTXMCAsmInfo> X(*T);
     66 
     67     // Register the MC instruction info.
     68     TargetRegistry::RegisterMCInstrInfo(*T, createNVPTXMCInstrInfo);
     69 
     70     // Register the MC register info.
     71     TargetRegistry::RegisterMCRegInfo(*T, createNVPTXMCRegisterInfo);
     72 
     73     // Register the MC subtarget info.
     74     TargetRegistry::RegisterMCSubtargetInfo(*T, createNVPTXMCSubtargetInfo);
     75 
     76     // Register the MCInstPrinter.
     77     TargetRegistry::RegisterMCInstPrinter(*T, createNVPTXMCInstPrinter);
     78   }
     79 }
     80