Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp
Line
Count
Source
1
//===-- SparcMCTargetDesc.cpp - Sparc 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 Sparc specific target descriptions.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "SparcMCTargetDesc.h"
14
#include "SparcInstPrinter.h"
15
#include "SparcMCAsmInfo.h"
16
#include "SparcTargetStreamer.h"
17
#include "TargetInfo/SparcTargetInfo.h"
18
#include "llvm/MC/MCInstrInfo.h"
19
#include "llvm/MC/MCRegisterInfo.h"
20
#include "llvm/MC/MCSubtargetInfo.h"
21
#include "llvm/Support/ErrorHandling.h"
22
#include "llvm/Support/TargetRegistry.h"
23
24
using namespace llvm;
25
26
#define GET_INSTRINFO_MC_DESC
27
#include "SparcGenInstrInfo.inc"
28
29
#define GET_SUBTARGETINFO_MC_DESC
30
#include "SparcGenSubtargetInfo.inc"
31
32
#define GET_REGINFO_MC_DESC
33
#include "SparcGenRegisterInfo.inc"
34
35
static MCAsmInfo *createSparcMCAsmInfo(const MCRegisterInfo &MRI,
36
191
                                       const Triple &TT) {
37
191
  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
38
191
  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
39
191
  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0);
40
191
  MAI->addInitialFrameState(Inst);
41
191
  return MAI;
42
191
}
43
44
static MCAsmInfo *createSparcV9MCAsmInfo(const MCRegisterInfo &MRI,
45
107
                                         const Triple &TT) {
46
107
  MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
47
107
  unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
48
107
  MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 2047);
49
107
  MAI->addInitialFrameState(Inst);
50
107
  return MAI;
51
107
}
52
53
345
static MCInstrInfo *createSparcMCInstrInfo() {
54
345
  MCInstrInfo *X = new MCInstrInfo();
55
345
  InitSparcMCInstrInfo(X);
56
345
  return X;
57
345
}
58
59
303
static MCRegisterInfo *createSparcMCRegisterInfo(const Triple &TT) {
60
303
  MCRegisterInfo *X = new MCRegisterInfo();
61
303
  InitSparcMCRegisterInfo(X, SP::O7);
62
303
  return X;
63
303
}
64
65
static MCSubtargetInfo *
66
296
createSparcMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
67
296
  if (CPU.empty())
68
250
    CPU = (TT.getArch() == Triple::sparcv9) ? 
"v9"104
:
"v8"146
;
69
296
  return createSparcMCSubtargetInfoImpl(TT, CPU, FS);
70
296
}
71
72
static MCTargetStreamer *
73
25
createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
74
25
  return new SparcTargetELFStreamer(S);
75
25
}
76
77
static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
78
                                                 formatted_raw_ostream &OS,
79
                                                 MCInstPrinter *InstPrint,
80
235
                                                 bool isVerboseAsm) {
81
235
  return new SparcTargetAsmStreamer(S, OS);
82
235
}
83
84
static MCInstPrinter *createSparcMCInstPrinter(const Triple &T,
85
                                               unsigned SyntaxVariant,
86
                                               const MCAsmInfo &MAI,
87
                                               const MCInstrInfo &MII,
88
238
                                               const MCRegisterInfo &MRI) {
89
238
  return new SparcInstPrinter(MAI, MII, MRI);
90
238
}
91
92
96.4k
extern "C" void LLVMInitializeSparcTargetMC() {
93
96.4k
  // Register the MC asm info.
94
96.4k
  RegisterMCAsmInfoFn X(getTheSparcTarget(), createSparcMCAsmInfo);
95
96.4k
  RegisterMCAsmInfoFn Y(getTheSparcV9Target(), createSparcV9MCAsmInfo);
96
96.4k
  RegisterMCAsmInfoFn Z(getTheSparcelTarget(), createSparcMCAsmInfo);
97
96.4k
98
96.4k
  for (Target *T :
99
289k
       {&getTheSparcTarget(), &getTheSparcV9Target(), &getTheSparcelTarget()}) {
100
289k
    // Register the MC instruction info.
101
289k
    TargetRegistry::RegisterMCInstrInfo(*T, createSparcMCInstrInfo);
102
289k
103
289k
    // Register the MC register info.
104
289k
    TargetRegistry::RegisterMCRegInfo(*T, createSparcMCRegisterInfo);
105
289k
106
289k
    // Register the MC subtarget info.
107
289k
    TargetRegistry::RegisterMCSubtargetInfo(*T, createSparcMCSubtargetInfo);
108
289k
109
289k
    // Register the MC Code Emitter.
110
289k
    TargetRegistry::RegisterMCCodeEmitter(*T, createSparcMCCodeEmitter);
111
289k
112
289k
    // Register the asm backend.
113
289k
    TargetRegistry::RegisterMCAsmBackend(*T, createSparcAsmBackend);
114
289k
115
289k
    // Register the object target streamer.
116
289k
    TargetRegistry::RegisterObjectTargetStreamer(*T,
117
289k
                                                 createObjectTargetStreamer);
118
289k
119
289k
    // Register the asm streamer.
120
289k
    TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer);
121
289k
122
289k
    // Register the MCInstPrinter
123
289k
    TargetRegistry::RegisterMCInstPrinter(*T, createSparcMCInstPrinter);
124
289k
  }
125
96.4k
}