Revert r354244 "[DAGCombiner] Eliminate dead stores to stack."
[llvm-complete.git] / lib / Target / XCore / MCTargetDesc / XCoreMCTargetDesc.cpp
blobe2ced98027c840eebd0e6faa0b00301ac7cc6df1
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.
11 //===----------------------------------------------------------------------===//
13 #include "MCTargetDesc/XCoreMCTargetDesc.h"
14 #include "InstPrinter/XCoreInstPrinter.h"
15 #include "MCTargetDesc/XCoreMCAsmInfo.h"
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"
21 #include "llvm/MC/MCSubtargetInfo.h"
22 #include "llvm/Support/CodeGen.h"
23 #include "llvm/Support/ErrorHandling.h"
24 #include "llvm/Support/FormattedStream.h"
25 #include "llvm/Support/TargetRegistry.h"
26 #include "llvm/Support/raw_ostream.h"
28 using namespace llvm;
30 #define GET_INSTRINFO_MC_DESC
31 #include "XCoreGenInstrInfo.inc"
33 #define GET_SUBTARGETINFO_MC_DESC
34 #include "XCoreGenSubtargetInfo.inc"
36 #define GET_REGINFO_MC_DESC
37 #include "XCoreGenRegisterInfo.inc"
39 static MCInstrInfo *createXCoreMCInstrInfo() {
40 MCInstrInfo *X = new MCInstrInfo();
41 InitXCoreMCInstrInfo(X);
42 return X;
45 static MCRegisterInfo *createXCoreMCRegisterInfo(const Triple &TT) {
46 MCRegisterInfo *X = new MCRegisterInfo();
47 InitXCoreMCRegisterInfo(X, XCore::LR);
48 return X;
51 static MCSubtargetInfo *
52 createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
53 return createXCoreMCSubtargetInfoImpl(TT, CPU, FS);
56 static MCAsmInfo *createXCoreMCAsmInfo(const MCRegisterInfo &MRI,
57 const Triple &TT) {
58 MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
60 // Initial state of the frame pointer is SP.
61 MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, XCore::SP, 0);
62 MAI->addInitialFrameState(Inst);
64 return MAI;
67 static MCInstPrinter *createXCoreMCInstPrinter(const Triple &T,
68 unsigned SyntaxVariant,
69 const MCAsmInfo &MAI,
70 const MCInstrInfo &MII,
71 const MCRegisterInfo &MRI) {
72 return new XCoreInstPrinter(MAI, MII, MRI);
75 XCoreTargetStreamer::XCoreTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
77 XCoreTargetStreamer::~XCoreTargetStreamer() = default;
79 namespace {
81 class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
82 formatted_raw_ostream &OS;
84 public:
85 XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
87 void emitCCTopData(StringRef Name) override;
88 void emitCCTopFunction(StringRef Name) override;
89 void emitCCBottomData(StringRef Name) override;
90 void emitCCBottomFunction(StringRef Name) override;
93 } // end anonymous namespace
95 XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
96 formatted_raw_ostream &OS)
97 : XCoreTargetStreamer(S), OS(OS) {}
99 void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) {
100 OS << "\t.cc_top " << Name << ".data," << Name << '\n';
103 void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) {
104 OS << "\t.cc_top " << Name << ".function," << Name << '\n';
107 void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
108 OS << "\t.cc_bottom " << Name << ".data\n";
111 void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
112 OS << "\t.cc_bottom " << Name << ".function\n";
115 static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
116 formatted_raw_ostream &OS,
117 MCInstPrinter *InstPrint,
118 bool isVerboseAsm) {
119 return new XCoreTargetAsmStreamer(S, OS);
122 // Force static initialization.
123 extern "C" void LLVMInitializeXCoreTargetMC() {
124 // Register the MC asm info.
125 RegisterMCAsmInfoFn X(getTheXCoreTarget(), createXCoreMCAsmInfo);
127 // Register the MC instruction info.
128 TargetRegistry::RegisterMCInstrInfo(getTheXCoreTarget(),
129 createXCoreMCInstrInfo);
131 // Register the MC register info.
132 TargetRegistry::RegisterMCRegInfo(getTheXCoreTarget(),
133 createXCoreMCRegisterInfo);
135 // Register the MC subtarget info.
136 TargetRegistry::RegisterMCSubtargetInfo(getTheXCoreTarget(),
137 createXCoreMCSubtargetInfo);
139 // Register the MCInstPrinter
140 TargetRegistry::RegisterMCInstPrinter(getTheXCoreTarget(),
141 createXCoreMCInstPrinter);
143 TargetRegistry::RegisterAsmTargetStreamer(getTheXCoreTarget(),
144 createTargetAsmStreamer);