blob: c36e75d1b0761f2023f48ecc571c7b7543007607 [file] [log] [blame]
Chris Lattner158e1f52006-02-05 05:50:24 +00001//===-- SparcISelDAGToDAG.cpp - A dag to dag inst selector for Sparc ------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner158e1f52006-02-05 05:50:24 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines an instruction selector for the SPARC target.
11//
12//===----------------------------------------------------------------------===//
13
Chris Lattner158e1f52006-02-05 05:50:24 +000014#include "SparcTargetMachine.h"
James Y Knight3994be82015-08-10 19:11:39 +000015#include "llvm/CodeGen/MachineRegisterInfo.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000016#include "llvm/CodeGen/SelectionDAGISel.h"
Chandler Carruth9fb823b2013-01-02 11:36:10 +000017#include "llvm/IR/Intrinsics.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000018#include "llvm/Support/Debug.h"
Torok Edwinfb8d6d52009-07-08 20:53:28 +000019#include "llvm/Support/ErrorHandling.h"
20#include "llvm/Support/raw_ostream.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000021using namespace llvm;
22
23//===----------------------------------------------------------------------===//
Chris Lattner158e1f52006-02-05 05:50:24 +000024// Instruction Selector Implementation
25//===----------------------------------------------------------------------===//
26
27//===--------------------------------------------------------------------===//
28/// SparcDAGToDAGISel - SPARC specific code to select SPARC machine
29/// instructions for SelectionDAG operations.
30///
31namespace {
32class SparcDAGToDAGISel : public SelectionDAGISel {
Chris Lattner158e1f52006-02-05 05:50:24 +000033 /// Subtarget - Keep a pointer to the Sparc Subtarget around so that we can
34 /// make the right decision when generating code for different targets.
Eric Christopherf5e94062015-01-30 23:46:43 +000035 const SparcSubtarget *Subtarget;
Chris Lattner158e1f52006-02-05 05:50:24 +000036public:
Eric Christopherf5e94062015-01-30 23:46:43 +000037 explicit SparcDAGToDAGISel(SparcTargetMachine &tm) : SelectionDAGISel(tm) {}
38
39 bool runOnMachineFunction(MachineFunction &MF) override {
40 Subtarget = &MF.getSubtarget<SparcSubtarget>();
41 return SelectionDAGISel::runOnMachineFunction(MF);
Chris Lattner158e1f52006-02-05 05:50:24 +000042 }
43
Justin Bogner5a625be2016-05-13 21:46:22 +000044 void Select(SDNode *N) override;
Chris Lattner158e1f52006-02-05 05:50:24 +000045
46 // Complex Pattern Selectors.
Chris Lattner0e023ea2010-09-21 20:31:19 +000047 bool SelectADDRrr(SDValue N, SDValue &R1, SDValue &R2);
48 bool SelectADDRri(SDValue N, SDValue &Base, SDValue &Offset);
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000049
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +000050 /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
51 /// inline asm expressions.
Craig Topperb0c941b2014-04-29 07:57:13 +000052 bool SelectInlineAsmMemoryOperand(const SDValue &Op,
Daniel Sanders60f1db02015-03-13 12:45:09 +000053 unsigned ConstraintID,
Craig Topperb0c941b2014-04-29 07:57:13 +000054 std::vector<SDValue> &OutOps) override;
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +000055
Mehdi Amini117296c2016-10-01 02:56:57 +000056 StringRef getPassName() const override {
Chris Lattner158e1f52006-02-05 05:50:24 +000057 return "SPARC DAG->DAG Pattern Instruction Selection";
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000058 }
59
Chris Lattner158e1f52006-02-05 05:50:24 +000060 // Include the pieces autogenerated from the target description.
61#include "SparcGenDAGISel.inc"
Chris Lattner840c7002009-09-15 17:46:24 +000062
63private:
64 SDNode* getGlobalBaseReg();
Justin Bogner5a625be2016-05-13 21:46:22 +000065 bool tryInlineAsm(SDNode *N);
Chris Lattner158e1f52006-02-05 05:50:24 +000066};
67} // end anonymous namespace
68
Chris Lattner840c7002009-09-15 17:46:24 +000069SDNode* SparcDAGToDAGISel::getGlobalBaseReg() {
Eric Christopherf5e94062015-01-30 23:46:43 +000070 unsigned GlobalBaseReg = Subtarget->getInstrInfo()->getGlobalBaseReg(MF);
Mehdi Amini44ede332015-07-09 02:09:04 +000071 return CurDAG->getRegister(GlobalBaseReg,
72 TLI->getPointerTy(CurDAG->getDataLayout()))
73 .getNode();
Chris Lattner840c7002009-09-15 17:46:24 +000074}
75
Chris Lattner0e023ea2010-09-21 20:31:19 +000076bool SparcDAGToDAGISel::SelectADDRri(SDValue Addr,
Dan Gohman2ce6f2a2008-07-27 21:46:04 +000077 SDValue &Base, SDValue &Offset) {
Chris Lattner158e1f52006-02-05 05:50:24 +000078 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) {
Mehdi Amini44ede332015-07-09 02:09:04 +000079 Base = CurDAG->getTargetFrameIndex(
80 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
Sergey Dmitrouk842a51b2015-04-28 14:05:47 +000081 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
Chris Lattner158e1f52006-02-05 05:50:24 +000082 return true;
83 }
Bill Wendling24c79f22008-09-16 21:48:12 +000084 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
Venkatraman Govindarajucb1dca62013-09-22 06:48:52 +000085 Addr.getOpcode() == ISD::TargetGlobalAddress ||
86 Addr.getOpcode() == ISD::TargetGlobalTLSAddress)
Chris Lattnerfcb8a3a2006-02-10 07:35:42 +000087 return false; // direct calls.
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000088
Chris Lattner158e1f52006-02-05 05:50:24 +000089 if (Addr.getOpcode() == ISD::ADD) {
90 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1))) {
Jakob Stoklund Olesenf02b4a62010-08-17 18:17:12 +000091 if (isInt<13>(CN->getSExtValue())) {
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000092 if (FrameIndexSDNode *FIN =
Chris Lattner158e1f52006-02-05 05:50:24 +000093 dyn_cast<FrameIndexSDNode>(Addr.getOperand(0))) {
94 // Constant offset from frame ref.
Mehdi Amini44ede332015-07-09 02:09:04 +000095 Base = CurDAG->getTargetFrameIndex(
96 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
Chris Lattner158e1f52006-02-05 05:50:24 +000097 } else {
Chris Lattner463fa702006-02-05 08:35:50 +000098 Base = Addr.getOperand(0);
Chris Lattner158e1f52006-02-05 05:50:24 +000099 }
Sergey Dmitrouk842a51b2015-04-28 14:05:47 +0000100 Offset = CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Addr),
101 MVT::i32);
Chris Lattner158e1f52006-02-05 05:50:24 +0000102 return true;
103 }
104 }
105 if (Addr.getOperand(0).getOpcode() == SPISD::Lo) {
Chris Lattner463fa702006-02-05 08:35:50 +0000106 Base = Addr.getOperand(1);
Chris Lattner158e1f52006-02-05 05:50:24 +0000107 Offset = Addr.getOperand(0).getOperand(0);
108 return true;
109 }
110 if (Addr.getOperand(1).getOpcode() == SPISD::Lo) {
Chris Lattner463fa702006-02-05 08:35:50 +0000111 Base = Addr.getOperand(0);
Chris Lattner158e1f52006-02-05 05:50:24 +0000112 Offset = Addr.getOperand(1).getOperand(0);
113 return true;
114 }
115 }
Chris Lattner463fa702006-02-05 08:35:50 +0000116 Base = Addr;
Sergey Dmitrouk842a51b2015-04-28 14:05:47 +0000117 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
Chris Lattner158e1f52006-02-05 05:50:24 +0000118 return true;
119}
120
Chris Lattner0e023ea2010-09-21 20:31:19 +0000121bool SparcDAGToDAGISel::SelectADDRrr(SDValue Addr, SDValue &R1, SDValue &R2) {
Chris Lattnerfcb8a3a2006-02-10 07:35:42 +0000122 if (Addr.getOpcode() == ISD::FrameIndex) return false;
Bill Wendling24c79f22008-09-16 21:48:12 +0000123 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
Venkatraman Govindarajucb1dca62013-09-22 06:48:52 +0000124 Addr.getOpcode() == ISD::TargetGlobalAddress ||
125 Addr.getOpcode() == ISD::TargetGlobalTLSAddress)
Chris Lattnerfcb8a3a2006-02-10 07:35:42 +0000126 return false; // direct calls.
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000127
Chris Lattner158e1f52006-02-05 05:50:24 +0000128 if (Addr.getOpcode() == ISD::ADD) {
Jakob Stoklund Olesenf02b4a62010-08-17 18:17:12 +0000129 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1)))
130 if (isInt<13>(CN->getSExtValue()))
131 return false; // Let the reg+imm pattern catch this!
Chris Lattner158e1f52006-02-05 05:50:24 +0000132 if (Addr.getOperand(0).getOpcode() == SPISD::Lo ||
133 Addr.getOperand(1).getOpcode() == SPISD::Lo)
134 return false; // Let the reg+imm pattern catch this!
Chris Lattner463fa702006-02-05 08:35:50 +0000135 R1 = Addr.getOperand(0);
136 R2 = Addr.getOperand(1);
Chris Lattner158e1f52006-02-05 05:50:24 +0000137 return true;
138 }
139
Chris Lattner463fa702006-02-05 08:35:50 +0000140 R1 = Addr;
Mehdi Amini44ede332015-07-09 02:09:04 +0000141 R2 = CurDAG->getRegister(SP::G0, TLI->getPointerTy(CurDAG->getDataLayout()));
Chris Lattner158e1f52006-02-05 05:50:24 +0000142 return true;
143}
144
James Y Knight3994be82015-08-10 19:11:39 +0000145
146// Re-assemble i64 arguments split up in SelectionDAGBuilder's
147// visitInlineAsm / GetRegistersForValue functions.
148//
149// Note: This function was copied from, and is essentially identical
150// to ARMISelDAGToDAG::SelectInlineAsm. It is very unfortunate that
151// such hacking-up is necessary; a rethink of how inline asm operands
152// are handled may be in order to make doing this more sane.
153//
154// TODO: fix inline asm support so I can simply tell it that 'i64'
155// inputs to asm need to be allocated to the IntPair register type,
156// and have that work. Then, delete this function.
Justin Bogner5a625be2016-05-13 21:46:22 +0000157bool SparcDAGToDAGISel::tryInlineAsm(SDNode *N){
James Y Knight3994be82015-08-10 19:11:39 +0000158 std::vector<SDValue> AsmNodeOperands;
159 unsigned Flag, Kind;
160 bool Changed = false;
161 unsigned NumOps = N->getNumOperands();
162
163 // Normally, i64 data is bounded to two arbitrary GPRs for "%r"
164 // constraint. However, some instructions (e.g. ldd/std) require
165 // (even/even+1) GPRs.
166
167 // So, here, we check for this case, and mutate the inlineasm to use
168 // a single IntPair register instead, which guarantees such even/odd
169 // placement.
170
171 SDLoc dl(N);
172 SDValue Glue = N->getGluedNode() ? N->getOperand(NumOps-1)
173 : SDValue(nullptr,0);
174
175 SmallVector<bool, 8> OpChanged;
176 // Glue node will be appended late.
177 for(unsigned i = 0, e = N->getGluedNode() ? NumOps - 1 : NumOps; i < e; ++i) {
178 SDValue op = N->getOperand(i);
179 AsmNodeOperands.push_back(op);
180
181 if (i < InlineAsm::Op_FirstOperand)
182 continue;
183
184 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N->getOperand(i))) {
185 Flag = C->getZExtValue();
186 Kind = InlineAsm::getKind(Flag);
187 }
188 else
189 continue;
190
191 // Immediate operands to inline asm in the SelectionDAG are modeled with
192 // two operands. The first is a constant of value InlineAsm::Kind_Imm, and
193 // the second is a constant with the value of the immediate. If we get here
194 // and we have a Kind_Imm, skip the next operand, and continue.
195 if (Kind == InlineAsm::Kind_Imm) {
196 SDValue op = N->getOperand(++i);
197 AsmNodeOperands.push_back(op);
198 continue;
199 }
200
201 unsigned NumRegs = InlineAsm::getNumOperandRegisters(Flag);
202 if (NumRegs)
203 OpChanged.push_back(false);
204
205 unsigned DefIdx = 0;
206 bool IsTiedToChangedOp = false;
207 // If it's a use that is tied with a previous def, it has no
208 // reg class constraint.
209 if (Changed && InlineAsm::isUseOperandTiedToDef(Flag, DefIdx))
210 IsTiedToChangedOp = OpChanged[DefIdx];
211
212 if (Kind != InlineAsm::Kind_RegUse && Kind != InlineAsm::Kind_RegDef
213 && Kind != InlineAsm::Kind_RegDefEarlyClobber)
214 continue;
215
216 unsigned RC;
217 bool HasRC = InlineAsm::hasRegClassConstraint(Flag, RC);
218 if ((!IsTiedToChangedOp && (!HasRC || RC != SP::IntRegsRegClassID))
219 || NumRegs != 2)
220 continue;
221
222 assert((i+2 < NumOps) && "Invalid number of operands in inline asm");
223 SDValue V0 = N->getOperand(i+1);
224 SDValue V1 = N->getOperand(i+2);
225 unsigned Reg0 = cast<RegisterSDNode>(V0)->getReg();
226 unsigned Reg1 = cast<RegisterSDNode>(V1)->getReg();
227 SDValue PairedReg;
228 MachineRegisterInfo &MRI = MF->getRegInfo();
229
230 if (Kind == InlineAsm::Kind_RegDef ||
231 Kind == InlineAsm::Kind_RegDefEarlyClobber) {
232 // Replace the two GPRs with 1 GPRPair and copy values from GPRPair to
233 // the original GPRs.
234
235 unsigned GPVR = MRI.createVirtualRegister(&SP::IntPairRegClass);
236 PairedReg = CurDAG->getRegister(GPVR, MVT::v2i32);
237 SDValue Chain = SDValue(N,0);
238
239 SDNode *GU = N->getGluedUser();
240 SDValue RegCopy = CurDAG->getCopyFromReg(Chain, dl, GPVR, MVT::v2i32,
241 Chain.getValue(1));
242
243 // Extract values from a GPRPair reg and copy to the original GPR reg.
244 SDValue Sub0 = CurDAG->getTargetExtractSubreg(SP::sub_even, dl, MVT::i32,
245 RegCopy);
246 SDValue Sub1 = CurDAG->getTargetExtractSubreg(SP::sub_odd, dl, MVT::i32,
247 RegCopy);
248 SDValue T0 = CurDAG->getCopyToReg(Sub0, dl, Reg0, Sub0,
249 RegCopy.getValue(1));
250 SDValue T1 = CurDAG->getCopyToReg(Sub1, dl, Reg1, Sub1, T0.getValue(1));
251
252 // Update the original glue user.
253 std::vector<SDValue> Ops(GU->op_begin(), GU->op_end()-1);
254 Ops.push_back(T1.getValue(1));
255 CurDAG->UpdateNodeOperands(GU, Ops);
256 }
257 else {
258 // For Kind == InlineAsm::Kind_RegUse, we first copy two GPRs into a
259 // GPRPair and then pass the GPRPair to the inline asm.
260 SDValue Chain = AsmNodeOperands[InlineAsm::Op_InputChain];
261
262 // As REG_SEQ doesn't take RegisterSDNode, we copy them first.
263 SDValue T0 = CurDAG->getCopyFromReg(Chain, dl, Reg0, MVT::i32,
264 Chain.getValue(1));
265 SDValue T1 = CurDAG->getCopyFromReg(Chain, dl, Reg1, MVT::i32,
266 T0.getValue(1));
267 SDValue Pair = SDValue(
268 CurDAG->getMachineNode(
269 TargetOpcode::REG_SEQUENCE, dl, MVT::v2i32,
270 {
271 CurDAG->getTargetConstant(SP::IntPairRegClassID, dl,
272 MVT::i32),
273 T0,
274 CurDAG->getTargetConstant(SP::sub_even, dl, MVT::i32),
275 T1,
276 CurDAG->getTargetConstant(SP::sub_odd, dl, MVT::i32),
277 }),
278 0);
279
280 // Copy REG_SEQ into a GPRPair-typed VR and replace the original two
281 // i32 VRs of inline asm with it.
282 unsigned GPVR = MRI.createVirtualRegister(&SP::IntPairRegClass);
283 PairedReg = CurDAG->getRegister(GPVR, MVT::v2i32);
284 Chain = CurDAG->getCopyToReg(T1, dl, GPVR, Pair, T1.getValue(1));
285
286 AsmNodeOperands[InlineAsm::Op_InputChain] = Chain;
287 Glue = Chain.getValue(1);
288 }
289
290 Changed = true;
291
292 if(PairedReg.getNode()) {
293 OpChanged[OpChanged.size() -1 ] = true;
294 Flag = InlineAsm::getFlagWord(Kind, 1 /* RegNum*/);
295 if (IsTiedToChangedOp)
296 Flag = InlineAsm::getFlagWordForMatchingOp(Flag, DefIdx);
297 else
298 Flag = InlineAsm::getFlagWordForRegClass(Flag, SP::IntPairRegClassID);
299 // Replace the current flag.
300 AsmNodeOperands[AsmNodeOperands.size() -1] = CurDAG->getTargetConstant(
301 Flag, dl, MVT::i32);
302 // Add the new register node and skip the original two GPRs.
303 AsmNodeOperands.push_back(PairedReg);
304 // Skip the next two GPRs.
305 i += 2;
306 }
307 }
308
309 if (Glue.getNode())
310 AsmNodeOperands.push_back(Glue);
311 if (!Changed)
Justin Bogner5a625be2016-05-13 21:46:22 +0000312 return false;
James Y Knight3994be82015-08-10 19:11:39 +0000313
314 SDValue New = CurDAG->getNode(ISD::INLINEASM, SDLoc(N),
315 CurDAG->getVTList(MVT::Other, MVT::Glue), AsmNodeOperands);
316 New->setNodeId(-1);
Justin Bogner5a625be2016-05-13 21:46:22 +0000317 ReplaceNode(N, New.getNode());
318 return true;
James Y Knight3994be82015-08-10 19:11:39 +0000319}
320
Justin Bogner5a625be2016-05-13 21:46:22 +0000321void SparcDAGToDAGISel::Select(SDNode *N) {
Andrew Trickef9de2a2013-05-25 02:42:55 +0000322 SDLoc dl(N);
Tim Northover31d093c2013-09-22 08:21:56 +0000323 if (N->isMachineOpcode()) {
324 N->setNodeId(-1);
Justin Bogner5a625be2016-05-13 21:46:22 +0000325 return; // Already selected.
Tim Northover31d093c2013-09-22 08:21:56 +0000326 }
Evan Cheng6dc90ca2006-02-09 00:37:58 +0000327
Chris Lattner158e1f52006-02-05 05:50:24 +0000328 switch (N->getOpcode()) {
329 default: break;
Justin Bogner5a625be2016-05-13 21:46:22 +0000330 case ISD::INLINEASM: {
331 if (tryInlineAsm(N))
332 return;
James Y Knight3994be82015-08-10 19:11:39 +0000333 break;
334 }
Chris Lattner840c7002009-09-15 17:46:24 +0000335 case SPISD::GLOBAL_BASE_REG:
Justin Bogner5a625be2016-05-13 21:46:22 +0000336 ReplaceNode(N, getGlobalBaseReg());
337 return;
Chris Lattner840c7002009-09-15 17:46:24 +0000338
Chris Lattner158e1f52006-02-05 05:50:24 +0000339 case ISD::SDIV:
340 case ISD::UDIV: {
Jakob Stoklund Olesen73d17392013-04-16 02:57:02 +0000341 // sdivx / udivx handle 64-bit divides.
342 if (N->getValueType(0) == MVT::i64)
343 break;
Chris Lattner158e1f52006-02-05 05:50:24 +0000344 // FIXME: should use a custom expander to expose the SRA to the dag.
Dan Gohman2ce6f2a2008-07-27 21:46:04 +0000345 SDValue DivLHS = N->getOperand(0);
346 SDValue DivRHS = N->getOperand(1);
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000347
Chris Lattner158e1f52006-02-05 05:50:24 +0000348 // Set the Y register to the high-part.
Dan Gohman2ce6f2a2008-07-27 21:46:04 +0000349 SDValue TopPart;
Chris Lattner158e1f52006-02-05 05:50:24 +0000350 if (N->getOpcode() == ISD::SDIV) {
Dan Gohman32f71d72009-09-25 18:54:59 +0000351 TopPart = SDValue(CurDAG->getMachineNode(SP::SRAri, dl, MVT::i32, DivLHS,
Sergey Dmitrouk842a51b2015-04-28 14:05:47 +0000352 CurDAG->getTargetConstant(31, dl, MVT::i32)),
353 0);
Chris Lattner158e1f52006-02-05 05:50:24 +0000354 } else {
Owen Anderson9f944592009-08-11 20:47:22 +0000355 TopPart = CurDAG->getRegister(SP::G0, MVT::i32);
Chris Lattner158e1f52006-02-05 05:50:24 +0000356 }
James Y Knightf238d172015-07-08 16:25:12 +0000357 TopPart = CurDAG->getCopyToReg(CurDAG->getEntryNode(), dl, SP::Y, TopPart,
358 SDValue())
359 .getValue(1);
Chris Lattner158e1f52006-02-05 05:50:24 +0000360
361 // FIXME: Handle div by immediate.
362 unsigned Opcode = N->getOpcode() == ISD::SDIV ? SP::SDIVrr : SP::UDIVrr;
Chris Dewhurst85013122016-10-10 08:53:06 +0000363 // SDIV is a hardware erratum on some LEON2 processors. Replace it with SDIVcc here.
364 if (((SparcTargetMachine&)TM).getSubtargetImpl()->performSDIVReplace()
365 &&
366 Opcode == SP::SDIVrr) {
367 Opcode = SP::SDIVCCrr;
368 }
Justin Bogner5a625be2016-05-13 21:46:22 +0000369 CurDAG->SelectNodeTo(N, Opcode, MVT::i32, DivLHS, DivRHS, TopPart);
370 return;
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000371 }
Chris Lattner158e1f52006-02-05 05:50:24 +0000372 }
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000373
Justin Bogner5a625be2016-05-13 21:46:22 +0000374 SelectCode(N);
Chris Lattner158e1f52006-02-05 05:50:24 +0000375}
376
377
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000378/// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
379/// inline asm expressions.
380bool
381SparcDAGToDAGISel::SelectInlineAsmMemoryOperand(const SDValue &Op,
Daniel Sanders60f1db02015-03-13 12:45:09 +0000382 unsigned ConstraintID,
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000383 std::vector<SDValue> &OutOps) {
384 SDValue Op0, Op1;
Daniel Sanders60f1db02015-03-13 12:45:09 +0000385 switch (ConstraintID) {
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000386 default: return true;
Daniel Sandersb1fbaca2015-03-19 11:27:23 +0000387 case InlineAsm::Constraint_i:
Chris Dewhurst0dfa6bc2016-05-20 09:03:01 +0000388 case InlineAsm::Constraint_o:
Daniel Sanders60f1db02015-03-13 12:45:09 +0000389 case InlineAsm::Constraint_m: // memory
Chris Lattner0e023ea2010-09-21 20:31:19 +0000390 if (!SelectADDRrr(Op, Op0, Op1))
391 SelectADDRri(Op, Op0, Op1);
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000392 break;
393 }
394
395 OutOps.push_back(Op0);
396 OutOps.push_back(Op1);
397 return false;
398}
399
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000400/// createSparcISelDag - This pass converts a legalized DAG into a
Chris Lattner158e1f52006-02-05 05:50:24 +0000401/// SPARC-specific DAG, ready for instruction scheduling.
402///
Dan Gohman2c836cf2008-10-03 16:55:19 +0000403FunctionPass *llvm::createSparcISelDag(SparcTargetMachine &TM) {
Chris Lattner158e1f52006-02-05 05:50:24 +0000404 return new SparcDAGToDAGISel(TM);
405}