[ARM] MVE integer min and max
[llvm-complete.git] / lib / Target / XCore / MCTargetDesc / XCoreMCTargetDesc.cpp
blob877f38e22f9b863466222a1b94c1fda9a7ec8c27
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 "MCTargetDesc/XCoreInstPrinter.h"
15 #include "MCTargetDesc/XCoreMCAsmInfo.h"
16 #include "TargetInfo/XCoreTargetInfo.h"
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"
22 #include "llvm/MC/MCSubtargetInfo.h"
23 #include "llvm/Support/CodeGen.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/FormattedStream.h"
26 #include "llvm/Support/TargetRegistry.h"
27 #include "llvm/Support/raw_ostream.h"
29 using namespace llvm;
31 #define GET_INSTRINFO_MC_DESC
32 #include "XCoreGenInstrInfo.inc"
34 #define GET_SUBTARGETINFO_MC_DESC
35 #include "XCoreGenSubtargetInfo.inc"
37 #define GET_REGINFO_MC_DESC
38 #include "XCoreGenRegisterInfo.inc"
40 static MCInstrInfo *createXCoreMCInstrInfo() {
41 MCInstrInfo *X = new MCInstrInfo();
42 InitXCoreMCInstrInfo(X);
43 return X;
46 static MCRegisterInfo *createXCoreMCRegisterInfo(const Triple &TT) {
47 MCRegisterInfo *X = new MCRegisterInfo();
48 InitXCoreMCRegisterInfo(X, XCore::LR);
49 return X;
52 static MCSubtargetInfo *
53 createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
54 return createXCoreMCSubtargetInfoImpl(TT, CPU, FS);
57 static MCAsmInfo *createXCoreMCAsmInfo(const MCRegisterInfo &MRI,
58 const Triple &TT) {
59 MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
61 // Initial state of the frame pointer is SP.
62 MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, XCore::SP, 0);
63 MAI->addInitialFrameState(Inst);
65 return MAI;
68 static MCInstPrinter *createXCoreMCInstPrinter(const Triple &T,
69 unsigned SyntaxVariant,
70 const MCAsmInfo &MAI,
71 const MCInstrInfo &MII,
72 const MCRegisterInfo &MRI) {
73 return new XCoreInstPrinter(MAI, MII, MRI);
76 XCoreTargetStreamer::XCoreTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
78 XCoreTargetStreamer::~XCoreTargetStreamer() = default;
80 namespace {
82 class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
83 formatted_raw_ostream &OS;
85 public:
86 XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
88 void emitCCTopData(StringRef Name) override;
89 void emitCCTopFunction(StringRef Name) override;
90 void emitCCBottomData(StringRef Name) override;
91 void emitCCBottomFunction(StringRef Name) override;
94 } // end anonymous namespace
96 XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
97 formatted_raw_ostream &OS)
98 : XCoreTargetStreamer(S), OS(OS) {}
100 void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) {
101 OS << "\t.cc_top " << Name << ".data," << Name << '\n';
104 void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) {
105 OS << "\t.cc_top " << Name << ".function," << Name << '\n';
108 void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
109 OS << "\t.cc_bottom " << Name << ".data\n";
112 void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
113 OS << "\t.cc_bottom " << Name << ".function\n";
116 static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
117 formatted_raw_ostream &OS,
118 MCInstPrinter *InstPrint,
119 bool isVerboseAsm) {
120 return new XCoreTargetAsmStreamer(S, OS);
123 // Force static initialization.
124 extern "C" void LLVMInitializeXCoreTargetMC() {
125 // Register the MC asm info.
126 RegisterMCAsmInfoFn X(getTheXCoreTarget(), createXCoreMCAsmInfo);
128 // Register the MC instruction info.
129 TargetRegistry::RegisterMCInstrInfo(getTheXCoreTarget(),
130 createXCoreMCInstrInfo);
132 // Register the MC register info.
133 TargetRegistry::RegisterMCRegInfo(getTheXCoreTarget(),
134 createXCoreMCRegisterInfo);
136 // Register the MC subtarget info.
137 TargetRegistry::RegisterMCSubtargetInfo(getTheXCoreTarget(),
138 createXCoreMCSubtargetInfo);
140 // Register the MCInstPrinter
141 TargetRegistry::RegisterMCInstPrinter(getTheXCoreTarget(),
142 createXCoreMCInstPrinter);
144 TargetRegistry::RegisterAsmTargetStreamer(getTheXCoreTarget(),
145 createTargetAsmStreamer);