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/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"
25 #define GET_INSTRINFO_MC_DESC
26 #include "NVPTXGenInstrInfo.inc"
28 #define GET_SUBTARGETINFO_MC_DESC
29 #include "NVPTXGenSubtargetInfo.inc"
31 #define GET_REGINFO_MC_DESC
32 #include "NVPTXGenRegisterInfo.inc"
34 static MCInstrInfo *createNVPTXMCInstrInfo() {
35 MCInstrInfo *X = new MCInstrInfo();
36 InitNVPTXMCInstrInfo(X);
40 static MCRegisterInfo *createNVPTXMCRegisterInfo(const TargetTuple &TT) {
41 MCRegisterInfo *X = new MCRegisterInfo();
42 // PTX does not have a return address register.
43 InitNVPTXMCRegisterInfo(X, 0);
47 static MCSubtargetInfo *
48 createNVPTXMCSubtargetInfo(const TargetTuple &TT, StringRef CPU, StringRef FS) {
49 return createNVPTXMCSubtargetInfoImpl(TT, CPU, FS);
52 static MCCodeGenInfo *createNVPTXMCCodeGenInfo(const TargetTuple &TT,
55 CodeGenOpt::Level OL) {
56 MCCodeGenInfo *X = new MCCodeGenInfo();
58 // The default relocation model is used regardless of what the client has
59 // specified, as it is the only relocation model currently supported.
60 X->initMCCodeGenInfo(Reloc::Default, CM, OL);
64 static MCInstPrinter *createNVPTXMCInstPrinter(const TargetTuple &T,
65 unsigned SyntaxVariant,
67 const MCInstrInfo &MII,
68 const MCRegisterInfo &MRI) {
69 if (SyntaxVariant == 0)
70 return new NVPTXInstPrinter(MAI, MII, MRI);
74 // Force static initialization.
75 extern "C" void LLVMInitializeNVPTXTargetMC() {
76 for (Target *T : {&TheNVPTXTarget32, &TheNVPTXTarget64}) {
77 // Register the MC asm info.
78 RegisterMCAsmInfo<NVPTXMCAsmInfo> X(*T);
80 // Register the MC codegen info.
81 TargetRegistry::RegisterMCCodeGenInfo(*T, createNVPTXMCCodeGenInfo);
83 // Register the MC instruction info.
84 TargetRegistry::RegisterMCInstrInfo(*T, createNVPTXMCInstrInfo);
86 // Register the MC register info.
87 TargetRegistry::RegisterMCRegInfo(*T, createNVPTXMCRegisterInfo);
89 // Register the MC subtarget info.
90 TargetRegistry::RegisterMCSubtargetInfo(*T, createNVPTXMCSubtargetInfo);
92 // Register the MCInstPrinter.
93 TargetRegistry::RegisterMCInstPrinter(*T, createNVPTXMCInstPrinter);