LLVM  9.0.0svn
SparcMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- SparcMCTargetDesc.cpp - Sparc 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 // This file provides Sparc specific target descriptions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "SparcMCTargetDesc.h"
14 #include "SparcInstPrinter.h"
15 #include "SparcMCAsmInfo.h"
16 #include "SparcTargetStreamer.h"
18 #include "llvm/MC/MCInstrInfo.h"
19 #include "llvm/MC/MCRegisterInfo.h"
23 
24 using namespace llvm;
25 
26 #define GET_INSTRINFO_MC_DESC
27 #include "SparcGenInstrInfo.inc"
28 
29 #define GET_SUBTARGETINFO_MC_DESC
30 #include "SparcGenSubtargetInfo.inc"
31 
32 #define GET_REGINFO_MC_DESC
33 #include "SparcGenRegisterInfo.inc"
34 
36  const Triple &TT) {
37  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
38  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
39  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0);
40  MAI->addInitialFrameState(Inst);
41  return MAI;
42 }
43 
45  const Triple &TT) {
46  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
47  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
48  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 2047);
49  MAI->addInitialFrameState(Inst);
50  return MAI;
51 }
52 
54  MCInstrInfo *X = new MCInstrInfo();
55  InitSparcMCInstrInfo(X);
56  return X;
57 }
58 
61  InitSparcMCRegisterInfo(X, SP::O7);
62  return X;
63 }
64 
65 static MCSubtargetInfo *
67  if (CPU.empty())
68  CPU = (TT.getArch() == Triple::sparcv9) ? "v9" : "v8";
69  return createSparcMCSubtargetInfoImpl(TT, CPU, FS);
70 }
71 
72 static MCTargetStreamer *
74  return new SparcTargetELFStreamer(S);
75 }
76 
79  MCInstPrinter *InstPrint,
80  bool isVerboseAsm) {
81  return new SparcTargetAsmStreamer(S, OS);
82 }
83 
85  unsigned SyntaxVariant,
86  const MCAsmInfo &MAI,
87  const MCInstrInfo &MII,
88  const MCRegisterInfo &MRI) {
89  return new SparcInstPrinter(MAI, MII, MRI);
90 }
91 
92 extern "C" void LLVMInitializeSparcTargetMC() {
93  // Register the MC asm info.
97 
98  for (Target *T :
100  // Register the MC instruction info.
102 
103  // Register the MC register info.
105 
106  // Register the MC subtarget info.
108 
109  // Register the MC Code Emitter.
111 
112  // Register the asm backend.
114 
115  // Register the object target streamer.
118 
119  // Register the asm streamer.
121 
122  // Register the MCInstPrinter
124  }
125 }
MCCodeEmitter * createSparcMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This class represents lattice values for constants.
Definition: AllocatorList.h:23
void LLVMInitializeSparcTargetMC()
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Target specific streamer interface.
Definition: MCStreamer.h:83
unsigned Reg
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static MCRegisterInfo * createSparcMCRegisterInfo(const Triple &TT)
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
static MCTargetStreamer * createTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:126
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:292
Target & getTheSparcTarget()
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
MCAsmBackend * createSparcAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
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
static MCInstPrinter * createSparcMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
unsigned const MachineRegisterInfo * MRI
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
Definition: MCDwarf.h:477
static MCAsmInfo * createSparcMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT)
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:23
Target & getTheSparcelTarget()
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
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.cpp:73
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static MCInstrInfo * createSparcMCInstrInfo()
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
Target & getTheSparcV9Target()
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:39
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 MCAsmInfo * createSparcV9MCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT)
static MCSubtargetInfo * createSparcMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48