1 //===-- llvm/MC/MCInstBuilder.h - Simplify creation of MCInsts --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the MCInstBuilder class for convenient creation of
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_MC_MCINSTBUILDER_H
16 #define LLVM_MC_MCINSTBUILDER_H
18 #include "llvm/MC/MCInst.h"
26 /// \brief Create a new MCInstBuilder for an MCInst with a specific opcode.
27 MCInstBuilder(unsigned Opcode) {
28 Inst.setOpcode(Opcode);
31 /// \brief Add a new register operand.
32 MCInstBuilder &addReg(unsigned Reg) {
33 Inst.addOperand(MCOperand::CreateReg(Reg));
37 /// \brief Add a new integer immediate operand.
38 MCInstBuilder &addImm(int64_t Val) {
39 Inst.addOperand(MCOperand::CreateImm(Val));
43 /// \brief Add a new floating point immediate operand.
44 MCInstBuilder &addFPImm(double Val) {
45 Inst.addOperand(MCOperand::CreateFPImm(Val));
49 /// \brief Add a new MCExpr operand.
50 MCInstBuilder &addExpr(const MCExpr *Val) {
51 Inst.addOperand(MCOperand::CreateExpr(Val));
55 /// \brief Add a new MCInst operand.
56 MCInstBuilder &addInst(const MCInst *Val) {
57 Inst.addOperand(MCOperand::CreateInst(Val));
66 } // end namespace llvm