Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:13

0001 //===-- llvm/MC/MCInstBuilder.h - Simplify creation of MCInsts --*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file contains the MCInstBuilder class for convenient creation of
0010 // MCInsts.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_MC_MCINSTBUILDER_H
0015 #define LLVM_MC_MCINSTBUILDER_H
0016 
0017 #include "llvm/MC/MCInst.h"
0018 
0019 namespace llvm {
0020 
0021 class MCInstBuilder {
0022   MCInst Inst;
0023 
0024 public:
0025   /// Create a new MCInstBuilder for an MCInst with a specific opcode.
0026   MCInstBuilder(unsigned Opcode) {
0027     Inst.setOpcode(Opcode);
0028   }
0029 
0030   /// Set the location.
0031   MCInstBuilder &setLoc(SMLoc SM) {
0032     Inst.setLoc(SM);
0033     return *this;
0034   }
0035 
0036   /// Add a new register operand.
0037   MCInstBuilder &addReg(MCRegister Reg) {
0038     Inst.addOperand(MCOperand::createReg(Reg));
0039     return *this;
0040   }
0041 
0042   /// Add a new integer immediate operand.
0043   MCInstBuilder &addImm(int64_t Val) {
0044     Inst.addOperand(MCOperand::createImm(Val));
0045     return *this;
0046   }
0047 
0048   /// Add a new single floating point immediate operand.
0049   MCInstBuilder &addSFPImm(uint32_t Val) {
0050     Inst.addOperand(MCOperand::createSFPImm(Val));
0051     return *this;
0052   }
0053 
0054   /// Add a new floating point immediate operand.
0055   MCInstBuilder &addDFPImm(uint64_t Val) {
0056     Inst.addOperand(MCOperand::createDFPImm(Val));
0057     return *this;
0058   }
0059 
0060   /// Add a new MCExpr operand.
0061   MCInstBuilder &addExpr(const MCExpr *Val) {
0062     Inst.addOperand(MCOperand::createExpr(Val));
0063     return *this;
0064   }
0065 
0066   /// Add a new MCInst operand.
0067   MCInstBuilder &addInst(const MCInst *Val) {
0068     Inst.addOperand(MCOperand::createInst(Val));
0069     return *this;
0070   }
0071 
0072   /// Add an operand.
0073   MCInstBuilder &addOperand(const MCOperand &Op) {
0074     Inst.addOperand(Op);
0075     return *this;
0076   }
0077 
0078   operator MCInst&() {
0079     return Inst;
0080   }
0081 };
0082 
0083 } // end namespace llvm
0084 
0085 #endif