blob: c4c641659df3cececef12543775f6be9f17c7015 [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 Lattner1770fb82008-02-03 05:43:57 +000018#include "llvm/Support/Compiler.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000019#include "llvm/Support/Debug.h"
Torok Edwinfb8d6d52009-07-08 20:53:28 +000020#include "llvm/Support/ErrorHandling.h"
21#include "llvm/Support/raw_ostream.h"
Chris Lattner158e1f52006-02-05 05:50:24 +000022using namespace llvm;
23
24//===----------------------------------------------------------------------===//
Chris Lattner158e1f52006-02-05 05:50:24 +000025// Instruction Selector Implementation
26//===----------------------------------------------------------------------===//
27
28//===--------------------------------------------------------------------===//
29/// SparcDAGToDAGISel - SPARC specific code to select SPARC machine
30/// instructions for SelectionDAG operations.
31///
32namespace {
33class SparcDAGToDAGISel : public SelectionDAGISel {
Chris Lattner158e1f52006-02-05 05:50:24 +000034 /// Subtarget - Keep a pointer to the Sparc Subtarget around so that we can
35 /// make the right decision when generating code for different targets.
Eric Christopherf5e94062015-01-30 23:46:43 +000036 const SparcSubtarget *Subtarget;
Chris Lattner158e1f52006-02-05 05:50:24 +000037public:
Eric Christopherf5e94062015-01-30 23:46:43 +000038 explicit SparcDAGToDAGISel(SparcTargetMachine &tm) : SelectionDAGISel(tm) {}
39
40 bool runOnMachineFunction(MachineFunction &MF) override {
41 Subtarget = &MF.getSubtarget<SparcSubtarget>();
42 return SelectionDAGISel::runOnMachineFunction(MF);
Chris Lattner158e1f52006-02-05 05:50:24 +000043 }
44
Craig Topperb0c941b2014-04-29 07:57:13 +000045 SDNode *Select(SDNode *N) override;
Chris Lattner158e1f52006-02-05 05:50:24 +000046
47 // Complex Pattern Selectors.
Chris Lattner0e023ea2010-09-21 20:31:19 +000048 bool SelectADDRrr(SDValue N, SDValue &R1, SDValue &R2);
49 bool SelectADDRri(SDValue N, SDValue &Base, SDValue &Offset);
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000050
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +000051 /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
52 /// inline asm expressions.
Craig Topperb0c941b2014-04-29 07:57:13 +000053 bool SelectInlineAsmMemoryOperand(const SDValue &Op,
Daniel Sanders60f1db02015-03-13 12:45:09 +000054 unsigned ConstraintID,
Craig Topperb0c941b2014-04-29 07:57:13 +000055 std::vector<SDValue> &OutOps) override;
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +000056
Craig Topperb0c941b2014-04-29 07:57:13 +000057 const char *getPassName() const override {
Chris Lattner158e1f52006-02-05 05:50:24 +000058 return "SPARC DAG->DAG Pattern Instruction Selection";
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000059 }
60
Chris Lattner158e1f52006-02-05 05:50:24 +000061 // Include the pieces autogenerated from the target description.
62#include "SparcGenDAGISel.inc"
Chris Lattner840c7002009-09-15 17:46:24 +000063
64private:
65 SDNode* getGlobalBaseReg();
James Y Knight3994be82015-08-10 19:11:39 +000066 SDNode *SelectInlineAsm(SDNode *N);
Chris Lattner158e1f52006-02-05 05:50:24 +000067};
68} // end anonymous namespace
69
Chris Lattner840c7002009-09-15 17:46:24 +000070SDNode* SparcDAGToDAGISel::getGlobalBaseReg() {
Eric Christopherf5e94062015-01-30 23:46:43 +000071 unsigned GlobalBaseReg = Subtarget->getInstrInfo()->getGlobalBaseReg(MF);
Mehdi Amini44ede332015-07-09 02:09:04 +000072 return CurDAG->getRegister(GlobalBaseReg,
73 TLI->getPointerTy(CurDAG->getDataLayout()))
74 .getNode();
Chris Lattner840c7002009-09-15 17:46:24 +000075}
76
Chris Lattner0e023ea2010-09-21 20:31:19 +000077bool SparcDAGToDAGISel::SelectADDRri(SDValue Addr,
Dan Gohman2ce6f2a2008-07-27 21:46:04 +000078 SDValue &Base, SDValue &Offset) {
Chris Lattner158e1f52006-02-05 05:50:24 +000079 if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) {
Mehdi Amini44ede332015-07-09 02:09:04 +000080 Base = CurDAG->getTargetFrameIndex(
81 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
Sergey Dmitrouk842a51b2015-04-28 14:05:47 +000082 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
Chris Lattner158e1f52006-02-05 05:50:24 +000083 return true;
84 }
Bill Wendling24c79f22008-09-16 21:48:12 +000085 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
Venkatraman Govindarajucb1dca62013-09-22 06:48:52 +000086 Addr.getOpcode() == ISD::TargetGlobalAddress ||
87 Addr.getOpcode() == ISD::TargetGlobalTLSAddress)
Chris Lattnerfcb8a3a2006-02-10 07:35:42 +000088 return false; // direct calls.
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000089
Chris Lattner158e1f52006-02-05 05:50:24 +000090 if (Addr.getOpcode() == ISD::ADD) {
91 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1))) {
Jakob Stoklund Olesenf02b4a62010-08-17 18:17:12 +000092 if (isInt<13>(CN->getSExtValue())) {
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +000093 if (FrameIndexSDNode *FIN =
Chris Lattner158e1f52006-02-05 05:50:24 +000094 dyn_cast<FrameIndexSDNode>(Addr.getOperand(0))) {
95 // Constant offset from frame ref.
Mehdi Amini44ede332015-07-09 02:09:04 +000096 Base = CurDAG->getTargetFrameIndex(
97 FIN->getIndex(), TLI->getPointerTy(CurDAG->getDataLayout()));
Chris Lattner158e1f52006-02-05 05:50:24 +000098 } else {
Chris Lattner463fa702006-02-05 08:35:50 +000099 Base = Addr.getOperand(0);
Chris Lattner158e1f52006-02-05 05:50:24 +0000100 }
Sergey Dmitrouk842a51b2015-04-28 14:05:47 +0000101 Offset = CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Addr),
102 MVT::i32);
Chris Lattner158e1f52006-02-05 05:50:24 +0000103 return true;
104 }
105 }
106 if (Addr.getOperand(0).getOpcode() == SPISD::Lo) {
Chris Lattner463fa702006-02-05 08:35:50 +0000107 Base = Addr.getOperand(1);
Chris Lattner158e1f52006-02-05 05:50:24 +0000108 Offset = Addr.getOperand(0).getOperand(0);
109 return true;
110 }
111 if (Addr.getOperand(1).getOpcode() == SPISD::Lo) {
Chris Lattner463fa702006-02-05 08:35:50 +0000112 Base = Addr.getOperand(0);
Chris Lattner158e1f52006-02-05 05:50:24 +0000113 Offset = Addr.getOperand(1).getOperand(0);
114 return true;
115 }
116 }
Chris Lattner463fa702006-02-05 08:35:50 +0000117 Base = Addr;
Sergey Dmitrouk842a51b2015-04-28 14:05:47 +0000118 Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), MVT::i32);
Chris Lattner158e1f52006-02-05 05:50:24 +0000119 return true;
120}
121
Chris Lattner0e023ea2010-09-21 20:31:19 +0000122bool SparcDAGToDAGISel::SelectADDRrr(SDValue Addr, SDValue &R1, SDValue &R2) {
Chris Lattnerfcb8a3a2006-02-10 07:35:42 +0000123 if (Addr.getOpcode() == ISD::FrameIndex) return false;
Bill Wendling24c79f22008-09-16 21:48:12 +0000124 if (Addr.getOpcode() == ISD::TargetExternalSymbol ||
Venkatraman Govindarajucb1dca62013-09-22 06:48:52 +0000125 Addr.getOpcode() == ISD::TargetGlobalAddress ||
126 Addr.getOpcode() == ISD::TargetGlobalTLSAddress)
Chris Lattnerfcb8a3a2006-02-10 07:35:42 +0000127 return false; // direct calls.
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000128
Chris Lattner158e1f52006-02-05 05:50:24 +0000129 if (Addr.getOpcode() == ISD::ADD) {
Jakob Stoklund Olesenf02b4a62010-08-17 18:17:12 +0000130 if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1)))
131 if (isInt<13>(CN->getSExtValue()))
132 return false; // Let the reg+imm pattern catch this!
Chris Lattner158e1f52006-02-05 05:50:24 +0000133 if (Addr.getOperand(0).getOpcode() == SPISD::Lo ||
134 Addr.getOperand(1).getOpcode() == SPISD::Lo)
135 return false; // Let the reg+imm pattern catch this!
Chris Lattner463fa702006-02-05 08:35:50 +0000136 R1 = Addr.getOperand(0);
137 R2 = Addr.getOperand(1);
Chris Lattner158e1f52006-02-05 05:50:24 +0000138 return true;
139 }
140
Chris Lattner463fa702006-02-05 08:35:50 +0000141 R1 = Addr;
Mehdi Amini44ede332015-07-09 02:09:04 +0000142 R2 = CurDAG->getRegister(SP::G0, TLI->getPointerTy(CurDAG->getDataLayout()));
Chris Lattner158e1f52006-02-05 05:50:24 +0000143 return true;
144}
145
James Y Knight3994be82015-08-10 19:11:39 +0000146
147// Re-assemble i64 arguments split up in SelectionDAGBuilder's
148// visitInlineAsm / GetRegistersForValue functions.
149//
150// Note: This function was copied from, and is essentially identical
151// to ARMISelDAGToDAG::SelectInlineAsm. It is very unfortunate that
152// such hacking-up is necessary; a rethink of how inline asm operands
153// are handled may be in order to make doing this more sane.
154//
155// TODO: fix inline asm support so I can simply tell it that 'i64'
156// inputs to asm need to be allocated to the IntPair register type,
157// and have that work. Then, delete this function.
158SDNode *SparcDAGToDAGISel::SelectInlineAsm(SDNode *N){
159 std::vector<SDValue> AsmNodeOperands;
160 unsigned Flag, Kind;
161 bool Changed = false;
162 unsigned NumOps = N->getNumOperands();
163
164 // Normally, i64 data is bounded to two arbitrary GPRs for "%r"
165 // constraint. However, some instructions (e.g. ldd/std) require
166 // (even/even+1) GPRs.
167
168 // So, here, we check for this case, and mutate the inlineasm to use
169 // a single IntPair register instead, which guarantees such even/odd
170 // placement.
171
172 SDLoc dl(N);
173 SDValue Glue = N->getGluedNode() ? N->getOperand(NumOps-1)
174 : SDValue(nullptr,0);
175
176 SmallVector<bool, 8> OpChanged;
177 // Glue node will be appended late.
178 for(unsigned i = 0, e = N->getGluedNode() ? NumOps - 1 : NumOps; i < e; ++i) {
179 SDValue op = N->getOperand(i);
180 AsmNodeOperands.push_back(op);
181
182 if (i < InlineAsm::Op_FirstOperand)
183 continue;
184
185 if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N->getOperand(i))) {
186 Flag = C->getZExtValue();
187 Kind = InlineAsm::getKind(Flag);
188 }
189 else
190 continue;
191
192 // Immediate operands to inline asm in the SelectionDAG are modeled with
193 // two operands. The first is a constant of value InlineAsm::Kind_Imm, and
194 // the second is a constant with the value of the immediate. If we get here
195 // and we have a Kind_Imm, skip the next operand, and continue.
196 if (Kind == InlineAsm::Kind_Imm) {
197 SDValue op = N->getOperand(++i);
198 AsmNodeOperands.push_back(op);
199 continue;
200 }
201
202 unsigned NumRegs = InlineAsm::getNumOperandRegisters(Flag);
203 if (NumRegs)
204 OpChanged.push_back(false);
205
206 unsigned DefIdx = 0;
207 bool IsTiedToChangedOp = false;
208 // If it's a use that is tied with a previous def, it has no
209 // reg class constraint.
210 if (Changed && InlineAsm::isUseOperandTiedToDef(Flag, DefIdx))
211 IsTiedToChangedOp = OpChanged[DefIdx];
212
213 if (Kind != InlineAsm::Kind_RegUse && Kind != InlineAsm::Kind_RegDef
214 && Kind != InlineAsm::Kind_RegDefEarlyClobber)
215 continue;
216
217 unsigned RC;
218 bool HasRC = InlineAsm::hasRegClassConstraint(Flag, RC);
219 if ((!IsTiedToChangedOp && (!HasRC || RC != SP::IntRegsRegClassID))
220 || NumRegs != 2)
221 continue;
222
223 assert((i+2 < NumOps) && "Invalid number of operands in inline asm");
224 SDValue V0 = N->getOperand(i+1);
225 SDValue V1 = N->getOperand(i+2);
226 unsigned Reg0 = cast<RegisterSDNode>(V0)->getReg();
227 unsigned Reg1 = cast<RegisterSDNode>(V1)->getReg();
228 SDValue PairedReg;
229 MachineRegisterInfo &MRI = MF->getRegInfo();
230
231 if (Kind == InlineAsm::Kind_RegDef ||
232 Kind == InlineAsm::Kind_RegDefEarlyClobber) {
233 // Replace the two GPRs with 1 GPRPair and copy values from GPRPair to
234 // the original GPRs.
235
236 unsigned GPVR = MRI.createVirtualRegister(&SP::IntPairRegClass);
237 PairedReg = CurDAG->getRegister(GPVR, MVT::v2i32);
238 SDValue Chain = SDValue(N,0);
239
240 SDNode *GU = N->getGluedUser();
241 SDValue RegCopy = CurDAG->getCopyFromReg(Chain, dl, GPVR, MVT::v2i32,
242 Chain.getValue(1));
243
244 // Extract values from a GPRPair reg and copy to the original GPR reg.
245 SDValue Sub0 = CurDAG->getTargetExtractSubreg(SP::sub_even, dl, MVT::i32,
246 RegCopy);
247 SDValue Sub1 = CurDAG->getTargetExtractSubreg(SP::sub_odd, dl, MVT::i32,
248 RegCopy);
249 SDValue T0 = CurDAG->getCopyToReg(Sub0, dl, Reg0, Sub0,
250 RegCopy.getValue(1));
251 SDValue T1 = CurDAG->getCopyToReg(Sub1, dl, Reg1, Sub1, T0.getValue(1));
252
253 // Update the original glue user.
254 std::vector<SDValue> Ops(GU->op_begin(), GU->op_end()-1);
255 Ops.push_back(T1.getValue(1));
256 CurDAG->UpdateNodeOperands(GU, Ops);
257 }
258 else {
259 // For Kind == InlineAsm::Kind_RegUse, we first copy two GPRs into a
260 // GPRPair and then pass the GPRPair to the inline asm.
261 SDValue Chain = AsmNodeOperands[InlineAsm::Op_InputChain];
262
263 // As REG_SEQ doesn't take RegisterSDNode, we copy them first.
264 SDValue T0 = CurDAG->getCopyFromReg(Chain, dl, Reg0, MVT::i32,
265 Chain.getValue(1));
266 SDValue T1 = CurDAG->getCopyFromReg(Chain, dl, Reg1, MVT::i32,
267 T0.getValue(1));
268 SDValue Pair = SDValue(
269 CurDAG->getMachineNode(
270 TargetOpcode::REG_SEQUENCE, dl, MVT::v2i32,
271 {
272 CurDAG->getTargetConstant(SP::IntPairRegClassID, dl,
273 MVT::i32),
274 T0,
275 CurDAG->getTargetConstant(SP::sub_even, dl, MVT::i32),
276 T1,
277 CurDAG->getTargetConstant(SP::sub_odd, dl, MVT::i32),
278 }),
279 0);
280
281 // Copy REG_SEQ into a GPRPair-typed VR and replace the original two
282 // i32 VRs of inline asm with it.
283 unsigned GPVR = MRI.createVirtualRegister(&SP::IntPairRegClass);
284 PairedReg = CurDAG->getRegister(GPVR, MVT::v2i32);
285 Chain = CurDAG->getCopyToReg(T1, dl, GPVR, Pair, T1.getValue(1));
286
287 AsmNodeOperands[InlineAsm::Op_InputChain] = Chain;
288 Glue = Chain.getValue(1);
289 }
290
291 Changed = true;
292
293 if(PairedReg.getNode()) {
294 OpChanged[OpChanged.size() -1 ] = true;
295 Flag = InlineAsm::getFlagWord(Kind, 1 /* RegNum*/);
296 if (IsTiedToChangedOp)
297 Flag = InlineAsm::getFlagWordForMatchingOp(Flag, DefIdx);
298 else
299 Flag = InlineAsm::getFlagWordForRegClass(Flag, SP::IntPairRegClassID);
300 // Replace the current flag.
301 AsmNodeOperands[AsmNodeOperands.size() -1] = CurDAG->getTargetConstant(
302 Flag, dl, MVT::i32);
303 // Add the new register node and skip the original two GPRs.
304 AsmNodeOperands.push_back(PairedReg);
305 // Skip the next two GPRs.
306 i += 2;
307 }
308 }
309
310 if (Glue.getNode())
311 AsmNodeOperands.push_back(Glue);
312 if (!Changed)
313 return nullptr;
314
315 SDValue New = CurDAG->getNode(ISD::INLINEASM, SDLoc(N),
316 CurDAG->getVTList(MVT::Other, MVT::Glue), AsmNodeOperands);
317 New->setNodeId(-1);
318 return New.getNode();
319}
320
Dan Gohmanea6f91f2010-01-05 01:24:18 +0000321SDNode *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);
Craig Topper062a2ba2014-04-25 05:30:21 +0000325 return nullptr; // 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;
James Y Knight3994be82015-08-10 19:11:39 +0000330 case ISD::INLINEASM: {
331 SDNode *ResNode = SelectInlineAsm(N);
332 if (ResNode)
333 return ResNode;
334 break;
335 }
Chris Lattner840c7002009-09-15 17:46:24 +0000336 case SPISD::GLOBAL_BASE_REG:
337 return getGlobalBaseReg();
338
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;
Owen Anderson9f944592009-08-11 20:47:22 +0000363 return CurDAG->SelectNodeTo(N, Opcode, MVT::i32, DivLHS, DivRHS,
Evan Cheng34b70ee2006-08-26 08:00:10 +0000364 TopPart);
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000365 }
Chris Lattner158e1f52006-02-05 05:50:24 +0000366 case ISD::MULHU:
367 case ISD::MULHS: {
368 // FIXME: Handle mul by immediate.
Dan Gohman2ce6f2a2008-07-27 21:46:04 +0000369 SDValue MulLHS = N->getOperand(0);
370 SDValue MulRHS = N->getOperand(1);
Chris Lattner158e1f52006-02-05 05:50:24 +0000371 unsigned Opcode = N->getOpcode() == ISD::MULHU ? SP::UMULrr : SP::SMULrr;
James Y Knightf238d172015-07-08 16:25:12 +0000372 SDNode *Mul =
373 CurDAG->getMachineNode(Opcode, dl, MVT::i32, MVT::i32, MulLHS, MulRHS);
374 SDValue ResultHigh = SDValue(Mul, 1);
375 ReplaceUses(SDValue(N, 0), ResultHigh);
376 return nullptr;
Chris Lattner158e1f52006-02-05 05:50:24 +0000377 }
Chris Lattner158e1f52006-02-05 05:50:24 +0000378 }
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000379
Dan Gohmanea6f91f2010-01-05 01:24:18 +0000380 return SelectCode(N);
Chris Lattner158e1f52006-02-05 05:50:24 +0000381}
382
383
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000384/// SelectInlineAsmMemoryOperand - Implement addressing mode selection for
385/// inline asm expressions.
386bool
387SparcDAGToDAGISel::SelectInlineAsmMemoryOperand(const SDValue &Op,
Daniel Sanders60f1db02015-03-13 12:45:09 +0000388 unsigned ConstraintID,
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000389 std::vector<SDValue> &OutOps) {
390 SDValue Op0, Op1;
Daniel Sanders60f1db02015-03-13 12:45:09 +0000391 switch (ConstraintID) {
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000392 default: return true;
Daniel Sandersb1fbaca2015-03-19 11:27:23 +0000393 case InlineAsm::Constraint_i:
Daniel Sanders60f1db02015-03-13 12:45:09 +0000394 case InlineAsm::Constraint_m: // memory
Chris Lattner0e023ea2010-09-21 20:31:19 +0000395 if (!SelectADDRrr(Op, Op0, Op1))
396 SelectADDRri(Op, Op0, Op1);
Anton Korobeynikov9aaaa402008-10-10 10:14:47 +0000397 break;
398 }
399
400 OutOps.push_back(Op0);
401 OutOps.push_back(Op1);
402 return false;
403}
404
Anton Korobeynikov1f9487b2008-10-10 10:14:15 +0000405/// createSparcISelDag - This pass converts a legalized DAG into a
Chris Lattner158e1f52006-02-05 05:50:24 +0000406/// SPARC-specific DAG, ready for instruction scheduling.
407///
Dan Gohman2c836cf2008-10-03 16:55:19 +0000408FunctionPass *llvm::createSparcISelDag(SparcTargetMachine &TM) {
Chris Lattner158e1f52006-02-05 05:50:24 +0000409 return new SparcDAGToDAGISel(TM);
410}