xref: /freebsd/contrib/llvm-project/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp (revision 0fca6ea1d4eea4c934cfff25ac9ee8ad6fe95583)
10b57cec5SDimitry Andric //===-- NVPTXMCTargetDesc.cpp - NVPTX Target Descriptions -------*- C++ -*-===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
80b57cec5SDimitry Andric //
90b57cec5SDimitry Andric // This file provides NVPTX specific target descriptions.
100b57cec5SDimitry Andric //
110b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
120b57cec5SDimitry Andric 
13349cc55cSDimitry Andric #include "NVPTXMCTargetDesc.h"
140b57cec5SDimitry Andric #include "NVPTXInstPrinter.h"
150b57cec5SDimitry Andric #include "NVPTXMCAsmInfo.h"
160b57cec5SDimitry Andric #include "NVPTXTargetStreamer.h"
170b57cec5SDimitry Andric #include "TargetInfo/NVPTXTargetInfo.h"
180b57cec5SDimitry Andric #include "llvm/MC/MCInstrInfo.h"
190b57cec5SDimitry Andric #include "llvm/MC/MCRegisterInfo.h"
200b57cec5SDimitry Andric #include "llvm/MC/MCSubtargetInfo.h"
21349cc55cSDimitry Andric #include "llvm/MC/TargetRegistry.h"
220b57cec5SDimitry Andric 
230b57cec5SDimitry Andric using namespace llvm;
240b57cec5SDimitry Andric 
250b57cec5SDimitry Andric #define GET_INSTRINFO_MC_DESC
26753f127fSDimitry Andric #define ENABLE_INSTR_PREDICATE_VERIFIER
270b57cec5SDimitry Andric #include "NVPTXGenInstrInfo.inc"
280b57cec5SDimitry Andric 
290b57cec5SDimitry Andric #define GET_SUBTARGETINFO_MC_DESC
300b57cec5SDimitry Andric #include "NVPTXGenSubtargetInfo.inc"
310b57cec5SDimitry Andric 
320b57cec5SDimitry Andric #define GET_REGINFO_MC_DESC
330b57cec5SDimitry Andric #include "NVPTXGenRegisterInfo.inc"
340b57cec5SDimitry Andric 
createNVPTXMCInstrInfo()350b57cec5SDimitry Andric static MCInstrInfo *createNVPTXMCInstrInfo() {
360b57cec5SDimitry Andric   MCInstrInfo *X = new MCInstrInfo();
370b57cec5SDimitry Andric   InitNVPTXMCInstrInfo(X);
380b57cec5SDimitry Andric   return X;
390b57cec5SDimitry Andric }
400b57cec5SDimitry Andric 
createNVPTXMCRegisterInfo(const Triple & TT)410b57cec5SDimitry Andric static MCRegisterInfo *createNVPTXMCRegisterInfo(const Triple &TT) {
420b57cec5SDimitry Andric   MCRegisterInfo *X = new MCRegisterInfo();
430b57cec5SDimitry Andric   // PTX does not have a return address register.
440b57cec5SDimitry Andric   InitNVPTXMCRegisterInfo(X, 0);
450b57cec5SDimitry Andric   return X;
460b57cec5SDimitry Andric }
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric static MCSubtargetInfo *
createNVPTXMCSubtargetInfo(const Triple & TT,StringRef CPU,StringRef FS)490b57cec5SDimitry Andric createNVPTXMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
50e8d8bef9SDimitry Andric   return createNVPTXMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
510b57cec5SDimitry Andric }
520b57cec5SDimitry Andric 
createNVPTXMCInstPrinter(const Triple & T,unsigned SyntaxVariant,const MCAsmInfo & MAI,const MCInstrInfo & MII,const MCRegisterInfo & MRI)530b57cec5SDimitry Andric static MCInstPrinter *createNVPTXMCInstPrinter(const Triple &T,
540b57cec5SDimitry Andric                                                unsigned SyntaxVariant,
550b57cec5SDimitry Andric                                                const MCAsmInfo &MAI,
560b57cec5SDimitry Andric                                                const MCInstrInfo &MII,
570b57cec5SDimitry Andric                                                const MCRegisterInfo &MRI) {
580b57cec5SDimitry Andric   if (SyntaxVariant == 0)
590b57cec5SDimitry Andric     return new NVPTXInstPrinter(MAI, MII, MRI);
600b57cec5SDimitry Andric   return nullptr;
610b57cec5SDimitry Andric }
620b57cec5SDimitry Andric 
createTargetAsmStreamer(MCStreamer & S,formatted_raw_ostream &,MCInstPrinter *)630b57cec5SDimitry Andric static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
640b57cec5SDimitry Andric                                                  formatted_raw_ostream &,
65*0fca6ea1SDimitry Andric                                                  MCInstPrinter *) {
66bdd1243dSDimitry Andric   return new NVPTXAsmTargetStreamer(S);
67bdd1243dSDimitry Andric }
68bdd1243dSDimitry Andric 
createNullTargetStreamer(MCStreamer & S)69bdd1243dSDimitry Andric static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) {
700b57cec5SDimitry Andric   return new NVPTXTargetStreamer(S);
710b57cec5SDimitry Andric }
720b57cec5SDimitry Andric 
730b57cec5SDimitry Andric // Force static initialization.
LLVMInitializeNVPTXTargetMC()74480093f4SDimitry Andric extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTargetMC() {
750b57cec5SDimitry Andric   for (Target *T : {&getTheNVPTXTarget32(), &getTheNVPTXTarget64()}) {
760b57cec5SDimitry Andric     // Register the MC asm info.
770b57cec5SDimitry Andric     RegisterMCAsmInfo<NVPTXMCAsmInfo> X(*T);
780b57cec5SDimitry Andric 
790b57cec5SDimitry Andric     // Register the MC instruction info.
800b57cec5SDimitry Andric     TargetRegistry::RegisterMCInstrInfo(*T, createNVPTXMCInstrInfo);
810b57cec5SDimitry Andric 
820b57cec5SDimitry Andric     // Register the MC register info.
830b57cec5SDimitry Andric     TargetRegistry::RegisterMCRegInfo(*T, createNVPTXMCRegisterInfo);
840b57cec5SDimitry Andric 
850b57cec5SDimitry Andric     // Register the MC subtarget info.
860b57cec5SDimitry Andric     TargetRegistry::RegisterMCSubtargetInfo(*T, createNVPTXMCSubtargetInfo);
870b57cec5SDimitry Andric 
880b57cec5SDimitry Andric     // Register the MCInstPrinter.
890b57cec5SDimitry Andric     TargetRegistry::RegisterMCInstPrinter(*T, createNVPTXMCInstPrinter);
900b57cec5SDimitry Andric 
910b57cec5SDimitry Andric     // Register the MCTargetStreamer.
920b57cec5SDimitry Andric     TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer);
93bdd1243dSDimitry Andric 
94bdd1243dSDimitry Andric     // Register the MCTargetStreamer.
95bdd1243dSDimitry Andric     TargetRegistry::RegisterNullTargetStreamer(*T, createNullTargetStreamer);
960b57cec5SDimitry Andric   }
970b57cec5SDimitry Andric }
98