LLVM 20.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"
23
24namespace llvm {
25namespace SparcASITag {
26#define GET_ASITagsList_IMPL
27#include "SparcGenSearchableTables.inc"
28} // end namespace SparcASITag
29
30namespace SparcPrefetchTag {
31#define GET_PrefetchTagsList_IMPL
32#include "SparcGenSearchableTables.inc"
33} // end namespace SparcPrefetchTag
34} // end namespace llvm
35
36using namespace llvm;
37
38#define GET_INSTRINFO_MC_DESC
39#define ENABLE_INSTR_PREDICATE_VERIFIER
40#include "SparcGenInstrInfo.inc"
41
42#define GET_SUBTARGETINFO_MC_DESC
43#include "SparcGenSubtargetInfo.inc"
44
45#define GET_REGINFO_MC_DESC
46#include "SparcGenRegisterInfo.inc"
47
49 const Triple &TT,
50 const MCTargetOptions &Options) {
51 MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
52 unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
53 MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 0);
54 MAI->addInitialFrameState(Inst);
55 return MAI;
56}
57
59 const Triple &TT,
60 const MCTargetOptions &Options) {
61 MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
62 unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
63 MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, Reg, 2047);
64 MAI->addInitialFrameState(Inst);
65 return MAI;
66}
67
69 MCInstrInfo *X = new MCInstrInfo();
70 InitSparcMCInstrInfo(X);
71 return X;
72}
73
76 InitSparcMCRegisterInfo(X, SP::O7);
77 return X;
78}
79
80static MCSubtargetInfo *
82 if (CPU.empty())
83 CPU = (TT.getArch() == Triple::sparcv9) ? "v9" : "v8";
84 return createSparcMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
85}
86
87static MCTargetStreamer *
89 return new SparcTargetELFStreamer(S, STI);
90}
91
94 MCInstPrinter *InstPrint) {
95 return new SparcTargetAsmStreamer(S, OS);
96}
97
99 return new SparcTargetStreamer(S);
100}
101
103 unsigned SyntaxVariant,
104 const MCAsmInfo &MAI,
105 const MCInstrInfo &MII,
106 const MCRegisterInfo &MRI) {
107 return new SparcInstPrinter(MAI, MII, MRI);
108}
109
111 // Register the MC asm info.
115
116 for (Target *T :
118 // Register the MC instruction info.
120
121 // Register the MC register info.
123
124 // Register the MC subtarget info.
126
127 // Register the MC Code Emitter.
129
130 // Register the asm backend.
132
133 // Register the object target streamer.
136
137 // Register the asm streamer.
139
140 // Register the null streamer.
142
143 // Register the MCInstPrinter
145 }
146}
unsigned const MachineRegisterInfo * MRI
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:128
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static LVOptions Options
Definition: LVOptions.cpp:25
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
raw_pwrite_stream & OS
static MCAsmInfo * createSparcMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
static MCAsmInfo * createSparcV9MCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
static MCTargetStreamer * createTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint)
static MCRegisterInfo * createSparcMCRegisterInfo(const Triple &TT)
static MCInstPrinter * createSparcMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
static MCInstrInfo * createSparcMCInstrInfo()
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTargetMC()
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static MCSubtargetInfo * createSparcMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.cpp:75
static MCCFIInstruction cfiDefCfa(MCSymbol *L, unsigned Register, int64_t Offset, SMLoc Loc={})
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it.
Definition: MCDwarf.h:575
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:46
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Streaming machine code generation interface.
Definition: MCStreamer.h:213
Generic base class for all target subtargets.
Target specific streamer interface.
Definition: MCStreamer.h:94
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Target & getTheSparcTarget()
Target & getTheSparcV9Target()
MCAsmBackend * createSparcAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
Target & getTheSparcelTarget()
MCCodeEmitter * createSparcMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
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)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)