LLVM  9.0.0svn
AMDGPUMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- AMDGPUMCTargetDesc.cpp - AMDGPU Target Descriptions ---------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// This file provides AMDGPU specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "AMDGPUMCTargetDesc.h"
15 #include "AMDGPUELFStreamer.h"
16 #include "AMDGPUMCAsmInfo.h"
17 #include "AMDGPUTargetStreamer.h"
19 #include "SIDefines.h"
20 #include "llvm/MC/MCAsmBackend.h"
21 #include "llvm/MC/MCCodeEmitter.h"
22 #include "llvm/MC/MCContext.h"
23 #include "llvm/MC/MCInstrInfo.h"
24 #include "llvm/MC/MCObjectWriter.h"
25 #include "llvm/MC/MCRegisterInfo.h"
26 #include "llvm/MC/MCStreamer.h"
31 
32 using namespace llvm;
33 
34 #define GET_INSTRINFO_MC_DESC
35 #include "AMDGPUGenInstrInfo.inc"
36 
37 #define GET_SUBTARGETINFO_MC_DESC
38 #include "AMDGPUGenSubtargetInfo.inc"
39 
40 #define NoSchedModel NoSchedModelR600
41 #define GET_SUBTARGETINFO_MC_DESC
42 #include "R600GenSubtargetInfo.inc"
43 #undef NoSchedModelR600
44 
45 #define GET_REGINFO_MC_DESC
46 #include "AMDGPUGenRegisterInfo.inc"
47 
48 #define GET_REGINFO_MC_DESC
49 #include "R600GenRegisterInfo.inc"
50 
52  MCInstrInfo *X = new MCInstrInfo();
53  InitAMDGPUMCInstrInfo(X);
54  return X;
55 }
56 
59  if (TT.getArch() == Triple::r600)
60  InitR600MCRegisterInfo(X, 0);
61  else
62  InitAMDGPUMCRegisterInfo(X, 0);
63  return X;
64 }
65 
66 static MCSubtargetInfo *
68  if (TT.getArch() == Triple::r600)
69  return createR600MCSubtargetInfoImpl(TT, CPU, FS);
70  return createAMDGPUMCSubtargetInfoImpl(TT, CPU, FS);
71 }
72 
74  unsigned SyntaxVariant,
75  const MCAsmInfo &MAI,
76  const MCInstrInfo &MII,
77  const MCRegisterInfo &MRI) {
78  if (T.getArch() == Triple::r600)
79  return new R600InstPrinter(MAI, MII, MRI);
80  else
81  return new AMDGPUInstPrinter(MAI, MII, MRI);
82 }
83 
86  MCInstPrinter *InstPrint,
87  bool isVerboseAsm) {
88  return new AMDGPUTargetAsmStreamer(S, OS);
89 }
90 
92  MCStreamer &S,
93  const MCSubtargetInfo &STI) {
94  return new AMDGPUTargetELFStreamer(S, STI);
95 }
96 
98  std::unique_ptr<MCAsmBackend> &&MAB,
99  std::unique_ptr<MCObjectWriter> &&OW,
100  std::unique_ptr<MCCodeEmitter> &&Emitter,
101  bool RelaxAll) {
102  return createAMDGPUELFStreamer(T, Context, std::move(MAB), std::move(OW),
103  std::move(Emitter), RelaxAll);
104 }
105 
106 extern "C" void LLVMInitializeAMDGPUTargetMC() {
107 
110  for (Target *T : {&getTheAMDGPUTarget(), &getTheGCNTarget()}) {
112 
118  }
119 
120  // R600 specific registration
125 
126  // GCN specific registration
129 
134 }
Target & getTheGCNTarget()
The target for GCN GPUs.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
MCCodeEmitter * createSIMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
LLVMContext & Context
MCInstrInfo * createR600MCInstrInfo()
This class represents lattice values for constants.
Definition: AllocatorList.h:23
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Target & getTheAMDGPUTarget()
The target which supports all AMD GPUs.
Target specific streamer interface.
Definition: MCStreamer.h:83
static MCInstrInfo * createAMDGPUMCInstrInfo()
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
static MCSubtargetInfo * createAMDGPUMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
MCCodeEmitter * createR600MCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
static MCRegisterInfo * createAMDGPUMCRegisterInfo(const Triple &TT)
Context object for machine code objects.
Definition: MCContext.h:62
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:289
void LLVMInitializeAMDGPUTargetMC()
static MCStreamer * createMCStreamer(const Triple &T, MCContext &Context, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter, bool RelaxAll)
static MCInstPrinter * createAMDGPUMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:55
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Streaming machine code generation interface.
Definition: MCStreamer.h:188
unsigned const MachineRegisterInfo * MRI
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:23
MCAsmBackend * createAMDGPUAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static MCTargetStreamer * createAMDGPUAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
static MCTargetStreamer * createAMDGPUObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Provides AMDGPU specific target descriptions.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:39
MCELFStreamer * createAMDGPUELFStreamer(const Triple &T, MCContext &Context, std::unique_ptr< MCAsmBackend > MAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter, bool RelaxAll)
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
Generic base class for all target subtargets.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48