1 //===-- MInstruction.cpp - Implementation code for the MInstruction class -===//
3 // This file contains a printer that converts from our internal representation
4 // of LLVM code to a nice human readable form that is suitable for debuggging.
6 //===----------------------------------------------------------------------===//
8 #include "llvm/CodeGen/MBasicBlock.h"
10 /// MInstruction ctor - Create a new instruction, and append it to the
11 /// specified basic block.
13 MInstruction::MInstruction(MBasicBlock *BB, unsigned O, unsigned D)
14 : Opcode(O), Dest(D) {
15 // Add this instruction to the specified basic block
16 BB->getInstList().push_back(this);
20 /// addOperand - Add a new operand to the instruction with the specified value
21 /// and interpretation.
23 void MInstruction::addOperand(unsigned Value, MOperand::Interpretation Ty) {
24 if (Operands.size() < 4) {
25 OperandInterpretation[Operands.size()] = Ty; // Save interpretation
27 assert(Ty == MOperand::Register &&
28 "Trying to add 5th operand that is not a register to MInstruction!");
30 Operands.push_back(Value);