1 //===-- llvm/MC/MCInstBuilder.h - Simplify creation of MCInsts --*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file contains the MCInstBuilder class for convenient creation of
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_MC_MCINSTBUILDER_H
15 #define LLVM_MC_MCINSTBUILDER_H
17 #include "llvm/MC/MCInst.h"
25 /// Create a new MCInstBuilder for an MCInst with a specific opcode.
26 MCInstBuilder(unsigned Opcode
) {
27 Inst
.setOpcode(Opcode
);
30 /// Add a new register operand.
31 MCInstBuilder
&addReg(unsigned Reg
) {
32 Inst
.addOperand(MCOperand::createReg(Reg
));
36 /// Add a new integer immediate operand.
37 MCInstBuilder
&addImm(int64_t Val
) {
38 Inst
.addOperand(MCOperand::createImm(Val
));
42 /// Add a new floating point immediate operand.
43 MCInstBuilder
&addFPImm(double Val
) {
44 Inst
.addOperand(MCOperand::createFPImm(Val
));
48 /// Add a new MCExpr operand.
49 MCInstBuilder
&addExpr(const MCExpr
*Val
) {
50 Inst
.addOperand(MCOperand::createExpr(Val
));
54 /// Add a new MCInst operand.
55 MCInstBuilder
&addInst(const MCInst
*Val
) {
56 Inst
.addOperand(MCOperand::createInst(Val
));
61 MCInstBuilder
&addOperand(const MCOperand
&Op
) {
71 } // end namespace llvm