1 //===-- NVPTXMCTargetDesc.cpp - NVPTX Target Descriptions -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file provides NVPTX specific target descriptions.
12 //===----------------------------------------------------------------------===//
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"
24 #define GET_INSTRINFO_MC_DESC
25 #include "NVPTXGenInstrInfo.inc"
27 #define GET_SUBTARGETINFO_MC_DESC
28 #include "NVPTXGenSubtargetInfo.inc"
30 #define GET_REGINFO_MC_DESC
31 #include "NVPTXGenRegisterInfo.inc"
33 static MCInstrInfo *createNVPTXMCInstrInfo() {
34 MCInstrInfo *X = new MCInstrInfo();
35 InitNVPTXMCInstrInfo(X);
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);
46 static MCSubtargetInfo *
47 createNVPTXMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
48 return createNVPTXMCSubtargetInfoImpl(TT, CPU, FS);
51 static MCInstPrinter *createNVPTXMCInstPrinter(const Triple &T,
52 unsigned SyntaxVariant,
54 const MCInstrInfo &MII,
55 const MCRegisterInfo &MRI) {
56 if (SyntaxVariant == 0)
57 return new NVPTXInstPrinter(MAI, MII, MRI);
61 // Force static initialization.
62 extern "C" void LLVMInitializeNVPTXTargetMC() {
63 for (Target *T : {&getTheNVPTXTarget32(), &getTheNVPTXTarget64()}) {
64 // Register the MC asm info.
65 RegisterMCAsmInfo<NVPTXMCAsmInfo> X(*T);
67 // Register the MC instruction info.
68 TargetRegistry::RegisterMCInstrInfo(*T, createNVPTXMCInstrInfo);
70 // Register the MC register info.
71 TargetRegistry::RegisterMCRegInfo(*T, createNVPTXMCRegisterInfo);
73 // Register the MC subtarget info.
74 TargetRegistry::RegisterMCSubtargetInfo(*T, createNVPTXMCSubtargetInfo);
76 // Register the MCInstPrinter.
77 TargetRegistry::RegisterMCInstPrinter(*T, createNVPTXMCInstPrinter);