Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp
Line
Count
Source
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
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"
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
40
82
static MCInstrInfo *createXCoreMCInstrInfo() {
41
82
  MCInstrInfo *X = new MCInstrInfo();
42
82
  InitXCoreMCInstrInfo(X);
43
82
  return X;
44
82
}
45
46
83
static MCRegisterInfo *createXCoreMCRegisterInfo(const Triple &TT) {
47
83
  MCRegisterInfo *X = new MCRegisterInfo();
48
83
  InitXCoreMCRegisterInfo(X, XCore::LR);
49
83
  return X;
50
83
}
51
52
static MCSubtargetInfo *
53
82
createXCoreMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
54
82
  return createXCoreMCSubtargetInfoImpl(TT, CPU, FS);
55
82
}
56
57
static MCAsmInfo *createXCoreMCAsmInfo(const MCRegisterInfo &MRI,
58
83
                                       const Triple &TT) {
59
83
  MCAsmInfo *MAI = new XCoreMCAsmInfo(TT);
60
83
61
83
  // Initial state of the frame pointer is SP.
62
83
  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, XCore::SP, 0);
63
83
  MAI->addInitialFrameState(Inst);
64
83
65
83
  return MAI;
66
83
}
67
68
static MCInstPrinter *createXCoreMCInstPrinter(const Triple &T,
69
                                               unsigned SyntaxVariant,
70
                                               const MCAsmInfo &MAI,
71
                                               const MCInstrInfo &MII,
72
71
                                               const MCRegisterInfo &MRI) {
73
71
  return new XCoreInstPrinter(MAI, MII, MRI);
74
71
}
75
76
71
XCoreTargetStreamer::XCoreTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
77
78
69
XCoreTargetStreamer::~XCoreTargetStreamer() = default;
79
80
namespace {
81
82
class XCoreTargetAsmStreamer : public XCoreTargetStreamer {
83
  formatted_raw_ostream &OS;
84
85
public:
86
  XCoreTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS);
87
88
  void emitCCTopData(StringRef Name) override;
89
  void emitCCTopFunction(StringRef Name) override;
90
  void emitCCBottomData(StringRef Name) override;
91
  void emitCCBottomFunction(StringRef Name) override;
92
};
93
94
} // end anonymous namespace
95
96
XCoreTargetAsmStreamer::XCoreTargetAsmStreamer(MCStreamer &S,
97
                                               formatted_raw_ostream &OS)
98
71
    : XCoreTargetStreamer(S), OS(OS) {}
99
100
52
void XCoreTargetAsmStreamer::emitCCTopData(StringRef Name) {
101
52
  OS << "\t.cc_top " << Name << ".data," << Name << '\n';
102
52
}
103
104
279
void XCoreTargetAsmStreamer::emitCCTopFunction(StringRef Name) {
105
279
  OS << "\t.cc_top " << Name << ".function," << Name << '\n';
106
279
}
107
108
52
void XCoreTargetAsmStreamer::emitCCBottomData(StringRef Name) {
109
52
  OS << "\t.cc_bottom " << Name << ".data\n";
110
52
}
111
112
278
void XCoreTargetAsmStreamer::emitCCBottomFunction(StringRef Name) {
113
278
  OS << "\t.cc_bottom " << Name << ".function\n";
114
278
}
115
116
static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
117
                                                 formatted_raw_ostream &OS,
118
                                                 MCInstPrinter *InstPrint,
119
71
                                                 bool isVerboseAsm) {
120
71
  return new XCoreTargetAsmStreamer(S, OS);
121
71
}
122
123
// Force static initialization.
124
96.4k
extern "C" void LLVMInitializeXCoreTargetMC() {
125
96.4k
  // Register the MC asm info.
126
96.4k
  RegisterMCAsmInfoFn X(getTheXCoreTarget(), createXCoreMCAsmInfo);
127
96.4k
128
96.4k
  // Register the MC instruction info.
129
96.4k
  TargetRegistry::RegisterMCInstrInfo(getTheXCoreTarget(),
130
96.4k
                                      createXCoreMCInstrInfo);
131
96.4k
132
96.4k
  // Register the MC register info.
133
96.4k
  TargetRegistry::RegisterMCRegInfo(getTheXCoreTarget(),
134
96.4k
                                    createXCoreMCRegisterInfo);
135
96.4k
136
96.4k
  // Register the MC subtarget info.
137
96.4k
  TargetRegistry::RegisterMCSubtargetInfo(getTheXCoreTarget(),
138
96.4k
                                          createXCoreMCSubtargetInfo);
139
96.4k
140
96.4k
  // Register the MCInstPrinter
141
96.4k
  TargetRegistry::RegisterMCInstPrinter(getTheXCoreTarget(),
142
96.4k
                                        createXCoreMCInstPrinter);
143
96.4k
144
96.4k
  TargetRegistry::RegisterAsmTargetStreamer(getTheXCoreTarget(),
145
96.4k
                                            createTargetAsmStreamer);
146
96.4k
}