/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/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 | | // The LLVM Compiler Infrastructure |
5 | | // |
6 | | // This file is distributed under the University of Illinois Open Source |
7 | | // License. See LICENSE.TXT for details. |
8 | | // |
9 | | //===----------------------------------------------------------------------===// |
10 | | |
11 | | #include "HexagonMCExpr.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/Object/ELF.h" |
17 | | #include "llvm/Support/raw_ostream.h" |
18 | | |
19 | | using namespace llvm; |
20 | | |
21 | | #define DEBUG_TYPE "hexagon-mcexpr" |
22 | | |
23 | 16.3k | HexagonMCExpr *HexagonMCExpr::create(MCExpr const *Expr, MCContext &Ctx) { |
24 | 16.3k | return new (Ctx) HexagonMCExpr(Expr); |
25 | 16.3k | } |
26 | | |
27 | | bool HexagonMCExpr::evaluateAsRelocatableImpl(MCValue &Res, |
28 | | MCAsmLayout const *Layout, |
29 | 37.7k | MCFixup const *Fixup) const { |
30 | 37.7k | return Expr->evaluateAsRelocatable(Res, Layout, Fixup); |
31 | 37.7k | } |
32 | | |
33 | 1.61k | void HexagonMCExpr::visitUsedExpr(MCStreamer &Streamer) const { |
34 | 1.61k | Streamer.visitUsedExpr(*Expr); |
35 | 1.61k | } |
36 | | |
37 | 0 | MCFragment *llvm::HexagonMCExpr::findAssociatedFragment() const { |
38 | 0 | return Expr->findAssociatedFragment(); |
39 | 0 | } |
40 | | |
41 | 136 | static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) { |
42 | 136 | switch (Expr->getKind()) { |
43 | 0 | case MCExpr::Target: |
44 | 0 | llvm_unreachable("Cannot handle nested target MCExpr"); |
45 | 0 | break; |
46 | 0 | case MCExpr::Constant: |
47 | 0 | break; |
48 | 136 | |
49 | 0 | case MCExpr::Binary: { |
50 | 0 | const MCBinaryExpr *be = cast<MCBinaryExpr>(Expr); |
51 | 0 | fixELFSymbolsInTLSFixupsImpl(be->getLHS(), Asm); |
52 | 0 | fixELFSymbolsInTLSFixupsImpl(be->getRHS(), Asm); |
53 | 0 | break; |
54 | 136 | } |
55 | 136 | case MCExpr::SymbolRef: { |
56 | 136 | const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(Expr); |
57 | 136 | switch (symRef.getKind()) { |
58 | 100 | default: |
59 | 100 | return; |
60 | 36 | case MCSymbolRefExpr::VK_Hexagon_GD_GOT: |
61 | 36 | case MCSymbolRefExpr::VK_Hexagon_LD_GOT: |
62 | 36 | case MCSymbolRefExpr::VK_Hexagon_GD_PLT: |
63 | 36 | case MCSymbolRefExpr::VK_Hexagon_LD_PLT: |
64 | 36 | case MCSymbolRefExpr::VK_Hexagon_IE: |
65 | 36 | case MCSymbolRefExpr::VK_Hexagon_IE_GOT: |
66 | 36 | case MCSymbolRefExpr::VK_TPREL: |
67 | 36 | break; |
68 | 36 | } |
69 | 36 | cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS); |
70 | 36 | break; |
71 | 36 | } |
72 | 0 | case MCExpr::Unary: |
73 | 0 | fixELFSymbolsInTLSFixupsImpl(cast<MCUnaryExpr>(Expr)->getSubExpr(), Asm); |
74 | 0 | break; |
75 | 36 | } |
76 | 36 | } |
77 | | |
78 | 136 | void HexagonMCExpr::fixELFSymbolsInTLSFixups(MCAssembler &Asm) const { |
79 | 136 | auto expr = getExpr(); |
80 | 136 | fixELFSymbolsInTLSFixupsImpl(expr, Asm); |
81 | 136 | } |
82 | | |
83 | 3.96k | MCExpr const *HexagonMCExpr::getExpr() const { return Expr; } |
84 | | |
85 | 14.4k | void HexagonMCExpr::setMustExtend(bool Val) { |
86 | 14.4k | assert((!Val || !MustNotExtend) && "Extension contradiction"); |
87 | 14.4k | MustExtend = Val; |
88 | 14.4k | } |
89 | | |
90 | 17.3k | bool HexagonMCExpr::mustExtend() const { return MustExtend; } |
91 | 1.12k | void HexagonMCExpr::setMustNotExtend(bool Val) { |
92 | 1.12k | assert((!Val || !MustExtend) && "Extension contradiction"); |
93 | 1.12k | MustNotExtend = Val; |
94 | 1.12k | } |
95 | 14.7k | bool HexagonMCExpr::mustNotExtend() const { return MustNotExtend; } |
96 | | |
97 | 25 | bool HexagonMCExpr::s27_2_reloc() const { return S27_2_reloc; } |
98 | 1 | void HexagonMCExpr::setS27_2_reloc(bool Val) { |
99 | 1 | S27_2_reloc = Val; |
100 | 1 | } |
101 | | |
102 | 34.0k | bool HexagonMCExpr::classof(MCExpr const *E) { |
103 | 34.0k | return E->getKind() == MCExpr::Target; |
104 | 34.0k | } |
105 | | |
106 | | HexagonMCExpr::HexagonMCExpr(MCExpr const *Expr) |
107 | | : Expr(Expr), MustNotExtend(false), MustExtend(false), S27_2_reloc(false), |
108 | 16.3k | SignMismatch(false) {} |
109 | | |
110 | 1.89k | void HexagonMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const { |
111 | 1.89k | Expr->print(OS, MAI); |
112 | 1.89k | } |
113 | | |
114 | 0 | void HexagonMCExpr::setSignMismatch(bool Val) { |
115 | 0 | SignMismatch = Val; |
116 | 0 | } |
117 | | |
118 | 1.27k | bool HexagonMCExpr::signMismatch() const { |
119 | 1.27k | return SignMismatch; |
120 | 1.27k | } |