LLVM API Documentation
00001 //===-- NVPTXMCTargetDesc.cpp - NVPTX Target Descriptions -------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file provides NVPTX specific target descriptions. 00011 // 00012 //===----------------------------------------------------------------------===// 00013 00014 #include "NVPTXMCTargetDesc.h" 00015 #include "InstPrinter/NVPTXInstPrinter.h" 00016 #include "NVPTXMCAsmInfo.h" 00017 #include "llvm/MC/MCCodeGenInfo.h" 00018 #include "llvm/MC/MCInstrInfo.h" 00019 #include "llvm/MC/MCRegisterInfo.h" 00020 #include "llvm/MC/MCSubtargetInfo.h" 00021 #include "llvm/Support/TargetRegistry.h" 00022 00023 using namespace llvm; 00024 00025 #define GET_INSTRINFO_MC_DESC 00026 #include "NVPTXGenInstrInfo.inc" 00027 00028 #define GET_SUBTARGETINFO_MC_DESC 00029 #include "NVPTXGenSubtargetInfo.inc" 00030 00031 #define GET_REGINFO_MC_DESC 00032 #include "NVPTXGenRegisterInfo.inc" 00033 00034 static MCInstrInfo *createNVPTXMCInstrInfo() { 00035 MCInstrInfo *X = new MCInstrInfo(); 00036 InitNVPTXMCInstrInfo(X); 00037 return X; 00038 } 00039 00040 static MCRegisterInfo *createNVPTXMCRegisterInfo(StringRef TT) { 00041 MCRegisterInfo *X = new MCRegisterInfo(); 00042 // PTX does not have a return address register. 00043 InitNVPTXMCRegisterInfo(X, 0); 00044 return X; 00045 } 00046 00047 static MCSubtargetInfo * 00048 createNVPTXMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS) { 00049 MCSubtargetInfo *X = new MCSubtargetInfo(); 00050 InitNVPTXMCSubtargetInfo(X, TT, CPU, FS); 00051 return X; 00052 } 00053 00054 static MCCodeGenInfo *createNVPTXMCCodeGenInfo( 00055 StringRef TT, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL) { 00056 MCCodeGenInfo *X = new MCCodeGenInfo(); 00057 X->InitMCCodeGenInfo(RM, CM, OL); 00058 return X; 00059 } 00060 00061 static MCInstPrinter *createNVPTXMCInstPrinter(const Target &T, 00062 unsigned SyntaxVariant, 00063 const MCAsmInfo &MAI, 00064 const MCInstrInfo &MII, 00065 const MCRegisterInfo &MRI, 00066 const MCSubtargetInfo &STI) { 00067 if (SyntaxVariant == 0) 00068 return new NVPTXInstPrinter(MAI, MII, MRI, STI); 00069 return nullptr; 00070 } 00071 00072 // Force static initialization. 00073 extern "C" void LLVMInitializeNVPTXTargetMC() { 00074 // Register the MC asm info. 00075 RegisterMCAsmInfo<NVPTXMCAsmInfo> X(TheNVPTXTarget32); 00076 RegisterMCAsmInfo<NVPTXMCAsmInfo> Y(TheNVPTXTarget64); 00077 00078 // Register the MC codegen info. 00079 TargetRegistry::RegisterMCCodeGenInfo(TheNVPTXTarget32, 00080 createNVPTXMCCodeGenInfo); 00081 TargetRegistry::RegisterMCCodeGenInfo(TheNVPTXTarget64, 00082 createNVPTXMCCodeGenInfo); 00083 00084 // Register the MC instruction info. 00085 TargetRegistry::RegisterMCInstrInfo(TheNVPTXTarget32, createNVPTXMCInstrInfo); 00086 TargetRegistry::RegisterMCInstrInfo(TheNVPTXTarget64, createNVPTXMCInstrInfo); 00087 00088 // Register the MC register info. 00089 TargetRegistry::RegisterMCRegInfo(TheNVPTXTarget32, 00090 createNVPTXMCRegisterInfo); 00091 TargetRegistry::RegisterMCRegInfo(TheNVPTXTarget64, 00092 createNVPTXMCRegisterInfo); 00093 00094 // Register the MC subtarget info. 00095 TargetRegistry::RegisterMCSubtargetInfo(TheNVPTXTarget32, 00096 createNVPTXMCSubtargetInfo); 00097 TargetRegistry::RegisterMCSubtargetInfo(TheNVPTXTarget64, 00098 createNVPTXMCSubtargetInfo); 00099 00100 // Register the MCInstPrinter. 00101 TargetRegistry::RegisterMCInstPrinter(TheNVPTXTarget32, 00102 createNVPTXMCInstPrinter); 00103 TargetRegistry::RegisterMCInstPrinter(TheNVPTXTarget64, 00104 createNVPTXMCInstPrinter); 00105 }