Coverage Report

Created: 2018-11-16 02:38

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCInstBuilder.h
Line
Count
Source
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
class MCInstBuilder {
23
  MCInst Inst;
24
25
public:
26
  /// Create a new MCInstBuilder for an MCInst with a specific opcode.
27
57.6k
  MCInstBuilder(unsigned Opcode) {
28
57.6k
    Inst.setOpcode(Opcode);
29
57.6k
  }
30
31
  /// Add a new register operand.
32
149k
  MCInstBuilder &addReg(unsigned Reg) {
33
149k
    Inst.addOperand(MCOperand::createReg(Reg));
34
149k
    return *this;
35
149k
  }
36
37
  /// Add a new integer immediate operand.
38
39.5k
  MCInstBuilder &addImm(int64_t Val) {
39
39.5k
    Inst.addOperand(MCOperand::createImm(Val));
40
39.5k
    return *this;
41
39.5k
  }
42
43
  /// Add a new floating point immediate operand.
44
  MCInstBuilder &addFPImm(double Val) {
45
    Inst.addOperand(MCOperand::createFPImm(Val));
46
    return *this;
47
  }
48
49
  /// Add a new MCExpr operand.
50
10.1k
  MCInstBuilder &addExpr(const MCExpr *Val) {
51
10.1k
    Inst.addOperand(MCOperand::createExpr(Val));
52
10.1k
    return *this;
53
10.1k
  }
54
55
  /// Add a new MCInst operand.
56
  MCInstBuilder &addInst(const MCInst *Val) {
57
    Inst.addOperand(MCOperand::createInst(Val));
58
    return *this;
59
  }
60
61
  /// Add an operand.
62
44
  MCInstBuilder &addOperand(const MCOperand &Op) {
63
44
    Inst.addOperand(Op);
64
44
    return *this;
65
44
  }
66
67
57.6k
  operator MCInst&() {
68
57.6k
    return Inst;
69
57.6k
  }
70
};
71
72
} // end namespace llvm
73
74
#endif