LLVM  13.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 
19 namespace llvm {
20 
22  MCInst Inst;
23 
24 public:
25  /// Create a new MCInstBuilder for an MCInst with a specific opcode.
26  MCInstBuilder(unsigned Opcode) {
27  Inst.setOpcode(Opcode);
28  }
29 
30  /// Add a new register operand.
31  MCInstBuilder &addReg(unsigned Reg) {
33  return *this;
34  }
35 
36  /// Add a new integer immediate operand.
37  MCInstBuilder &addImm(int64_t Val) {
39  return *this;
40  }
41 
42  /// Add a new single floating point immediate operand.
45  return *this;
46  }
47 
48  /// Add a new floating point immediate operand.
49  MCInstBuilder &addDFPImm(uint64_t Val) {
51  return *this;
52  }
53 
54  /// Add a new MCExpr operand.
55  MCInstBuilder &addExpr(const MCExpr *Val) {
57  return *this;
58  }
59 
60  /// Add a new MCInst operand.
61  MCInstBuilder &addInst(const MCInst *Val) {
63  return *this;
64  }
65 
66  /// Add an operand.
68  Inst.addOperand(Op);
69  return *this;
70  }
71 
72  operator MCInst&() {
73  return Inst;
74  }
75 };
76 
77 } // end namespace llvm
78 
79 #endif
llvm
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::MCOperand::createExpr
static MCOperand createExpr(const MCExpr *Val)
Definition: MCInst.h:161
llvm::MCOperand::createImm
static MCOperand createImm(int64_t Val)
Definition: MCInst.h:140
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:183
llvm::MCInstBuilder::MCInstBuilder
MCInstBuilder(unsigned Opcode)
Create a new MCInstBuilder for an MCInst with a specific opcode.
Definition: MCInstBuilder.h:26
llvm::MCInst::setOpcode
void setOpcode(unsigned Op)
Definition: MCInst.h:196
llvm::MCInstBuilder::addSFPImm
MCInstBuilder & addSFPImm(uint32_t Val)
Add a new single floating point immediate operand.
Definition: MCInstBuilder.h:43
llvm::MCInstBuilder::addOperand
MCInstBuilder & addOperand(const MCOperand &Op)
Add an operand.
Definition: MCInstBuilder.h:67
MCInst.h
llvm::MCInstBuilder::addDFPImm
MCInstBuilder & addDFPImm(uint64_t Val)
Add a new floating point immediate operand.
Definition: MCInstBuilder.h:49
llvm::MCOperand::createInst
static MCOperand createInst(const MCInst *Val)
Definition: MCInst.h:168
llvm::MCInst::addOperand
void addOperand(const MCOperand Op)
Definition: MCInst.h:209
llvm::MCInstBuilder
Definition: MCInstBuilder.h:21
llvm::MCInstBuilder::addImm
MCInstBuilder & addImm(int64_t Val)
Add a new integer immediate operand.
Definition: MCInstBuilder.h:37
llvm::MCOperand::createReg
static MCOperand createReg(unsigned Reg)
Definition: MCInst.h:133
uint32_t
llvm::MCInstBuilder::addExpr
MCInstBuilder & addExpr(const MCExpr *Val)
Add a new MCExpr operand.
Definition: MCInstBuilder.h:55
llvm::MCOperand::createSFPImm
static MCOperand createSFPImm(uint32_t Val)
Definition: MCInst.h:147
llvm::MCOperand::createDFPImm
static MCOperand createDFPImm(uint64_t Val)
Definition: MCInst.h:154
llvm::MCInstBuilder::addInst
MCInstBuilder & addInst(const MCInst *Val)
Add a new MCInst operand.
Definition: MCInstBuilder.h:61
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::MCInstBuilder::addReg
MCInstBuilder & addReg(unsigned Reg)
Add a new register operand.
Definition: MCInstBuilder.h:31
llvm::MCOperand
Instances of this class represent operands of the MCInst class.
Definition: MCInst.h:35
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35