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"
15 #include "SparcMCAsmInfo.h"
16 #include "SparcTargetStreamer.h"
17 #include "llvm/MC/MCInstrInfo.h"
18 #include "llvm/MC/MCRegisterInfo.h"
22 
23 using namespace llvm;
24 
25 #define GET_INSTRINFO_MC_DESC
26 #include "SparcGenInstrInfo.inc"
27 
28 #define GET_SUBTARGETINFO_MC_DESC
29 #include "SparcGenSubtargetInfo.inc"
30 
31 #define GET_REGINFO_MC_DESC
32 #include "SparcGenRegisterInfo.inc"
33 
35  const Triple &TT) {
36  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
37  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
38  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0);
39  MAI->addInitialFrameState(Inst);
40  return MAI;
41 }
42 
44  const Triple &TT) {
45  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
46  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
47  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 2047);
48  MAI->addInitialFrameState(Inst);
49  return MAI;
50 }
51 
53  MCInstrInfo *X = new MCInstrInfo();
54  InitSparcMCInstrInfo(X);
55  return X;
56 }
57 
60  InitSparcMCRegisterInfo(X, SP::O7);
61  return X;
62 }
63 
64 static MCSubtargetInfo *
66  if (CPU.empty())
67  CPU = (TT.getArch() == Triple::sparcv9) ? "v9" : "v8";
68  return createSparcMCSubtargetInfoImpl(TT, CPU, FS);
69 }
70 
71 static MCTargetStreamer *
73  return new SparcTargetELFStreamer(S);
74 }
75 
78  MCInstPrinter *InstPrint,
79  bool isVerboseAsm) {
80  return new SparcTargetAsmStreamer(S, OS);
81 }
82 
84  unsigned SyntaxVariant,
85  const MCAsmInfo &MAI,
86  const MCInstrInfo &MII,
87  const MCRegisterInfo &MRI) {
88  return new SparcInstPrinter(MAI, MII, MRI);
89 }
90 
91 extern "C" void LLVMInitializeSparcTargetMC() {
92  // Register the MC asm info.
96 
97  for (Target *T :
99  // Register the MC instruction info.
101 
102  // Register the MC register info.
104 
105  // Register the MC subtarget info.
107 
108  // Register the MC Code Emitter.
110 
111  // Register the asm backend.
113 
114  // Register the object target streamer.
117 
118  // Register the asm streamer.
120 
121  // Register the MCInstPrinter
123  }
124 }
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:291
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