LLVM 17.0.0git
XCoreMCTargetDesc.cpp
Go to the documentation of this file.
1//===-- XCoreMCTargetDesc.cpp - XCore 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 XCore specific target descriptions.
10//
11//===----------------------------------------------------------------------===//
12
17#include "XCoreTargetStreamer.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/MC/MCDwarf.h"
20#include "llvm/MC/MCInstrInfo.h"
28
29using namespace llvm;
30
31#define GET_INSTRINFO_MC_DESC
32#define ENABLE_INSTR_PREDICATE_VERIFIER
33#include "XCoreGenInstrInfo.inc"
34
35#define GET_SUBTARGETINFO_MC_DESC
36#include "XCoreGenSubtargetInfo.inc"
37
38#define GET_REGINFO_MC_DESC
39#include "XCoreGenRegisterInfo.inc"
40
42 MCInstrInfo *X = new MCInstrInfo();
43 InitXCoreMCInstrInfo(X);
44 return X;
45}
46
49 InitXCoreMCRegisterInfo(X, XCore::LR);
50 return X;
51}
52
53static MCSubtargetInfo *
55 return createXCoreMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
56}
57
59 const Triple &TT,
60 const MCTargetOptions &Options) {
61 MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
62
63 // Initial state of the frame pointer is SP.
64 MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, XCore::SP, 0);
65 MAI->addInitialFrameState(Inst);
66
67 return MAI;
68}
69
71 unsigned SyntaxVariant,
72 const MCAsmInfo &MAI,
73 const MCInstrInfo &MII,
74 const MCRegisterInfo &MRI) {
75 return new XCoreInstPrinter(MAI, MII, MRI);
76}
77
79
81
82namespace {
83
84class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
86
87public:
88 XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
89
90 void emitCCTopData(StringRef Name) override;
91 void emitCCTopFunction(StringRef Name) override;
92 void emitCCBottomData(StringRef Name) override;
93 void emitCCBottomFunction(StringRef Name) override;
94};
95
96} // end anonymous namespace
97
98XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
100 : XCoreTargetStreamer(S), OS(OS) {}
101
102void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) {
103 OS << "\t.cc_top " << Name << ".data," << Name << '\n';
104}
105
106void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) {
107 OS << "\t.cc_top " << Name << ".function," << Name << '\n';
108}
109
110void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
111 OS << "\t.cc_bottom " << Name << ".data\n";
112}
113
114void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
115 OS << "\t.cc_bottom " << Name << ".function\n";
116}
117
120 MCInstPrinter *InstPrint,
121 bool isVerboseAsm) {
122 return new XCoreTargetAsmStreamer(S, OS);
123}
124
126 return new XCoreTargetStreamer(S);
127}
128
129// Force static initialization.
131 // Register the MC asm info.
133
134 // Register the MC instruction info.
137
138 // Register the MC register info.
141
142 // Register the MC subtarget info.
145
146 // Register the MCInstPrinter
149
152
155}
unsigned const MachineRegisterInfo * MRI
static MCTargetStreamer * createTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:127
std::string Name
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static LVOptions Options
Definition: LVOptions.cpp:25
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
This file contains the declaration of the XCoreInstPrinter class, which is used to print XCore MCInst...
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTargetMC()
static MCSubtargetInfo * createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
static MCAsmInfo * createXCoreMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
static MCInstrInfo * createXCoreMCInstrInfo()
static MCRegisterInfo * createXCoreMCRegisterInfo(const Triple &TT)
static MCInstPrinter * createXCoreMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
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:86
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:533
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:44
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:212
Generic base class for all target subtargets.
Target specific streamer interface.
Definition: MCStreamer.h:93
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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 & getTheXCoreTarget()
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 RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
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)