Chris Lattner | 78cee7e | 2002-10-25 22:54:41 +0000 | [diff] [blame^] | 1 | //===-- MInstruction.cpp - Implementation code for the MInstruction class -===// |
| 2 | // |
| 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. |
| 5 | // |
| 6 | //===----------------------------------------------------------------------===// |
| 7 | |
| 8 | #include "llvm/CodeGen/MBasicBlock.h" |
| 9 | |
| 10 | /// MInstruction ctor - Create a new instruction, and append it to the |
| 11 | /// specified basic block. |
| 12 | /// |
| 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); |
| 17 | } |
| 18 | |
| 19 | |
| 20 | /// addOperand - Add a new operand to the instruction with the specified value |
| 21 | /// and interpretation. |
| 22 | /// |
| 23 | void MInstruction::addOperand(unsigned Value, MOperand::Interpretation Ty) { |
| 24 | if (Operands.size() < 4) { |
| 25 | OperandInterpretation[Operands.size()] = Ty; // Save interpretation |
| 26 | } else { |
| 27 | assert(Ty == MOperand::Register && |
| 28 | "Trying to add 5th operand that is not a register to MInstruction!"); |
| 29 | } |
| 30 | Operands.push_back(Value); |
| 31 | } |