Coverage Report

Created: 2025-08-30 07:19

/src/keystone/llvm/lib/MC/MCInst.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- lib/MC/MCInst.cpp - MCInst 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/MCInst.h"
11
#include "llvm/MC/MCExpr.h"
12
#include "llvm/Support/Debug.h"
13
#include "llvm/Support/raw_ostream.h"
14
15
using namespace llvm_ks;
16
17
0
void MCOperand::print(raw_ostream &OS) const {
18
0
  OS << "<MCOperand ";
19
0
  if (!isValid())
20
0
    OS << "INVALID";
21
0
  else if (isReg())
22
0
    OS << "Reg:" << getReg();
23
0
  else if (isImm())
24
0
    OS << "Imm:" << getImm();
25
0
  else if (isFPImm())
26
0
    OS << "FPImm:" << getFPImm();
27
0
  else if (isExpr()) {
28
0
    OS << "Expr:(" << *getExpr() << ")";
29
0
  } else if (isInst()) {
30
0
    OS << "Inst:(" << *getInst() << ")";
31
0
  } else
32
0
    OS << "UNDEFINED";
33
0
  OS << ">";
34
0
}
35
36
942
bool MCOperand::evaluateAsConstantImm(int64_t &Imm) const {
37
942
  if (isImm()) {
38
755
    Imm = getImm();
39
755
    return true;
40
755
  }
41
187
  return false;
42
942
}
43
44
186
bool MCOperand::isBareSymbolRef() const {
45
186
  assert(isExpr() &&
46
186
         "isBareSymbolRef expects only expressions");
47
186
  const MCExpr *Expr = getExpr();
48
186
  MCExpr::ExprKind Kind = getExpr()->getKind();
49
186
  return Kind == MCExpr::SymbolRef &&
50
186
    cast<MCSymbolRefExpr>(Expr)->getKind() == MCSymbolRefExpr::VK_None;
51
186
}
52
53
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
54
0
LLVM_DUMP_METHOD void MCOperand::dump() const {
55
0
}
56
#endif
57
58
0
void MCInst::print(raw_ostream &OS) const {
59
0
  OS << "<MCInst " << getOpcode();
60
0
  for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
61
0
    OS << " ";
62
0
    getOperand(i).print(OS);
63
0
  }
64
0
  OS << ">";
65
0
}
66
67
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
68
0
LLVM_DUMP_METHOD void MCInst::dump() const {
69
0
}
70
#endif