LLVM  14.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"
21 #include "llvm/MC/MCRegisterInfo.h"
23 #include "llvm/Support/CodeGen.h"
28 
29 using namespace llvm;
30 
31 #define GET_INSTRINFO_MC_DESC
32 #include "XCoreGenInstrInfo.inc"
33 
34 #define GET_SUBTARGETINFO_MC_DESC
35 #include "XCoreGenSubtargetInfo.inc"
36 
37 #define GET_REGINFO_MC_DESC
38 #include "XCoreGenRegisterInfo.inc"
39 
41  MCInstrInfo *X = new MCInstrInfo();
42  InitXCoreMCInstrInfo(X);
43  return X;
44 }
45 
48  InitXCoreMCRegisterInfo(X, XCore::LR);
49  return X;
50 }
51 
52 static MCSubtargetInfo *
54  return createXCoreMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
55 }
56 
58  const Triple &TT,
59  const MCTargetOptions &Options) {
60  MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
61 
62  // Initial state of the frame pointer is SP.
63  MCCFIInstruction Inst = MCCFIInstruction::cfiDefCfa(nullptr, XCore::SP, 0);
64  MAI->addInitialFrameState(Inst);
65 
66  return MAI;
67 }
68 
70  unsigned SyntaxVariant,
71  const MCAsmInfo &MAI,
72  const MCInstrInfo &MII,
73  const MCRegisterInfo &MRI) {
74  return new XCoreInstPrinter(MAI, MII, MRI);
75 }
76 
78 
80 
81 namespace {
82 
83 class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
85 
86 public:
87  XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
88 
89  void emitCCTopData(StringRef Name) override;
90  void emitCCTopFunction(StringRef Name) override;
91  void emitCCBottomData(StringRef Name) override;
92  void emitCCBottomFunction(StringRef Name) override;
93 };
94 
95 } // end anonymous namespace
96 
97 XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
99  : XCoreTargetStreamer(S), OS(OS) {}
100 
101 void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) {
102  OS << "\t.cc_top " << Name << ".data," << Name << '\n';
103 }
104 
105 void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) {
106  OS << "\t.cc_top " << Name << ".function," << Name << '\n';
107 }
108 
109 void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
110  OS << "\t.cc_bottom " << Name << ".data\n";
111 }
112 
113 void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
114  OS << "\t.cc_bottom " << Name << ".function\n";
115 }
116 
119  MCInstPrinter *InstPrint,
120  bool isVerboseAsm) {
121  return new XCoreTargetAsmStreamer(S, OS);
122 }
123 
124 // Force static initialization.
126  // Register the MC asm info.
128 
129  // Register the MC instruction info.
132 
133  // Register the MC register info.
136 
137  // Register the MC subtarget info.
140 
141  // Register the MCInstPrinter
144 
147 }
MCDwarf.h
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
XCoreMCAsmInfo.h
LLVMInitializeXCoreTargetMC
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTargetMC()
Definition: XCoreMCTargetDesc.cpp:125
createXCoreMCInstPrinter
static MCInstPrinter * createXCoreMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: XCoreMCTargetDesc.cpp:69
llvm::XCoreTargetStreamer
Definition: XCoreTargetStreamer.h:15
StringRef.h
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
llvm::TargetRegistry::RegisterAsmTargetStreamer
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:972
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
XCoreInstPrinter.h
llvm::XCoreMCAsmInfo
Definition: XCoreMCAsmInfo.h:21
llvm::TargetRegistry::RegisterMCInstPrinter
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
Definition: TargetRegistry.h:930
llvm::XCoreInstPrinter
Definition: XCoreInstPrinter.h:23
FormattedStream.h
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
llvm::XCoreTargetStreamer::~XCoreTargetStreamer
~XCoreTargetStreamer() override
XCoreTargetStreamer.h
MCInstrInfo.h
MCSubtargetInfo.h
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:91
XCoreMCTargetDesc.h
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")
llvm::getTheXCoreTarget
Target & getTheXCoreTarget()
Definition: XCoreTargetInfo.cpp:13
createXCoreMCRegisterInfo
static MCRegisterInfo * createXCoreMCRegisterInfo(const Triple &TT)
Definition: XCoreMCTargetDesc.cpp:46
llvm::XCoreTargetStreamer::XCoreTargetStreamer
XCoreTargetStreamer(MCStreamer &S)
Definition: XCoreMCTargetDesc.cpp:77
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
createXCoreMCInstrInfo
static MCInstrInfo * createXCoreMCInstrInfo()
Definition: XCoreMCTargetDesc.cpp:40
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
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
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::TargetRegistry::RegisterMCInstrInfo
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
Definition: TargetRegistry.h:817
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:25
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::TargetRegistry::RegisterMCRegInfo
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Definition: TargetRegistry.h:837
CodeGen.h
createTargetAsmStreamer
static MCTargetStreamer * createTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
Definition: XCoreMCTargetDesc.cpp:117
createXCoreMCSubtargetInfo
static MCSubtargetInfo * createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Definition: XCoreMCTargetDesc.cpp:53
raw_ostream.h
XCoreTargetInfo.h
TargetRegistry.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
createXCoreMCAsmInfo
static MCAsmInfo * createXCoreMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, const MCTargetOptions &Options)
Definition: XCoreMCTargetDesc.cpp:57