1 //===- BlackfinISelLowering.cpp - Blackfin DAG Lowering Implementation ----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the interfaces that Blackfin uses to lower LLVM code
11 // into a selection DAG.
13 //===----------------------------------------------------------------------===//
15 #include "BlackfinISelLowering.h"
16 #include "BlackfinTargetMachine.h"
17 #include "llvm/Function.h"
18 #include "llvm/CodeGen/CallingConvLower.h"
19 #include "llvm/CodeGen/MachineFrameInfo.h"
20 #include "llvm/CodeGen/MachineFunction.h"
21 #include "llvm/CodeGen/MachineInstrBuilder.h"
22 #include "llvm/CodeGen/MachineRegisterInfo.h"
23 #include "llvm/CodeGen/PseudoSourceValue.h"
24 #include "llvm/CodeGen/SelectionDAG.h"
25 #include "llvm/Target/TargetLoweringObjectFile.h"
26 #include "llvm/ADT/VectorExtras.h"
27 #include "llvm/Support/Debug.h"
31 //===----------------------------------------------------------------------===//
32 // Calling Convention Implementation
33 //===----------------------------------------------------------------------===//
35 #include "BlackfinGenCallingConv.inc"
37 //===----------------------------------------------------------------------===//
38 // TargetLowering Implementation
39 //===----------------------------------------------------------------------===//
41 BlackfinTargetLowering::BlackfinTargetLowering(TargetMachine &TM)
42 : TargetLowering(TM, new TargetLoweringObjectFileELF()) {
43 setShiftAmountType(MVT::i16);
44 setBooleanContents(ZeroOrOneBooleanContent);
45 setStackPointerRegisterToSaveRestore(BF::SP);
46 setIntDivIsCheap(false);
48 // Set up the legal register classes.
49 addRegisterClass(MVT::i32, BF::DRegisterClass);
50 addRegisterClass(MVT::i16, BF::D16RegisterClass);
52 computeRegisterProperties();
54 // Blackfin doesn't have i1 loads or stores
55 setLoadExtAction(ISD::EXTLOAD, MVT::i1, Promote);
56 setLoadExtAction(ISD::ZEXTLOAD, MVT::i1, Promote);
57 setLoadExtAction(ISD::SEXTLOAD, MVT::i1, Promote);
59 setOperationAction(ISD::GlobalAddress, MVT::i32, Custom);
60 setOperationAction(ISD::JumpTable, MVT::i32, Custom);
62 setOperationAction(ISD::SELECT_CC, MVT::Other, Expand);
63 setOperationAction(ISD::BR_JT, MVT::Other, Expand);
64 setOperationAction(ISD::BR_CC, MVT::Other, Expand);
66 // i16 registers don't do much
67 setOperationAction(ISD::AND, MVT::i16, Promote);
68 setOperationAction(ISD::OR, MVT::i16, Promote);
69 setOperationAction(ISD::XOR, MVT::i16, Promote);
70 setOperationAction(ISD::CTPOP, MVT::i16, Promote);
71 // The expansion of CTLZ/CTTZ uses AND/OR, so we might as well promote
73 setOperationAction(ISD::CTLZ, MVT::i16, Promote);
74 setOperationAction(ISD::CTTZ, MVT::i16, Promote);
75 setOperationAction(ISD::SETCC, MVT::i16, Promote);
77 // Blackfin has no division
78 setOperationAction(ISD::SDIV, MVT::i16, Expand);
79 setOperationAction(ISD::SDIV, MVT::i32, Expand);
80 setOperationAction(ISD::SDIVREM, MVT::i16, Expand);
81 setOperationAction(ISD::SDIVREM, MVT::i32, Expand);
82 setOperationAction(ISD::SREM, MVT::i16, Expand);
83 setOperationAction(ISD::SREM, MVT::i32, Expand);
84 setOperationAction(ISD::UDIV, MVT::i16, Expand);
85 setOperationAction(ISD::UDIV, MVT::i32, Expand);
86 setOperationAction(ISD::UDIVREM, MVT::i16, Expand);
87 setOperationAction(ISD::UDIVREM, MVT::i32, Expand);
88 setOperationAction(ISD::UREM, MVT::i16, Expand);
89 setOperationAction(ISD::UREM, MVT::i32, Expand);
91 setOperationAction(ISD::SMUL_LOHI, MVT::i32, Expand);
92 setOperationAction(ISD::UMUL_LOHI, MVT::i32, Expand);
93 setOperationAction(ISD::MULHU, MVT::i32, Expand);
94 setOperationAction(ISD::MULHS, MVT::i32, Expand);
96 // No carry-in operations.
97 setOperationAction(ISD::ADDE, MVT::i32, Custom);
98 setOperationAction(ISD::SUBE, MVT::i32, Custom);
100 // Blackfin has no intrinsics for these particular operations.
101 setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand);
102 setOperationAction(ISD::BSWAP, MVT::i32, Expand);
104 setOperationAction(ISD::SHL_PARTS, MVT::i32, Expand);
105 setOperationAction(ISD::SRA_PARTS, MVT::i32, Expand);
106 setOperationAction(ISD::SRL_PARTS, MVT::i32, Expand);
108 setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand);
110 // i32 has native CTPOP, but not CTLZ/CTTZ
111 setOperationAction(ISD::CTLZ, MVT::i32, Expand);
112 setOperationAction(ISD::CTTZ, MVT::i32, Expand);
114 // We don't have line number support yet.
115 setOperationAction(ISD::DBG_STOPPOINT, MVT::Other, Expand);
116 setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand);
117 setOperationAction(ISD::DBG_LABEL, MVT::Other, Expand);
118 setOperationAction(ISD::EH_LABEL, MVT::Other, Expand);
119 setOperationAction(ISD::DECLARE, MVT::Other, Expand);
121 // Use the default implementation.
122 setOperationAction(ISD::VACOPY, MVT::Other, Expand);
123 setOperationAction(ISD::VAEND, MVT::Other, Expand);
124 setOperationAction(ISD::STACKSAVE, MVT::Other, Expand);
125 setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand);
127 // RET must be custom lowered, to meet ABI requirements
128 setOperationAction(ISD::RET, MVT::Other, Custom);
131 const char *BlackfinTargetLowering::getTargetNodeName(unsigned Opcode) const {
134 case BFISD::CALL: return "BFISD::CALL";
135 case BFISD::RET_FLAG: return "BFISD::RET_FLAG";
136 case BFISD::Wrapper: return "BFISD::Wrapper";
140 MVT BlackfinTargetLowering::getSetCCResultType(MVT VT) const {
141 // SETCC always sets the CC register. Technically that is an i1 register, but
142 // that type is not legal, so we treat it as an i32 register.
146 SDValue BlackfinTargetLowering::LowerGlobalAddress(SDValue Op,
148 DebugLoc DL = Op.getDebugLoc();
149 GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
151 Op = DAG.getTargetGlobalAddress(GV, MVT::i32);
152 return DAG.getNode(BFISD::Wrapper, DL, MVT::i32, Op);
155 SDValue BlackfinTargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) {
156 DebugLoc DL = Op.getDebugLoc();
157 int JTI = cast<JumpTableSDNode>(Op)->getIndex();
159 Op = DAG.getTargetJumpTable(JTI, MVT::i32);
160 return DAG.getNode(BFISD::Wrapper, DL, MVT::i32, Op);
163 // FORMAL_ARGUMENTS(CHAIN, CC#, ISVARARG, FLAG0, ..., FLAGn) - This node
164 // represents the formal arguments for a function. CC# is a Constant value
165 // indicating the calling convention of the function, and ISVARARG is a
166 // flag that indicates whether the function is varargs or not. This node
167 // has one result value for each incoming argument, plus one for the output
169 SDValue BlackfinTargetLowering::LowerFORMAL_ARGUMENTS(SDValue Op,
171 DebugLoc dl = Op.getDebugLoc();
172 SDValue Root = Op.getOperand(0);
173 unsigned CC = Op.getConstantOperandVal(1);
174 bool isVarArg = Op.getConstantOperandVal(2);
175 MachineFunction &MF = DAG.getMachineFunction();
176 MachineFrameInfo *MFI = MF.getFrameInfo();
178 SmallVector<CCValAssign, 16> ArgLocs;
179 CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs, *DAG.getContext());
180 CCInfo.AllocateStack(12, 4); // ABI requires 12 bytes stack space
181 CCInfo.AnalyzeFormalArguments(Op.getNode(), CC_Blackfin);
183 SmallVector<SDValue, 8> ArgValues;
184 for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
185 CCValAssign &VA = ArgLocs[i];
188 MVT RegVT = VA.getLocVT();
189 TargetRegisterClass *RC = VA.getLocReg() == BF::P0 ?
190 BF::PRegisterClass : BF::DRegisterClass;
191 assert(RC->contains(VA.getLocReg()));
192 assert(RC->hasType(RegVT));
194 unsigned Reg = MF.getRegInfo().createVirtualRegister(RC);
195 MF.getRegInfo().addLiveIn(VA.getLocReg(), Reg);
196 SDValue ArgValue = DAG.getCopyFromReg(Root, dl, Reg, RegVT);
198 // If this is an 8 or 16-bit value, it is really passed promoted to 32
199 // bits. Insert an assert[sz]ext to capture this, then truncate to the
201 if (VA.getLocInfo() == CCValAssign::SExt)
202 ArgValue = DAG.getNode(ISD::AssertSext, dl, RegVT, ArgValue,
203 DAG.getValueType(VA.getValVT()));
204 else if (VA.getLocInfo() == CCValAssign::ZExt)
205 ArgValue = DAG.getNode(ISD::AssertZext, dl, RegVT, ArgValue,
206 DAG.getValueType(VA.getValVT()));
208 if (VA.getLocInfo() != CCValAssign::Full)
209 ArgValue = DAG.getNode(ISD::TRUNCATE, dl, VA.getValVT(), ArgValue);
211 ArgValues.push_back(ArgValue);
213 assert(VA.isMemLoc());
214 unsigned ObjSize = VA.getLocVT().getStoreSizeInBits()/8;
215 int FI = MFI->CreateFixedObject(ObjSize, VA.getLocMemOffset());
216 SDValue FIN = DAG.getFrameIndex(FI, MVT::i32);
217 ArgValues.push_back(DAG.getLoad(VA.getValVT(), dl, Root, FIN, NULL, 0));
221 ArgValues.push_back(Root);
223 // Return the new list of results.
224 return DAG.getNode(ISD::MERGE_VALUES, dl, Op.getNode()->getVTList(),
225 &ArgValues[0], ArgValues.size()).getValue(Op.getResNo());
228 SDValue BlackfinTargetLowering::LowerRET(SDValue Op, SelectionDAG &DAG) {
229 // CCValAssign - represent the assignment of the return value to locations.
230 SmallVector<CCValAssign, 16> RVLocs;
231 unsigned CC = DAG.getMachineFunction().getFunction()->getCallingConv();
232 bool isVarArg = DAG.getMachineFunction().getFunction()->isVarArg();
233 DebugLoc dl = Op.getDebugLoc();
235 // CCState - Info about the registers and stack slot.
236 CCState CCInfo(CC, isVarArg, DAG.getTarget(), RVLocs, *DAG.getContext());
238 // Analize return values of ISD::RET
239 CCInfo.AnalyzeReturn(Op.getNode(), RetCC_Blackfin);
241 // If this is the first return lowered for this function, add the regs to the
242 // liveout set for the function.
243 if (DAG.getMachineFunction().getRegInfo().liveout_empty()) {
244 for (unsigned i = 0; i != RVLocs.size(); ++i)
245 DAG.getMachineFunction().getRegInfo().addLiveOut(RVLocs[i].getLocReg());
248 SDValue Chain = Op.getOperand(0);
251 // Copy the result values into the output registers.
252 for (unsigned i = 0; i != RVLocs.size(); ++i) {
253 CCValAssign &VA = RVLocs[i];
254 assert(VA.isRegLoc() && "Can only return in registers!");
255 SDValue Opi = Op.getOperand(i*2+1);
257 // Expand to i32 if necessary
258 switch (VA.getLocInfo()) {
259 default: llvm_unreachable("Unknown loc info!");
260 case CCValAssign::Full: break;
261 case CCValAssign::SExt:
262 Opi = DAG.getNode(ISD::SIGN_EXTEND, dl, VA.getLocVT(), Opi);
264 case CCValAssign::ZExt:
265 Opi = DAG.getNode(ISD::ZERO_EXTEND, dl, VA.getLocVT(), Opi);
267 case CCValAssign::AExt:
268 Opi = DAG.getNode(ISD::ANY_EXTEND, dl, VA.getLocVT(), Opi);
271 // ISD::RET => ret chain, (regnum1,val1), ...
272 // So i*2+1 index only the regnums.
273 Chain = DAG.getCopyToReg(Chain, dl, VA.getLocReg(), Opi, SDValue());
274 // Guarantee that all emitted copies are stuck together with flags.
275 Flag = Chain.getValue(1);
278 if (Flag.getNode()) {
279 return DAG.getNode(BFISD::RET_FLAG, dl, MVT::Other, Chain, Flag);
281 return DAG.getNode(BFISD::RET_FLAG, dl, MVT::Other, Chain);
285 SDValue BlackfinTargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) {
286 CallSDNode *TheCall = cast<CallSDNode>(Op.getNode());
287 unsigned CallingConv = TheCall->getCallingConv();
288 SDValue Chain = TheCall->getChain();
289 SDValue Callee = TheCall->getCallee();
290 bool isVarArg = TheCall->isVarArg();
291 DebugLoc dl = TheCall->getDebugLoc();
293 // Analyze operands of the call, assigning locations to each operand.
294 SmallVector<CCValAssign, 16> ArgLocs;
295 CCState CCInfo(CallingConv, isVarArg, DAG.getTarget(), ArgLocs,
297 CCInfo.AllocateStack(12, 4); // ABI requires 12 bytes stack space
298 CCInfo.AnalyzeCallOperands(TheCall, CC_Blackfin);
300 // Get the size of the outgoing arguments stack space requirement.
301 unsigned ArgsSize = CCInfo.getNextStackOffset();
303 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(ArgsSize, true));
304 SmallVector<std::pair<unsigned, SDValue>, 8> RegsToPass;
305 SmallVector<SDValue, 8> MemOpChains;
307 // Walk the register/memloc assignments, inserting copies/loads.
308 for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
309 CCValAssign &VA = ArgLocs[i];
311 // Arguments start after the 5 first operands of ISD::CALL
312 SDValue Arg = TheCall->getArg(i);
314 // Promote the value if needed.
315 switch (VA.getLocInfo()) {
316 default: llvm_unreachable("Unknown loc info!");
317 case CCValAssign::Full: break;
318 case CCValAssign::SExt:
319 Arg = DAG.getNode(ISD::SIGN_EXTEND, dl, VA.getLocVT(), Arg);
321 case CCValAssign::ZExt:
322 Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, VA.getLocVT(), Arg);
324 case CCValAssign::AExt:
325 Arg = DAG.getNode(ISD::ANY_EXTEND, dl, VA.getLocVT(), Arg);
329 // Arguments that can be passed on register must be kept at
332 RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
334 assert(VA.isMemLoc());
335 int Offset = VA.getLocMemOffset();
336 assert(Offset%4 == 0);
337 assert(VA.getLocVT()==MVT::i32);
338 SDValue SPN = DAG.getCopyFromReg(Chain, dl, BF::SP, MVT::i32);
339 SDValue OffsetN = DAG.getIntPtrConstant(Offset);
340 OffsetN = DAG.getNode(ISD::ADD, dl, MVT::i32, SPN, OffsetN);
341 MemOpChains.push_back(DAG.getStore(Chain, dl, Arg, OffsetN,
342 PseudoSourceValue::getStack(),
347 // Transform all store nodes into one single node because
348 // all store nodes are independent of each other.
349 if (!MemOpChains.empty())
350 Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other,
351 &MemOpChains[0], MemOpChains.size());
353 // Build a sequence of copy-to-reg nodes chained together with token
354 // chain and flag operands which copy the outgoing args into registers.
355 // The InFlag in necessary since all emited instructions must be
358 for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
359 Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
360 RegsToPass[i].second, InFlag);
361 InFlag = Chain.getValue(1);
364 // If the callee is a GlobalAddress node (quite common, every direct call is)
365 // turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
366 // Likewise ExternalSymbol -> TargetExternalSymbol.
367 if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))
368 Callee = DAG.getTargetGlobalAddress(G->getGlobal(), MVT::i32);
369 else if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(Callee))
370 Callee = DAG.getTargetExternalSymbol(E->getSymbol(), MVT::i32);
372 std::vector<MVT> NodeTys;
373 NodeTys.push_back(MVT::Other); // Returns a chain
374 NodeTys.push_back(MVT::Flag); // Returns a flag for retval copy to use.
375 SDValue Ops[] = { Chain, Callee, InFlag };
376 Chain = DAG.getNode(BFISD::CALL, dl, NodeTys, Ops,
377 InFlag.getNode() ? 3 : 2);
378 InFlag = Chain.getValue(1);
380 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(ArgsSize, true),
381 DAG.getIntPtrConstant(0, true), InFlag);
382 InFlag = Chain.getValue(1);
384 // Assign locations to each value returned by this call.
385 SmallVector<CCValAssign, 16> RVLocs;
386 CCState RVInfo(CallingConv, isVarArg, DAG.getTarget(), RVLocs,
389 RVInfo.AnalyzeCallResult(TheCall, RetCC_Blackfin);
390 SmallVector<SDValue, 8> ResultVals;
392 // Copy all of the result registers out of their specified physreg.
393 for (unsigned i = 0; i != RVLocs.size(); ++i) {
394 CCValAssign &RV = RVLocs[i];
395 unsigned Reg = RV.getLocReg();
397 Chain = DAG.getCopyFromReg(Chain, dl, Reg,
398 RVLocs[i].getLocVT(), InFlag);
399 SDValue Val = Chain.getValue(0);
400 InFlag = Chain.getValue(2);
401 Chain = Chain.getValue(1);
403 // Callee is responsible for extending any i16 return values.
404 switch (RV.getLocInfo()) {
405 case CCValAssign::SExt:
406 Val = DAG.getNode(ISD::AssertSext, dl, RV.getLocVT(), Val,
407 DAG.getValueType(RV.getValVT()));
409 case CCValAssign::ZExt:
410 Val = DAG.getNode(ISD::AssertZext, dl, RV.getLocVT(), Val,
411 DAG.getValueType(RV.getValVT()));
417 // Truncate to valtype
418 if (RV.getLocInfo() != CCValAssign::Full)
419 Val = DAG.getNode(ISD::TRUNCATE, dl, RV.getValVT(), Val);
420 ResultVals.push_back(Val);
423 ResultVals.push_back(Chain);
425 // Merge everything together with a MERGE_VALUES node.
426 SDValue merge = DAG.getNode(ISD::MERGE_VALUES, dl,
427 TheCall->getVTList(), &ResultVals[0],
432 // Expansion of ADDE / SUBE. This is a bit involved since blackfin doesn't have
433 // add-with-carry instructions.
434 SDValue BlackfinTargetLowering::LowerADDE(SDValue Op, SelectionDAG &DAG) {
435 // Operands: lhs, rhs, carry-in (AC0 flag)
436 // Results: sum, carry-out (AC0 flag)
437 DebugLoc dl = Op.getDebugLoc();
439 unsigned Opcode = Op.getOpcode()==ISD::ADDE ? BF::ADD : BF::SUB;
441 // zext incoming carry flag in AC0 to 32 bits
442 SDNode* CarryIn = DAG.getTargetNode(BF::MOVE_cc_ac0, dl, MVT::i32,
443 /* flag= */ Op.getOperand(2));
444 CarryIn = DAG.getTargetNode(BF::MOVECC_zext, dl, MVT::i32,
445 SDValue(CarryIn, 0));
447 // Add operands, produce sum and carry flag
448 SDNode *Sum = DAG.getTargetNode(Opcode, dl, MVT::i32, MVT::Flag,
449 Op.getOperand(0), Op.getOperand(1));
451 // Store intermediate carry from Sum
452 SDNode* Carry1 = DAG.getTargetNode(BF::MOVE_cc_ac0, dl, MVT::i32,
453 /* flag= */ SDValue(Sum, 1));
455 // Add incoming carry, again producing an output flag
456 Sum = DAG.getTargetNode(Opcode, dl, MVT::i32, MVT::Flag,
457 SDValue(Sum, 0), SDValue(CarryIn, 0));
459 // Update AC0 with the intermediate carry, producing a flag.
460 SDNode *CarryOut = DAG.getTargetNode(BF::OR_ac0_cc, dl, MVT::Flag,
463 // Compose (i32, flag) pair
464 SDValue ops[2] = { SDValue(Sum, 0), SDValue(CarryOut, 0) };
465 return DAG.getMergeValues(ops, 2, dl);
468 SDValue BlackfinTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) {
469 switch (Op.getOpcode()) {
471 Op.getNode()->dump();
472 llvm_unreachable("Should not custom lower this!");
473 case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG);
474 case ISD::GlobalTLSAddress:
475 llvm_unreachable("TLS not implemented for Blackfin.");
476 case ISD::JumpTable: return LowerJumpTable(Op, DAG);
477 // Frame & Return address. Currently unimplemented
478 case ISD::FRAMEADDR: return SDValue();
479 case ISD::RETURNADDR: return SDValue();
480 case ISD::FORMAL_ARGUMENTS: return LowerFORMAL_ARGUMENTS(Op, DAG);
481 case ISD::CALL: return LowerCALL(Op, DAG);
482 case ISD::RET: return LowerRET(Op, DAG);
484 case ISD::SUBE: return LowerADDE(Op, DAG);
488 /// getFunctionAlignment - Return the Log2 alignment of this function.
489 unsigned BlackfinTargetLowering::getFunctionAlignment(const Function *F) const {
493 //===----------------------------------------------------------------------===//
494 // Blackfin Inline Assembly Support
495 //===----------------------------------------------------------------------===//
497 /// getConstraintType - Given a constraint letter, return the type of
498 /// constraint it is for this target.
499 BlackfinTargetLowering::ConstraintType
500 BlackfinTargetLowering::getConstraintType(const std::string &Constraint) const {
501 if (Constraint.size() != 1)
502 return TargetLowering::getConstraintType(Constraint);
504 switch (Constraint[0]) {
505 // Standard constraints
507 return C_RegisterClass;
509 // Blackfin-specific constraints
526 return C_RegisterClass;
535 // Not implemented: q0-q7, qA. Use {R2} etc instead
537 return TargetLowering::getConstraintType(Constraint);
540 /// getRegForInlineAsmConstraint - Return register no and class for a C_Register
542 std::pair<unsigned, const TargetRegisterClass*> BlackfinTargetLowering::
543 getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const {
544 typedef std::pair<unsigned, const TargetRegisterClass*> Pair;
547 if (Constraint.size() != 1)
548 return TargetLowering::getRegForInlineAsmConstraint(Constraint, VT);
550 switch (Constraint[0]) {
551 // Standard constraints
553 return Pair(0U, VT == MVT::i16 ? D16RegisterClass : DPRegisterClass);
555 // Blackfin-specific constraints
556 case 'a': return Pair(0U, PRegisterClass);
557 case 'd': return Pair(0U, DRegisterClass);
558 case 'e': return Pair(0U, AccuRegisterClass);
559 case 'A': return Pair(A0, AccuRegisterClass);
560 case 'B': return Pair(A1, AccuRegisterClass);
561 case 'b': return Pair(0U, IRegisterClass);
562 case 'v': return Pair(0U, BRegisterClass);
563 case 'f': return Pair(0U, MRegisterClass);
564 case 'C': return Pair(CC, JustCCRegisterClass);
565 case 'x': return Pair(0U, GRRegisterClass);
566 case 'w': return Pair(0U, ALLRegisterClass);
567 case 'Z': return Pair(P3, PRegisterClass);
568 case 'Y': return Pair(P1, PRegisterClass);
571 // Not implemented: q0-q7, qA. Use {R2} etc instead.
572 // Constraints z, D, W, c, t, u, k, and y use non-existing classes, defer to
573 // getRegClassForInlineAsmConstraint()
575 return TargetLowering::getRegForInlineAsmConstraint(Constraint, VT);
578 std::vector<unsigned> BlackfinTargetLowering::
579 getRegClassForInlineAsmConstraint(const std::string &Constraint, MVT VT) const {
582 if (Constraint.size() != 1)
583 return std::vector<unsigned>();
585 switch (Constraint[0]) {
586 case 'z': return make_vector<unsigned>(P0, P1, P2, 0);
587 case 'D': return make_vector<unsigned>(R0, R2, R4, R6, 0);
588 case 'W': return make_vector<unsigned>(R1, R3, R5, R7, 0);
589 case 'c': return make_vector<unsigned>(I0, I1, I2, I3,
592 case 't': return make_vector<unsigned>(LT0, LT1, 0);
593 case 'u': return make_vector<unsigned>(LB0, LB1, 0);
594 case 'k': return make_vector<unsigned>(LC0, LC1, 0);
595 case 'y': return make_vector<unsigned>(RETS, RETN, RETI, RETX, RETE,
596 ASTAT, SEQSTAT, USP, 0);
599 return std::vector<unsigned>();
602 bool BlackfinTargetLowering::
603 isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const {
604 // The Blackfin target isn't yet aware of offsets.