LCOV - code coverage report
Current view: top level - include/llvm/MC - MCInstBuilder.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 10 10 100.0 %
Date: 2017-09-14 15:23:50 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- llvm/MC/MCInstBuilder.h - Simplify creation of MCInsts --*- C++ -*-===//
       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             : // This file contains the MCInstBuilder class for convenient creation of
      11             : // MCInsts.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #ifndef LLVM_MC_MCINSTBUILDER_H
      16             : #define LLVM_MC_MCINSTBUILDER_H
      17             : 
      18             : #include "llvm/MC/MCInst.h"
      19             : 
      20             : namespace llvm {
      21             : 
      22       44790 : class MCInstBuilder {
      23             :   MCInst Inst;
      24             : 
      25             : public:
      26             :   /// \brief Create a new MCInstBuilder for an MCInst with a specific opcode.
      27       44790 :   MCInstBuilder(unsigned Opcode) {
      28       44761 :     Inst.setOpcode(Opcode);
      29             :   }
      30             : 
      31             :   /// \brief Add a new register operand.
      32       28680 :   MCInstBuilder &addReg(unsigned Reg) {
      33       86040 :     Inst.addOperand(MCOperand::createReg(Reg));
      34       28680 :     return *this;
      35             :   }
      36             : 
      37             :   /// \brief Add a new integer immediate operand.
      38             :   MCInstBuilder &addImm(int64_t Val) {
      39       17634 :     Inst.addOperand(MCOperand::createImm(Val));
      40             :     return *this;
      41             :   }
      42             : 
      43             :   /// \brief Add a new floating point immediate operand.
      44             :   MCInstBuilder &addFPImm(double Val) {
      45             :     Inst.addOperand(MCOperand::createFPImm(Val));
      46             :     return *this;
      47             :   }
      48             : 
      49             :   /// \brief Add a new MCExpr operand.
      50             :   MCInstBuilder &addExpr(const MCExpr *Val) {
      51       23982 :     Inst.addOperand(MCOperand::createExpr(Val));
      52             :     return *this;
      53             :   }
      54             : 
      55             :   /// \brief Add a new MCInst operand.
      56             :   MCInstBuilder &addInst(const MCInst *Val) {
      57             :     Inst.addOperand(MCOperand::createInst(Val));
      58             :     return *this;
      59             :   }
      60             : 
      61             :   /// \brief Add an operand.
      62             :   MCInstBuilder &addOperand(const MCOperand &Op) {
      63          80 :     Inst.addOperand(Op);
      64             :     return *this;
      65             :   }
      66             : 
      67             :   operator MCInst&() {
      68       10454 :     return Inst;
      69             :   }
      70             : };
      71             : 
      72             : } // end namespace llvm
      73             : 
      74             : #endif

Generated by: LCOV version 1.13