LLVM 22.0.0git
MCInstBuilder.h
Go to the documentation of this file.
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
19namespace llvm {
20
22 MCInst Inst;
23
24public:
25 /// Create a new MCInstBuilder for an MCInst with a specific opcode.
26 MCInstBuilder(unsigned Opcode) {
27 Inst.setOpcode(Opcode);
28 }
29
30 /// Set the location.
32 Inst.setLoc(SM);
33 return *this;
34 }
35
36 /// Add a new register operand.
41
42 /// Add a new integer immediate operand.
43 MCInstBuilder &addImm(int64_t Val) {
45 return *this;
46 }
47
48 /// Add a new single floating point immediate operand.
51 return *this;
52 }
53
54 /// Add a new floating point immediate operand.
57 return *this;
58 }
59
60 /// Add a new MCExpr operand.
63 return *this;
64 }
65
66 /// Add a new MCInst operand.
69 return *this;
70 }
71
72 /// Add an operand.
74 Inst.addOperand(Op);
75 return *this;
76 }
77
78 operator MCInst&() {
79 return Inst;
80 }
81};
82
83} // end namespace llvm
84
85#endif
Register Reg
Base class for the full range of assembler expressions which are needed for parsing.
Definition MCExpr.h:34
MCInstBuilder & setLoc(SMLoc SM)
Set the location.
MCInstBuilder & addInst(const MCInst *Val)
Add a new MCInst operand.
MCInstBuilder & addReg(MCRegister Reg)
Add a new register operand.
MCInstBuilder & addSFPImm(uint32_t Val)
Add a new single floating point immediate operand.
MCInstBuilder & addOperand(const MCOperand &Op)
Add an operand.
MCInstBuilder(unsigned Opcode)
Create a new MCInstBuilder for an MCInst with a specific opcode.
MCInstBuilder & addDFPImm(uint64_t Val)
Add a new floating point immediate operand.
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
MCInstBuilder & addExpr(const MCExpr *Val)
Add a new MCExpr operand.
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
static MCOperand createExpr(const MCExpr *Val)
Definition MCInst.h:166
static MCOperand createSFPImm(uint32_t Val)
Definition MCInst.h:152
static MCOperand createReg(MCRegister Reg)
Definition MCInst.h:138
static MCOperand createImm(int64_t Val)
Definition MCInst.h:145
static MCOperand createDFPImm(uint64_t Val)
Definition MCInst.h:159
static MCOperand createInst(const MCInst *Val)
Definition MCInst.h:173
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:33
Represents a location in source code.
Definition SMLoc.h:23
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op