blob: 84081b4afcab9fc18dbccd1bae4ebacf5ec79630 [file] [log] [blame]
Anton Korobeynikov4403b932009-07-16 13:27:25 +00001//==-- SystemZISelDAGToDAG.cpp - A dag to dag inst selector for SystemZ ---===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines an instruction selector for the SystemZ target.
11//
12//===----------------------------------------------------------------------===//
13
14#include "SystemZ.h"
15#include "SystemZISelLowering.h"
16#include "SystemZTargetMachine.h"
17#include "llvm/DerivedTypes.h"
18#include "llvm/Function.h"
19#include "llvm/Intrinsics.h"
20#include "llvm/CallingConv.h"
21#include "llvm/Constants.h"
22#include "llvm/CodeGen/MachineFrameInfo.h"
23#include "llvm/CodeGen/MachineFunction.h"
24#include "llvm/CodeGen/MachineInstrBuilder.h"
25#include "llvm/CodeGen/MachineRegisterInfo.h"
26#include "llvm/CodeGen/SelectionDAG.h"
27#include "llvm/CodeGen/SelectionDAGISel.h"
28#include "llvm/Target/TargetLowering.h"
29#include "llvm/Support/Compiler.h"
30#include "llvm/Support/Debug.h"
31using namespace llvm;
32
Anton Korobeynikov3360da92009-07-16 13:44:00 +000033namespace {
34 /// SystemZRRIAddressMode - This corresponds to rriaddr, but uses SDValue's
35 /// instead of register numbers for the leaves of the matched tree.
36 struct SystemZRRIAddressMode {
37 enum {
38 RegBase,
39 FrameIndexBase
40 } BaseType;
41
42 struct { // This is really a union, discriminated by BaseType!
43 SDValue Reg;
44 int FrameIndex;
45 } Base;
46
47 SDValue IndexReg;
Anton Korobeynikov32407402009-07-16 13:48:23 +000048 int64_t Disp;
Anton Korobeynikov3360da92009-07-16 13:44:00 +000049
50 SystemZRRIAddressMode()
51 : BaseType(RegBase), IndexReg(), Disp(0) {
52 }
53
54 void dump() {
Anton Korobeynikov961bb6f2009-07-16 13:45:00 +000055 cerr << "SystemZRRIAddressMode " << this << '\n';
Anton Korobeynikov3360da92009-07-16 13:44:00 +000056 if (BaseType == RegBase) {
57 cerr << "Base.Reg ";
58 if (Base.Reg.getNode() != 0) Base.Reg.getNode()->dump();
59 else cerr << "nul";
Anton Korobeynikov961bb6f2009-07-16 13:45:00 +000060 cerr << '\n';
Anton Korobeynikov3360da92009-07-16 13:44:00 +000061 } else {
Anton Korobeynikov961bb6f2009-07-16 13:45:00 +000062 cerr << " Base.FrameIndex " << Base.FrameIndex << '\n';
Anton Korobeynikov3360da92009-07-16 13:44:00 +000063 }
64 cerr << "IndexReg ";
65 if (IndexReg.getNode() != 0) IndexReg.getNode()->dump();
66 else cerr << "nul";
Anton Korobeynikov961bb6f2009-07-16 13:45:00 +000067 cerr << " Disp " << Disp << '\n';
Anton Korobeynikov3360da92009-07-16 13:44:00 +000068 }
69 };
70}
71
Anton Korobeynikov4403b932009-07-16 13:27:25 +000072/// SystemZDAGToDAGISel - SystemZ specific code to select SystemZ machine
73/// instructions for SelectionDAG operations.
74///
75namespace {
76 class SystemZDAGToDAGISel : public SelectionDAGISel {
77 SystemZTargetLowering &Lowering;
78 const SystemZSubtarget &Subtarget;
79
80 public:
81 SystemZDAGToDAGISel(SystemZTargetMachine &TM, CodeGenOpt::Level OptLevel)
82 : SelectionDAGISel(TM, OptLevel),
83 Lowering(*TM.getTargetLowering()),
84 Subtarget(*TM.getSubtargetImpl()) { }
85
86 virtual void InstructionSelect();
87
88 virtual const char *getPassName() const {
89 return "SystemZ DAG->DAG Pattern Instruction Selection";
90 }
91
Anton Korobeynikov89edcd02009-07-16 13:33:57 +000092 /// getI16Imm - Return a target constant with the specified value, of type
93 /// i16.
94 inline SDValue getI16Imm(uint64_t Imm) {
95 return CurDAG->getTargetConstant(Imm, MVT::i16);
96 }
97
Anton Korobeynikovda308c92009-07-16 13:34:50 +000098 /// getI32Imm - Return a target constant with the specified value, of type
99 /// i32.
100 inline SDValue getI32Imm(uint64_t Imm) {
101 return CurDAG->getTargetConstant(Imm, MVT::i32);
102 }
103
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000104 // Include the pieces autogenerated from the target description.
Anton Korobeynikov89edcd02009-07-16 13:33:57 +0000105 #include "SystemZGenDAGISel.inc"
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000106
107 private:
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000108 bool SelectAddrRRI(SDValue Op, SDValue Addr,
109 SDValue &Base, SDValue &Index, SDValue &Disp);
Anton Korobeynikov711d5b62009-07-16 13:47:59 +0000110 bool SelectLAAddr(SDValue Op, SDValue Addr,
111 SDValue &Base, SDValue &Index, SDValue &Disp);
112
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000113 SDNode *Select(SDValue Op);
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000114 bool SelectAddrRI(const SDValue& Op, SDValue& Addr,
115 SDValue &Base, SDValue &Disp);
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000116 bool MatchAddress(SDValue N, SystemZRRIAddressMode &AM, unsigned Depth = 0);
117 bool MatchAddressBase(SDValue N, SystemZRRIAddressMode &AM);
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000118
119 #ifndef NDEBUG
120 unsigned Indent;
121 #endif
122 };
123} // end anonymous namespace
124
125/// createSystemZISelDag - This pass converts a legalized DAG into a
126/// SystemZ-specific DAG, ready for instruction scheduling.
127///
128FunctionPass *llvm::createSystemZISelDag(SystemZTargetMachine &TM,
129 CodeGenOpt::Level OptLevel) {
130 return new SystemZDAGToDAGISel(TM, OptLevel);
131}
132
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000133/// isImmSExt20 - This method tests to see if the node is either a 32-bit
134/// or 64-bit immediate, and if the value can be accurately represented as a
135/// sign extension from a 20-bit value. If so, this returns true and the
136/// immediate.
Anton Korobeynikov32407402009-07-16 13:48:23 +0000137static bool isImmSExt20(int64_t Val, int64_t &Imm) {
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000138 if (Val >= -524288 && Val <= 524287) {
Anton Korobeynikov32407402009-07-16 13:48:23 +0000139 Imm = Val;
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000140 return true;
141 }
142 return false;
143}
144
Anton Korobeynikov32407402009-07-16 13:48:23 +0000145static bool isImmSExt20(SDNode *N, int64_t &Imm) {
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000146 if (N->getOpcode() != ISD::Constant)
147 return false;
148
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000149 return isImmSExt20(cast<ConstantSDNode>(N)->getSExtValue(), Imm);
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000150}
151
Anton Korobeynikov32407402009-07-16 13:48:23 +0000152static bool isImmSExt20(SDValue Op, int64_t &Imm) {
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000153 return isImmSExt20(Op.getNode(), Imm);
154}
155
156/// Returns true if the address can be represented by a base register plus
157/// a signed 20-bit displacement [r+imm].
158bool SystemZDAGToDAGISel::SelectAddrRI(const SDValue& Op, SDValue& Addr,
159 SDValue &Base, SDValue &Disp) {
160 // FIXME dl should come from parent load or store, not from address
161 DebugLoc dl = Addr.getDebugLoc();
162 MVT VT = Addr.getValueType();
163
164 if (Addr.getOpcode() == ISD::ADD) {
Anton Korobeynikov32407402009-07-16 13:48:23 +0000165 int64_t Imm = 0;
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000166 if (isImmSExt20(Addr.getOperand(1), Imm)) {
Anton Korobeynikov32407402009-07-16 13:48:23 +0000167 Disp = CurDAG->getTargetConstant(Imm, MVT::i64);
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000168 if (FrameIndexSDNode *FI =
169 dyn_cast<FrameIndexSDNode>(Addr.getOperand(0))) {
170 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), VT);
171 } else {
172 Base = Addr.getOperand(0);
173 }
174 return true; // [r+i]
175 }
176 } else if (Addr.getOpcode() == ISD::OR) {
Anton Korobeynikov32407402009-07-16 13:48:23 +0000177 int64_t Imm = 0;
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000178 if (isImmSExt20(Addr.getOperand(1), Imm)) {
179 // If this is an or of disjoint bitfields, we can codegen this as an add
180 // (for better address arithmetic) if the LHS and RHS of the OR are
181 // provably disjoint.
182 APInt LHSKnownZero, LHSKnownOne;
183 CurDAG->ComputeMaskedBits(Addr.getOperand(0),
184 APInt::getAllOnesValue(Addr.getOperand(0)
185 .getValueSizeInBits()),
186 LHSKnownZero, LHSKnownOne);
187
188 if ((LHSKnownZero.getZExtValue()|~(uint64_t)Imm) == ~0ULL) {
189 // If all of the bits are known zero on the LHS or RHS, the add won't
190 // carry.
191 Base = Addr.getOperand(0);
Anton Korobeynikov32407402009-07-16 13:48:23 +0000192 Disp = CurDAG->getTargetConstant(Imm, MVT::i64);
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000193 return true;
194 }
195 }
196 } else if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr)) {
197 // Loading from a constant address.
198
199 // If this address fits entirely in a 20-bit sext immediate field, codegen
200 // this as "d(r0)"
Anton Korobeynikov32407402009-07-16 13:48:23 +0000201 int64_t Imm;
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000202 if (isImmSExt20(CN, Imm)) {
Anton Korobeynikov32407402009-07-16 13:48:23 +0000203 Disp = CurDAG->getTargetConstant(Imm, MVT::i64);
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000204 Base = CurDAG->getRegister(0, VT);
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000205 return true;
206 }
207 }
208
Anton Korobeynikov32407402009-07-16 13:48:23 +0000209 Disp = CurDAG->getTargetConstant(0, MVT::i64);
Anton Korobeynikov9e4816e2009-07-16 13:43:18 +0000210 if (FrameIndexSDNode *FI = dyn_cast<FrameIndexSDNode>(Addr))
211 Base = CurDAG->getTargetFrameIndex(FI->getIndex(), VT);
212 else
213 Base = Addr;
214 return true; // [r+0]
215}
216
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000217/// MatchAddress - Add the specified node to the specified addressing mode,
218/// returning true if it cannot be done. This just pattern matches for the
219/// addressing mode.
220bool SystemZDAGToDAGISel::MatchAddress(SDValue N, SystemZRRIAddressMode &AM,
221 unsigned Depth) {
222 DebugLoc dl = N.getDebugLoc();
223 DOUT << "MatchAddress: "; DEBUG(AM.dump());
224 // Limit recursion.
225 if (Depth > 5)
226 return MatchAddressBase(N, AM);
227
Anton Korobeynikovdc289552009-07-16 13:44:30 +0000228 // FIXME: We can perform better here. If we have something like
229 // (shift (add A, imm), N), we can try to reassociate stuff and fold shift of
230 // imm into addressing mode.
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000231 switch (N.getOpcode()) {
232 default: break;
233 case ISD::Constant: {
Anton Korobeynikov32407402009-07-16 13:48:23 +0000234 int64_t Val = cast<ConstantSDNode>(N)->getSExtValue();
235 int64_t Imm;
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000236 if (isImmSExt20(AM.Disp + Val, Imm)) {
237 AM.Disp = Imm;
238 return false;
239 }
240 break;
241 }
242
243 case ISD::FrameIndex:
244 if (AM.BaseType == SystemZRRIAddressMode::RegBase
245 && AM.Base.Reg.getNode() == 0) {
246 AM.BaseType = SystemZRRIAddressMode::FrameIndexBase;
247 AM.Base.FrameIndex = cast<FrameIndexSDNode>(N)->getIndex();
248 return false;
249 }
250 break;
251
252 case ISD::SUB: {
253 // Given A-B, if A can be completely folded into the address and
254 // the index field with the index field unused, use -B as the index.
255 // This is a win if a has multiple parts that can be folded into
256 // the address. Also, this saves a mov if the base register has
257 // other uses, since it avoids a two-address sub instruction, however
258 // it costs an additional mov if the index register has other uses.
259
260 // Test if the LHS of the sub can be folded.
261 SystemZRRIAddressMode Backup = AM;
262 if (MatchAddress(N.getNode()->getOperand(0), AM, Depth+1)) {
263 AM = Backup;
264 break;
265 }
266 // Test if the index field is free for use.
267 if (AM.IndexReg.getNode()) {
268 AM = Backup;
269 break;
270 }
271
272 // If the base is a register with multiple uses, this transformation may
273 // save a mov. Otherwise it's probably better not to do it.
274 if (AM.BaseType == SystemZRRIAddressMode::RegBase &&
275 (!AM.Base.Reg.getNode() || AM.Base.Reg.getNode()->hasOneUse())) {
276 AM = Backup;
277 break;
278 }
279
280 // Ok, the transformation is legal and appears profitable. Go for it.
281 SDValue RHS = N.getNode()->getOperand(1);
282 SDValue Zero = CurDAG->getConstant(0, N.getValueType());
283 SDValue Neg = CurDAG->getNode(ISD::SUB, dl, N.getValueType(), Zero, RHS);
284 AM.IndexReg = Neg;
285
286 // Insert the new nodes into the topological ordering.
287 if (Zero.getNode()->getNodeId() == -1 ||
288 Zero.getNode()->getNodeId() > N.getNode()->getNodeId()) {
289 CurDAG->RepositionNode(N.getNode(), Zero.getNode());
290 Zero.getNode()->setNodeId(N.getNode()->getNodeId());
291 }
292 if (Neg.getNode()->getNodeId() == -1 ||
293 Neg.getNode()->getNodeId() > N.getNode()->getNodeId()) {
294 CurDAG->RepositionNode(N.getNode(), Neg.getNode());
295 Neg.getNode()->setNodeId(N.getNode()->getNodeId());
296 }
297 return false;
298 }
299
300 case ISD::ADD: {
301 SystemZRRIAddressMode Backup = AM;
302 if (!MatchAddress(N.getNode()->getOperand(0), AM, Depth+1) &&
303 !MatchAddress(N.getNode()->getOperand(1), AM, Depth+1))
304 return false;
305 AM = Backup;
306 if (!MatchAddress(N.getNode()->getOperand(1), AM, Depth+1) &&
307 !MatchAddress(N.getNode()->getOperand(0), AM, Depth+1))
308 return false;
309 AM = Backup;
310
311 // If we couldn't fold both operands into the address at the same time,
312 // see if we can just put each operand into a register and fold at least
313 // the add.
314 if (AM.BaseType == SystemZRRIAddressMode::RegBase &&
315 !AM.Base.Reg.getNode() && !AM.IndexReg.getNode()) {
316 AM.Base.Reg = N.getNode()->getOperand(0);
317 AM.IndexReg = N.getNode()->getOperand(1);
318 return false;
319 }
320 break;
321 }
322
323 case ISD::OR:
324 // Handle "X | C" as "X + C" iff X is known to have C bits clear.
325 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N.getOperand(1))) {
326 SystemZRRIAddressMode Backup = AM;
Anton Korobeynikov32407402009-07-16 13:48:23 +0000327 int64_t Offset = CN->getSExtValue();
328 int64_t Imm;
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000329 // Start with the LHS as an addr mode.
330 if (!MatchAddress(N.getOperand(0), AM, Depth+1) &&
331 // The resultant disp must fit in 20-bits.
332 isImmSExt20(AM.Disp + Offset, Imm) &&
333 // Check to see if the LHS & C is zero.
334 CurDAG->MaskedValueIsZero(N.getOperand(0), CN->getAPIntValue())) {
335 AM.Disp = Imm;
336 return false;
337 }
338 AM = Backup;
339 }
340 break;
341 }
342
343 return MatchAddressBase(N, AM);
344}
345
346/// MatchAddressBase - Helper for MatchAddress. Add the specified node to the
347/// specified addressing mode without any further recursion.
348bool SystemZDAGToDAGISel::MatchAddressBase(SDValue N,
349 SystemZRRIAddressMode &AM) {
350 // Is the base register already occupied?
351 if (AM.BaseType != SystemZRRIAddressMode::RegBase || AM.Base.Reg.getNode()) {
352 // If so, check to see if the scale index register is set.
353 if (AM.IndexReg.getNode() == 0) {
354 AM.IndexReg = N;
355 return false;
356 }
357
358 // Otherwise, we cannot select it.
359 return true;
360 }
361
362 // Default, generate it as a register.
363 AM.BaseType = SystemZRRIAddressMode::RegBase;
364 AM.Base.Reg = N;
365 return false;
366}
367
368/// Returns true if the address can be represented by a base register plus
369/// index register plus a signed 20-bit displacement [base + idx + imm].
370bool SystemZDAGToDAGISel::SelectAddrRRI(SDValue Op, SDValue Addr,
371 SDValue &Base, SDValue &Index, SDValue &Disp) {
372 SystemZRRIAddressMode AM;
373 bool Done = false;
374
Anton Korobeynikov711d5b62009-07-16 13:47:59 +0000375 if (!Addr.hasOneUse()) {
376 unsigned Opcode = Addr.getOpcode();
377 if (Opcode != ISD::Constant && Opcode != ISD::FrameIndex) {
378 // If we are able to fold N into addressing mode, then we'll allow it even
379 // if N has multiple uses. In general, addressing computation is used as
380 // addresses by all of its uses. But watch out for CopyToReg uses, that
381 // means the address computation is liveout. It will be computed by a LA
382 // so we want to avoid computing the address twice.
383 for (SDNode::use_iterator UI = Addr.getNode()->use_begin(),
384 UE = Addr.getNode()->use_end(); UI != UE; ++UI) {
385 if (UI->getOpcode() == ISD::CopyToReg) {
386 MatchAddressBase(Addr, AM);
387 Done = true;
388 break;
389 }
390 }
391 }
392 }
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000393 if (!Done && MatchAddress(Addr, AM))
394 return false;
395
Anton Korobeynikov32407402009-07-16 13:48:23 +0000396 DOUT << "MatchAddress (final): "; DEBUG(AM.dump());
397
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000398 MVT VT = Addr.getValueType();
399 if (AM.BaseType == SystemZRRIAddressMode::RegBase) {
400 if (!AM.Base.Reg.getNode())
401 AM.Base.Reg = CurDAG->getRegister(0, VT);
402 }
403
404 if (!AM.IndexReg.getNode())
405 AM.IndexReg = CurDAG->getRegister(0, VT);
406
407 if (AM.BaseType == SystemZRRIAddressMode::RegBase)
408 Base = AM.Base.Reg;
409 else
410 Base = CurDAG->getTargetFrameIndex(AM.Base.FrameIndex, TLI.getPointerTy());
411 Index = AM.IndexReg;
Anton Korobeynikov32407402009-07-16 13:48:23 +0000412 Disp = CurDAG->getTargetConstant(AM.Disp, MVT::i64);
Anton Korobeynikov3360da92009-07-16 13:44:00 +0000413
414 return true;
415}
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000416
Anton Korobeynikov711d5b62009-07-16 13:47:59 +0000417/// SelectLAAddr - it calls SelectAddr and determines if the maximal addressing
418/// mode it matches can be cost effectively emitted as an LA/LAY instruction.
419bool SystemZDAGToDAGISel::SelectLAAddr(SDValue Op, SDValue Addr,
420 SDValue &Base, SDValue &Index, SDValue &Disp) {
421 SystemZRRIAddressMode AM;
422
423 if (MatchAddress(Addr, AM))
424 return false;
425
426 MVT VT = Addr.getValueType();
427 unsigned Complexity = 0;
428 if (AM.BaseType == SystemZRRIAddressMode::RegBase)
429 if (AM.Base.Reg.getNode())
430 Complexity = 1;
431 else
432 AM.Base.Reg = CurDAG->getRegister(0, VT);
433 else if (AM.BaseType == SystemZRRIAddressMode::FrameIndexBase)
434 Complexity = 4;
435
436 if (AM.IndexReg.getNode())
437 Complexity += 1;
438 else
439 AM.IndexReg = CurDAG->getRegister(0, VT);
440
441 if (AM.Disp && (AM.Base.Reg.getNode() || AM.IndexReg.getNode()))
442 Complexity += 1;
443
444 if (Complexity > 2) {
445 if (AM.BaseType == SystemZRRIAddressMode::RegBase)
446 Base = AM.Base.Reg;
447 else
448 Base = CurDAG->getTargetFrameIndex(AM.Base.FrameIndex,
449 TLI.getPointerTy());
450 Index = AM.IndexReg;
Anton Korobeynikov32407402009-07-16 13:48:23 +0000451 Disp = CurDAG->getTargetConstant(AM.Disp, MVT::i64);
Anton Korobeynikov711d5b62009-07-16 13:47:59 +0000452 return true;
453 }
454
455 return false;
456}
457
Anton Korobeynikov4403b932009-07-16 13:27:25 +0000458/// InstructionSelect - This callback is invoked by
459/// SelectionDAGISel when it has created a SelectionDAG for us to codegen.
460void SystemZDAGToDAGISel::InstructionSelect() {
461 DEBUG(BB->dump());
462
463 // Codegen the basic block.
464#ifndef NDEBUG
465 DOUT << "===== Instruction selection begins:\n";
466 Indent = 0;
467#endif
468 SelectRoot(*CurDAG);
469#ifndef NDEBUG
470 DOUT << "===== Instruction selection ends:\n";
471#endif
472
473 CurDAG->RemoveDeadNodes();
474}
475
476SDNode *SystemZDAGToDAGISel::Select(SDValue Op) {
477 SDNode *Node = Op.getNode();
478 DebugLoc dl = Op.getDebugLoc();
479
480 // Dump information about the Node being selected
481 #ifndef NDEBUG
482 DOUT << std::string(Indent, ' ') << "Selecting: ";
483 DEBUG(Node->dump(CurDAG));
484 DOUT << "\n";
485 Indent += 2;
486 #endif
487
488 // If we have a custom node, we already have selected!
489 if (Node->isMachineOpcode()) {
490 #ifndef NDEBUG
491 DOUT << std::string(Indent-2, ' ') << "== ";
492 DEBUG(Node->dump(CurDAG));
493 DOUT << "\n";
494 Indent -= 2;
495 #endif
496 return NULL;
497 }
498
499 // Select the default instruction
500 SDNode *ResNode = SelectCode(Op);
501
502 #ifndef NDEBUG
503 DOUT << std::string(Indent-2, ' ') << "=> ";
504 if (ResNode == NULL || ResNode == Op.getNode())
505 DEBUG(Op.getNode()->dump(CurDAG));
506 else
507 DEBUG(ResNode->dump(CurDAG));
508 DOUT << "\n";
509 Indent -= 2;
510 #endif
511
512 return ResNode;
513}