LLVM  8.0.1
AMDGPUMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- AMDGPUMCTargetDesc.cpp - AMDGPU Target Descriptions ---------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 /// This file provides AMDGPU specific target descriptions.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "AMDGPUMCTargetDesc.h"
16 #include "AMDGPUELFStreamer.h"
17 #include "AMDGPUMCAsmInfo.h"
18 #include "AMDGPUTargetStreamer.h"
20 #include "SIDefines.h"
21 #include "llvm/MC/MCAsmBackend.h"
22 #include "llvm/MC/MCCodeEmitter.h"
23 #include "llvm/MC/MCContext.h"
24 #include "llvm/MC/MCInstrInfo.h"
25 #include "llvm/MC/MCObjectWriter.h"
26 #include "llvm/MC/MCRegisterInfo.h"
27 #include "llvm/MC/MCStreamer.h"
32 
33 using namespace llvm;
34 
35 #define GET_INSTRINFO_MC_DESC
36 #include "AMDGPUGenInstrInfo.inc"
37 
38 #define GET_SUBTARGETINFO_MC_DESC
39 #include "AMDGPUGenSubtargetInfo.inc"
40 
41 #define NoSchedModel NoSchedModelR600
42 #define GET_SUBTARGETINFO_MC_DESC
43 #include "R600GenSubtargetInfo.inc"
44 #undef NoSchedModelR600
45 
46 #define GET_REGINFO_MC_DESC
47 #include "AMDGPUGenRegisterInfo.inc"
48 
49 #define GET_REGINFO_MC_DESC
50 #include "R600GenRegisterInfo.inc"
51 
53  MCInstrInfo *X = new MCInstrInfo();
54  InitAMDGPUMCInstrInfo(X);
55  return X;
56 }
57 
60  if (TT.getArch() == Triple::r600)
61  InitR600MCRegisterInfo(X, 0);
62  else
63  InitAMDGPUMCRegisterInfo(X, 0);
64  return X;
65 }
66 
67 static MCSubtargetInfo *
69  if (TT.getArch() == Triple::r600)
70  return createR600MCSubtargetInfoImpl(TT, CPU, FS);
71  return createAMDGPUMCSubtargetInfoImpl(TT, CPU, FS);
72 }
73 
75  unsigned SyntaxVariant,
76  const MCAsmInfo &MAI,
77  const MCInstrInfo &MII,
78  const MCRegisterInfo &MRI) {
79  if (T.getArch() == Triple::r600)
80  return new R600InstPrinter(MAI, MII, MRI);
81  else
82  return new AMDGPUInstPrinter(MAI, MII, MRI);
83 }
84 
87  MCInstPrinter *InstPrint,
88  bool isVerboseAsm) {
89  return new AMDGPUTargetAsmStreamer(S, OS);
90 }
91 
93  MCStreamer &S,
94  const MCSubtargetInfo &STI) {
95  return new AMDGPUTargetELFStreamer(S, STI);
96 }
97 
99  std::unique_ptr<MCAsmBackend> &&MAB,
100  std::unique_ptr<MCObjectWriter> &&OW,
101  std::unique_ptr<MCCodeEmitter> &&Emitter,
102  bool RelaxAll) {
103  return createAMDGPUELFStreamer(T, Context, std::move(MAB), std::move(OW),
104  std::move(Emitter), RelaxAll);
105 }
106 
107 extern "C" void LLVMInitializeAMDGPUTargetMC() {
108 
111  for (Target *T : {&getTheAMDGPUTarget(), &getTheGCNTarget()}) {
113 
119  }
120 
121  // R600 specific registration
126 
127  // GCN specific registration
130 
135 }
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:24
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:84
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:63
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:290
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:56
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:189
unsigned const MachineRegisterInfo * MRI
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
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:44
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:40
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:49