LLVM  14.0.0git
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  const MCTargetOptions &Options) {
38  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
39  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
41  MAI->addInitialFrameState(Inst);
42  return MAI;
43 }
44 
46  const Triple &TT,
47  const MCTargetOptions &Options) {
48  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
49  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
50  MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 2047);
51  MAI->addInitialFrameState(Inst);
52  return MAI;
53 }
54 
56  MCInstrInfo *X = new MCInstrInfo();
57  InitSparcMCInstrInfo(X);
58  return X;
59 }
60 
63  InitSparcMCRegisterInfo(X, SP::O7);
64  return X;
65 }
66 
67 static MCSubtargetInfo *
69  if (CPU.empty())
70  CPU = (TT.getArch() == Triple::sparcv9) ? "v9" : "v8";
71  return createSparcMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
72 }
73 
74 static MCTargetStreamer *
76  return new SparcTargetELFStreamer(S);
77 }
78 
81  MCInstPrinter *InstPrint,
82  bool isVerboseAsm) {
83  return new SparcTargetAsmStreamer(S, OS);
84 }
85 
87  unsigned SyntaxVariant,
88  const MCAsmInfo &MAI,
89  const MCInstrInfo &MII,
90  const MCRegisterInfo &MRI) {
91  return new SparcInstPrinter(MAI, MII, MRI);
92 }
93 
95  // Register the MC asm info.
99 
100  for (Target *T :
102  // Register the MC instruction info.
104 
105  // Register the MC register info.
107 
108  // Register the MC subtarget info.
110 
111  // Register the MC Code Emitter.
113 
114  // Register the asm backend.
116 
117  // Register the object target streamer.
120 
121  // Register the asm streamer.
123 
124  // Register the MCInstPrinter
126  }
127 }
createSparcMCSubtargetInfo
static MCSubtargetInfo * createSparcMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Definition: SparcMCTargetDesc.cpp:68
SparcTargetInfo.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
SparcMCTargetDesc.h
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
ErrorHandling.h
createSparcMCRegisterInfo
static MCRegisterInfo * createSparcMCRegisterInfo(const Triple &TT)
Definition: SparcMCTargetDesc.cpp:61
llvm::TargetRegistry::RegisterAsmTargetStreamer
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:972
llvm::getTheSparcTarget
Target & getTheSparcTarget()
Definition: SparcTargetInfo.cpp:13
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
createTargetAsmStreamer
static MCTargetStreamer * createTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
Definition: SparcMCTargetDesc.cpp:79
T
#define T
Definition: Mips16ISelLowering.cpp:341
createSparcV9MCAsmInfo
static MCAsmInfo * createSparcV9MCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
Definition: SparcMCTargetDesc.cpp:45
llvm::TargetRegistry::RegisterMCInstPrinter
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
Definition: TargetRegistry.h:930
SparcInstPrinter.h
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
llvm::Triple::sparcv9
@ sparcv9
Definition: Triple.h:76
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
MCInstrInfo.h
llvm::SparcELFMCAsmInfo
Definition: SparcMCAsmInfo.h:22
llvm::getTheSparcelTarget
Target & getTheSparcelTarget()
Definition: SparcTargetInfo.cpp:21
MCSubtargetInfo.h
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:91
llvm::RegisterMCAsmInfoFn
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
Definition: TargetRegistry.h:1097
llvm::MCCFIInstruction
Definition: MCDwarf.h:434
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
createSparcMCInstPrinter
static MCInstPrinter * createSparcMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: SparcMCTargetDesc.cpp:86
llvm::TargetRegistry::RegisterMCAsmBackend
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Definition: TargetRegistry.h:877
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
llvm::TargetRegistry::RegisterObjectTargetStreamer
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:978
MCRegisterInfo.h
llvm::formatted_raw_ostream
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Definition: FormattedStream.h:30
createSparcMCAsmInfo
static MCAsmInfo * createSparcMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
Definition: SparcMCTargetDesc.cpp:35
llvm::createSparcMCCodeEmitter
MCCodeEmitter * createSparcMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
Definition: SparcMCCodeEmitter.cpp:255
SparcTargetStreamer.h
llvm::MCCFIInstruction::cfiDefCfa
static MCCFIInstruction cfiDefCfa(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:488
llvm::MCAsmInfo::addInitialFrameState
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.cpp:86
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::TargetRegistry::RegisterMCSubtargetInfo
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
Definition: TargetRegistry.h:850
llvm::MCTargetOptions
Definition: MCTargetOptions.h:36
SparcMCAsmInfo.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::SparcTargetELFStreamer
Definition: SparcTargetStreamer.h:41
llvm::TargetRegistry::RegisterMCInstrInfo
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
Definition: TargetRegistry.h:817
llvm::TargetRegistry::RegisterMCCodeEmitter
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
Definition: TargetRegistry.h:943
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:25
llvm::TargetRegistry::RegisterMCRegInfo
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Definition: TargetRegistry.h:837
createSparcMCInstrInfo
static MCInstrInfo * createSparcMCInstrInfo()
Definition: SparcMCTargetDesc.cpp:55
llvm::SparcInstPrinter
Definition: SparcInstPrinter.h:20
LLVMInitializeSparcTargetMC
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTargetMC()
Definition: SparcMCTargetDesc.cpp:94
llvm::SparcTargetAsmStreamer
Definition: SparcTargetStreamer.h:31
TargetRegistry.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::getTheSparcV9Target
Target & getTheSparcV9Target()
Definition: SparcTargetInfo.cpp:17
createObjectTargetStreamer
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition: SparcMCTargetDesc.cpp:75
llvm::createSparcAsmBackend
MCAsmBackend * createSparcAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Definition: SparcAsmBackend.cpp:325