Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCExpr.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- HexagonMCExpr.cpp - Hexagon specific MC expression classes
2
//----------===//
3
//
4
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5
// See https://llvm.org/LICENSE.txt for license information.
6
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7
//
8
//===----------------------------------------------------------------------===//
9
10
#include "HexagonMCExpr.h"
11
#include "llvm/BinaryFormat/ELF.h"
12
#include "llvm/MC/MCContext.h"
13
#include "llvm/MC/MCStreamer.h"
14
#include "llvm/MC/MCSymbolELF.h"
15
#include "llvm/MC/MCValue.h"
16
#include "llvm/Support/raw_ostream.h"
17
18
using namespace llvm;
19
20
#define DEBUG_TYPE "hexagon-mcexpr"
21
22
23.9k
HexagonMCExpr *HexagonMCExpr::create(MCExpr const *Expr, MCContext &Ctx) {
23
23.9k
  return new (Ctx) HexagonMCExpr(Expr);
24
23.9k
}
25
26
bool HexagonMCExpr::evaluateAsRelocatableImpl(MCValue &Res,
27
                                              MCAsmLayout const *Layout,
28
54.2k
                                              MCFixup const *Fixup) const {
29
54.2k
  return Expr->evaluateAsRelocatable(Res, Layout, Fixup);
30
54.2k
}
31
32
1.86k
void HexagonMCExpr::visitUsedExpr(MCStreamer &Streamer) const {
33
1.86k
  Streamer.visitUsedExpr(*Expr);
34
1.86k
}
35
36
0
MCFragment *llvm::HexagonMCExpr::findAssociatedFragment() const {
37
0
  return Expr->findAssociatedFragment();
38
0
}
39
40
247
static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
41
247
  switch (Expr->getKind()) {
42
247
  case MCExpr::Target:
43
0
    llvm_unreachable("Cannot handle nested target MCExpr");
44
247
    
break0
;
45
247
  case MCExpr::Constant:
46
0
    break;
47
247
48
247
  case MCExpr::Binary: {
49
0
    const MCBinaryExpr *be = cast<MCBinaryExpr>(Expr);
50
0
    fixELFSymbolsInTLSFixupsImpl(be->getLHS(), Asm);
51
0
    fixELFSymbolsInTLSFixupsImpl(be->getRHS(), Asm);
52
0
    break;
53
247
  }
54
247
  case MCExpr::SymbolRef: {
55
247
    const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(Expr);
56
247
    switch (symRef.getKind()) {
57
247
    default:
58
211
      return;
59
247
    case MCSymbolRefExpr::VK_Hexagon_GD_GOT:
60
36
    case MCSymbolRefExpr::VK_Hexagon_LD_GOT:
61
36
    case MCSymbolRefExpr::VK_Hexagon_GD_PLT:
62
36
    case MCSymbolRefExpr::VK_Hexagon_LD_PLT:
63
36
    case MCSymbolRefExpr::VK_Hexagon_IE:
64
36
    case MCSymbolRefExpr::VK_Hexagon_IE_GOT:
65
36
    case MCSymbolRefExpr::VK_TPREL:
66
36
      break;
67
36
    }
68
36
    cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS);
69
36
    break;
70
36
  }
71
36
  case MCExpr::Unary:
72
0
    fixELFSymbolsInTLSFixupsImpl(cast<MCUnaryExpr>(Expr)->getSubExpr(), Asm);
73
0
    break;
74
247
  }
75
247
}
76
77
247
void HexagonMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const {
78
247
  auto expr = getExpr();
79
247
  fixELFSymbolsInTLSFixupsImpl(expr, Asm);
80
247
}
81
82
5.59k
MCExpr const *HexagonMCExpr::getExpr() const { return Expr; }
83
84
21.0k
void HexagonMCExpr::setMustExtend(bool Val) {
85
21.0k
  assert((!Val || !MustNotExtend) && "Extension contradiction");
86
21.0k
  MustExtend = Val;
87
21.0k
}
88
89
21.4k
bool HexagonMCExpr::mustExtend() const { return MustExtend; }
90
1.81k
void HexagonMCExpr::setMustNotExtend(bool Val) {
91
1.81k
  assert((!Val || !MustExtend) && "Extension contradiction");
92
1.81k
  MustNotExtend = Val;
93
1.81k
}
94
16.5k
bool HexagonMCExpr::mustNotExtend() const { return MustNotExtend; }
95
96
31
bool HexagonMCExpr::s27_2_reloc() const { return S27_2_reloc; }
97
1
void HexagonMCExpr::setS27_2_reloc(bool Val) {
98
1
  S27_2_reloc = Val;
99
1
}
100
101
39.4k
bool HexagonMCExpr::classof(MCExpr const *E) {
102
39.4k
  return E->getKind() == MCExpr::Target;
103
39.4k
}
104
105
HexagonMCExpr::HexagonMCExpr(MCExpr const *Expr)
106
    : Expr(Expr), MustNotExtend(false), MustExtend(false), S27_2_reloc(false),
107
23.9k
      SignMismatch(false) {}
108
109
4.55k
void HexagonMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
110
4.55k
  Expr->print(OS, MAI);
111
4.55k
}
112
113
0
void HexagonMCExpr::setSignMismatch(bool Val) {
114
0
  SignMismatch = Val;
115
0
}
116
117
1.37k
bool HexagonMCExpr::signMismatch() const {
118
1.37k
  return SignMismatch;
119
1.37k
}