LCOV - code coverage report
Current view: top level - lib/MC - MCInst.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 30 42 71.4 %
Date: 2018-09-23 13:06:45 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/Config/llvm-config.h"
      12             : #include "llvm/MC/MCExpr.h"
      13             : #include "llvm/MC/MCInstPrinter.h"
      14             : #include "llvm/Support/Casting.h"
      15             : #include "llvm/Support/Compiler.h"
      16             : #include "llvm/Support/Debug.h"
      17             : #include "llvm/Support/raw_ostream.h"
      18             : 
      19             : using namespace llvm;
      20             : 
      21       22976 : void MCOperand::print(raw_ostream &OS) const {
      22       22976 :   OS << "<MCOperand ";
      23       22976 :   if (!isValid())
      24          27 :     OS << "INVALID";
      25       22949 :   else if (isReg())
      26       18117 :     OS << "Reg:" << getReg();
      27        4832 :   else if (isImm())
      28        4131 :     OS << "Imm:" << getImm();
      29         701 :   else if (isFPImm())
      30           6 :     OS << "FPImm:" << getFPImm();
      31         695 :   else if (isExpr()) {
      32         695 :     OS << "Expr:(" << *getExpr() << ")";
      33           0 :   } else if (isInst()) {
      34           0 :     OS << "Inst:(" << *getInst() << ")";
      35             :   } else
      36           0 :     OS << "UNDEFINED";
      37       22976 :   OS << ">";
      38       22976 : }
      39             : 
      40           0 : bool MCOperand::evaluateAsConstantImm(int64_t &Imm) const {
      41           0 :   if (isImm()) {
      42           0 :     Imm = getImm();
      43           0 :     return true;
      44             :   }
      45             :   return false;
      46             : }
      47             : 
      48           0 : bool MCOperand::isBareSymbolRef() const {
      49             :   assert(isExpr() &&
      50             :          "isBareSymbolRef expects only expressions");
      51           0 :   const MCExpr *Expr = getExpr();
      52           0 :   MCExpr::ExprKind Kind = getExpr()->getKind();
      53           0 :   return Kind == MCExpr::SymbolRef &&
      54           0 :     cast<MCSymbolRefExpr>(Expr)->getKind() == MCSymbolRefExpr::VK_None;
      55             : }
      56             : 
      57             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
      58             : LLVM_DUMP_METHOD void MCOperand::dump() const {
      59             :   print(dbgs());
      60             :   dbgs() << "\n";
      61             : }
      62             : #endif
      63             : 
      64           4 : void MCInst::print(raw_ostream &OS) const {
      65           4 :   OS << "<MCInst " << getOpcode();
      66          20 :   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
      67          16 :     OS << " ";
      68          16 :     getOperand(i).print(OS);
      69             :   }
      70           4 :   OS << ">";
      71           4 : }
      72             : 
      73        8617 : void MCInst::dump_pretty(raw_ostream &OS, const MCInstPrinter *Printer,
      74             :                          StringRef Separator) const {
      75        8617 :   OS << "<MCInst #" << getOpcode();
      76             : 
      77             :   // Show the instruction opcode name if we have access to a printer.
      78        8617 :   if (Printer)
      79        8617 :     OS << ' ' << Printer->getOpcodeName(getOpcode());
      80             : 
      81       31042 :   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
      82       22425 :     OS << Separator;
      83       22425 :     getOperand(i).print(OS);
      84             :   }
      85        8617 :   OS << ">";
      86        8617 : }
      87             : 
      88             : #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
      89             : LLVM_DUMP_METHOD void MCInst::dump() const {
      90             :   print(dbgs());
      91             :   dbgs() << "\n";
      92             : }
      93             : #endif

Generated by: LCOV version 1.13