Coverage Report

Created: 2025-07-14 06:17

/src/keystone/llvm/lib/MC/MCValue.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- lib/MC/MCValue.cpp - MCValue implementation ------------------------===//
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 "llvm/MC/MCValue.h"
11
#include "llvm/MC/MCExpr.h"
12
#include "llvm/Support/Debug.h"
13
#include "llvm/Support/ErrorHandling.h"
14
#include "llvm/Support/raw_ostream.h"
15
16
using namespace llvm_ks;
17
18
0
void MCValue::print(raw_ostream &OS) const {
19
0
  if (isAbsolute()) {
20
0
    OS << getConstant();
21
0
    return;
22
0
  }
23
24
  // FIXME: prints as a number, which isn't ideal. But the meaning will be
25
  // target-specific anyway.
26
0
  if (getRefKind())
27
0
    OS << ':' << getRefKind() <<  ':';
28
29
0
  OS << *getSymA();
30
31
0
  if (getSymB()) {
32
0
    OS << " - ";
33
0
    OS << *getSymB();
34
0
  }
35
36
0
  if (getConstant())
37
0
    OS << " + " << getConstant();
38
0
}
39
40
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
41
0
LLVM_DUMP_METHOD void MCValue::dump() const {
42
0
}
43
#endif
44
45
49.0k
MCSymbolRefExpr::VariantKind MCValue::getAccessVariant() const {
46
49.0k
  const MCSymbolRefExpr *B = getSymB();
47
49.0k
  if (B) {
48
3.46k
    if (B->getKind() != MCSymbolRefExpr::VK_None)
49
0
      llvm_unreachable("unsupported");
50
3.46k
  }
51
52
49.0k
  const MCSymbolRefExpr *A = getSymA();
53
49.0k
  if (!A)
54
5.56k
    return MCSymbolRefExpr::VK_None;
55
56
43.4k
  MCSymbolRefExpr::VariantKind Kind = A->getKind();
57
43.4k
  if (Kind == MCSymbolRefExpr::VK_WEAKREF)
58
0
    return MCSymbolRefExpr::VK_None;
59
43.4k
  return Kind;
60
43.4k
}