149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===-- NVPTXMCTargetDesc.cpp - NVPTX Target Descriptions -------*- C++ -*-===// 249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// The LLVM Compiler Infrastructure 449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// This file is distributed under the University of Illinois Open Source 649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// License. See LICENSE.TXT for details. 749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===----------------------------------------------------------------------===// 949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 1049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// This file provides NVPTX specific target descriptions. 1149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// 1249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===----------------------------------------------------------------------===// 1349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 1449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTXMCTargetDesc.h" 1582767327c59ede1f8663ec9b9a64a668993d501fJustin Holewinski#include "InstPrinter/NVPTXInstPrinter.h" 1636b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "NVPTXMCAsmInfo.h" 1749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "llvm/MC/MCCodeGenInfo.h" 1849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "llvm/MC/MCInstrInfo.h" 1949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "llvm/MC/MCRegisterInfo.h" 2049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "llvm/MC/MCSubtargetInfo.h" 2149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "llvm/Support/TargetRegistry.h" 2249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 23dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hinesusing namespace llvm; 24dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines 2549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define GET_INSTRINFO_MC_DESC 2649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTXGenInstrInfo.inc" 2749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 2849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define GET_SUBTARGETINFO_MC_DESC 2949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTXGenSubtargetInfo.inc" 3049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 3149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define GET_REGINFO_MC_DESC 3249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTXGenRegisterInfo.inc" 3349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 3449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinskistatic MCInstrInfo *createNVPTXMCInstrInfo() { 3549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski MCInstrInfo *X = new MCInstrInfo(); 3649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski InitNVPTXMCInstrInfo(X); 3749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski return X; 3849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} 3949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 40cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarstatic MCRegisterInfo *createNVPTXMCRegisterInfo(const Triple &TT) { 4149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski MCRegisterInfo *X = new MCRegisterInfo(); 4249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski // PTX does not have a return address register. 4349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski InitNVPTXMCRegisterInfo(X, 0); 4449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski return X; 4549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} 4649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 473639ce2575660a0e6938d2e84e8bd9a738fd7051Justin Holewinskistatic MCSubtargetInfo * 486948897e478cbd66626159776a8017b3c18579b9Pirama Arumuga NainarcreateNVPTXMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) { 49cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar return createNVPTXMCSubtargetInfoImpl(TT, CPU, FS); 5049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} 5149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 52cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainarstatic MCCodeGenInfo *createNVPTXMCCodeGenInfo(const Triple &TT, 53cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar Reloc::Model RM, 54cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar CodeModel::Model CM, 55cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar CodeGenOpt::Level OL) { 5649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski MCCodeGenInfo *X = new MCCodeGenInfo(); 57cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar 58cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // The default relocation model is used regardless of what the client has 59cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar // specified, as it is the only relocation model currently supported. 60cddc3e03e4ec99c0268c03a126195173e519ed58Pirama Arumuga Nainar X->initMCCodeGenInfo(Reloc::Default, CM, OL); 6149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski return X; 6249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} 6349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski 640c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainarstatic MCInstPrinter *createNVPTXMCInstPrinter(const Triple &T, 6582767327c59ede1f8663ec9b9a64a668993d501fJustin Holewinski unsigned SyntaxVariant, 6682767327c59ede1f8663ec9b9a64a668993d501fJustin Holewinski const MCAsmInfo &MAI, 6782767327c59ede1f8663ec9b9a64a668993d501fJustin Holewinski const MCInstrInfo &MII, 680c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar const MCRegisterInfo &MRI) { 6982767327c59ede1f8663ec9b9a64a668993d501fJustin Holewinski if (SyntaxVariant == 0) 700c7f116bb6950ef819323d855415b2f2b0aad987Pirama Arumuga Nainar return new NVPTXInstPrinter(MAI, MII, MRI); 71dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines return nullptr; 7282767327c59ede1f8663ec9b9a64a668993d501fJustin Holewinski} 7382767327c59ede1f8663ec9b9a64a668993d501fJustin Holewinski 7449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// Force static initialization. 7549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinskiextern "C" void LLVMInitializeNVPTXTargetMC() { 764c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar for (Target *T : {&TheNVPTXTarget32, &TheNVPTXTarget64}) { 774c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar // Register the MC asm info. 784c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar RegisterMCAsmInfo<NVPTXMCAsmInfo> X(*T); 794c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 804c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar // Register the MC codegen info. 814c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar TargetRegistry::RegisterMCCodeGenInfo(*T, createNVPTXMCCodeGenInfo); 824c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 834c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar // Register the MC instruction info. 844c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar TargetRegistry::RegisterMCInstrInfo(*T, createNVPTXMCInstrInfo); 854c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 864c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar // Register the MC register info. 874c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar TargetRegistry::RegisterMCRegInfo(*T, createNVPTXMCRegisterInfo); 884c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 894c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar // Register the MC subtarget info. 904c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar TargetRegistry::RegisterMCSubtargetInfo(*T, createNVPTXMCSubtargetInfo); 914c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar 924c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar // Register the MCInstPrinter. 934c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar TargetRegistry::RegisterMCInstPrinter(*T, createNVPTXMCInstPrinter); 944c5e43da7792f75567b693105cc53e3f1992ad98Pirama Arumuga Nainar } 9549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} 96