1 //===-- PTXMCTargetDesc.cpp - PTX 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 PTX specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "PTXMCTargetDesc.h"
15 #include "PTXMCAsmInfo.h"
16 #include "InstPrinter/PTXInstPrinter.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"
22
23 #define GET_INSTRINFO_MC_DESC
24 #include "PTXGenInstrInfo.inc"
25
26 #define GET_SUBTARGETINFO_MC_DESC
27 #include "PTXGenSubtargetInfo.inc"
28
29 #define GET_REGINFO_MC_DESC
30 #include "PTXGenRegisterInfo.inc"
31
32 using namespace llvm;
33
createPTXMCInstrInfo()34 static MCInstrInfo *createPTXMCInstrInfo() {
35 MCInstrInfo *X = new MCInstrInfo();
36 InitPTXMCInstrInfo(X);
37 return X;
38 }
39
createPTXMCRegisterInfo(StringRef TT)40 static MCRegisterInfo *createPTXMCRegisterInfo(StringRef TT) {
41 MCRegisterInfo *X = new MCRegisterInfo();
42 // PTX does not have a return address register.
43 InitPTXMCRegisterInfo(X, 0);
44 return X;
45 }
46
createPTXMCSubtargetInfo(StringRef TT,StringRef CPU,StringRef FS)47 static MCSubtargetInfo *createPTXMCSubtargetInfo(StringRef TT, StringRef CPU,
48 StringRef FS) {
49 MCSubtargetInfo *X = new MCSubtargetInfo();
50 InitPTXMCSubtargetInfo(X, TT, CPU, FS);
51 return X;
52 }
53
createPTXMCCodeGenInfo(StringRef TT,Reloc::Model RM,CodeModel::Model CM)54 static MCCodeGenInfo *createPTXMCCodeGenInfo(StringRef TT, Reloc::Model RM,
55 CodeModel::Model CM) {
56 MCCodeGenInfo *X = new MCCodeGenInfo();
57 X->InitMCCodeGenInfo(RM, CM);
58 return X;
59 }
60
createPTXMCInstPrinter(const Target & T,unsigned SyntaxVariant,const MCAsmInfo & MAI,const MCSubtargetInfo & STI)61 static MCInstPrinter *createPTXMCInstPrinter(const Target &T,
62 unsigned SyntaxVariant,
63 const MCAsmInfo &MAI,
64 const MCSubtargetInfo &STI) {
65 assert(SyntaxVariant == 0 && "We only have one syntax variant");
66 return new PTXInstPrinter(MAI, STI);
67 }
68
LLVMInitializePTXTargetMC()69 extern "C" void LLVMInitializePTXTargetMC() {
70 // Register the MC asm info.
71 RegisterMCAsmInfo<PTXMCAsmInfo> X(ThePTX32Target);
72 RegisterMCAsmInfo<PTXMCAsmInfo> Y(ThePTX64Target);
73
74 // Register the MC codegen info.
75 TargetRegistry::RegisterMCCodeGenInfo(ThePTX32Target, createPTXMCCodeGenInfo);
76 TargetRegistry::RegisterMCCodeGenInfo(ThePTX64Target, createPTXMCCodeGenInfo);
77
78 // Register the MC instruction info.
79 TargetRegistry::RegisterMCInstrInfo(ThePTX32Target, createPTXMCInstrInfo);
80 TargetRegistry::RegisterMCInstrInfo(ThePTX64Target, createPTXMCInstrInfo);
81
82 // Register the MC register info.
83 TargetRegistry::RegisterMCRegInfo(ThePTX32Target, createPTXMCRegisterInfo);
84 TargetRegistry::RegisterMCRegInfo(ThePTX64Target, createPTXMCRegisterInfo);
85
86 // Register the MC subtarget info.
87 TargetRegistry::RegisterMCSubtargetInfo(ThePTX32Target,
88 createPTXMCSubtargetInfo);
89 TargetRegistry::RegisterMCSubtargetInfo(ThePTX64Target,
90 createPTXMCSubtargetInfo);
91
92 // Register the MCInstPrinter.
93 TargetRegistry::RegisterMCInstPrinter(ThePTX32Target, createPTXMCInstPrinter);
94 TargetRegistry::RegisterMCInstPrinter(ThePTX64Target, createPTXMCInstPrinter);
95 }
96