/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/MC/MCInstBuilder.h
Line | Count | Source (jump to first uncovered line) |
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 | 59.4k | MCInstBuilder(unsigned Opcode) { |
27 | 59.4k | Inst.setOpcode(Opcode); |
28 | 59.4k | } |
29 | | |
30 | | /// Add a new register operand. |
31 | 158k | MCInstBuilder &addReg(unsigned Reg) { |
32 | 158k | Inst.addOperand(MCOperand::createReg(Reg)); |
33 | 158k | return *this; |
34 | 158k | } |
35 | | |
36 | | /// Add a new integer immediate operand. |
37 | 42.3k | MCInstBuilder &addImm(int64_t Val) { |
38 | 42.3k | Inst.addOperand(MCOperand::createImm(Val)); |
39 | 42.3k | return *this; |
40 | 42.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 | 10.7k | MCInstBuilder &addExpr(const MCExpr *Val) { |
50 | 10.7k | Inst.addOperand(MCOperand::createExpr(Val)); |
51 | 10.7k | return *this; |
52 | 10.7k | } |
53 | | |
54 | | /// Add a new MCInst operand. |
55 | 0 | MCInstBuilder &addInst(const MCInst *Val) { |
56 | 0 | Inst.addOperand(MCOperand::createInst(Val)); |
57 | 0 | return *this; |
58 | 0 | } |
59 | | |
60 | | /// Add an operand. |
61 | 845 | MCInstBuilder &addOperand(const MCOperand &Op) { |
62 | 845 | Inst.addOperand(Op); |
63 | 845 | return *this; |
64 | 845 | } |
65 | | |
66 | 59.4k | operator MCInst&() { |
67 | 59.4k | return Inst; |
68 | 59.4k | } |
69 | | }; |
70 | | |
71 | | } // end namespace llvm |
72 | | |
73 | | #endif |