1 //===-- llvm/MC/MCInst.h - MCInst class -------------------------*- 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 declaration of the MCInst and MCOperand classes, which
11 // is the basic representation used to represent low-level machine code
14 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_MC_MCINST_H
18 #define LLVM_MC_MCINST_H
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/Support/DataTypes.h"
25 /// MCOperand - Instances of this class represent operands of the MCInst class.
26 /// This is a simple discriminated union.
28 enum MachineOperandType {
29 kInvalid, ///< Uninitialized.
30 kRegister, ///< Register operand.
31 kImmediate ///< Immediate operand.
41 MCOperand() : Kind(kInvalid) {}
42 MCOperand(const MCOperand &RHS) { *this = RHS; }
44 bool isReg() const { return Kind == kRegister; }
45 bool isImm() const { return Kind == kImmediate; }
47 /// getReg - Returns the register number.
48 unsigned getReg() const {
49 assert(isReg() && "This is not a register operand!");
53 /// setReg - Set the register number.
54 void setReg(unsigned Reg) {
55 assert(isReg() && "This is not a register operand!");
59 uint64_t getImm() const {
60 assert(isImm() && "This is not an immediate");
63 void setImm(uint64_t Val) {
64 assert(isImm() && "This is not an immediate");
68 void MakeReg(unsigned Reg) {
72 void MakeImm(uint64_t Val) {
79 /// MCInst - Instances of this class represent a single low-level machine
83 SmallVector<MCOperand, 8> Operands;
85 MCInst() : Opcode(~0U) {}
92 } // end namespace llvm