LLVM  9.0.0svn
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 
16 #include "XCoreTargetStreamer.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/MCDwarf.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCRegisterInfo.h"
22 #include "llvm/Support/CodeGen.h"
27 
28 using namespace llvm;
29 
30 #define GET_INSTRINFO_MC_DESC
31 #include "XCoreGenInstrInfo.inc"
32 
33 #define GET_SUBTARGETINFO_MC_DESC
34 #include "XCoreGenSubtargetInfo.inc"
35 
36 #define GET_REGINFO_MC_DESC
37 #include "XCoreGenRegisterInfo.inc"
38 
40  MCInstrInfo *X = new MCInstrInfo();
41  InitXCoreMCInstrInfo(X);
42  return X;
43 }
44 
47  InitXCoreMCRegisterInfo(X, XCore::LR);
48  return X;
49 }
50 
51 static MCSubtargetInfo *
53  return createXCoreMCSubtargetInfoImpl(TT, CPU, FS);
54 }
55 
57  const Triple &TT) {
58  MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
59 
60  // Initial state of the frame pointer is SP.
61  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, XCore::SP, 0);
62  MAI->addInitialFrameState(Inst);
63 
64  return MAI;
65 }
66 
68  unsigned SyntaxVariant,
69  const MCAsmInfo &MAI,
70  const MCInstrInfo &MII,
71  const MCRegisterInfo &MRI) {
72  return new XCoreInstPrinter(MAI, MII, MRI);
73 }
74 
76 
78 
79 namespace {
80 
81 class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
83 
84 public:
85  XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
86 
87  void emitCCTopData(StringRef Name) override;
88  void emitCCTopFunction(StringRef Name) override;
89  void emitCCBottomData(StringRef Name) override;
90  void emitCCBottomFunction(StringRef Name) override;
91 };
92 
93 } // end anonymous namespace
94 
95 XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
97  : XCoreTargetStreamer(S), OS(OS) {}
98 
99 void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) {
100  OS << "\t.cc_top " << Name << ".data," << Name << '\n';
101 }
102 
103 void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) {
104  OS << "\t.cc_top " << Name << ".function," << Name << '\n';
105 }
106 
107 void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
108  OS << "\t.cc_bottom " << Name << ".data\n";
109 }
110 
111 void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
112  OS << "\t.cc_bottom " << Name << ".function\n";
113 }
114 
117  MCInstPrinter *InstPrint,
118  bool isVerboseAsm) {
119  return new XCoreTargetAsmStreamer(S, OS);
120 }
121 
122 // Force static initialization.
123 extern "C" void LLVMInitializeXCoreTargetMC() {
124  // Register the MC asm info.
126 
127  // Register the MC instruction info.
130 
131  // Register the MC register info.
134 
135  // Register the MC subtarget info.
138 
139  // Register the MCInstPrinter
142 
145 }
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static MCSubtargetInfo * createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
This class represents lattice values for constants.
Definition: AllocatorList.h:23
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
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
void LLVMInitializeXCoreTargetMC()
virtual void emitCCTopFunction(StringRef Name)=0
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
static MCInstPrinter * createXCoreMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static MCInstrInfo * createXCoreMCInstrInfo()
virtual void emitCCBottomFunction(StringRef Name)=0
void addInitialFrameState(const MCCFIInstruction &Inst)
Definition: MCAsmInfo.h:600
virtual void emitCCBottomData(StringRef Name)=0
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
Streaming machine code generation interface.
Definition: MCStreamer.h:188
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:460
virtual void emitCCTopData(StringRef Name)=0
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:23
static MCRegisterInfo * createXCoreMCRegisterInfo(const Triple &TT)
static MCAsmInfo * createXCoreMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT)
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
Target & getTheXCoreTarget()
static MCTargetStreamer * createTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
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.
This file contains the declaration of the XCoreInstPrinter class, which is used to print XCore MCInst...
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48