blob: 973e3ec1e6ee0621e0235484078d9a2a341dae19 [file] [log] [blame]
Chris Lattner035dfbe2002-08-09 20:08:06 +00001//===-- MachineInstr.cpp --------------------------------------------------===//
Misha Brukmanedf128a2005-04-21 22:36:52 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukmanedf128a2005-04-21 22:36:52 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Brian Gaeke21326fc2004-02-13 04:39:32 +00009//
10// Methods common to all machine instructions.
11//
12// FIXME: Now that MachineInstrs have parent pointers, they should always
13// print themselves using their MachineFunction's TargetMachine.
14//
Chris Lattner035dfbe2002-08-09 20:08:06 +000015//===----------------------------------------------------------------------===//
Vikram S. Adve70bc4b52001-07-21 12:41:50 +000016
Chris Lattner822b4fb2001-09-07 17:18:30 +000017#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner8517e1f2004-02-19 16:17:08 +000018#include "llvm/CodeGen/MachineFunction.h"
Chris Lattner3801f6d2002-02-03 07:46:01 +000019#include "llvm/Value.h"
Chris Lattner10491642002-10-30 00:48:05 +000020#include "llvm/Target/TargetMachine.h"
Chris Lattner3501fea2003-01-14 22:00:31 +000021#include "llvm/Target/TargetInstrInfo.h"
Chris Lattner2a79a092002-10-30 00:58:19 +000022#include "llvm/Target/MRegisterInfo.h"
Reid Spencer551ccae2004-09-01 22:55:40 +000023#include "llvm/Support/LeakDetector.h"
Reid Spencer954da372004-07-04 12:19:56 +000024#include <iostream>
25
Chris Lattner0742b592004-02-23 18:38:20 +000026using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000027
Chris Lattnerf1757c42002-10-29 17:40:30 +000028// Global variable holding an array of descriptors for machine instructions.
29// The actual object needs to be created separately for each target machine.
Chris Lattner3501fea2003-01-14 22:00:31 +000030// This variable is initialized and reset by class TargetInstrInfo.
Misha Brukmanedf128a2005-04-21 22:36:52 +000031//
Chris Lattnerf1757c42002-10-29 17:40:30 +000032// FIXME: This should be a property of the target so that more than one target
33// at a time can be active...
34//
Chris Lattner11d1f212004-02-23 18:40:08 +000035namespace llvm {
Chris Lattner0742b592004-02-23 18:38:20 +000036 extern const TargetInstrDescriptor *TargetInstrDescriptors;
37}
Ruchira Sasanka69917e22001-10-18 22:40:02 +000038
Vikram S. Adve1885da42001-07-31 21:49:28 +000039// Constructor for instructions with variable #operands
Alkis Evlogimenosab8672c2004-02-12 18:49:07 +000040MachineInstr::MachineInstr(short opcode, unsigned numOperands)
41 : Opcode(opcode),
Alkis Evlogimenosab8672c2004-02-12 18:49:07 +000042 operands(numOperands, MachineOperand()),
43 parent(0) {
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000044 // Make sure that we get added to a machine basicblock
45 LeakDetector::addGarbageObject(this);
Vikram S. Adve70bc4b52001-07-21 12:41:50 +000046}
47
Chris Lattnerddd7fcb2002-10-29 23:19:00 +000048/// MachineInstr ctor - This constructor only does a _reserve_ of the operands,
49/// not a resize for them. It is expected that if you use this that you call
50/// add* methods below to fill up the operands, instead of the Set methods.
51/// Eventually, the "resizing" ctors will be phased out.
52///
Brian Gaeke21326fc2004-02-13 04:39:32 +000053MachineInstr::MachineInstr(short opcode, unsigned numOperands, bool XX, bool YY)
Chris Lattner02e5f8d2006-04-20 18:08:53 +000054 : Opcode(opcode), parent(0) {
Chris Lattner72791222002-10-28 20:59:49 +000055 operands.reserve(numOperands);
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000056 // Make sure that we get added to a machine basicblock
57 LeakDetector::addGarbageObject(this);
Chris Lattner72791222002-10-28 20:59:49 +000058}
59
Chris Lattnerddd7fcb2002-10-29 23:19:00 +000060/// MachineInstr ctor - Work exactly the same as the ctor above, except that the
61/// MachineInstr is created and added to the end of the specified basic block.
62///
Alkis Evlogimenosab8672c2004-02-12 18:49:07 +000063MachineInstr::MachineInstr(MachineBasicBlock *MBB, short opcode,
Chris Lattnerddd7fcb2002-10-29 23:19:00 +000064 unsigned numOperands)
Chris Lattner02e5f8d2006-04-20 18:08:53 +000065 : Opcode(opcode), parent(0) {
Chris Lattnerddd7fcb2002-10-29 23:19:00 +000066 assert(MBB && "Cannot use inserting ctor with null basic block!");
67 operands.reserve(numOperands);
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000068 // Make sure that we get added to a machine basicblock
69 LeakDetector::addGarbageObject(this);
Chris Lattnerddd7fcb2002-10-29 23:19:00 +000070 MBB->push_back(this); // Add instruction to end of basic block!
71}
72
Misha Brukmance22e762004-07-09 14:45:17 +000073/// MachineInstr ctor - Copies MachineInstr arg exactly
74///
Tanya Lattner466b5342004-05-23 19:35:12 +000075MachineInstr::MachineInstr(const MachineInstr &MI) {
76 Opcode = MI.getOpcode();
Tanya Lattnerb5159ed2004-05-23 20:58:02 +000077 operands.reserve(MI.getNumOperands());
78
Misha Brukmance22e762004-07-09 14:45:17 +000079 // Add operands
80 for (unsigned i = 0; i < MI.getNumOperands(); ++i)
Tanya Lattner466b5342004-05-23 19:35:12 +000081 operands.push_back(MachineOperand(MI.getOperand(i)));
Tanya Lattner0c63e032004-05-24 03:14:18 +000082
Misha Brukmance22e762004-07-09 14:45:17 +000083 // Set parent, next, and prev to null
Tanya Lattner0c63e032004-05-24 03:14:18 +000084 parent = 0;
85 prev = 0;
86 next = 0;
Tanya Lattner466b5342004-05-23 19:35:12 +000087}
88
89
Misha Brukmance22e762004-07-09 14:45:17 +000090MachineInstr::~MachineInstr() {
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +000091 LeakDetector::removeGarbageObject(this);
92}
93
Misha Brukmance22e762004-07-09 14:45:17 +000094/// clone - Create a copy of 'this' instruction that is identical in all ways
95/// except the following: the new instruction has no parent and it has no name
96///
Tanya Lattner0c63e032004-05-24 03:14:18 +000097MachineInstr* MachineInstr::clone() const {
Tanya Lattnerb5159ed2004-05-23 20:58:02 +000098 return new MachineInstr(*this);
Tanya Lattner466b5342004-05-23 19:35:12 +000099}
100
Chris Lattner48d7c062006-04-17 21:35:41 +0000101/// removeFromParent - This method unlinks 'this' from the containing basic
102/// block, and returns it, but does not delete it.
103MachineInstr *MachineInstr::removeFromParent() {
104 assert(getParent() && "Not embedded in a basic block!");
105 getParent()->remove(this);
106 return this;
107}
108
109
Brian Gaeke21326fc2004-02-13 04:39:32 +0000110/// OperandComplete - Return true if it's illegal to add a new operand
111///
Chris Lattner2a90ba62004-02-12 16:09:53 +0000112bool MachineInstr::OperandsComplete() const {
113 int NumOperands = TargetInstrDescriptors[Opcode].numOperands;
Vikram S. Advea2bae302002-10-29 19:41:18 +0000114 if (NumOperands >= 0 && getNumOperands() >= (unsigned)NumOperands)
Vikram S. Adve34977822003-05-31 07:39:06 +0000115 return true; // Broken: we have all the operands of this instruction!
Chris Lattner413746e2002-10-28 20:48:39 +0000116 return false;
117}
118
Chris Lattnera2dd7452003-08-05 16:58:46 +0000119void MachineInstr::SetMachineOperandVal(unsigned i,
120 MachineOperand::MachineOperandType opTy,
121 Value* V) {
Vikram S. Advea2bae302002-10-29 19:41:18 +0000122 assert(i < operands.size()); // may be explicit or implicit op
Chris Lattnera2dd7452003-08-05 16:58:46 +0000123 operands[i].opType = opTy;
Brian Gaekec5483952004-03-03 19:07:27 +0000124 operands[i].contents.value = V;
Chris Lattnerca4f6eb2004-10-15 04:38:41 +0000125 operands[i].extra.regNum = -1;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000126}
127
128void
Chris Lattner572f5c82002-10-28 04:24:49 +0000129MachineInstr::SetMachineOperandConst(unsigned i,
Brian Gaeke21326fc2004-02-13 04:39:32 +0000130 MachineOperand::MachineOperandType opTy,
Chris Lattner561c0102004-02-29 05:07:02 +0000131 int intValue) {
Vikram S. Advea2bae302002-10-29 19:41:18 +0000132 assert(i < getNumOperands()); // must be explicit op
Chris Lattner572f5c82002-10-28 04:24:49 +0000133
Brian Gaeke21326fc2004-02-13 04:39:32 +0000134 operands[i].opType = opTy;
Brian Gaekec5483952004-03-03 19:07:27 +0000135 operands[i].contents.value = NULL;
136 operands[i].contents.immedVal = intValue;
Chris Lattnerca4f6eb2004-10-15 04:38:41 +0000137 operands[i].extra.regNum = -1;
Chris Lattner572f5c82002-10-28 04:24:49 +0000138 operands[i].flags = 0;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000139}
140
Chris Lattnera2dd7452003-08-05 16:58:46 +0000141void MachineInstr::SetMachineOperandReg(unsigned i, int regNum) {
Vikram S. Advea2bae302002-10-29 19:41:18 +0000142 assert(i < getNumOperands()); // must be explicit op
Chris Lattner572f5c82002-10-28 04:24:49 +0000143
Chris Lattner2f305982002-10-28 19:46:59 +0000144 operands[i].opType = MachineOperand::MO_MachineRegister;
Brian Gaekec5483952004-03-03 19:07:27 +0000145 operands[i].contents.value = NULL;
Chris Lattnerca4f6eb2004-10-15 04:38:41 +0000146 operands[i].extra.regNum = regNum;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000147}
148
Brian Gaeke21326fc2004-02-13 04:39:32 +0000149void MachineInstr::dump() const {
Chris Lattner925b7712003-08-03 20:24:29 +0000150 std::cerr << " " << *this;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000151}
152
Brian Gaeke21326fc2004-02-13 04:39:32 +0000153static inline std::ostream& OutputValue(std::ostream &os, const Value* val) {
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000154 os << "(val ";
Misha Brukmance22e762004-07-09 14:45:17 +0000155 os << (void*) val; // print address always
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000156 if (val && val->hasName())
Misha Brukmance22e762004-07-09 14:45:17 +0000157 os << " " << val->getName(); // print name also, if available
Brian Gaeke21326fc2004-02-13 04:39:32 +0000158 os << ")";
Vikram S. Adve627eb312003-07-10 19:45:07 +0000159 return os;
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000160}
161
Chris Lattner2a79a092002-10-30 00:58:19 +0000162static inline void OutputReg(std::ostream &os, unsigned RegNo,
163 const MRegisterInfo *MRI = 0) {
Alkis Evlogimenosddcfd9e2004-02-27 01:52:34 +0000164 if (!RegNo || MRegisterInfo::isPhysicalRegister(RegNo)) {
Chris Lattner8517e1f2004-02-19 16:17:08 +0000165 if (MRI)
Chris Lattner2a79a092002-10-30 00:58:19 +0000166 os << "%" << MRI->get(RegNo).Name;
167 else
Chris Lattner8517e1f2004-02-19 16:17:08 +0000168 os << "%mreg(" << RegNo << ")";
Chris Lattner2a79a092002-10-30 00:58:19 +0000169 } else
Chris Lattner8517e1f2004-02-19 16:17:08 +0000170 os << "%reg" << RegNo;
Vikram S. Adve8c6936a2002-09-16 15:18:53 +0000171}
172
Chris Lattner10491642002-10-30 00:48:05 +0000173static void print(const MachineOperand &MO, std::ostream &OS,
Tanya Lattnerb1407622004-06-25 00:13:11 +0000174 const TargetMachine *TM) {
Misha Brukmance22e762004-07-09 14:45:17 +0000175 const MRegisterInfo *MRI = 0;
Misha Brukmanedf128a2005-04-21 22:36:52 +0000176
Misha Brukmance22e762004-07-09 14:45:17 +0000177 if (TM) MRI = TM->getRegisterInfo();
Tanya Lattnerb1407622004-06-25 00:13:11 +0000178
Chris Lattner10491642002-10-30 00:48:05 +0000179 bool CloseParen = true;
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000180 if (MO.isHiBits32())
Chris Lattner10491642002-10-30 00:48:05 +0000181 OS << "%lm(";
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000182 else if (MO.isLoBits32())
Chris Lattner10491642002-10-30 00:48:05 +0000183 OS << "%lo(";
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000184 else if (MO.isHiBits64())
Chris Lattner10491642002-10-30 00:48:05 +0000185 OS << "%hh(";
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000186 else if (MO.isLoBits64())
Chris Lattner10491642002-10-30 00:48:05 +0000187 OS << "%hm(";
188 else
189 CloseParen = false;
Misha Brukmanedf128a2005-04-21 22:36:52 +0000190
Chris Lattner10491642002-10-30 00:48:05 +0000191 switch (MO.getType()) {
192 case MachineOperand::MO_VirtualRegister:
193 if (MO.getVRegValue()) {
194 OS << "%reg";
195 OutputValue(OS, MO.getVRegValue());
196 if (MO.hasAllocatedReg())
197 OS << "==";
198 }
199 if (MO.hasAllocatedReg())
Alkis Evlogimenosbe766c72004-02-13 21:01:20 +0000200 OutputReg(OS, MO.getReg(), MRI);
Chris Lattner10491642002-10-30 00:48:05 +0000201 break;
202 case MachineOperand::MO_CCRegister:
203 OS << "%ccreg";
204 OutputValue(OS, MO.getVRegValue());
205 if (MO.hasAllocatedReg()) {
206 OS << "==";
Alkis Evlogimenosbe766c72004-02-13 21:01:20 +0000207 OutputReg(OS, MO.getReg(), MRI);
Chris Lattner10491642002-10-30 00:48:05 +0000208 }
209 break;
210 case MachineOperand::MO_MachineRegister:
Chris Lattner2a79a092002-10-30 00:58:19 +0000211 OutputReg(OS, MO.getMachineRegNum(), MRI);
Chris Lattner10491642002-10-30 00:48:05 +0000212 break;
213 case MachineOperand::MO_SignExtendedImmed:
214 OS << (long)MO.getImmedValue();
215 break;
216 case MachineOperand::MO_UnextendedImmed:
217 OS << (long)MO.getImmedValue();
218 break;
219 case MachineOperand::MO_PCRelativeDisp: {
220 const Value* opVal = MO.getVRegValue();
221 bool isLabel = isa<Function>(opVal) || isa<BasicBlock>(opVal);
222 OS << "%disp(" << (isLabel? "label " : "addr-of-val ");
223 if (opVal->hasName())
224 OS << opVal->getName();
225 else
226 OS << (const void*) opVal;
227 OS << ")";
228 break;
229 }
Chris Lattner2109f502002-12-15 20:35:25 +0000230 case MachineOperand::MO_MachineBasicBlock:
Brian Gaeke988b7ba2004-06-17 22:26:53 +0000231 OS << "mbb<"
Chris Lattner2109f502002-12-15 20:35:25 +0000232 << ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
Brian Gaeke988b7ba2004-06-17 22:26:53 +0000233 << "," << (void*)MO.getMachineBasicBlock() << ">";
Chris Lattner2109f502002-12-15 20:35:25 +0000234 break;
Chris Lattner10cb79b2002-12-28 20:37:37 +0000235 case MachineOperand::MO_FrameIndex:
236 OS << "<fi#" << MO.getFrameIndex() << ">";
237 break;
Chris Lattner8d95ef42003-01-13 00:23:24 +0000238 case MachineOperand::MO_ConstantPoolIndex:
239 OS << "<cp#" << MO.getConstantPoolIndex() << ">";
240 break;
241 case MachineOperand::MO_GlobalAddress:
Chris Lattnerca4f6eb2004-10-15 04:38:41 +0000242 OS << "<ga:" << ((Value*)MO.getGlobal())->getName();
243 if (MO.getOffset()) OS << "+" << MO.getOffset();
244 OS << ">";
Chris Lattner8d95ef42003-01-13 00:23:24 +0000245 break;
246 case MachineOperand::MO_ExternalSymbol:
Chris Lattnerca4f6eb2004-10-15 04:38:41 +0000247 OS << "<es:" << MO.getSymbolName();
248 if (MO.getOffset()) OS << "+" << MO.getOffset();
249 OS << ">";
Chris Lattner8d95ef42003-01-13 00:23:24 +0000250 break;
Chris Lattner10491642002-10-30 00:48:05 +0000251 default:
252 assert(0 && "Unrecognized operand type");
253 }
254
255 if (CloseParen)
256 OS << ")";
257}
258
Tanya Lattnerb1407622004-06-25 00:13:11 +0000259void MachineInstr::print(std::ostream &OS, const TargetMachine *TM) const {
Chris Lattner6a592272002-10-30 01:55:38 +0000260 unsigned StartOp = 0;
Chris Lattner10491642002-10-30 00:48:05 +0000261
Chris Lattner6a592272002-10-30 01:55:38 +0000262 // Specialize printing if op#0 is definition
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000263 if (getNumOperands() && getOperand(0).isDef() && !getOperand(0).isUse()) {
Chris Lattner0742b592004-02-23 18:38:20 +0000264 ::print(getOperand(0), OS, TM);
Chris Lattner6a592272002-10-30 01:55:38 +0000265 OS << " = ";
266 ++StartOp; // Don't print this operand again!
267 }
Tanya Lattnerb1407622004-06-25 00:13:11 +0000268
Misha Brukmance22e762004-07-09 14:45:17 +0000269 // Must check if Target machine is not null because machine BB could not
270 // be attached to a Machine function yet
271 if (TM)
Tanya Lattnerb1407622004-06-25 00:13:11 +0000272 OS << TM->getInstrInfo()->getName(getOpcode());
Misha Brukmanedf128a2005-04-21 22:36:52 +0000273
Chris Lattner6a592272002-10-30 01:55:38 +0000274 for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
Vikram S. Adve5f2180c2003-05-27 00:05:23 +0000275 const MachineOperand& mop = getOperand(i);
Chris Lattner6a592272002-10-30 01:55:38 +0000276 if (i != StartOp)
277 OS << ",";
278 OS << " ";
Chris Lattner0742b592004-02-23 18:38:20 +0000279 ::print(mop, OS, TM);
Misha Brukmanedf128a2005-04-21 22:36:52 +0000280
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000281 if (mop.isDef())
282 if (mop.isUse())
283 OS << "<def&use>";
284 else
285 OS << "<def>";
Chris Lattner10491642002-10-30 00:48:05 +0000286 }
Misha Brukmanedf128a2005-04-21 22:36:52 +0000287
Chris Lattner10491642002-10-30 00:48:05 +0000288 OS << "\n";
289}
290
Chris Lattner11d1f212004-02-23 18:40:08 +0000291namespace llvm {
Chris Lattner8517e1f2004-02-19 16:17:08 +0000292std::ostream &operator<<(std::ostream &os, const MachineInstr &MI) {
293 // If the instruction is embedded into a basic block, we can find the target
294 // info for the instruction.
295 if (const MachineBasicBlock *MBB = MI.getParent()) {
296 const MachineFunction *MF = MBB->getParent();
Misha Brukmance22e762004-07-09 14:45:17 +0000297 if (MF)
Tanya Lattnerb1407622004-06-25 00:13:11 +0000298 MI.print(os, &MF->getTarget());
299 else
300 MI.print(os, 0);
Chris Lattner8517e1f2004-02-19 16:17:08 +0000301 return os;
302 }
303
304 // Otherwise, print it out in the "raw" format without symbolic register names
305 // and such.
Chris Lattner2a90ba62004-02-12 16:09:53 +0000306 os << TargetInstrDescriptors[MI.getOpcode()].Name;
Misha Brukmanedf128a2005-04-21 22:36:52 +0000307
Misha Brukmance22e762004-07-09 14:45:17 +0000308 for (unsigned i = 0, N = MI.getNumOperands(); i < N; i++) {
Chris Lattner8d95ef42003-01-13 00:23:24 +0000309 os << "\t" << MI.getOperand(i);
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000310 if (MI.getOperand(i).isDef())
311 if (MI.getOperand(i).isUse())
312 os << "<d&u>";
313 else
314 os << "<d>";
Ruchira Sasanka8d243372001-11-14 20:05:23 +0000315 }
Misha Brukmanedf128a2005-04-21 22:36:52 +0000316
Chris Lattner697954c2002-01-20 22:54:45 +0000317 return os << "\n";
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000318}
319
Brian Gaeke21326fc2004-02-13 04:39:32 +0000320std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO) {
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000321 if (MO.isHiBits32())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000322 OS << "%lm(";
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000323 else if (MO.isLoBits32())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000324 OS << "%lo(";
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000325 else if (MO.isHiBits64())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000326 OS << "%hh(";
Alkis Evlogimenos4d7af652003-12-14 13:24:17 +0000327 else if (MO.isLoBits64())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000328 OS << "%hm(";
Misha Brukmanedf128a2005-04-21 22:36:52 +0000329
Misha Brukmance22e762004-07-09 14:45:17 +0000330 switch (MO.getType()) {
331 case MachineOperand::MO_VirtualRegister:
332 if (MO.hasAllocatedReg())
333 OutputReg(OS, MO.getReg());
Chris Lattner8d95ef42003-01-13 00:23:24 +0000334
Misha Brukmance22e762004-07-09 14:45:17 +0000335 if (MO.getVRegValue()) {
336 if (MO.hasAllocatedReg()) OS << "==";
337 OS << "%vreg";
Chris Lattner10cb79b2002-12-28 20:37:37 +0000338 OutputValue(OS, MO.getVRegValue());
Vikram S. Adve6e447182001-09-18 12:56:28 +0000339 }
Misha Brukmance22e762004-07-09 14:45:17 +0000340 break;
341 case MachineOperand::MO_CCRegister:
342 OS << "%ccreg";
343 OutputValue(OS, MO.getVRegValue());
344 if (MO.hasAllocatedReg()) {
345 OS << "==";
346 OutputReg(OS, MO.getReg());
347 }
348 break;
349 case MachineOperand::MO_MachineRegister:
350 OutputReg(OS, MO.getMachineRegNum());
351 break;
352 case MachineOperand::MO_SignExtendedImmed:
353 OS << (long)MO.getImmedValue();
354 break;
355 case MachineOperand::MO_UnextendedImmed:
356 OS << (long)MO.getImmedValue();
357 break;
358 case MachineOperand::MO_PCRelativeDisp: {
359 const Value* opVal = MO.getVRegValue();
360 bool isLabel = isa<Function>(opVal) || isa<BasicBlock>(opVal);
361 OS << "%disp(" << (isLabel? "label " : "addr-of-val ");
362 if (opVal->hasName())
363 OS << opVal->getName();
364 else
365 OS << (const void*) opVal;
366 OS << ")";
367 break;
368 }
369 case MachineOperand::MO_MachineBasicBlock:
370 OS << "<mbb:"
371 << ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
372 << "@" << (void*)MO.getMachineBasicBlock() << ">";
373 break;
374 case MachineOperand::MO_FrameIndex:
375 OS << "<fi#" << MO.getFrameIndex() << ">";
376 break;
377 case MachineOperand::MO_ConstantPoolIndex:
378 OS << "<cp#" << MO.getConstantPoolIndex() << ">";
379 break;
380 case MachineOperand::MO_GlobalAddress:
381 OS << "<ga:" << ((Value*)MO.getGlobal())->getName() << ">";
382 break;
383 case MachineOperand::MO_ExternalSymbol:
384 OS << "<es:" << MO.getSymbolName() << ">";
385 break;
386 default:
387 assert(0 && "Unrecognized operand type");
388 break;
389 }
Misha Brukmanedf128a2005-04-21 22:36:52 +0000390
Chris Lattner0742b592004-02-23 18:38:20 +0000391 if (MO.isHiBits32() || MO.isLoBits32() || MO.isHiBits64() || MO.isLoBits64())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000392 OS << ")";
Misha Brukmanedf128a2005-04-21 22:36:52 +0000393
Chris Lattner10cb79b2002-12-28 20:37:37 +0000394 return OS;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000395}
Brian Gaeked0fde302003-11-11 22:41:34 +0000396
Chris Lattner11d1f212004-02-23 18:40:08 +0000397}