Coverage Report

Created: 2019-02-21 13:17

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file contains the MCInstBuilder class for convenient creation of
10
// MCInsts.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_MC_MCINSTBUILDER_H
15
#define LLVM_MC_MCINSTBUILDER_H
16
17
#include "llvm/MC/MCInst.h"
18
19
namespace llvm {
20
21
class MCInstBuilder {
22
  MCInst Inst;
23
24
public:
25
  /// Create a new MCInstBuilder for an MCInst with a specific opcode.
26
54.5k
  MCInstBuilder(unsigned Opcode) {
27
54.5k
    Inst.setOpcode(Opcode);
28
54.5k
  }
29
30
  /// Add a new register operand.
31
149k
  MCInstBuilder &addReg(unsigned Reg) {
32
149k
    Inst.addOperand(MCOperand::createReg(Reg));
33
149k
    return *this;
34
149k
  }
35
36
  /// Add a new integer immediate operand.
37
39.3k
  MCInstBuilder &addImm(int64_t Val) {
38
39.3k
    Inst.addOperand(MCOperand::createImm(Val));
39
39.3k
    return *this;
40
39.3k
  }
41
42
  /// Add a new floating point immediate operand.
43
  MCInstBuilder &addFPImm(double Val) {
44
    Inst.addOperand(MCOperand::createFPImm(Val));
45
    return *this;
46
  }
47
48
  /// Add a new MCExpr operand.
49
8.60k
  MCInstBuilder &addExpr(const MCExpr *Val) {
50
8.60k
    Inst.addOperand(MCOperand::createExpr(Val));
51
8.60k
    return *this;
52
8.60k
  }
53
54
  /// Add a new MCInst operand.
55
  MCInstBuilder &addInst(const MCInst *Val) {
56
    Inst.addOperand(MCOperand::createInst(Val));
57
    return *this;
58
  }
59
60
  /// Add an operand.
61
44
  MCInstBuilder &addOperand(const MCOperand &Op) {
62
44
    Inst.addOperand(Op);
63
44
    return *this;
64
44
  }
65
66
54.5k
  operator MCInst&() {
67
54.5k
    return Inst;
68
54.5k
  }
69
};
70
71
} // end namespace llvm
72
73
#endif