LLVM  8.0.1
MCInstBuilder.h
Go to the documentation of this file.
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 
23  MCInst Inst;
24 
25 public:
26  /// Create a new MCInstBuilder for an MCInst with a specific opcode.
27  MCInstBuilder(unsigned Opcode) {
28  Inst.setOpcode(Opcode);
29  }
30 
31  /// Add a new register operand.
32  MCInstBuilder &addReg(unsigned Reg) {
34  return *this;
35  }
36 
37  /// Add a new integer immediate operand.
38  MCInstBuilder &addImm(int64_t Val) {
40  return *this;
41  }
42 
43  /// Add a new floating point immediate operand.
44  MCInstBuilder &addFPImm(double Val) {
46  return *this;
47  }
48 
49  /// Add a new MCExpr operand.
50  MCInstBuilder &addExpr(const MCExpr *Val) {
52  return *this;
53  }
54 
55  /// Add a new MCInst operand.
56  MCInstBuilder &addInst(const MCInst *Val) {
58  return *this;
59  }
60 
61  /// Add an operand.
63  Inst.addOperand(Op);
64  return *this;
65  }
66 
67  operator MCInst&() {
68  return Inst;
69  }
70 };
71 
72 } // end namespace llvm
73 
74 #endif
MCInstBuilder & addInst(const MCInst *Val)
Add a new MCInst operand.
Definition: MCInstBuilder.h:56
This class represents lattice values for constants.
Definition: AllocatorList.h:24
static MCOperand createExpr(const MCExpr *Val)
Definition: MCInst.h:137
unsigned Reg
MCInstBuilder & addFPImm(double Val)
Add a new floating point immediate operand.
Definition: MCInstBuilder.h:44
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:116
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
MCInstBuilder(unsigned Opcode)
Create a new MCInstBuilder for an MCInst with a specific opcode.
Definition: MCInstBuilder.h:27
MCInstBuilder & addOperand(const MCOperand &Op)
Add an operand.
Definition: MCInstBuilder.h:62
MCInstBuilder & addExpr(const MCExpr *Val)
Add a new MCExpr operand.
Definition: MCInstBuilder.h:50
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:161
MCInstBuilder & addReg(unsigned Reg)
Add a new register operand.
Definition: MCInstBuilder.h:32
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
Definition: MCInstBuilder.h:38
void setOpcode(unsigned Op)
Definition: MCInst.h:173
static MCOperand createFPImm(double Val)
Definition: MCInst.h:130
static MCOperand createInst(const MCInst *Val)
Definition: MCInst.h:144
void addOperand(const MCOperand &Op)
Definition: MCInst.h:186
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:35
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:123