Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/Target/Mips/MCTargetDesc/MipsELFStreamer.cpp
Line
Count
Source
1
//===-------- MipsELFStreamer.cpp - ELF Object Output ---------------------===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#include "MipsELFStreamer.h"
11
#include "MipsOptionRecord.h"
12
#include "MipsTargetStreamer.h"
13
#include "llvm/BinaryFormat/ELF.h"
14
#include "llvm/MC/MCAssembler.h"
15
#include "llvm/MC/MCContext.h"
16
#include "llvm/MC/MCInst.h"
17
#include "llvm/MC/MCSymbolELF.h"
18
#include "llvm/Support/Casting.h"
19
20
using namespace llvm;
21
22
void MipsELFStreamer::EmitInstruction(const MCInst &Inst,
23
2.47k
                                      const MCSubtargetInfo &STI, bool) {
24
2.47k
  MCELFStreamer::EmitInstruction(Inst, STI);
25
2.47k
26
2.47k
  MCContext &Context = getContext();
27
2.47k
  const MCRegisterInfo *MCRegInfo = Context.getRegisterInfo();
28
2.47k
29
9.18k
  for (unsigned OpIndex = 0; 
OpIndex < Inst.getNumOperands()9.18k
;
++OpIndex6.71k
) {
30
6.71k
    const MCOperand &Op = Inst.getOperand(OpIndex);
31
6.71k
32
6.71k
    if (!Op.isReg())
33
2.09k
      continue;
34
4.61k
35
4.61k
    unsigned Reg = Op.getReg();
36
4.61k
    RegInfoRecord->SetPhysRegUsed(Reg, MCRegInfo);
37
4.61k
  }
38
2.47k
39
2.47k
  createPendingLabelRelocs();
40
2.47k
}
41
42
2.48k
void MipsELFStreamer::createPendingLabelRelocs() {
43
2.48k
  MipsTargetELFStreamer *ELFTargetStreamer =
44
2.48k
      static_cast<MipsTargetELFStreamer *>(getTargetStreamer());
45
2.48k
46
2.48k
  // FIXME: Also mark labels when in MIPS16 mode.
47
2.48k
  if (
ELFTargetStreamer->isMicroMipsEnabled()2.48k
) {
48
46
    for (auto *L : Labels) {
49
46
      auto *Label = cast<MCSymbolELF>(L);
50
46
      getAssembler().registerSymbol(*Label);
51
46
      Label->setOther(ELF::STO_MIPS_MICROMIPS);
52
46
    }
53
193
  }
54
2.48k
55
2.48k
  Labels.clear();
56
2.48k
}
57
58
1.67k
void MipsELFStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) {
59
1.67k
  MCELFStreamer::EmitLabel(Symbol);
60
1.67k
  Labels.push_back(Symbol);
61
1.67k
}
62
63
void MipsELFStreamer::SwitchSection(MCSection *Section,
64
2.32k
                                    const MCExpr *Subsection) {
65
2.32k
  MCELFStreamer::SwitchSection(Section, Subsection);
66
2.32k
  Labels.clear();
67
2.32k
}
68
69
void MipsELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
70
827
                                    SMLoc Loc) {
71
827
  MCELFStreamer::EmitValueImpl(Value, Size, Loc);
72
827
  Labels.clear();
73
827
}
74
75
461
void MipsELFStreamer::EmitMipsOptionRecords() {
76
461
  for (const auto &I : MipsOptionRecords)
77
461
    I->EmitMipsOptionRecord();
78
461
}
79
80
MCELFStreamer *llvm::createMipsELFStreamer(MCContext &Context,
81
                                           MCAsmBackend &MAB,
82
                                           raw_pwrite_stream &OS,
83
                                           MCCodeEmitter *Emitter,
84
461
                                           bool RelaxAll) {
85
461
  return new MipsELFStreamer(Context, MAB, OS, Emitter);
86
461
}