1 //===-- NVPTXMCTargetDesc.cpp - NVPTX Target Descriptions -------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file provides NVPTX specific target descriptions.
11 //===----------------------------------------------------------------------===//
13 #include "NVPTXMCTargetDesc.h"
14 #include "NVPTXInstPrinter.h"
15 #include "NVPTXMCAsmInfo.h"
16 #include "NVPTXTargetStreamer.h"
17 #include "TargetInfo/NVPTXTargetInfo.h"
18 #include "llvm/MC/MCInstrInfo.h"
19 #include "llvm/MC/MCRegisterInfo.h"
20 #include "llvm/MC/MCSubtargetInfo.h"
21 #include "llvm/MC/TargetRegistry.h"
25 #define GET_INSTRINFO_MC_DESC
26 #define ENABLE_INSTR_PREDICATE_VERIFIER
27 #include "NVPTXGenInstrInfo.inc"
29 #define GET_SUBTARGETINFO_MC_DESC
30 #include "NVPTXGenSubtargetInfo.inc"
32 #define GET_REGINFO_MC_DESC
33 #include "NVPTXGenRegisterInfo.inc"
35 static MCInstrInfo
*createNVPTXMCInstrInfo() {
36 MCInstrInfo
*X
= new MCInstrInfo();
37 InitNVPTXMCInstrInfo(X
);
41 static MCRegisterInfo
*createNVPTXMCRegisterInfo(const Triple
&TT
) {
42 MCRegisterInfo
*X
= new MCRegisterInfo();
43 // PTX does not have a return address register.
44 InitNVPTXMCRegisterInfo(X
, 0);
48 static MCSubtargetInfo
*
49 createNVPTXMCSubtargetInfo(const Triple
&TT
, StringRef CPU
, StringRef FS
) {
50 return createNVPTXMCSubtargetInfoImpl(TT
, CPU
, /*TuneCPU*/ CPU
, FS
);
53 static MCInstPrinter
*createNVPTXMCInstPrinter(const Triple
&T
,
54 unsigned SyntaxVariant
,
56 const MCInstrInfo
&MII
,
57 const MCRegisterInfo
&MRI
) {
58 if (SyntaxVariant
== 0)
59 return new NVPTXInstPrinter(MAI
, MII
, MRI
);
63 static MCTargetStreamer
*createTargetAsmStreamer(MCStreamer
&S
,
64 formatted_raw_ostream
&,
65 MCInstPrinter
*, bool) {
66 return new NVPTXAsmTargetStreamer(S
);
69 static MCTargetStreamer
*createNullTargetStreamer(MCStreamer
&S
) {
70 return new NVPTXTargetStreamer(S
);
73 // Force static initialization.
74 extern "C" LLVM_EXTERNAL_VISIBILITY
void LLVMInitializeNVPTXTargetMC() {
75 for (Target
*T
: {&getTheNVPTXTarget32(), &getTheNVPTXTarget64()}) {
76 // Register the MC asm info.
77 RegisterMCAsmInfo
<NVPTXMCAsmInfo
> X(*T
);
79 // Register the MC instruction info.
80 TargetRegistry::RegisterMCInstrInfo(*T
, createNVPTXMCInstrInfo
);
82 // Register the MC register info.
83 TargetRegistry::RegisterMCRegInfo(*T
, createNVPTXMCRegisterInfo
);
85 // Register the MC subtarget info.
86 TargetRegistry::RegisterMCSubtargetInfo(*T
, createNVPTXMCSubtargetInfo
);
88 // Register the MCInstPrinter.
89 TargetRegistry::RegisterMCInstPrinter(*T
, createNVPTXMCInstPrinter
);
91 // Register the MCTargetStreamer.
92 TargetRegistry::RegisterAsmTargetStreamer(*T
, createTargetAsmStreamer
);
94 // Register the MCTargetStreamer.
95 TargetRegistry::RegisterNullTargetStreamer(*T
, createNullTargetStreamer
);