2002-08-09 22:08:06 +02:00
|
|
|
//===-- MachineInstr.cpp --------------------------------------------------===//
|
2005-04-22 00:36:52 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-22 00:36:52 +02:00
|
|
|
//
|
2003-10-20 21:43:21 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2004-02-13 05:39:32 +01:00
|
|
|
//
|
|
|
|
// Methods common to all machine instructions.
|
|
|
|
//
|
2002-08-09 22:08:06 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-21 14:41:50 +02:00
|
|
|
|
2001-09-07 19:18:30 +02:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2004-02-19 17:17:08 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2002-10-30 01:48:05 +01:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2003-01-14 23:00:31 +01:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2002-10-30 01:58:19 +01:00
|
|
|
#include "llvm/Target/MRegisterInfo.h"
|
2004-09-02 00:55:40 +02:00
|
|
|
#include "llvm/Support/LeakDetector.h"
|
2004-07-04 14:19:56 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
2004-02-23 19:38:20 +01:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2002-10-29 18:40:30 +01:00
|
|
|
// Global variable holding an array of descriptors for machine instructions.
|
|
|
|
// The actual object needs to be created separately for each target machine.
|
2003-01-14 23:00:31 +01:00
|
|
|
// This variable is initialized and reset by class TargetInstrInfo.
|
2005-04-22 00:36:52 +02:00
|
|
|
//
|
2002-10-29 18:40:30 +01:00
|
|
|
// FIXME: This should be a property of the target so that more than one target
|
|
|
|
// at a time can be active...
|
|
|
|
//
|
2004-02-23 19:40:08 +01:00
|
|
|
namespace llvm {
|
2004-02-23 19:38:20 +01:00
|
|
|
extern const TargetInstrDescriptor *TargetInstrDescriptors;
|
|
|
|
}
|
2001-10-19 00:40:02 +02:00
|
|
|
|
2002-10-30 00:19:00 +01:00
|
|
|
/// MachineInstr ctor - This constructor only does a _reserve_ of the operands,
|
|
|
|
/// not a resize for them. It is expected that if you use this that you call
|
|
|
|
/// add* methods below to fill up the operands, instead of the Set methods.
|
|
|
|
/// Eventually, the "resizing" ctors will be phased out.
|
|
|
|
///
|
2006-05-04 20:16:01 +02:00
|
|
|
MachineInstr::MachineInstr(short opcode, unsigned numOperands)
|
2006-11-15 21:54:29 +01:00
|
|
|
: Opcode(opcode), NumImplicitOps(0), parent(0) {
|
2006-05-04 21:14:44 +02:00
|
|
|
Operands.reserve(numOperands);
|
2004-02-16 08:17:43 +01:00
|
|
|
// Make sure that we get added to a machine basicblock
|
|
|
|
LeakDetector::addGarbageObject(this);
|
2002-10-28 21:59:49 +01:00
|
|
|
}
|
|
|
|
|
2006-11-14 00:34:06 +01:00
|
|
|
void MachineInstr::addImplicitDefUseOperands(const TargetInstrDescriptor &TID) {
|
|
|
|
if (TID.ImplicitDefs)
|
|
|
|
for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) {
|
|
|
|
MachineOperand Op;
|
|
|
|
Op.opType = MachineOperand::MO_Register;
|
|
|
|
Op.IsDef = true;
|
|
|
|
Op.IsImp = true;
|
|
|
|
Op.IsKill = false;
|
|
|
|
Op.IsDead = false;
|
|
|
|
Op.contents.RegNo = *ImpDefs;
|
|
|
|
Op.offset = 0;
|
|
|
|
Operands.push_back(Op);
|
|
|
|
}
|
|
|
|
if (TID.ImplicitUses)
|
|
|
|
for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses) {
|
|
|
|
MachineOperand Op;
|
|
|
|
Op.opType = MachineOperand::MO_Register;
|
|
|
|
Op.IsDef = false;
|
|
|
|
Op.IsImp = true;
|
|
|
|
Op.IsKill = false;
|
|
|
|
Op.IsDead = false;
|
|
|
|
Op.contents.RegNo = *ImpUses;
|
|
|
|
Op.offset = 0;
|
|
|
|
Operands.push_back(Op);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// MachineInstr ctor - This constructor create a MachineInstr and add the
|
|
|
|
/// implicit operands. It reserves space for numOperand operands.
|
|
|
|
MachineInstr::MachineInstr(const TargetInstrInfo &TII, short opcode,
|
|
|
|
unsigned numOperands)
|
2006-11-15 21:54:29 +01:00
|
|
|
: Opcode(opcode), NumImplicitOps(0), parent(0) {
|
2006-11-14 00:34:06 +01:00
|
|
|
const TargetInstrDescriptor &TID = TII.get(opcode);
|
|
|
|
if (TID.ImplicitDefs)
|
|
|
|
for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs)
|
|
|
|
NumImplicitOps++;
|
|
|
|
if (TID.ImplicitUses)
|
|
|
|
for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses)
|
|
|
|
NumImplicitOps++;
|
|
|
|
Operands.reserve(NumImplicitOps + numOperands);
|
|
|
|
addImplicitDefUseOperands(TID);
|
|
|
|
// Make sure that we get added to a machine basicblock
|
|
|
|
LeakDetector::addGarbageObject(this);
|
|
|
|
}
|
|
|
|
|
2002-10-30 00:19:00 +01:00
|
|
|
/// MachineInstr ctor - Work exactly the same as the ctor above, except that the
|
|
|
|
/// MachineInstr is created and added to the end of the specified basic block.
|
|
|
|
///
|
2004-02-12 19:49:07 +01:00
|
|
|
MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode,
|
2002-10-30 00:19:00 +01:00
|
|
|
unsigned numOperands)
|
2006-11-15 21:54:29 +01:00
|
|
|
: Opcode(opcode), NumImplicitOps(0), parent(0) {
|
2002-10-30 00:19:00 +01:00
|
|
|
assert(MBB && "Cannot use inserting ctor with null basic block!");
|
2006-11-14 00:34:06 +01:00
|
|
|
const TargetInstrDescriptor &TID = MBB->getParent()->getTarget().
|
|
|
|
getInstrInfo()->get(opcode);
|
|
|
|
if (TID.ImplicitDefs)
|
|
|
|
for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs)
|
|
|
|
NumImplicitOps++;
|
|
|
|
if (TID.ImplicitUses)
|
|
|
|
for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses)
|
|
|
|
NumImplicitOps++;
|
|
|
|
Operands.reserve(NumImplicitOps + numOperands);
|
|
|
|
addImplicitDefUseOperands(TID);
|
2004-02-16 08:17:43 +01:00
|
|
|
// Make sure that we get added to a machine basicblock
|
|
|
|
LeakDetector::addGarbageObject(this);
|
2002-10-30 00:19:00 +01:00
|
|
|
MBB->push_back(this); // Add instruction to end of basic block!
|
|
|
|
}
|
|
|
|
|
2004-07-09 16:45:17 +02:00
|
|
|
/// MachineInstr ctor - Copies MachineInstr arg exactly
|
|
|
|
///
|
2004-05-23 21:35:12 +02:00
|
|
|
MachineInstr::MachineInstr(const MachineInstr &MI) {
|
|
|
|
Opcode = MI.getOpcode();
|
2006-11-15 21:54:29 +01:00
|
|
|
NumImplicitOps = MI.NumImplicitOps;
|
2006-05-04 21:14:44 +02:00
|
|
|
Operands.reserve(MI.getNumOperands());
|
2004-05-23 22:58:02 +02:00
|
|
|
|
2004-07-09 16:45:17 +02:00
|
|
|
// Add operands
|
2006-05-04 21:14:44 +02:00
|
|
|
for (unsigned i = 0; i != MI.getNumOperands(); ++i)
|
|
|
|
Operands.push_back(MI.getOperand(i));
|
2004-05-24 05:14:18 +02:00
|
|
|
|
2004-07-09 16:45:17 +02:00
|
|
|
// Set parent, next, and prev to null
|
2004-05-24 05:14:18 +02:00
|
|
|
parent = 0;
|
|
|
|
prev = 0;
|
|
|
|
next = 0;
|
2004-05-23 21:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-09 16:45:17 +02:00
|
|
|
MachineInstr::~MachineInstr() {
|
2004-02-16 08:17:43 +01:00
|
|
|
LeakDetector::removeGarbageObject(this);
|
|
|
|
}
|
|
|
|
|
2006-04-17 23:35:41 +02:00
|
|
|
/// removeFromParent - This method unlinks 'this' from the containing basic
|
|
|
|
/// block, and returns it, but does not delete it.
|
|
|
|
MachineInstr *MachineInstr::removeFromParent() {
|
|
|
|
assert(getParent() && "Not embedded in a basic block!");
|
|
|
|
getParent()->remove(this);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-13 05:39:32 +01:00
|
|
|
/// OperandComplete - Return true if it's illegal to add a new operand
|
|
|
|
///
|
2004-02-12 17:09:53 +01:00
|
|
|
bool MachineInstr::OperandsComplete() const {
|
|
|
|
int NumOperands = TargetInstrDescriptors[Opcode].numOperands;
|
2006-06-15 09:22:16 +02:00
|
|
|
if ((TargetInstrDescriptors[Opcode].Flags & M_VARIABLE_OPS) == 0 &&
|
2006-11-14 00:34:06 +01:00
|
|
|
getNumOperands()-NumImplicitOps >= (unsigned)NumOperands)
|
2003-05-31 09:39:06 +02:00
|
|
|
return true; // Broken: we have all the operands of this instruction!
|
2002-10-28 21:48:39 +01:00
|
|
|
return false;
|
2001-07-21 14:41:50 +02:00
|
|
|
}
|
|
|
|
|
2006-10-21 00:39:59 +02:00
|
|
|
/// isIdenticalTo - Return true if this operand is identical to the specified
|
|
|
|
/// operand.
|
|
|
|
bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
|
|
|
|
if (getType() != Other.getType()) return false;
|
|
|
|
|
|
|
|
switch (getType()) {
|
|
|
|
default: assert(0 && "Unrecognized operand type");
|
|
|
|
case MachineOperand::MO_Register:
|
|
|
|
return getReg() == Other.getReg() && isDef() == Other.isDef();
|
|
|
|
case MachineOperand::MO_Immediate:
|
|
|
|
return getImm() == Other.getImm();
|
|
|
|
case MachineOperand::MO_MachineBasicBlock:
|
|
|
|
return getMBB() == Other.getMBB();
|
|
|
|
case MachineOperand::MO_FrameIndex:
|
|
|
|
return getFrameIndex() == Other.getFrameIndex();
|
|
|
|
case MachineOperand::MO_ConstantPoolIndex:
|
|
|
|
return getConstantPoolIndex() == Other.getConstantPoolIndex() &&
|
|
|
|
getOffset() == Other.getOffset();
|
|
|
|
case MachineOperand::MO_JumpTableIndex:
|
|
|
|
return getJumpTableIndex() == Other.getJumpTableIndex();
|
|
|
|
case MachineOperand::MO_GlobalAddress:
|
|
|
|
return getGlobal() == Other.getGlobal() && getOffset() == Other.getOffset();
|
|
|
|
case MachineOperand::MO_ExternalSymbol:
|
2006-10-25 20:08:14 +02:00
|
|
|
return !strcmp(getSymbolName(), Other.getSymbolName()) &&
|
2006-10-21 00:39:59 +02:00
|
|
|
getOffset() == Other.getOffset();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-14 00:34:06 +01:00
|
|
|
/// setOpcode - Replace the opcode of the current instruction with a new one.
|
|
|
|
///
|
|
|
|
void MachineInstr::setOpcode(unsigned Op) {
|
|
|
|
Operands.erase(Operands.begin(), Operands.begin()+NumImplicitOps);
|
|
|
|
NumImplicitOps = 0;
|
|
|
|
Opcode = Op;
|
|
|
|
if (!getParent())
|
|
|
|
return;
|
|
|
|
const TargetInstrDescriptor &TID = getParent()->getParent()->
|
|
|
|
getTarget().getInstrInfo()->get(Op);
|
2006-11-11 11:20:02 +01:00
|
|
|
if (TID.ImplicitDefs)
|
2006-11-14 00:34:06 +01:00
|
|
|
for (const unsigned *ImpDefs = TID.ImplicitDefs; *ImpDefs; ++ImpDefs) {
|
|
|
|
MachineOperand Op;
|
|
|
|
Op.opType = MachineOperand::MO_Register;
|
|
|
|
Op.IsDef = true;
|
|
|
|
Op.IsImp = true;
|
|
|
|
Op.IsKill = false;
|
|
|
|
Op.IsDead = false;
|
|
|
|
Op.contents.RegNo = *ImpDefs;
|
|
|
|
Op.offset = 0;
|
|
|
|
Operands.insert(Operands.begin()+NumImplicitOps, Op);
|
|
|
|
NumImplicitOps++;
|
|
|
|
}
|
2006-11-11 11:20:02 +01:00
|
|
|
if (TID.ImplicitUses)
|
2006-11-14 00:34:06 +01:00
|
|
|
for (const unsigned *ImpUses = TID.ImplicitUses; *ImpUses; ++ImpUses) {
|
|
|
|
MachineOperand Op;
|
|
|
|
Op.opType = MachineOperand::MO_Register;
|
|
|
|
Op.IsDef = false;
|
|
|
|
Op.IsImp = true;
|
|
|
|
Op.IsKill = false;
|
|
|
|
Op.IsDead = false;
|
|
|
|
Op.contents.RegNo = *ImpUses;
|
|
|
|
Op.offset = 0;
|
|
|
|
Operands.insert(Operands.begin()+NumImplicitOps, Op);
|
|
|
|
NumImplicitOps++;
|
|
|
|
}
|
2006-11-11 11:20:02 +01:00
|
|
|
}
|
|
|
|
|
2006-10-21 00:39:59 +02:00
|
|
|
|
2004-02-13 05:39:32 +01:00
|
|
|
void MachineInstr::dump() const {
|
2003-08-03 22:24:29 +02:00
|
|
|
std::cerr << " " << *this;
|
2001-07-21 14:41:50 +02:00
|
|
|
}
|
|
|
|
|
2002-10-30 01:58:19 +01:00
|
|
|
static inline void OutputReg(std::ostream &os, unsigned RegNo,
|
|
|
|
const MRegisterInfo *MRI = 0) {
|
2004-02-27 02:52:34 +01:00
|
|
|
if (!RegNo || MRegisterInfo::isPhysicalRegister(RegNo)) {
|
2004-02-19 17:17:08 +01:00
|
|
|
if (MRI)
|
2002-10-30 01:58:19 +01:00
|
|
|
os << "%" << MRI->get(RegNo).Name;
|
|
|
|
else
|
2004-02-19 17:17:08 +01:00
|
|
|
os << "%mreg(" << RegNo << ")";
|
2002-10-30 01:58:19 +01:00
|
|
|
} else
|
2004-02-19 17:17:08 +01:00
|
|
|
os << "%reg" << RegNo;
|
2002-09-16 17:18:53 +02:00
|
|
|
}
|
|
|
|
|
2002-10-30 01:48:05 +01:00
|
|
|
static void print(const MachineOperand &MO, std::ostream &OS,
|
2004-06-25 02:13:11 +02:00
|
|
|
const TargetMachine *TM) {
|
2004-07-09 16:45:17 +02:00
|
|
|
const MRegisterInfo *MRI = 0;
|
2005-04-22 00:36:52 +02:00
|
|
|
|
2004-07-09 16:45:17 +02:00
|
|
|
if (TM) MRI = TM->getRegisterInfo();
|
2004-06-25 02:13:11 +02:00
|
|
|
|
2002-10-30 01:48:05 +01:00
|
|
|
switch (MO.getType()) {
|
2006-05-04 20:05:43 +02:00
|
|
|
case MachineOperand::MO_Register:
|
2006-05-04 03:26:39 +02:00
|
|
|
OutputReg(OS, MO.getReg(), MRI);
|
2002-10-30 01:48:05 +01:00
|
|
|
break;
|
2006-05-04 19:21:20 +02:00
|
|
|
case MachineOperand::MO_Immediate:
|
2006-05-26 10:00:14 +02:00
|
|
|
OS << MO.getImmedValue();
|
2002-10-30 01:48:05 +01:00
|
|
|
break;
|
2002-12-15 21:35:25 +01:00
|
|
|
case MachineOperand::MO_MachineBasicBlock:
|
2004-06-18 00:26:53 +02:00
|
|
|
OS << "mbb<"
|
2002-12-15 21:35:25 +01:00
|
|
|
<< ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
|
2004-06-18 00:26:53 +02:00
|
|
|
<< "," << (void*)MO.getMachineBasicBlock() << ">";
|
2002-12-15 21:35:25 +01:00
|
|
|
break;
|
2002-12-28 21:37:37 +01:00
|
|
|
case MachineOperand::MO_FrameIndex:
|
|
|
|
OS << "<fi#" << MO.getFrameIndex() << ">";
|
|
|
|
break;
|
2003-01-13 01:23:24 +01:00
|
|
|
case MachineOperand::MO_ConstantPoolIndex:
|
|
|
|
OS << "<cp#" << MO.getConstantPoolIndex() << ">";
|
|
|
|
break;
|
2006-04-22 20:53:45 +02:00
|
|
|
case MachineOperand::MO_JumpTableIndex:
|
|
|
|
OS << "<jt#" << MO.getJumpTableIndex() << ">";
|
|
|
|
break;
|
2003-01-13 01:23:24 +01:00
|
|
|
case MachineOperand::MO_GlobalAddress:
|
2004-10-15 06:38:41 +02:00
|
|
|
OS << "<ga:" << ((Value*)MO.getGlobal())->getName();
|
|
|
|
if (MO.getOffset()) OS << "+" << MO.getOffset();
|
|
|
|
OS << ">";
|
2003-01-13 01:23:24 +01:00
|
|
|
break;
|
|
|
|
case MachineOperand::MO_ExternalSymbol:
|
2004-10-15 06:38:41 +02:00
|
|
|
OS << "<es:" << MO.getSymbolName();
|
|
|
|
if (MO.getOffset()) OS << "+" << MO.getOffset();
|
|
|
|
OS << ">";
|
2003-01-13 01:23:24 +01:00
|
|
|
break;
|
2002-10-30 01:48:05 +01:00
|
|
|
default:
|
|
|
|
assert(0 && "Unrecognized operand type");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-25 02:13:11 +02:00
|
|
|
void MachineInstr::print(std::ostream &OS, const TargetMachine *TM) const {
|
2002-10-30 02:55:38 +01:00
|
|
|
unsigned StartOp = 0;
|
|
|
|
|
|
|
|
// Specialize printing if op#0 is definition
|
2006-09-05 22:19:27 +02:00
|
|
|
if (getNumOperands() && getOperand(0).isReg() && getOperand(0).isDef()) {
|
2004-02-23 19:38:20 +01:00
|
|
|
::print(getOperand(0), OS, TM);
|
2002-10-30 02:55:38 +01:00
|
|
|
OS << " = ";
|
|
|
|
++StartOp; // Don't print this operand again!
|
|
|
|
}
|
2004-06-25 02:13:11 +02:00
|
|
|
|
2004-07-09 16:45:17 +02:00
|
|
|
// Must check if Target machine is not null because machine BB could not
|
|
|
|
// be attached to a Machine function yet
|
|
|
|
if (TM)
|
2004-06-25 02:13:11 +02:00
|
|
|
OS << TM->getInstrInfo()->getName(getOpcode());
|
2005-04-22 00:36:52 +02:00
|
|
|
|
2002-10-30 02:55:38 +01:00
|
|
|
for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
|
2003-05-27 02:05:23 +02:00
|
|
|
const MachineOperand& mop = getOperand(i);
|
2002-10-30 02:55:38 +01:00
|
|
|
if (i != StartOp)
|
|
|
|
OS << ",";
|
|
|
|
OS << " ";
|
2004-02-23 19:38:20 +01:00
|
|
|
::print(mop, OS, TM);
|
2005-04-22 00:36:52 +02:00
|
|
|
|
2006-11-10 09:43:01 +01:00
|
|
|
if (mop.isReg()) {
|
2006-11-14 00:34:06 +01:00
|
|
|
if (mop.isDef() || mop.isKill() || mop.isDead() || mop.isImplicit()) {
|
|
|
|
OS << "<";
|
|
|
|
bool NeedComma = false;
|
|
|
|
if (mop.isImplicit()) {
|
|
|
|
OS << (mop.isDef() ? "imp-def" : "imp-use");
|
|
|
|
NeedComma = true;
|
|
|
|
} else if (mop.isDef()) {
|
|
|
|
OS << "def";
|
|
|
|
NeedComma = true;
|
|
|
|
}
|
|
|
|
if (mop.isKill() || mop.isDead()) {
|
|
|
|
if (NeedComma)
|
|
|
|
OS << ",";
|
|
|
|
if (mop.isKill())
|
|
|
|
OS << "kill";
|
|
|
|
if (mop.isDead())
|
|
|
|
OS << "dead";
|
|
|
|
}
|
|
|
|
OS << ">";
|
|
|
|
}
|
2006-11-10 09:43:01 +01:00
|
|
|
}
|
2002-10-30 01:48:05 +01:00
|
|
|
}
|
2005-04-22 00:36:52 +02:00
|
|
|
|
2002-10-30 01:48:05 +01:00
|
|
|
OS << "\n";
|
|
|
|
}
|
|
|
|
|
2006-05-04 02:49:59 +02:00
|
|
|
std::ostream &llvm::operator<<(std::ostream &os, const MachineInstr &MI) {
|
2004-02-19 17:17:08 +01:00
|
|
|
// If the instruction is embedded into a basic block, we can find the target
|
|
|
|
// info for the instruction.
|
|
|
|
if (const MachineBasicBlock *MBB = MI.getParent()) {
|
|
|
|
const MachineFunction *MF = MBB->getParent();
|
2004-07-09 16:45:17 +02:00
|
|
|
if (MF)
|
2004-06-25 02:13:11 +02:00
|
|
|
MI.print(os, &MF->getTarget());
|
|
|
|
else
|
|
|
|
MI.print(os, 0);
|
2004-02-19 17:17:08 +01:00
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, print it out in the "raw" format without symbolic register names
|
|
|
|
// and such.
|
2004-02-12 17:09:53 +01:00
|
|
|
os << TargetInstrDescriptors[MI.getOpcode()].Name;
|
2005-04-22 00:36:52 +02:00
|
|
|
|
2004-07-09 16:45:17 +02:00
|
|
|
for (unsigned i = 0, N = MI.getNumOperands(); i < N; i++) {
|
2003-01-13 01:23:24 +01:00
|
|
|
os << "\t" << MI.getOperand(i);
|
2006-09-05 22:19:27 +02:00
|
|
|
if (MI.getOperand(i).isReg() && MI.getOperand(i).isDef())
|
|
|
|
os << "<d>";
|
2001-11-14 21:05:23 +01:00
|
|
|
}
|
2005-04-22 00:36:52 +02:00
|
|
|
|
2002-01-20 23:54:45 +01:00
|
|
|
return os << "\n";
|
2001-07-21 14:41:50 +02:00
|
|
|
}
|
|
|
|
|
2006-05-04 02:49:59 +02:00
|
|
|
std::ostream &llvm::operator<<(std::ostream &OS, const MachineOperand &MO) {
|
2004-07-09 16:45:17 +02:00
|
|
|
switch (MO.getType()) {
|
2006-05-04 20:05:43 +02:00
|
|
|
case MachineOperand::MO_Register:
|
2006-05-04 03:26:39 +02:00
|
|
|
OutputReg(OS, MO.getReg());
|
2004-07-09 16:45:17 +02:00
|
|
|
break;
|
2006-05-04 19:21:20 +02:00
|
|
|
case MachineOperand::MO_Immediate:
|
2004-07-09 16:45:17 +02:00
|
|
|
OS << (long)MO.getImmedValue();
|
|
|
|
break;
|
|
|
|
case MachineOperand::MO_MachineBasicBlock:
|
|
|
|
OS << "<mbb:"
|
|
|
|
<< ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
|
|
|
|
<< "@" << (void*)MO.getMachineBasicBlock() << ">";
|
|
|
|
break;
|
|
|
|
case MachineOperand::MO_FrameIndex:
|
|
|
|
OS << "<fi#" << MO.getFrameIndex() << ">";
|
|
|
|
break;
|
|
|
|
case MachineOperand::MO_ConstantPoolIndex:
|
|
|
|
OS << "<cp#" << MO.getConstantPoolIndex() << ">";
|
|
|
|
break;
|
2006-04-22 20:53:45 +02:00
|
|
|
case MachineOperand::MO_JumpTableIndex:
|
|
|
|
OS << "<jt#" << MO.getJumpTableIndex() << ">";
|
|
|
|
break;
|
2004-07-09 16:45:17 +02:00
|
|
|
case MachineOperand::MO_GlobalAddress:
|
|
|
|
OS << "<ga:" << ((Value*)MO.getGlobal())->getName() << ">";
|
|
|
|
break;
|
|
|
|
case MachineOperand::MO_ExternalSymbol:
|
|
|
|
OS << "<es:" << MO.getSymbolName() << ">";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0 && "Unrecognized operand type");
|
|
|
|
break;
|
|
|
|
}
|
2005-04-22 00:36:52 +02:00
|
|
|
|
2002-12-28 21:37:37 +01:00
|
|
|
return OS;
|
2001-07-21 14:41:50 +02:00
|
|
|
}
|