blob: baab1203df05fa5520dad6a82fd561b66873736d [file] [log] [blame]
Chris Lattnere138b3d2008-01-01 20:36:19 +00001//===-- lib/CodeGen/MachineInstr.cpp --------------------------------------===//
Misha Brukmanedf128a2005-04-21 22:36:52 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// 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//
Chris Lattner035dfbe2002-08-09 20:08:06 +000012//===----------------------------------------------------------------------===//
Vikram S. Adve70bc4b52001-07-21 12:41:50 +000013
Chris Lattner822b4fb2001-09-07 17:18:30 +000014#include "llvm/CodeGen/MachineInstr.h"
Evan Chengfb112882009-03-23 08:01:15 +000015#include "llvm/Constants.h"
16#include "llvm/InlineAsm.h"
Chris Lattner84bc5422007-12-31 04:13:23 +000017#include "llvm/Value.h"
Dan Gohmancd26ec52009-09-23 01:33:16 +000018#include "llvm/Assembly/Writer.h"
Chris Lattner8517e1f2004-02-19 16:17:08 +000019#include "llvm/CodeGen/MachineFunction.h"
Chris Lattner62ed6b92008-01-01 01:12:31 +000020#include "llvm/CodeGen/MachineRegisterInfo.h"
Dan Gohman69de1932008-02-06 22:27:42 +000021#include "llvm/CodeGen/PseudoSourceValue.h"
Chris Lattner10491642002-10-30 00:48:05 +000022#include "llvm/Target/TargetMachine.h"
Evan Chengbb81d972008-01-31 09:59:15 +000023#include "llvm/Target/TargetInstrInfo.h"
Chris Lattnerf14cf852008-01-07 07:42:25 +000024#include "llvm/Target/TargetInstrDesc.h"
Dan Gohman6f0d0242008-02-10 18:45:23 +000025#include "llvm/Target/TargetRegisterInfo.h"
Argyrios Kyrtzidisa26eae62009-04-30 23:22:31 +000026#include "llvm/Analysis/DebugInfo.h"
Torok Edwinc25e7582009-07-11 20:10:48 +000027#include "llvm/Support/ErrorHandling.h"
Dan Gohman2c3f7ae2008-07-17 23:49:46 +000028#include "llvm/Support/LeakDetector.h"
Dan Gohmance42e402008-07-07 20:32:02 +000029#include "llvm/Support/MathExtras.h"
Chris Lattneredfb72c2008-08-24 20:37:32 +000030#include "llvm/Support/raw_ostream.h"
Dan Gohmanb8d2f552008-08-20 15:58:01 +000031#include "llvm/ADT/FoldingSet.h"
Chris Lattner0742b592004-02-23 18:38:20 +000032using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000033
Chris Lattnerf7382302007-12-30 21:56:09 +000034//===----------------------------------------------------------------------===//
35// MachineOperand Implementation
36//===----------------------------------------------------------------------===//
37
Chris Lattner62ed6b92008-01-01 01:12:31 +000038/// AddRegOperandToRegInfo - Add this register operand to the specified
39/// MachineRegisterInfo. If it is null, then the next/prev fields should be
40/// explicitly nulled out.
41void MachineOperand::AddRegOperandToRegInfo(MachineRegisterInfo *RegInfo) {
Dan Gohmand735b802008-10-03 15:45:36 +000042 assert(isReg() && "Can only add reg operand to use lists");
Chris Lattner62ed6b92008-01-01 01:12:31 +000043
44 // If the reginfo pointer is null, just explicitly null out or next/prev
45 // pointers, to ensure they are not garbage.
46 if (RegInfo == 0) {
47 Contents.Reg.Prev = 0;
48 Contents.Reg.Next = 0;
49 return;
50 }
51
52 // Otherwise, add this operand to the head of the registers use/def list.
Chris Lattner80fe5312008-01-01 21:08:22 +000053 MachineOperand **Head = &RegInfo->getRegUseDefListHead(getReg());
Chris Lattner62ed6b92008-01-01 01:12:31 +000054
Chris Lattner80fe5312008-01-01 21:08:22 +000055 // For SSA values, we prefer to keep the definition at the start of the list.
56 // we do this by skipping over the definition if it is at the head of the
57 // list.
58 if (*Head && (*Head)->isDef())
59 Head = &(*Head)->Contents.Reg.Next;
60
61 Contents.Reg.Next = *Head;
Chris Lattner62ed6b92008-01-01 01:12:31 +000062 if (Contents.Reg.Next) {
63 assert(getReg() == Contents.Reg.Next->getReg() &&
64 "Different regs on the same list!");
65 Contents.Reg.Next->Contents.Reg.Prev = &Contents.Reg.Next;
66 }
67
Chris Lattner80fe5312008-01-01 21:08:22 +000068 Contents.Reg.Prev = Head;
69 *Head = this;
Chris Lattner62ed6b92008-01-01 01:12:31 +000070}
71
Dan Gohman3bc1a372009-04-15 01:17:37 +000072/// RemoveRegOperandFromRegInfo - Remove this register operand from the
73/// MachineRegisterInfo it is linked with.
74void MachineOperand::RemoveRegOperandFromRegInfo() {
75 assert(isOnRegUseList() && "Reg operand is not on a use list");
76 // Unlink this from the doubly linked list of operands.
77 MachineOperand *NextOp = Contents.Reg.Next;
78 *Contents.Reg.Prev = NextOp;
79 if (NextOp) {
80 assert(NextOp->getReg() == getReg() && "Corrupt reg use/def chain!");
81 NextOp->Contents.Reg.Prev = Contents.Reg.Prev;
82 }
83 Contents.Reg.Prev = 0;
84 Contents.Reg.Next = 0;
85}
86
Chris Lattner62ed6b92008-01-01 01:12:31 +000087void MachineOperand::setReg(unsigned Reg) {
88 if (getReg() == Reg) return; // No change.
89
90 // Otherwise, we have to change the register. If this operand is embedded
91 // into a machine function, we need to update the old and new register's
92 // use/def lists.
93 if (MachineInstr *MI = getParent())
94 if (MachineBasicBlock *MBB = MI->getParent())
95 if (MachineFunction *MF = MBB->getParent()) {
96 RemoveRegOperandFromRegInfo();
97 Contents.Reg.RegNo = Reg;
98 AddRegOperandToRegInfo(&MF->getRegInfo());
99 return;
100 }
101
102 // Otherwise, just change the register, no problem. :)
103 Contents.Reg.RegNo = Reg;
104}
105
106/// ChangeToImmediate - Replace this operand with a new immediate operand of
107/// the specified value. If an operand is known to be an immediate already,
108/// the setImm method should be used.
109void MachineOperand::ChangeToImmediate(int64_t ImmVal) {
110 // If this operand is currently a register operand, and if this is in a
111 // function, deregister the operand from the register's use/def list.
Dan Gohmand735b802008-10-03 15:45:36 +0000112 if (isReg() && getParent() && getParent()->getParent() &&
Chris Lattner62ed6b92008-01-01 01:12:31 +0000113 getParent()->getParent()->getParent())
114 RemoveRegOperandFromRegInfo();
115
116 OpKind = MO_Immediate;
117 Contents.ImmVal = ImmVal;
118}
119
120/// ChangeToRegister - Replace this operand with a new register operand of
121/// the specified value. If an operand is known to be an register already,
122/// the setReg method should be used.
123void MachineOperand::ChangeToRegister(unsigned Reg, bool isDef, bool isImp,
Evan Cheng4784f1f2009-06-30 08:49:04 +0000124 bool isKill, bool isDead, bool isUndef) {
Chris Lattner62ed6b92008-01-01 01:12:31 +0000125 // If this operand is already a register operand, use setReg to update the
126 // register's use/def lists.
Dan Gohmand735b802008-10-03 15:45:36 +0000127 if (isReg()) {
Dale Johannesene0091802008-09-14 01:44:36 +0000128 assert(!isEarlyClobber());
Chris Lattner62ed6b92008-01-01 01:12:31 +0000129 setReg(Reg);
130 } else {
131 // Otherwise, change this to a register and set the reg#.
132 OpKind = MO_Register;
133 Contents.Reg.RegNo = Reg;
134
135 // If this operand is embedded in a function, add the operand to the
136 // register's use/def list.
137 if (MachineInstr *MI = getParent())
138 if (MachineBasicBlock *MBB = MI->getParent())
139 if (MachineFunction *MF = MBB->getParent())
140 AddRegOperandToRegInfo(&MF->getRegInfo());
141 }
142
143 IsDef = isDef;
144 IsImp = isImp;
145 IsKill = isKill;
146 IsDead = isDead;
Evan Cheng4784f1f2009-06-30 08:49:04 +0000147 IsUndef = isUndef;
Dale Johannesene0091802008-09-14 01:44:36 +0000148 IsEarlyClobber = false;
Chris Lattner62ed6b92008-01-01 01:12:31 +0000149 SubReg = 0;
150}
151
Chris Lattnerf7382302007-12-30 21:56:09 +0000152/// isIdenticalTo - Return true if this operand is identical to the specified
153/// operand.
154bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
Chris Lattner31530612009-06-24 17:54:48 +0000155 if (getType() != Other.getType() ||
156 getTargetFlags() != Other.getTargetFlags())
157 return false;
Chris Lattnerf7382302007-12-30 21:56:09 +0000158
159 switch (getType()) {
Torok Edwinc23197a2009-07-14 16:55:14 +0000160 default: llvm_unreachable("Unrecognized operand type");
Chris Lattnerf7382302007-12-30 21:56:09 +0000161 case MachineOperand::MO_Register:
162 return getReg() == Other.getReg() && isDef() == Other.isDef() &&
163 getSubReg() == Other.getSubReg();
164 case MachineOperand::MO_Immediate:
165 return getImm() == Other.getImm();
Nate Begemane8b7ccf2008-02-14 07:39:30 +0000166 case MachineOperand::MO_FPImmediate:
167 return getFPImm() == Other.getFPImm();
Chris Lattnerf7382302007-12-30 21:56:09 +0000168 case MachineOperand::MO_MachineBasicBlock:
169 return getMBB() == Other.getMBB();
170 case MachineOperand::MO_FrameIndex:
Chris Lattner8aa797a2007-12-30 23:10:15 +0000171 return getIndex() == Other.getIndex();
Chris Lattnerf7382302007-12-30 21:56:09 +0000172 case MachineOperand::MO_ConstantPoolIndex:
Chris Lattner8aa797a2007-12-30 23:10:15 +0000173 return getIndex() == Other.getIndex() && getOffset() == Other.getOffset();
Chris Lattnerf7382302007-12-30 21:56:09 +0000174 case MachineOperand::MO_JumpTableIndex:
Chris Lattner8aa797a2007-12-30 23:10:15 +0000175 return getIndex() == Other.getIndex();
Chris Lattnerf7382302007-12-30 21:56:09 +0000176 case MachineOperand::MO_GlobalAddress:
177 return getGlobal() == Other.getGlobal() && getOffset() == Other.getOffset();
178 case MachineOperand::MO_ExternalSymbol:
179 return !strcmp(getSymbolName(), Other.getSymbolName()) &&
180 getOffset() == Other.getOffset();
181 }
182}
183
184/// print - Print the specified machine operand.
185///
Mon P Wang5ca6bd12008-10-10 01:43:55 +0000186void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
Chris Lattnerf7382302007-12-30 21:56:09 +0000187 switch (getType()) {
188 case MachineOperand::MO_Register:
Dan Gohman6f0d0242008-02-10 18:45:23 +0000189 if (getReg() == 0 || TargetRegisterInfo::isVirtualRegister(getReg())) {
Chris Lattnerf7382302007-12-30 21:56:09 +0000190 OS << "%reg" << getReg();
191 } else {
192 // If the instruction is embedded into a basic block, we can find the
Chris Lattner62ed6b92008-01-01 01:12:31 +0000193 // target info for the instruction.
Chris Lattnerf7382302007-12-30 21:56:09 +0000194 if (TM == 0)
195 if (const MachineInstr *MI = getParent())
196 if (const MachineBasicBlock *MBB = MI->getParent())
197 if (const MachineFunction *MF = MBB->getParent())
198 TM = &MF->getTarget();
199
200 if (TM)
Bill Wendlinge6d088a2008-02-26 21:47:57 +0000201 OS << "%" << TM->getRegisterInfo()->get(getReg()).Name;
Chris Lattnerf7382302007-12-30 21:56:09 +0000202 else
203 OS << "%mreg" << getReg();
204 }
Dan Gohman2ccc8392008-12-18 21:51:27 +0000205
Evan Cheng4784f1f2009-06-30 08:49:04 +0000206 if (getSubReg() != 0)
Chris Lattner31530612009-06-24 17:54:48 +0000207 OS << ':' << getSubReg();
Dan Gohman2ccc8392008-12-18 21:51:27 +0000208
Evan Cheng4784f1f2009-06-30 08:49:04 +0000209 if (isDef() || isKill() || isDead() || isImplicit() || isUndef() ||
210 isEarlyClobber()) {
Chris Lattner31530612009-06-24 17:54:48 +0000211 OS << '<';
Chris Lattnerf7382302007-12-30 21:56:09 +0000212 bool NeedComma = false;
213 if (isImplicit()) {
Chris Lattner31530612009-06-24 17:54:48 +0000214 if (NeedComma) OS << ',';
Chris Lattnerf7382302007-12-30 21:56:09 +0000215 OS << (isDef() ? "imp-def" : "imp-use");
216 NeedComma = true;
217 } else if (isDef()) {
Chris Lattner31530612009-06-24 17:54:48 +0000218 if (NeedComma) OS << ',';
Dale Johannesen913d3df2008-09-12 17:49:03 +0000219 if (isEarlyClobber())
220 OS << "earlyclobber,";
Chris Lattnerf7382302007-12-30 21:56:09 +0000221 OS << "def";
222 NeedComma = true;
223 }
Evan Cheng4784f1f2009-06-30 08:49:04 +0000224 if (isKill() || isDead() || isUndef()) {
Chris Lattner31530612009-06-24 17:54:48 +0000225 if (NeedComma) OS << ',';
Bill Wendling181eb732008-02-24 00:56:13 +0000226 if (isKill()) OS << "kill";
227 if (isDead()) OS << "dead";
Evan Cheng4784f1f2009-06-30 08:49:04 +0000228 if (isUndef()) {
229 if (isKill() || isDead())
230 OS << ',';
231 OS << "undef";
232 }
Chris Lattnerf7382302007-12-30 21:56:09 +0000233 }
Chris Lattner31530612009-06-24 17:54:48 +0000234 OS << '>';
Chris Lattnerf7382302007-12-30 21:56:09 +0000235 }
236 break;
237 case MachineOperand::MO_Immediate:
238 OS << getImm();
239 break;
Nate Begemane8b7ccf2008-02-14 07:39:30 +0000240 case MachineOperand::MO_FPImmediate:
Owen Anderson1d0be152009-08-13 21:58:54 +0000241 if (getFPImm()->getType() == Type::getFloatTy(getFPImm()->getContext()))
Nate Begemane8b7ccf2008-02-14 07:39:30 +0000242 OS << getFPImm()->getValueAPF().convertToFloat();
Chris Lattner31530612009-06-24 17:54:48 +0000243 else
Nate Begemane8b7ccf2008-02-14 07:39:30 +0000244 OS << getFPImm()->getValueAPF().convertToDouble();
Nate Begemane8b7ccf2008-02-14 07:39:30 +0000245 break;
Chris Lattnerf7382302007-12-30 21:56:09 +0000246 case MachineOperand::MO_MachineBasicBlock:
247 OS << "mbb<"
Chris Lattner8aa797a2007-12-30 23:10:15 +0000248 << ((Value*)getMBB()->getBasicBlock())->getName()
Chris Lattner31530612009-06-24 17:54:48 +0000249 << "," << (void*)getMBB() << '>';
Chris Lattnerf7382302007-12-30 21:56:09 +0000250 break;
251 case MachineOperand::MO_FrameIndex:
Chris Lattner31530612009-06-24 17:54:48 +0000252 OS << "<fi#" << getIndex() << '>';
Chris Lattnerf7382302007-12-30 21:56:09 +0000253 break;
254 case MachineOperand::MO_ConstantPoolIndex:
Chris Lattner8aa797a2007-12-30 23:10:15 +0000255 OS << "<cp#" << getIndex();
Chris Lattnerf7382302007-12-30 21:56:09 +0000256 if (getOffset()) OS << "+" << getOffset();
Chris Lattner31530612009-06-24 17:54:48 +0000257 OS << '>';
Chris Lattnerf7382302007-12-30 21:56:09 +0000258 break;
259 case MachineOperand::MO_JumpTableIndex:
Chris Lattner31530612009-06-24 17:54:48 +0000260 OS << "<jt#" << getIndex() << '>';
Chris Lattnerf7382302007-12-30 21:56:09 +0000261 break;
262 case MachineOperand::MO_GlobalAddress:
263 OS << "<ga:" << ((Value*)getGlobal())->getName();
264 if (getOffset()) OS << "+" << getOffset();
Chris Lattner31530612009-06-24 17:54:48 +0000265 OS << '>';
Chris Lattnerf7382302007-12-30 21:56:09 +0000266 break;
267 case MachineOperand::MO_ExternalSymbol:
268 OS << "<es:" << getSymbolName();
269 if (getOffset()) OS << "+" << getOffset();
Chris Lattner31530612009-06-24 17:54:48 +0000270 OS << '>';
Chris Lattnerf7382302007-12-30 21:56:09 +0000271 break;
272 default:
Torok Edwinc23197a2009-07-14 16:55:14 +0000273 llvm_unreachable("Unrecognized operand type");
Chris Lattnerf7382302007-12-30 21:56:09 +0000274 }
Chris Lattner31530612009-06-24 17:54:48 +0000275
276 if (unsigned TF = getTargetFlags())
277 OS << "[TF=" << TF << ']';
Chris Lattnerf7382302007-12-30 21:56:09 +0000278}
279
280//===----------------------------------------------------------------------===//
Dan Gohmance42e402008-07-07 20:32:02 +0000281// MachineMemOperand Implementation
282//===----------------------------------------------------------------------===//
283
284MachineMemOperand::MachineMemOperand(const Value *v, unsigned int f,
285 int64_t o, uint64_t s, unsigned int a)
286 : Offset(o), Size(s), V(v),
287 Flags((f & 7) | ((Log2_32(a) + 1) << 3)) {
Dan Gohman28f02fd2009-09-21 19:47:04 +0000288 assert(getBaseAlignment() == a && "Alignment is not a power of 2!");
Dan Gohmanc5e1f982008-07-16 15:56:42 +0000289 assert((isLoad() || isStore()) && "Not a load/store!");
Dan Gohmance42e402008-07-07 20:32:02 +0000290}
291
Dan Gohmanb8d2f552008-08-20 15:58:01 +0000292/// Profile - Gather unique data for the object.
293///
294void MachineMemOperand::Profile(FoldingSetNodeID &ID) const {
295 ID.AddInteger(Offset);
296 ID.AddInteger(Size);
297 ID.AddPointer(V);
298 ID.AddInteger(Flags);
299}
300
Dan Gohmancd26ec52009-09-23 01:33:16 +0000301raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineMemOperand &MRO) {
302 assert((MRO.isLoad() || MRO.isStore()) &&
303 "SV has to be a load, store or both.");
304
305 if (MRO.isVolatile())
306 OS << "Volatile ";
307
308 if (MRO.isLoad())
309 OS << "LD";
310 if (MRO.isStore())
311 OS << "ST";
312 OS << MRO.getSize();
313
314 // Print the address information.
315 OS << "[";
316 if (!MRO.getValue())
317 OS << "<unknown>";
318 else
319 WriteAsOperand(OS, MRO.getValue(), /*PrintType=*/false);
320
321 // If the alignment of the memory reference itself differs from the alignment
322 // of the base pointer, print the base alignment explicitly, next to the base
323 // pointer.
324 if (MRO.getBaseAlignment() != MRO.getAlignment())
325 OS << "(align=" << MRO.getBaseAlignment() << ")";
326
327 if (MRO.getOffset() != 0)
328 OS << "+" << MRO.getOffset();
329 OS << "]";
330
331 // Print the alignment of the reference.
332 if (MRO.getBaseAlignment() != MRO.getAlignment() ||
333 MRO.getBaseAlignment() != MRO.getSize())
334 OS << "(align=" << MRO.getAlignment() << ")";
335
336 return OS;
337}
338
Dan Gohmance42e402008-07-07 20:32:02 +0000339//===----------------------------------------------------------------------===//
Chris Lattnerf7382302007-12-30 21:56:09 +0000340// MachineInstr Implementation
341//===----------------------------------------------------------------------===//
342
Evan Chengc0f64ff2006-11-27 23:37:22 +0000343/// MachineInstr ctor - This constructor creates a dummy MachineInstr with
Evan Cheng67f660c2006-11-30 07:08:44 +0000344/// TID NULL and no operands.
Evan Chengc0f64ff2006-11-27 23:37:22 +0000345MachineInstr::MachineInstr()
Dale Johannesen06efc022009-01-27 23:20:29 +0000346 : TID(0), NumImplicitOps(0), Parent(0), debugLoc(DebugLoc::getUnknownLoc()) {
Dan Gohman2c3f7ae2008-07-17 23:49:46 +0000347 // Make sure that we get added to a machine basicblock
348 LeakDetector::addGarbageObject(this);
Chris Lattner72791222002-10-28 20:59:49 +0000349}
350
Evan Cheng67f660c2006-11-30 07:08:44 +0000351void MachineInstr::addImplicitDefUseOperands() {
352 if (TID->ImplicitDefs)
Chris Lattnera4161ee2007-12-30 00:12:25 +0000353 for (const unsigned *ImpDefs = TID->ImplicitDefs; *ImpDefs; ++ImpDefs)
Chris Lattner8019f412007-12-30 00:41:17 +0000354 addOperand(MachineOperand::CreateReg(*ImpDefs, true, true));
Evan Cheng67f660c2006-11-30 07:08:44 +0000355 if (TID->ImplicitUses)
Chris Lattnera4161ee2007-12-30 00:12:25 +0000356 for (const unsigned *ImpUses = TID->ImplicitUses; *ImpUses; ++ImpUses)
Chris Lattner8019f412007-12-30 00:41:17 +0000357 addOperand(MachineOperand::CreateReg(*ImpUses, false, true));
Evan Chengd7de4962006-11-13 23:34:06 +0000358}
359
360/// MachineInstr ctor - This constructor create a MachineInstr and add the
Evan Chengc0f64ff2006-11-27 23:37:22 +0000361/// implicit operands. It reserves space for number of operands specified by
Chris Lattner749c6f62008-01-07 07:27:27 +0000362/// TargetInstrDesc or the numOperands if it is not zero. (for
Evan Chengc0f64ff2006-11-27 23:37:22 +0000363/// instructions with variable number of operands).
Chris Lattner749c6f62008-01-07 07:27:27 +0000364MachineInstr::MachineInstr(const TargetInstrDesc &tid, bool NoImp)
Dale Johannesen06efc022009-01-27 23:20:29 +0000365 : TID(&tid), NumImplicitOps(0), Parent(0),
366 debugLoc(DebugLoc::getUnknownLoc()) {
Chris Lattner349c4952008-01-07 03:13:06 +0000367 if (!NoImp && TID->getImplicitDefs())
368 for (const unsigned *ImpDefs = TID->getImplicitDefs(); *ImpDefs; ++ImpDefs)
Evan Chengd7de4962006-11-13 23:34:06 +0000369 NumImplicitOps++;
Chris Lattner349c4952008-01-07 03:13:06 +0000370 if (!NoImp && TID->getImplicitUses())
371 for (const unsigned *ImpUses = TID->getImplicitUses(); *ImpUses; ++ImpUses)
Evan Chengd7de4962006-11-13 23:34:06 +0000372 NumImplicitOps++;
Chris Lattner349c4952008-01-07 03:13:06 +0000373 Operands.reserve(NumImplicitOps + TID->getNumOperands());
Evan Chengfa945722007-10-13 02:23:01 +0000374 if (!NoImp)
375 addImplicitDefUseOperands();
Dan Gohman2c3f7ae2008-07-17 23:49:46 +0000376 // Make sure that we get added to a machine basicblock
377 LeakDetector::addGarbageObject(this);
Evan Chengd7de4962006-11-13 23:34:06 +0000378}
379
Dale Johannesen06efc022009-01-27 23:20:29 +0000380/// MachineInstr ctor - As above, but with a DebugLoc.
381MachineInstr::MachineInstr(const TargetInstrDesc &tid, const DebugLoc dl,
382 bool NoImp)
383 : TID(&tid), NumImplicitOps(0), Parent(0), debugLoc(dl) {
384 if (!NoImp && TID->getImplicitDefs())
385 for (const unsigned *ImpDefs = TID->getImplicitDefs(); *ImpDefs; ++ImpDefs)
386 NumImplicitOps++;
387 if (!NoImp && TID->getImplicitUses())
388 for (const unsigned *ImpUses = TID->getImplicitUses(); *ImpUses; ++ImpUses)
389 NumImplicitOps++;
390 Operands.reserve(NumImplicitOps + TID->getNumOperands());
391 if (!NoImp)
392 addImplicitDefUseOperands();
393 // Make sure that we get added to a machine basicblock
394 LeakDetector::addGarbageObject(this);
395}
396
397/// MachineInstr ctor - Work exactly the same as the ctor two above, except
398/// that the MachineInstr is created and added to the end of the specified
399/// basic block.
Chris Lattnerddd7fcb2002-10-29 23:19:00 +0000400///
Dale Johannesen06efc022009-01-27 23:20:29 +0000401MachineInstr::MachineInstr(MachineBasicBlock *MBB, const TargetInstrDesc &tid)
402 : TID(&tid), NumImplicitOps(0), Parent(0),
403 debugLoc(DebugLoc::getUnknownLoc()) {
404 assert(MBB && "Cannot use inserting ctor with null basic block!");
405 if (TID->ImplicitDefs)
406 for (const unsigned *ImpDefs = TID->getImplicitDefs(); *ImpDefs; ++ImpDefs)
407 NumImplicitOps++;
408 if (TID->ImplicitUses)
409 for (const unsigned *ImpUses = TID->getImplicitUses(); *ImpUses; ++ImpUses)
410 NumImplicitOps++;
411 Operands.reserve(NumImplicitOps + TID->getNumOperands());
412 addImplicitDefUseOperands();
413 // Make sure that we get added to a machine basicblock
414 LeakDetector::addGarbageObject(this);
415 MBB->push_back(this); // Add instruction to end of basic block!
416}
417
418/// MachineInstr ctor - As above, but with a DebugLoc.
419///
420MachineInstr::MachineInstr(MachineBasicBlock *MBB, const DebugLoc dl,
Chris Lattner749c6f62008-01-07 07:27:27 +0000421 const TargetInstrDesc &tid)
Dale Johannesen06efc022009-01-27 23:20:29 +0000422 : TID(&tid), NumImplicitOps(0), Parent(0), debugLoc(dl) {
Chris Lattnerddd7fcb2002-10-29 23:19:00 +0000423 assert(MBB && "Cannot use inserting ctor with null basic block!");
Evan Cheng67f660c2006-11-30 07:08:44 +0000424 if (TID->ImplicitDefs)
Chris Lattner349c4952008-01-07 03:13:06 +0000425 for (const unsigned *ImpDefs = TID->getImplicitDefs(); *ImpDefs; ++ImpDefs)
Evan Chengd7de4962006-11-13 23:34:06 +0000426 NumImplicitOps++;
Evan Cheng67f660c2006-11-30 07:08:44 +0000427 if (TID->ImplicitUses)
Chris Lattner349c4952008-01-07 03:13:06 +0000428 for (const unsigned *ImpUses = TID->getImplicitUses(); *ImpUses; ++ImpUses)
Evan Chengd7de4962006-11-13 23:34:06 +0000429 NumImplicitOps++;
Chris Lattner349c4952008-01-07 03:13:06 +0000430 Operands.reserve(NumImplicitOps + TID->getNumOperands());
Evan Cheng67f660c2006-11-30 07:08:44 +0000431 addImplicitDefUseOperands();
Dan Gohman2c3f7ae2008-07-17 23:49:46 +0000432 // Make sure that we get added to a machine basicblock
433 LeakDetector::addGarbageObject(this);
Chris Lattnerddd7fcb2002-10-29 23:19:00 +0000434 MBB->push_back(this); // Add instruction to end of basic block!
435}
436
Misha Brukmance22e762004-07-09 14:45:17 +0000437/// MachineInstr ctor - Copies MachineInstr arg exactly
438///
Evan Cheng1ed99222008-07-19 00:37:25 +0000439MachineInstr::MachineInstr(MachineFunction &MF, const MachineInstr &MI)
Dale Johannesen06efc022009-01-27 23:20:29 +0000440 : TID(&MI.getDesc()), NumImplicitOps(0), Parent(0),
441 debugLoc(MI.getDebugLoc()) {
Chris Lattner943b5e12006-05-04 19:14:44 +0000442 Operands.reserve(MI.getNumOperands());
Tanya Lattnerb5159ed2004-05-23 20:58:02 +0000443
Misha Brukmance22e762004-07-09 14:45:17 +0000444 // Add operands
Evan Cheng1ed99222008-07-19 00:37:25 +0000445 for (unsigned i = 0; i != MI.getNumOperands(); ++i)
446 addOperand(MI.getOperand(i));
447 NumImplicitOps = MI.NumImplicitOps;
Tanya Lattner0c63e032004-05-24 03:14:18 +0000448
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000449 // Add memory operands.
Dan Gohmanfed90b62008-07-28 21:51:04 +0000450 for (std::list<MachineMemOperand>::const_iterator i = MI.memoperands_begin(),
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000451 j = MI.memoperands_end(); i != j; ++i)
452 addMemOperand(MF, *i);
453
454 // Set parent to null.
Chris Lattnerf20c1a42007-12-31 04:56:33 +0000455 Parent = 0;
Dan Gohman6116a732008-07-21 18:47:29 +0000456
457 LeakDetector::addGarbageObject(this);
Tanya Lattner466b5342004-05-23 19:35:12 +0000458}
459
Misha Brukmance22e762004-07-09 14:45:17 +0000460MachineInstr::~MachineInstr() {
Dan Gohman2c3f7ae2008-07-17 23:49:46 +0000461 LeakDetector::removeGarbageObject(this);
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000462 assert(MemOperands.empty() &&
463 "MachineInstr being deleted with live memoperands!");
Chris Lattnere12d6ab2007-12-30 06:11:04 +0000464#ifndef NDEBUG
Chris Lattner62ed6b92008-01-01 01:12:31 +0000465 for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
Chris Lattnere12d6ab2007-12-30 06:11:04 +0000466 assert(Operands[i].ParentMI == this && "ParentMI mismatch!");
Dan Gohmand735b802008-10-03 15:45:36 +0000467 assert((!Operands[i].isReg() || !Operands[i].isOnRegUseList()) &&
Chris Lattner62ed6b92008-01-01 01:12:31 +0000468 "Reg operand def/use list corrupted");
469 }
Chris Lattnere12d6ab2007-12-30 06:11:04 +0000470#endif
Alkis Evlogimenosaad5c052004-02-16 07:17:43 +0000471}
472
Chris Lattner62ed6b92008-01-01 01:12:31 +0000473/// getRegInfo - If this instruction is embedded into a MachineFunction,
474/// return the MachineRegisterInfo object for the current function, otherwise
475/// return null.
476MachineRegisterInfo *MachineInstr::getRegInfo() {
477 if (MachineBasicBlock *MBB = getParent())
Dan Gohman4e526b92008-07-08 23:59:09 +0000478 return &MBB->getParent()->getRegInfo();
Chris Lattner62ed6b92008-01-01 01:12:31 +0000479 return 0;
480}
481
482/// RemoveRegOperandsFromUseLists - Unlink all of the register operands in
483/// this instruction from their respective use lists. This requires that the
484/// operands already be on their use lists.
485void MachineInstr::RemoveRegOperandsFromUseLists() {
486 for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
Dan Gohmand735b802008-10-03 15:45:36 +0000487 if (Operands[i].isReg())
Chris Lattner62ed6b92008-01-01 01:12:31 +0000488 Operands[i].RemoveRegOperandFromRegInfo();
489 }
490}
491
492/// AddRegOperandsToUseLists - Add all of the register operands in
493/// this instruction from their respective use lists. This requires that the
494/// operands not be on their use lists yet.
495void MachineInstr::AddRegOperandsToUseLists(MachineRegisterInfo &RegInfo) {
496 for (unsigned i = 0, e = Operands.size(); i != e; ++i) {
Dan Gohmand735b802008-10-03 15:45:36 +0000497 if (Operands[i].isReg())
Chris Lattner62ed6b92008-01-01 01:12:31 +0000498 Operands[i].AddRegOperandToRegInfo(&RegInfo);
499 }
500}
501
502
503/// addOperand - Add the specified operand to the instruction. If it is an
504/// implicit operand, it is added to the end of the operand list. If it is
505/// an explicit operand it is added at the end of the explicit operand list
506/// (before the first implicit operand).
507void MachineInstr::addOperand(const MachineOperand &Op) {
Dan Gohmand735b802008-10-03 15:45:36 +0000508 bool isImpReg = Op.isReg() && Op.isImplicit();
Chris Lattner62ed6b92008-01-01 01:12:31 +0000509 assert((isImpReg || !OperandsComplete()) &&
510 "Trying to add an operand to a machine instr that is already done!");
511
Dan Gohmanbcf28c02008-12-09 22:45:08 +0000512 MachineRegisterInfo *RegInfo = getRegInfo();
513
Chris Lattner62ed6b92008-01-01 01:12:31 +0000514 // If we are adding the operand to the end of the list, our job is simpler.
515 // This is true most of the time, so this is a reasonable optimization.
516 if (isImpReg || NumImplicitOps == 0) {
517 // We can only do this optimization if we know that the operand list won't
518 // reallocate.
519 if (Operands.empty() || Operands.size()+1 <= Operands.capacity()) {
520 Operands.push_back(Op);
521
522 // Set the parent of the operand.
523 Operands.back().ParentMI = this;
524
525 // If the operand is a register, update the operand's use list.
Dan Gohmand735b802008-10-03 15:45:36 +0000526 if (Op.isReg())
Dan Gohmanbcf28c02008-12-09 22:45:08 +0000527 Operands.back().AddRegOperandToRegInfo(RegInfo);
Chris Lattner62ed6b92008-01-01 01:12:31 +0000528 return;
529 }
530 }
531
532 // Otherwise, we have to insert a real operand before any implicit ones.
533 unsigned OpNo = Operands.size()-NumImplicitOps;
534
Chris Lattner62ed6b92008-01-01 01:12:31 +0000535 // If this instruction isn't embedded into a function, then we don't need to
536 // update any operand lists.
537 if (RegInfo == 0) {
538 // Simple insertion, no reginfo update needed for other register operands.
539 Operands.insert(Operands.begin()+OpNo, Op);
540 Operands[OpNo].ParentMI = this;
541
542 // Do explicitly set the reginfo for this operand though, to ensure the
543 // next/prev fields are properly nulled out.
Dan Gohmand735b802008-10-03 15:45:36 +0000544 if (Operands[OpNo].isReg())
Chris Lattner62ed6b92008-01-01 01:12:31 +0000545 Operands[OpNo].AddRegOperandToRegInfo(0);
546
547 } else if (Operands.size()+1 <= Operands.capacity()) {
548 // Otherwise, we have to remove register operands from their register use
549 // list, add the operand, then add the register operands back to their use
550 // list. This also must handle the case when the operand list reallocates
551 // to somewhere else.
552
553 // If insertion of this operand won't cause reallocation of the operand
554 // list, just remove the implicit operands, add the operand, then re-add all
555 // the rest of the operands.
556 for (unsigned i = OpNo, e = Operands.size(); i != e; ++i) {
Dan Gohmand735b802008-10-03 15:45:36 +0000557 assert(Operands[i].isReg() && "Should only be an implicit reg!");
Chris Lattner62ed6b92008-01-01 01:12:31 +0000558 Operands[i].RemoveRegOperandFromRegInfo();
559 }
560
561 // Add the operand. If it is a register, add it to the reg list.
562 Operands.insert(Operands.begin()+OpNo, Op);
563 Operands[OpNo].ParentMI = this;
564
Dan Gohmand735b802008-10-03 15:45:36 +0000565 if (Operands[OpNo].isReg())
Chris Lattner62ed6b92008-01-01 01:12:31 +0000566 Operands[OpNo].AddRegOperandToRegInfo(RegInfo);
567
568 // Re-add all the implicit ops.
569 for (unsigned i = OpNo+1, e = Operands.size(); i != e; ++i) {
Dan Gohmand735b802008-10-03 15:45:36 +0000570 assert(Operands[i].isReg() && "Should only be an implicit reg!");
Chris Lattner62ed6b92008-01-01 01:12:31 +0000571 Operands[i].AddRegOperandToRegInfo(RegInfo);
572 }
573 } else {
574 // Otherwise, we will be reallocating the operand list. Remove all reg
575 // operands from their list, then readd them after the operand list is
576 // reallocated.
577 RemoveRegOperandsFromUseLists();
578
579 Operands.insert(Operands.begin()+OpNo, Op);
580 Operands[OpNo].ParentMI = this;
581
582 // Re-add all the operands.
583 AddRegOperandsToUseLists(*RegInfo);
584 }
585}
586
587/// RemoveOperand - Erase an operand from an instruction, leaving it with one
588/// fewer operand than it started with.
589///
590void MachineInstr::RemoveOperand(unsigned OpNo) {
591 assert(OpNo < Operands.size() && "Invalid operand number");
592
593 // Special case removing the last one.
594 if (OpNo == Operands.size()-1) {
595 // If needed, remove from the reg def/use list.
Dan Gohmand735b802008-10-03 15:45:36 +0000596 if (Operands.back().isReg() && Operands.back().isOnRegUseList())
Chris Lattner62ed6b92008-01-01 01:12:31 +0000597 Operands.back().RemoveRegOperandFromRegInfo();
598
599 Operands.pop_back();
600 return;
601 }
602
603 // Otherwise, we are removing an interior operand. If we have reginfo to
604 // update, remove all operands that will be shifted down from their reg lists,
605 // move everything down, then re-add them.
606 MachineRegisterInfo *RegInfo = getRegInfo();
607 if (RegInfo) {
608 for (unsigned i = OpNo, e = Operands.size(); i != e; ++i) {
Dan Gohmand735b802008-10-03 15:45:36 +0000609 if (Operands[i].isReg())
Chris Lattner62ed6b92008-01-01 01:12:31 +0000610 Operands[i].RemoveRegOperandFromRegInfo();
611 }
612 }
613
614 Operands.erase(Operands.begin()+OpNo);
615
616 if (RegInfo) {
617 for (unsigned i = OpNo, e = Operands.size(); i != e; ++i) {
Dan Gohmand735b802008-10-03 15:45:36 +0000618 if (Operands[i].isReg())
Chris Lattner62ed6b92008-01-01 01:12:31 +0000619 Operands[i].AddRegOperandToRegInfo(RegInfo);
620 }
621 }
622}
623
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000624/// addMemOperand - Add a MachineMemOperand to the machine instruction,
625/// referencing arbitrary storage.
626void MachineInstr::addMemOperand(MachineFunction &MF,
627 const MachineMemOperand &MO) {
Dan Gohmanfed90b62008-07-28 21:51:04 +0000628 MemOperands.push_back(MO);
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000629}
630
631/// clearMemOperands - Erase all of this MachineInstr's MachineMemOperands.
632void MachineInstr::clearMemOperands(MachineFunction &MF) {
Dan Gohmanfed90b62008-07-28 21:51:04 +0000633 MemOperands.clear();
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000634}
635
Chris Lattner62ed6b92008-01-01 01:12:31 +0000636
Chris Lattner48d7c062006-04-17 21:35:41 +0000637/// removeFromParent - This method unlinks 'this' from the containing basic
638/// block, and returns it, but does not delete it.
639MachineInstr *MachineInstr::removeFromParent() {
640 assert(getParent() && "Not embedded in a basic block!");
641 getParent()->remove(this);
642 return this;
643}
644
645
Dan Gohman8e5f2c62008-07-07 23:14:23 +0000646/// eraseFromParent - This method unlinks 'this' from the containing basic
647/// block, and deletes it.
648void MachineInstr::eraseFromParent() {
649 assert(getParent() && "Not embedded in a basic block!");
650 getParent()->erase(this);
651}
652
653
Brian Gaeke21326fc2004-02-13 04:39:32 +0000654/// OperandComplete - Return true if it's illegal to add a new operand
655///
Chris Lattner2a90ba62004-02-12 16:09:53 +0000656bool MachineInstr::OperandsComplete() const {
Chris Lattner349c4952008-01-07 03:13:06 +0000657 unsigned short NumOperands = TID->getNumOperands();
Chris Lattner8f707e12008-01-07 05:19:29 +0000658 if (!TID->isVariadic() && getNumOperands()-NumImplicitOps >= NumOperands)
Vikram S. Adve34977822003-05-31 07:39:06 +0000659 return true; // Broken: we have all the operands of this instruction!
Chris Lattner413746e2002-10-28 20:48:39 +0000660 return false;
661}
662
Evan Cheng19e3f312007-05-15 01:26:09 +0000663/// getNumExplicitOperands - Returns the number of non-implicit operands.
664///
665unsigned MachineInstr::getNumExplicitOperands() const {
Chris Lattner349c4952008-01-07 03:13:06 +0000666 unsigned NumOperands = TID->getNumOperands();
Chris Lattner8f707e12008-01-07 05:19:29 +0000667 if (!TID->isVariadic())
Evan Cheng19e3f312007-05-15 01:26:09 +0000668 return NumOperands;
669
Dan Gohman9407cd42009-04-15 17:59:11 +0000670 for (unsigned i = NumOperands, e = getNumOperands(); i != e; ++i) {
671 const MachineOperand &MO = getOperand(i);
Dan Gohmand735b802008-10-03 15:45:36 +0000672 if (!MO.isReg() || !MO.isImplicit())
Evan Cheng19e3f312007-05-15 01:26:09 +0000673 NumOperands++;
674 }
675 return NumOperands;
676}
677
Chris Lattner8ace2cd2006-10-20 22:39:59 +0000678
Dan Gohman44066042008-07-01 00:05:16 +0000679/// isLabel - Returns true if the MachineInstr represents a label.
680///
681bool MachineInstr::isLabel() const {
682 return getOpcode() == TargetInstrInfo::DBG_LABEL ||
683 getOpcode() == TargetInstrInfo::EH_LABEL ||
684 getOpcode() == TargetInstrInfo::GC_LABEL;
685}
686
Evan Chengbb81d972008-01-31 09:59:15 +0000687/// isDebugLabel - Returns true if the MachineInstr represents a debug label.
688///
689bool MachineInstr::isDebugLabel() const {
Dan Gohman44066042008-07-01 00:05:16 +0000690 return getOpcode() == TargetInstrInfo::DBG_LABEL;
Evan Chengbb81d972008-01-31 09:59:15 +0000691}
692
Evan Chengfaa51072007-04-26 19:00:32 +0000693/// findRegisterUseOperandIdx() - Returns the MachineOperand that is a use of
Jim Grosbachf9ca50e2009-09-17 17:57:26 +0000694/// the specific register or -1 if it is not found. It further tightens
Evan Cheng76d7e762007-02-23 01:04:26 +0000695/// the search criteria to a use that kills the register if isKill is true.
Evan Cheng6130f662008-03-05 00:59:57 +0000696int MachineInstr::findRegisterUseOperandIdx(unsigned Reg, bool isKill,
697 const TargetRegisterInfo *TRI) const {
Evan Cheng576d1232006-12-06 08:27:42 +0000698 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
Evan Chengf277ee42007-05-29 18:35:22 +0000699 const MachineOperand &MO = getOperand(i);
Dan Gohmand735b802008-10-03 15:45:36 +0000700 if (!MO.isReg() || !MO.isUse())
Evan Cheng6130f662008-03-05 00:59:57 +0000701 continue;
702 unsigned MOReg = MO.getReg();
703 if (!MOReg)
704 continue;
705 if (MOReg == Reg ||
706 (TRI &&
707 TargetRegisterInfo::isPhysicalRegister(MOReg) &&
708 TargetRegisterInfo::isPhysicalRegister(Reg) &&
709 TRI->isSubRegister(MOReg, Reg)))
Evan Cheng76d7e762007-02-23 01:04:26 +0000710 if (!isKill || MO.isKill())
Evan Cheng32eb1f12007-03-26 22:37:45 +0000711 return i;
Evan Cheng576d1232006-12-06 08:27:42 +0000712 }
Evan Cheng32eb1f12007-03-26 22:37:45 +0000713 return -1;
Evan Cheng576d1232006-12-06 08:27:42 +0000714}
715
Evan Cheng6130f662008-03-05 00:59:57 +0000716/// findRegisterDefOperandIdx() - Returns the operand index that is a def of
Dan Gohman703bfe62008-05-06 00:20:10 +0000717/// the specified register or -1 if it is not found. If isDead is true, defs
718/// that are not dead are skipped. If TargetRegisterInfo is non-null, then it
719/// also checks if there is a def of a super-register.
Evan Cheng6130f662008-03-05 00:59:57 +0000720int MachineInstr::findRegisterDefOperandIdx(unsigned Reg, bool isDead,
721 const TargetRegisterInfo *TRI) const {
Evan Chengb371f452007-02-19 21:49:54 +0000722 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
Evan Cheng6130f662008-03-05 00:59:57 +0000723 const MachineOperand &MO = getOperand(i);
Dan Gohmand735b802008-10-03 15:45:36 +0000724 if (!MO.isReg() || !MO.isDef())
Evan Cheng6130f662008-03-05 00:59:57 +0000725 continue;
726 unsigned MOReg = MO.getReg();
727 if (MOReg == Reg ||
728 (TRI &&
729 TargetRegisterInfo::isPhysicalRegister(MOReg) &&
730 TargetRegisterInfo::isPhysicalRegister(Reg) &&
731 TRI->isSubRegister(MOReg, Reg)))
732 if (!isDead || MO.isDead())
733 return i;
Evan Chengb371f452007-02-19 21:49:54 +0000734 }
Evan Cheng6130f662008-03-05 00:59:57 +0000735 return -1;
Evan Chengb371f452007-02-19 21:49:54 +0000736}
Evan Cheng19e3f312007-05-15 01:26:09 +0000737
Evan Chengf277ee42007-05-29 18:35:22 +0000738/// findFirstPredOperandIdx() - Find the index of the first operand in the
739/// operand list that is used to represent the predicate. It returns -1 if
740/// none is found.
741int MachineInstr::findFirstPredOperandIdx() const {
Chris Lattner749c6f62008-01-07 07:27:27 +0000742 const TargetInstrDesc &TID = getDesc();
743 if (TID.isPredicable()) {
Evan Cheng19e3f312007-05-15 01:26:09 +0000744 for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
Chris Lattner749c6f62008-01-07 07:27:27 +0000745 if (TID.OpInfo[i].isPredicate())
Evan Chengf277ee42007-05-29 18:35:22 +0000746 return i;
Evan Cheng19e3f312007-05-15 01:26:09 +0000747 }
748
Evan Chengf277ee42007-05-29 18:35:22 +0000749 return -1;
Evan Cheng19e3f312007-05-15 01:26:09 +0000750}
Evan Chengb371f452007-02-19 21:49:54 +0000751
Bob Wilsond9df5012009-04-09 17:16:43 +0000752/// isRegTiedToUseOperand - Given the index of a register def operand,
753/// check if the register def is tied to a source operand, due to either
754/// two-address elimination or inline assembly constraints. Returns the
755/// first tied use operand index by reference is UseOpIdx is not null.
Jakob Stoklund Olesence9be2c2009-04-29 20:57:16 +0000756bool MachineInstr::
757isRegTiedToUseOperand(unsigned DefOpIdx, unsigned *UseOpIdx) const {
Evan Chengfb112882009-03-23 08:01:15 +0000758 if (getOpcode() == TargetInstrInfo::INLINEASM) {
Bob Wilsond9df5012009-04-09 17:16:43 +0000759 assert(DefOpIdx >= 2);
760 const MachineOperand &MO = getOperand(DefOpIdx);
Chris Lattnerc30aa7b2009-04-09 23:33:34 +0000761 if (!MO.isReg() || !MO.isDef() || MO.getReg() == 0)
Evan Chengfb112882009-03-23 08:01:15 +0000762 return false;
Evan Chengef5d0702009-06-24 02:05:51 +0000763 // Determine the actual operand index that corresponds to this index.
Evan Chengfb112882009-03-23 08:01:15 +0000764 unsigned DefNo = 0;
Evan Chengef5d0702009-06-24 02:05:51 +0000765 unsigned DefPart = 0;
Evan Chengfb112882009-03-23 08:01:15 +0000766 for (unsigned i = 1, e = getNumOperands(); i < e; ) {
767 const MachineOperand &FMO = getOperand(i);
Jakob Stoklund Olesen45d34fe2009-07-19 19:09:59 +0000768 // After the normal asm operands there may be additional imp-def regs.
769 if (!FMO.isImm())
770 return false;
Evan Chengfb112882009-03-23 08:01:15 +0000771 // Skip over this def.
Evan Chengef5d0702009-06-24 02:05:51 +0000772 unsigned NumOps = InlineAsm::getNumOperandRegisters(FMO.getImm());
773 unsigned PrevDef = i + 1;
774 i = PrevDef + NumOps;
775 if (i > DefOpIdx) {
776 DefPart = DefOpIdx - PrevDef;
Evan Chengfb112882009-03-23 08:01:15 +0000777 break;
Evan Chengef5d0702009-06-24 02:05:51 +0000778 }
Evan Chengfb112882009-03-23 08:01:15 +0000779 ++DefNo;
780 }
Evan Chengef5d0702009-06-24 02:05:51 +0000781 for (unsigned i = 1, e = getNumOperands(); i != e; ++i) {
Evan Chengfb112882009-03-23 08:01:15 +0000782 const MachineOperand &FMO = getOperand(i);
783 if (!FMO.isImm())
784 continue;
785 if (i+1 >= e || !getOperand(i+1).isReg() || !getOperand(i+1).isUse())
786 continue;
787 unsigned Idx;
Evan Chengef5d0702009-06-24 02:05:51 +0000788 if (InlineAsm::isUseOperandTiedToDef(FMO.getImm(), Idx) &&
Bob Wilsond9df5012009-04-09 17:16:43 +0000789 Idx == DefNo) {
790 if (UseOpIdx)
Evan Chengef5d0702009-06-24 02:05:51 +0000791 *UseOpIdx = (unsigned)i + 1 + DefPart;
Evan Chengfb112882009-03-23 08:01:15 +0000792 return true;
Bob Wilsond9df5012009-04-09 17:16:43 +0000793 }
Evan Chengfb112882009-03-23 08:01:15 +0000794 }
Evan Chengef5d0702009-06-24 02:05:51 +0000795 return false;
Evan Chengfb112882009-03-23 08:01:15 +0000796 }
797
Bob Wilsond9df5012009-04-09 17:16:43 +0000798 assert(getOperand(DefOpIdx).isDef() && "DefOpIdx is not a def!");
Chris Lattner749c6f62008-01-07 07:27:27 +0000799 const TargetInstrDesc &TID = getDesc();
Evan Chengef0732d2008-07-10 07:35:43 +0000800 for (unsigned i = 0, e = TID.getNumOperands(); i != e; ++i) {
801 const MachineOperand &MO = getOperand(i);
Dan Gohman2ce7f202008-12-05 05:45:42 +0000802 if (MO.isReg() && MO.isUse() &&
Bob Wilsond9df5012009-04-09 17:16:43 +0000803 TID.getOperandConstraint(i, TOI::TIED_TO) == (int)DefOpIdx) {
804 if (UseOpIdx)
805 *UseOpIdx = (unsigned)i;
Evan Chengef0732d2008-07-10 07:35:43 +0000806 return true;
Bob Wilsond9df5012009-04-09 17:16:43 +0000807 }
Evan Cheng32dfbea2007-10-12 08:50:34 +0000808 }
809 return false;
810}
811
Evan Chenga24752f2009-03-19 20:30:06 +0000812/// isRegTiedToDefOperand - Return true if the operand of the specified index
813/// is a register use and it is tied to an def operand. It also returns the def
814/// operand index by reference.
Jakob Stoklund Olesence9be2c2009-04-29 20:57:16 +0000815bool MachineInstr::
816isRegTiedToDefOperand(unsigned UseOpIdx, unsigned *DefOpIdx) const {
Evan Chengfb112882009-03-23 08:01:15 +0000817 if (getOpcode() == TargetInstrInfo::INLINEASM) {
818 const MachineOperand &MO = getOperand(UseOpIdx);
Chris Lattner0c8382c2009-04-09 16:50:43 +0000819 if (!MO.isReg() || !MO.isUse() || MO.getReg() == 0)
Evan Chengfb112882009-03-23 08:01:15 +0000820 return false;
Jakob Stoklund Olesen57e599a2009-07-16 20:58:34 +0000821
822 // Find the flag operand corresponding to UseOpIdx
823 unsigned FlagIdx, NumOps=0;
824 for (FlagIdx = 1; FlagIdx < UseOpIdx; FlagIdx += NumOps+1) {
825 const MachineOperand &UFMO = getOperand(FlagIdx);
Jakob Stoklund Olesen45d34fe2009-07-19 19:09:59 +0000826 // After the normal asm operands there may be additional imp-def regs.
827 if (!UFMO.isImm())
828 return false;
Jakob Stoklund Olesen57e599a2009-07-16 20:58:34 +0000829 NumOps = InlineAsm::getNumOperandRegisters(UFMO.getImm());
830 assert(NumOps < getNumOperands() && "Invalid inline asm flag");
831 if (UseOpIdx < FlagIdx+NumOps+1)
832 break;
Evan Chengef5d0702009-06-24 02:05:51 +0000833 }
Jakob Stoklund Olesen57e599a2009-07-16 20:58:34 +0000834 if (FlagIdx >= UseOpIdx)
Evan Chengef5d0702009-06-24 02:05:51 +0000835 return false;
Jakob Stoklund Olesen57e599a2009-07-16 20:58:34 +0000836 const MachineOperand &UFMO = getOperand(FlagIdx);
Evan Chengfb112882009-03-23 08:01:15 +0000837 unsigned DefNo;
838 if (InlineAsm::isUseOperandTiedToDef(UFMO.getImm(), DefNo)) {
839 if (!DefOpIdx)
840 return true;
841
842 unsigned DefIdx = 1;
843 // Remember to adjust the index. First operand is asm string, then there
844 // is a flag for each.
845 while (DefNo) {
846 const MachineOperand &FMO = getOperand(DefIdx);
847 assert(FMO.isImm());
848 // Skip over this def.
849 DefIdx += InlineAsm::getNumOperandRegisters(FMO.getImm()) + 1;
850 --DefNo;
851 }
Evan Chengef5d0702009-06-24 02:05:51 +0000852 *DefOpIdx = DefIdx + UseOpIdx - FlagIdx;
Evan Chengfb112882009-03-23 08:01:15 +0000853 return true;
854 }
855 return false;
856 }
857
Evan Chenga24752f2009-03-19 20:30:06 +0000858 const TargetInstrDesc &TID = getDesc();
859 if (UseOpIdx >= TID.getNumOperands())
860 return false;
861 const MachineOperand &MO = getOperand(UseOpIdx);
862 if (!MO.isReg() || !MO.isUse())
863 return false;
864 int DefIdx = TID.getOperandConstraint(UseOpIdx, TOI::TIED_TO);
865 if (DefIdx == -1)
866 return false;
867 if (DefOpIdx)
868 *DefOpIdx = (unsigned)DefIdx;
869 return true;
870}
871
Evan Cheng576d1232006-12-06 08:27:42 +0000872/// copyKillDeadInfo - Copies kill / dead operand properties from MI.
873///
874void MachineInstr::copyKillDeadInfo(const MachineInstr *MI) {
875 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
876 const MachineOperand &MO = MI->getOperand(i);
Dan Gohmand735b802008-10-03 15:45:36 +0000877 if (!MO.isReg() || (!MO.isKill() && !MO.isDead()))
Evan Cheng576d1232006-12-06 08:27:42 +0000878 continue;
879 for (unsigned j = 0, ee = getNumOperands(); j != ee; ++j) {
880 MachineOperand &MOp = getOperand(j);
881 if (!MOp.isIdenticalTo(MO))
882 continue;
883 if (MO.isKill())
884 MOp.setIsKill();
885 else
886 MOp.setIsDead();
887 break;
888 }
889 }
890}
891
Evan Cheng19e3f312007-05-15 01:26:09 +0000892/// copyPredicates - Copies predicate operand(s) from MI.
893void MachineInstr::copyPredicates(const MachineInstr *MI) {
Chris Lattner749c6f62008-01-07 07:27:27 +0000894 const TargetInstrDesc &TID = MI->getDesc();
Evan Chengb27087f2008-03-13 00:44:09 +0000895 if (!TID.isPredicable())
896 return;
897 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
898 if (TID.OpInfo[i].isPredicate()) {
899 // Predicated operands must be last operands.
900 addOperand(MI->getOperand(i));
Evan Cheng19e3f312007-05-15 01:26:09 +0000901 }
902 }
903}
904
Evan Cheng9f1c8312008-07-03 09:09:37 +0000905/// isSafeToMove - Return true if it is safe to move this instruction. If
906/// SawStore is set to true, it means that there is a store (or call) between
907/// the instruction's location and its intended destination.
Dan Gohmanb3b930a2008-11-18 19:04:29 +0000908bool MachineInstr::isSafeToMove(const TargetInstrInfo *TII,
909 bool &SawStore) const {
Evan Chengb27087f2008-03-13 00:44:09 +0000910 // Ignore stuff that we obviously can't move.
911 if (TID->mayStore() || TID->isCall()) {
912 SawStore = true;
913 return false;
914 }
Dan Gohman237dee12008-12-23 17:28:50 +0000915 if (TID->isTerminator() || TID->hasUnmodeledSideEffects())
Evan Chengb27087f2008-03-13 00:44:09 +0000916 return false;
917
918 // See if this instruction does a load. If so, we have to guarantee that the
919 // loaded value doesn't change between the load and the its intended
920 // destination. The check for isInvariantLoad gives the targe the chance to
921 // classify the load as always returning a constant, e.g. a constant pool
922 // load.
Dan Gohman3e4fb702008-09-24 00:06:15 +0000923 if (TID->mayLoad() && !TII->isInvariantLoad(this))
Evan Chengb27087f2008-03-13 00:44:09 +0000924 // Otherwise, this is a real load. If there is a store between the load and
Evan Cheng7cc2c402009-07-28 21:49:18 +0000925 // end of block, or if the load is volatile, we can't move it.
Dan Gohmand790a5c2008-10-02 15:04:30 +0000926 return !SawStore && !hasVolatileMemoryRef();
Dan Gohman3e4fb702008-09-24 00:06:15 +0000927
Evan Chengb27087f2008-03-13 00:44:09 +0000928 return true;
929}
930
Evan Chengdf3b9932008-08-27 20:33:50 +0000931/// isSafeToReMat - Return true if it's safe to rematerialize the specified
932/// instruction which defined the specified register instead of copying it.
Dan Gohmanb3b930a2008-11-18 19:04:29 +0000933bool MachineInstr::isSafeToReMat(const TargetInstrInfo *TII,
934 unsigned DstReg) const {
Evan Chengdf3b9932008-08-27 20:33:50 +0000935 bool SawStore = false;
Evan Cheng3689ff42008-08-30 09:07:18 +0000936 if (!getDesc().isRematerializable() ||
937 !TII->isTriviallyReMaterializable(this) ||
938 !isSafeToMove(TII, SawStore))
Evan Chengdf3b9932008-08-27 20:33:50 +0000939 return false;
940 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
Dan Gohmancbad42c2008-11-18 19:49:32 +0000941 const MachineOperand &MO = getOperand(i);
Dan Gohmand735b802008-10-03 15:45:36 +0000942 if (!MO.isReg())
Evan Chengdf3b9932008-08-27 20:33:50 +0000943 continue;
944 // FIXME: For now, do not remat any instruction with register operands.
945 // Later on, we can loosen the restriction is the register operands have
946 // not been modified between the def and use. Note, this is different from
Evan Cheng8763c1c2008-08-27 20:58:54 +0000947 // MachineSink because the code is no longer in two-address form (at least
Evan Chengdf3b9932008-08-27 20:33:50 +0000948 // partially).
949 if (MO.isUse())
950 return false;
951 else if (!MO.isDead() && MO.getReg() != DstReg)
952 return false;
953 }
954 return true;
955}
956
Dan Gohman3e4fb702008-09-24 00:06:15 +0000957/// hasVolatileMemoryRef - Return true if this instruction may have a
958/// volatile memory reference, or if the information describing the
959/// memory reference is not available. Return false if it is known to
960/// have no volatile memory references.
961bool MachineInstr::hasVolatileMemoryRef() const {
962 // An instruction known never to access memory won't have a volatile access.
963 if (!TID->mayStore() &&
964 !TID->mayLoad() &&
965 !TID->isCall() &&
966 !TID->hasUnmodeledSideEffects())
967 return false;
968
969 // Otherwise, if the instruction has no memory reference information,
970 // conservatively assume it wasn't preserved.
971 if (memoperands_empty())
972 return true;
973
974 // Check the memory reference information for volatile references.
975 for (std::list<MachineMemOperand>::const_iterator I = memoperands_begin(),
976 E = memoperands_end(); I != E; ++I)
977 if (I->isVolatile())
978 return true;
979
980 return false;
981}
982
Brian Gaeke21326fc2004-02-13 04:39:32 +0000983void MachineInstr::dump() const {
Chris Lattner705e07f2009-08-23 03:41:05 +0000984 errs() << " " << *this;
Mon P Wang5ca6bd12008-10-10 01:43:55 +0000985}
986
987void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
Chris Lattnere3087892007-12-30 21:31:53 +0000988 // Specialize printing if op#0 is definition
Chris Lattner6a592272002-10-30 01:55:38 +0000989 unsigned StartOp = 0;
Dan Gohmand735b802008-10-03 15:45:36 +0000990 if (getNumOperands() && getOperand(0).isReg() && getOperand(0).isDef()) {
Chris Lattnerf7382302007-12-30 21:56:09 +0000991 getOperand(0).print(OS, TM);
Chris Lattner6a592272002-10-30 01:55:38 +0000992 OS << " = ";
993 ++StartOp; // Don't print this operand again!
994 }
Tanya Lattnerb1407622004-06-25 00:13:11 +0000995
Chris Lattner749c6f62008-01-07 07:27:27 +0000996 OS << getDesc().getName();
Misha Brukmanedf128a2005-04-21 22:36:52 +0000997
Chris Lattner6a592272002-10-30 01:55:38 +0000998 for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
999 if (i != StartOp)
1000 OS << ",";
1001 OS << " ";
Chris Lattnerf7382302007-12-30 21:56:09 +00001002 getOperand(i).print(OS, TM);
Chris Lattner10491642002-10-30 00:48:05 +00001003 }
Misha Brukmanedf128a2005-04-21 22:36:52 +00001004
Dan Gohman8e5f2c62008-07-07 23:14:23 +00001005 if (!memoperands_empty()) {
Dan Gohman2bfe6ff2008-02-07 16:18:00 +00001006 OS << ", Mem:";
Dan Gohmanfed90b62008-07-28 21:51:04 +00001007 for (std::list<MachineMemOperand>::const_iterator i = memoperands_begin(),
Dan Gohman8e5f2c62008-07-07 23:14:23 +00001008 e = memoperands_end(); i != e; ++i) {
Dan Gohmancd26ec52009-09-23 01:33:16 +00001009 OS << *i;
1010 if (next(i) != e)
1011 OS << " ";
Dan Gohman69de1932008-02-06 22:27:42 +00001012 }
1013 }
1014
Bill Wendlingb5ef2732009-02-19 21:44:55 +00001015 if (!debugLoc.isUnknown()) {
1016 const MachineFunction *MF = getParent()->getParent();
1017 DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc);
Argyrios Kyrtzidisa26eae62009-04-30 23:22:31 +00001018 DICompileUnit CU(DLT.CompileUnit);
1019 std::string Dir, Fn;
Bill Wendlingb5ef2732009-02-19 21:44:55 +00001020 OS << " [dbg: "
Argyrios Kyrtzidisa26eae62009-04-30 23:22:31 +00001021 << CU.getDirectory(Dir) << '/' << CU.getFilename(Fn) << ","
Bill Wendlingb5ef2732009-02-19 21:44:55 +00001022 << DLT.Line << ","
1023 << DLT.Col << "]";
1024 }
1025
Chris Lattner10491642002-10-30 00:48:05 +00001026 OS << "\n";
1027}
1028
Owen Andersonb487e722008-01-24 01:10:07 +00001029bool MachineInstr::addRegisterKilled(unsigned IncomingReg,
Dan Gohman6f0d0242008-02-10 18:45:23 +00001030 const TargetRegisterInfo *RegInfo,
Owen Andersonb487e722008-01-24 01:10:07 +00001031 bool AddIfNotFound) {
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001032 bool isPhysReg = TargetRegisterInfo::isPhysicalRegister(IncomingReg);
Dan Gohman2ebc11a2008-07-03 01:18:51 +00001033 bool hasAliases = isPhysReg && RegInfo->getAliasSet(IncomingReg);
Dan Gohman3f629402008-09-03 15:56:16 +00001034 bool Found = false;
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001035 SmallVector<unsigned,4> DeadOps;
Bill Wendling4a23d722008-03-03 22:14:33 +00001036 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1037 MachineOperand &MO = getOperand(i);
Jakob Stoklund Olesenefb8e3e2009-08-04 20:09:25 +00001038 if (!MO.isReg() || !MO.isUse() || MO.isUndef())
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001039 continue;
1040 unsigned Reg = MO.getReg();
1041 if (!Reg)
1042 continue;
Bill Wendling4a23d722008-03-03 22:14:33 +00001043
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001044 if (Reg == IncomingReg) {
Dan Gohman3f629402008-09-03 15:56:16 +00001045 if (!Found) {
1046 if (MO.isKill())
1047 // The register is already marked kill.
1048 return true;
Jakob Stoklund Olesenece48182009-08-02 19:13:03 +00001049 if (isPhysReg && isRegTiedToDefOperand(i))
1050 // Two-address uses of physregs must not be marked kill.
1051 return true;
Dan Gohman3f629402008-09-03 15:56:16 +00001052 MO.setIsKill();
1053 Found = true;
1054 }
1055 } else if (hasAliases && MO.isKill() &&
1056 TargetRegisterInfo::isPhysicalRegister(Reg)) {
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001057 // A super-register kill already exists.
1058 if (RegInfo->isSuperRegister(IncomingReg, Reg))
Dan Gohman2ebc11a2008-07-03 01:18:51 +00001059 return true;
1060 if (RegInfo->isSubRegister(IncomingReg, Reg))
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001061 DeadOps.push_back(i);
Bill Wendling4a23d722008-03-03 22:14:33 +00001062 }
1063 }
1064
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001065 // Trim unneeded kill operands.
1066 while (!DeadOps.empty()) {
1067 unsigned OpIdx = DeadOps.back();
1068 if (getOperand(OpIdx).isImplicit())
1069 RemoveOperand(OpIdx);
1070 else
1071 getOperand(OpIdx).setIsKill(false);
1072 DeadOps.pop_back();
1073 }
1074
Bill Wendling4a23d722008-03-03 22:14:33 +00001075 // If not found, this means an alias of one of the operands is killed. Add a
Owen Andersonb487e722008-01-24 01:10:07 +00001076 // new implicit operand if required.
Dan Gohman3f629402008-09-03 15:56:16 +00001077 if (!Found && AddIfNotFound) {
Bill Wendling4a23d722008-03-03 22:14:33 +00001078 addOperand(MachineOperand::CreateReg(IncomingReg,
1079 false /*IsDef*/,
1080 true /*IsImp*/,
1081 true /*IsKill*/));
Owen Andersonb487e722008-01-24 01:10:07 +00001082 return true;
1083 }
Dan Gohman3f629402008-09-03 15:56:16 +00001084 return Found;
Owen Andersonb487e722008-01-24 01:10:07 +00001085}
1086
1087bool MachineInstr::addRegisterDead(unsigned IncomingReg,
Dan Gohman6f0d0242008-02-10 18:45:23 +00001088 const TargetRegisterInfo *RegInfo,
Owen Andersonb487e722008-01-24 01:10:07 +00001089 bool AddIfNotFound) {
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001090 bool isPhysReg = TargetRegisterInfo::isPhysicalRegister(IncomingReg);
Evan Cheng01b2e232008-06-27 22:11:49 +00001091 bool hasAliases = isPhysReg && RegInfo->getAliasSet(IncomingReg);
Dan Gohman3f629402008-09-03 15:56:16 +00001092 bool Found = false;
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001093 SmallVector<unsigned,4> DeadOps;
Owen Andersonb487e722008-01-24 01:10:07 +00001094 for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
1095 MachineOperand &MO = getOperand(i);
Dan Gohmand735b802008-10-03 15:45:36 +00001096 if (!MO.isReg() || !MO.isDef())
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001097 continue;
1098 unsigned Reg = MO.getReg();
Dan Gohman3f629402008-09-03 15:56:16 +00001099 if (!Reg)
1100 continue;
1101
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001102 if (Reg == IncomingReg) {
Dan Gohman3f629402008-09-03 15:56:16 +00001103 if (!Found) {
1104 if (MO.isDead())
1105 // The register is already marked dead.
1106 return true;
1107 MO.setIsDead();
1108 Found = true;
1109 }
1110 } else if (hasAliases && MO.isDead() &&
1111 TargetRegisterInfo::isPhysicalRegister(Reg)) {
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001112 // There exists a super-register that's marked dead.
1113 if (RegInfo->isSuperRegister(IncomingReg, Reg))
Dan Gohman2ebc11a2008-07-03 01:18:51 +00001114 return true;
Owen Anderson22ae9992008-08-14 18:34:18 +00001115 if (RegInfo->getSubRegisters(IncomingReg) &&
1116 RegInfo->getSuperRegisters(Reg) &&
1117 RegInfo->isSubRegister(IncomingReg, Reg))
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001118 DeadOps.push_back(i);
Owen Andersonb487e722008-01-24 01:10:07 +00001119 }
1120 }
1121
Evan Cheng9b6d7b92008-04-16 09:41:59 +00001122 // Trim unneeded dead operands.
1123 while (!DeadOps.empty()) {
1124 unsigned OpIdx = DeadOps.back();
1125 if (getOperand(OpIdx).isImplicit())
1126 RemoveOperand(OpIdx);
1127 else
1128 getOperand(OpIdx).setIsDead(false);
1129 DeadOps.pop_back();
1130 }
1131
Dan Gohman3f629402008-09-03 15:56:16 +00001132 // If not found, this means an alias of one of the operands is dead. Add a
1133 // new implicit operand if required.
Chris Lattner31530612009-06-24 17:54:48 +00001134 if (Found || !AddIfNotFound)
1135 return Found;
1136
1137 addOperand(MachineOperand::CreateReg(IncomingReg,
1138 true /*IsDef*/,
1139 true /*IsImp*/,
1140 false /*IsKill*/,
1141 true /*IsDead*/));
1142 return true;
Owen Andersonb487e722008-01-24 01:10:07 +00001143}