LLVM  14.0.0git
ARCISelLowering.cpp
Go to the documentation of this file.
1 //===- ARCISelLowering.cpp - ARC DAG Lowering Impl --------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the ARCTargetLowering class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "ARCISelLowering.h"
14 #include "ARC.h"
15 #include "ARCMachineFunctionInfo.h"
16 #include "ARCSubtarget.h"
17 #include "ARCTargetMachine.h"
18 #include "MCTargetDesc/ARCInfo.h"
26 #include "llvm/IR/CallingConv.h"
27 #include "llvm/IR/Intrinsics.h"
28 #include "llvm/Support/Debug.h"
29 #include <algorithm>
30 
31 #define DEBUG_TYPE "arc-lower"
32 
33 using namespace llvm;
34 
35 static SDValue lowerCallResult(SDValue Chain, SDValue InFlag,
36  const SmallVectorImpl<CCValAssign> &RVLocs,
37  SDLoc dl, SelectionDAG &DAG,
38  SmallVectorImpl<SDValue> &InVals);
39 
41  switch (isdCC) {
42  case ISD::SETUEQ:
43  return ARCCC::EQ;
44  case ISD::SETUGT:
45  return ARCCC::HI;
46  case ISD::SETUGE:
47  return ARCCC::HS;
48  case ISD::SETULT:
49  return ARCCC::LO;
50  case ISD::SETULE:
51  return ARCCC::LS;
52  case ISD::SETUNE:
53  return ARCCC::NE;
54  case ISD::SETEQ:
55  return ARCCC::EQ;
56  case ISD::SETGT:
57  return ARCCC::GT;
58  case ISD::SETGE:
59  return ARCCC::GE;
60  case ISD::SETLT:
61  return ARCCC::LT;
62  case ISD::SETLE:
63  return ARCCC::LE;
64  case ISD::SETNE:
65  return ARCCC::NE;
66  default:
67  llvm_unreachable("Unhandled ISDCC code.");
68  }
69 }
70 
71 void ARCTargetLowering::ReplaceNodeResults(SDNode *N,
73  SelectionDAG &DAG) const {
74  LLVM_DEBUG(dbgs() << "[ARC-ISEL] ReplaceNodeResults ");
75  LLVM_DEBUG(N->dump(&DAG));
76  LLVM_DEBUG(dbgs() << "; use_count=" << N->use_size() << "\n");
77 
78  switch (N->getOpcode()) {
80  if (N->getValueType(0) == MVT::i64) {
81  // We read the TIMER0 and zero-extend it to 64-bits as the intrinsic
82  // requires.
83  SDValue V =
85  DAG.getVTList(MVT::i32, MVT::Other), N->getOperand(0));
87  Results.push_back(Op);
88  Results.push_back(V.getValue(1));
89  }
90  break;
91  default:
92  break;
93  }
94 }
95 
97  const ARCSubtarget &Subtarget)
98  : TargetLowering(TM), Subtarget(Subtarget) {
99  // Set up the register classes.
100  addRegisterClass(MVT::i32, &ARC::GPR32RegClass);
101 
102  // Compute derived properties from the register classes
104 
106 
108 
109  // Use i32 for setcc operations results (slt, sgt, ...).
112 
113  for (unsigned Opc = 0; Opc < ISD::BUILTIN_OP_END; ++Opc)
115 
116  // Operations to get us off of the ground.
117  // Basic.
123 
128 
129  // Need barrel shifter.
134 
137 
138  // Need multiplier
144 
150 
151  // Have pseudo instruction for frame addresses.
153  // Custom lower global addresses.
155 
156  // Expand var-args ops.
161 
162  // Other expansions
165 
166  // Sign extend inreg
168 
169  // TODO: Predicate these with `options.hasBitScan() ? Legal : Expand`
170  // when the HasBitScan predicate is available.
173 
177 }
178 
179 const char *ARCTargetLowering::getTargetNodeName(unsigned Opcode) const {
180  switch (Opcode) {
181  case ARCISD::BL:
182  return "ARCISD::BL";
183  case ARCISD::CMOV:
184  return "ARCISD::CMOV";
185  case ARCISD::CMP:
186  return "ARCISD::CMP";
187  case ARCISD::BRcc:
188  return "ARCISD::BRcc";
189  case ARCISD::RET:
190  return "ARCISD::RET";
191  case ARCISD::GAWRAPPER:
192  return "ARCISD::GAWRAPPER";
193  }
194  return nullptr;
195 }
196 
197 //===----------------------------------------------------------------------===//
198 // Misc Lower Operation implementation
199 //===----------------------------------------------------------------------===//
200 
201 SDValue ARCTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const {
202  SDValue LHS = Op.getOperand(0);
203  SDValue RHS = Op.getOperand(1);
204  ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(4))->get();
205  SDValue TVal = Op.getOperand(2);
206  SDValue FVal = Op.getOperand(3);
207  SDLoc dl(Op);
208  ARCCC::CondCode ArcCC = ISDCCtoARCCC(CC);
209  assert(LHS.getValueType() == MVT::i32 && "Only know how to SELECT_CC i32");
210  SDValue Cmp = DAG.getNode(ARCISD::CMP, dl, MVT::Glue, LHS, RHS);
211  return DAG.getNode(ARCISD::CMOV, dl, TVal.getValueType(), TVal, FVal,
212  DAG.getConstant(ArcCC, dl, MVT::i32), Cmp);
213 }
214 
215 SDValue ARCTargetLowering::LowerSIGN_EXTEND_INREG(SDValue Op,
216  SelectionDAG &DAG) const {
217  SDValue Op0 = Op.getOperand(0);
218  SDLoc dl(Op);
219  assert(Op.getValueType() == MVT::i32 &&
220  "Unhandled target sign_extend_inreg.");
221  // These are legal
222  unsigned Width = cast<VTSDNode>(Op.getOperand(1))->getVT().getSizeInBits();
223  if (Width == 16 || Width == 8)
224  return Op;
225  if (Width >= 32) {
226  return {};
227  }
228  SDValue LS = DAG.getNode(ISD::SHL, dl, MVT::i32, Op0,
229  DAG.getConstant(32 - Width, dl, MVT::i32));
230  SDValue SR = DAG.getNode(ISD::SRA, dl, MVT::i32, LS,
231  DAG.getConstant(32 - Width, dl, MVT::i32));
232  return SR;
233 }
234 
235 SDValue ARCTargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) const {
236  SDValue Chain = Op.getOperand(0);
237  ISD::CondCode CC = cast<CondCodeSDNode>(Op.getOperand(1))->get();
238  SDValue LHS = Op.getOperand(2);
239  SDValue RHS = Op.getOperand(3);
240  SDValue Dest = Op.getOperand(4);
241  SDLoc dl(Op);
242  ARCCC::CondCode arcCC = ISDCCtoARCCC(CC);
243  assert(LHS.getValueType() == MVT::i32 && "Only know how to BR_CC i32");
244  return DAG.getNode(ARCISD::BRcc, dl, MVT::Other, Chain, Dest, LHS, RHS,
245  DAG.getConstant(arcCC, dl, MVT::i32));
246 }
247 
248 SDValue ARCTargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) const {
249  auto *N = cast<JumpTableSDNode>(Op);
250  SDValue GA = DAG.getTargetJumpTable(N->getIndex(), MVT::i32);
251  return DAG.getNode(ARCISD::GAWRAPPER, SDLoc(N), MVT::i32, GA);
252 }
253 
254 #include "ARCGenCallingConv.inc"
255 
256 //===----------------------------------------------------------------------===//
257 // Call Calling Convention Implementation
258 //===----------------------------------------------------------------------===//
259 
260 /// ARC call implementation
261 SDValue ARCTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
262  SmallVectorImpl<SDValue> &InVals) const {
263  SelectionDAG &DAG = CLI.DAG;
264  SDLoc &dl = CLI.DL;
266  SmallVectorImpl<SDValue> &OutVals = CLI.OutVals;
268  SDValue Chain = CLI.Chain;
269  SDValue Callee = CLI.Callee;
270  CallingConv::ID CallConv = CLI.CallConv;
271  bool IsVarArg = CLI.IsVarArg;
272  bool &IsTailCall = CLI.IsTailCall;
273 
274  IsTailCall = false; // Do not support tail calls yet.
275 
277  CCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), ArgLocs,
278  *DAG.getContext());
279 
280  CCInfo.AnalyzeCallOperands(Outs, CC_ARC);
281 
283  // Analyze return values to determine the number of bytes of stack required.
284  CCState RetCCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), RVLocs,
285  *DAG.getContext());
286  RetCCInfo.AllocateStack(CCInfo.getNextStackOffset(), Align(4));
287  RetCCInfo.AnalyzeCallResult(Ins, RetCC_ARC);
288 
289  // Get a count of how many bytes are to be pushed on the stack.
290  unsigned NumBytes = RetCCInfo.getNextStackOffset();
291  auto PtrVT = getPointerTy(DAG.getDataLayout());
292 
293  Chain = DAG.getCALLSEQ_START(Chain, NumBytes, 0, dl);
294 
296  SmallVector<SDValue, 12> MemOpChains;
297 
299  // Walk the register/memloc assignments, inserting copies/loads.
300  for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
301  CCValAssign &VA = ArgLocs[i];
302  SDValue Arg = OutVals[i];
303 
304  // Promote the value if needed.
305  switch (VA.getLocInfo()) {
306  default:
307  llvm_unreachable("Unknown loc info!");
308  case CCValAssign::Full:
309  break;
310  case CCValAssign::SExt:
311  Arg = DAG.getNode(ISD::SIGN_EXTEND, dl, VA.getLocVT(), Arg);
312  break;
313  case CCValAssign::ZExt:
314  Arg = DAG.getNode(ISD::ZERO_EXTEND, dl, VA.getLocVT(), Arg);
315  break;
316  case CCValAssign::AExt:
317  Arg = DAG.getNode(ISD::ANY_EXTEND, dl, VA.getLocVT(), Arg);
318  break;
319  }
320 
321  // Arguments that can be passed on register must be kept at
322  // RegsToPass vector
323  if (VA.isRegLoc()) {
324  RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg));
325  } else {
326  assert(VA.isMemLoc() && "Must be register or memory argument.");
327  if (!StackPtr.getNode())
328  StackPtr = DAG.getCopyFromReg(Chain, dl, ARC::SP,
329  getPointerTy(DAG.getDataLayout()));
330  // Calculate the stack position.
331  SDValue SOffset = DAG.getIntPtrConstant(VA.getLocMemOffset(), dl);
332  SDValue PtrOff = DAG.getNode(
333  ISD::ADD, dl, getPointerTy(DAG.getDataLayout()), StackPtr, SOffset);
334 
335  SDValue Store =
336  DAG.getStore(Chain, dl, Arg, PtrOff, MachinePointerInfo());
337  MemOpChains.push_back(Store);
338  IsTailCall = false;
339  }
340  }
341 
342  // Transform all store nodes into one single node because
343  // all store nodes are independent of each other.
344  if (!MemOpChains.empty())
345  Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, MemOpChains);
346 
347  // Build a sequence of copy-to-reg nodes chained together with token
348  // chain and flag operands which copy the outgoing args into registers.
349  // The InFlag in necessary since all emitted instructions must be
350  // stuck together.
351  SDValue Glue;
352  for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) {
353  Chain = DAG.getCopyToReg(Chain, dl, RegsToPass[i].first,
354  RegsToPass[i].second, Glue);
355  Glue = Chain.getValue(1);
356  }
357 
358  // If the callee is a GlobalAddress node (quite common, every direct call is)
359  // turn it into a TargetGlobalAddress node so that legalize doesn't hack it.
360  // Likewise ExternalSymbol -> TargetExternalSymbol.
361  bool IsDirect = true;
362  if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee))
363  Callee = DAG.getTargetGlobalAddress(G->getGlobal(), dl, MVT::i32);
364  else if (auto *E = dyn_cast<ExternalSymbolSDNode>(Callee))
365  Callee = DAG.getTargetExternalSymbol(E->getSymbol(), MVT::i32);
366  else
367  IsDirect = false;
368  // Branch + Link = #chain, #target_address, #opt_in_flags...
369  // = Chain, Callee, Reg#1, Reg#2, ...
370  //
371  // Returns a chain & a flag for retval copy to use.
372  SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue);
374  Ops.push_back(Chain);
375  Ops.push_back(Callee);
376 
377  for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i)
378  Ops.push_back(DAG.getRegister(RegsToPass[i].first,
379  RegsToPass[i].second.getValueType()));
380 
381  // Add a register mask operand representing the call-preserved registers.
382  const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();
383  const uint32_t *Mask =
384  TRI->getCallPreservedMask(DAG.getMachineFunction(), CallConv);
385  assert(Mask && "Missing call preserved mask for calling convention");
386  Ops.push_back(DAG.getRegisterMask(Mask));
387 
388  if (Glue.getNode())
389  Ops.push_back(Glue);
390 
391  Chain = DAG.getNode(IsDirect ? ARCISD::BL : ARCISD::JL, dl, NodeTys, Ops);
392  Glue = Chain.getValue(1);
393 
394  // Create the CALLSEQ_END node.
395  Chain = DAG.getCALLSEQ_END(Chain, DAG.getConstant(NumBytes, dl, PtrVT, true),
396  DAG.getConstant(0, dl, PtrVT, true), Glue, dl);
397  Glue = Chain.getValue(1);
398 
399  // Handle result values, copying them out of physregs into vregs that we
400  // return.
401  if (IsTailCall)
402  return Chain;
403  return lowerCallResult(Chain, Glue, RVLocs, dl, DAG, InVals);
404 }
405 
406 /// Lower the result values of a call into the appropriate copies out of
407 /// physical registers / memory locations.
409  const SmallVectorImpl<CCValAssign> &RVLocs,
410  SDLoc dl, SelectionDAG &DAG,
411  SmallVectorImpl<SDValue> &InVals) {
412  SmallVector<std::pair<int, unsigned>, 4> ResultMemLocs;
413  // Copy results out of physical registers.
414  for (unsigned i = 0, e = RVLocs.size(); i != e; ++i) {
415  const CCValAssign &VA = RVLocs[i];
416  if (VA.isRegLoc()) {
417  SDValue RetValue;
418  RetValue =
419  DAG.getCopyFromReg(Chain, dl, VA.getLocReg(), VA.getValVT(), Glue);
420  Chain = RetValue.getValue(1);
421  Glue = RetValue.getValue(2);
422  InVals.push_back(RetValue);
423  } else {
424  assert(VA.isMemLoc() && "Must be memory location.");
425  ResultMemLocs.push_back(
426  std::make_pair(VA.getLocMemOffset(), InVals.size()));
427 
428  // Reserve space for this result.
429  InVals.push_back(SDValue());
430  }
431  }
432 
433  // Copy results out of memory.
434  SmallVector<SDValue, 4> MemOpChains;
435  for (unsigned i = 0, e = ResultMemLocs.size(); i != e; ++i) {
436  int Offset = ResultMemLocs[i].first;
437  unsigned Index = ResultMemLocs[i].second;
438  SDValue StackPtr = DAG.getRegister(ARC::SP, MVT::i32);
439  SDValue SpLoc = DAG.getNode(ISD::ADD, dl, MVT::i32, StackPtr,
440  DAG.getConstant(Offset, dl, MVT::i32));
441  SDValue Load =
442  DAG.getLoad(MVT::i32, dl, Chain, SpLoc, MachinePointerInfo());
443  InVals[Index] = Load;
444  MemOpChains.push_back(Load.getValue(1));
445  }
446 
447  // Transform all loads nodes into one single node because
448  // all load nodes are independent of each other.
449  if (!MemOpChains.empty())
450  Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, MemOpChains);
451 
452  return Chain;
453 }
454 
455 //===----------------------------------------------------------------------===//
456 // Formal Arguments Calling Convention Implementation
457 //===----------------------------------------------------------------------===//
458 
459 namespace {
460 
461 struct ArgDataPair {
462  SDValue SDV;
463  ISD::ArgFlagsTy Flags;
464 };
465 
466 } // end anonymous namespace
467 
468 /// ARC formal arguments implementation
469 SDValue ARCTargetLowering::LowerFormalArguments(
470  SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
471  const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &dl,
472  SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const {
473  switch (CallConv) {
474  default:
475  llvm_unreachable("Unsupported calling convention");
476  case CallingConv::C:
477  case CallingConv::Fast:
478  return LowerCallArguments(Chain, CallConv, IsVarArg, Ins, dl, DAG, InVals);
479  }
480 }
481 
482 /// Transform physical registers into virtual registers, and generate load
483 /// operations for argument places on the stack.
484 SDValue ARCTargetLowering::LowerCallArguments(
485  SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
487  SmallVectorImpl<SDValue> &InVals) const {
489  MachineFrameInfo &MFI = MF.getFrameInfo();
490  MachineRegisterInfo &RegInfo = MF.getRegInfo();
491  auto *AFI = MF.getInfo<ARCFunctionInfo>();
492 
493  // Assign locations to all of the incoming arguments.
495  CCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), ArgLocs,
496  *DAG.getContext());
497 
498  CCInfo.AnalyzeFormalArguments(Ins, CC_ARC);
499 
500  unsigned StackSlotSize = 4;
501 
502  if (!IsVarArg)
503  AFI->setReturnStackOffset(CCInfo.getNextStackOffset());
504 
505  // All getCopyFromReg ops must precede any getMemcpys to prevent the
506  // scheduler clobbering a register before it has been copied.
507  // The stages are:
508  // 1. CopyFromReg (and load) arg & vararg registers.
509  // 2. Chain CopyFromReg nodes into a TokenFactor.
510  // 3. Memcpy 'byVal' args & push final InVals.
511  // 4. Chain mem ops nodes into a TokenFactor.
512  SmallVector<SDValue, 4> CFRegNode;
515 
516  // 1a. CopyFromReg (and load) arg registers.
517  for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
518  CCValAssign &VA = ArgLocs[i];
519  SDValue ArgIn;
520 
521  if (VA.isRegLoc()) {
522  // Arguments passed in registers
523  EVT RegVT = VA.getLocVT();
524  switch (RegVT.getSimpleVT().SimpleTy) {
525  default: {
526  LLVM_DEBUG(errs() << "LowerFormalArguments Unhandled argument type: "
527  << (unsigned)RegVT.getSimpleVT().SimpleTy << "\n");
528  llvm_unreachable("Unhandled LowerFormalArguments type.");
529  }
530  case MVT::i32:
531  unsigned VReg = RegInfo.createVirtualRegister(&ARC::GPR32RegClass);
532  RegInfo.addLiveIn(VA.getLocReg(), VReg);
533  ArgIn = DAG.getCopyFromReg(Chain, dl, VReg, RegVT);
534  CFRegNode.push_back(ArgIn.getValue(ArgIn->getNumValues() - 1));
535  }
536  } else {
537  // sanity check
538  assert(VA.isMemLoc());
539  // Load the argument to a virtual register
540  unsigned ObjSize = VA.getLocVT().getStoreSize();
541  assert((ObjSize <= StackSlotSize) && "Unhandled argument");
542 
543  // Create the frame index object for this incoming parameter...
544  int FI = MFI.CreateFixedObject(ObjSize, VA.getLocMemOffset(), true);
545 
546  // Create the SelectionDAG nodes corresponding to a load
547  // from this parameter
548  SDValue FIN = DAG.getFrameIndex(FI, MVT::i32);
549  ArgIn = DAG.getLoad(VA.getLocVT(), dl, Chain, FIN,
551  }
552  const ArgDataPair ADP = {ArgIn, Ins[i].Flags};
553  ArgData.push_back(ADP);
554  }
555 
556  // 1b. CopyFromReg vararg registers.
557  if (IsVarArg) {
558  // Argument registers
559  static const MCPhysReg ArgRegs[] = {ARC::R0, ARC::R1, ARC::R2, ARC::R3,
560  ARC::R4, ARC::R5, ARC::R6, ARC::R7};
561  auto *AFI = MF.getInfo<ARCFunctionInfo>();
562  unsigned FirstVAReg = CCInfo.getFirstUnallocated(ArgRegs);
563  if (FirstVAReg < array_lengthof(ArgRegs)) {
564  int Offset = 0;
565  // Save remaining registers, storing higher register numbers at a higher
566  // address
567  // There are (array_lengthof(ArgRegs) - FirstVAReg) registers which
568  // need to be saved.
569  int VarFI =
570  MFI.CreateFixedObject((array_lengthof(ArgRegs) - FirstVAReg) * 4,
571  CCInfo.getNextStackOffset(), true);
572  AFI->setVarArgsFrameIndex(VarFI);
573  SDValue FIN = DAG.getFrameIndex(VarFI, MVT::i32);
574  for (unsigned i = FirstVAReg; i < array_lengthof(ArgRegs); i++) {
575  // Move argument from phys reg -> virt reg
576  unsigned VReg = RegInfo.createVirtualRegister(&ARC::GPR32RegClass);
577  RegInfo.addLiveIn(ArgRegs[i], VReg);
578  SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i32);
579  CFRegNode.push_back(Val.getValue(Val->getNumValues() - 1));
580  SDValue VAObj = DAG.getNode(ISD::ADD, dl, MVT::i32, FIN,
581  DAG.getConstant(Offset, dl, MVT::i32));
582  // Move argument from virt reg -> stack
583  SDValue Store =
584  DAG.getStore(Val.getValue(1), dl, Val, VAObj, MachinePointerInfo());
585  MemOps.push_back(Store);
586  Offset += 4;
587  }
588  } else {
589  llvm_unreachable("Too many var args parameters.");
590  }
591  }
592 
593  // 2. Chain CopyFromReg nodes into a TokenFactor.
594  if (!CFRegNode.empty())
595  Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, CFRegNode);
596 
597  // 3. Memcpy 'byVal' args & push final InVals.
598  // Aggregates passed "byVal" need to be copied by the callee.
599  // The callee will use a pointer to this copy, rather than the original
600  // pointer.
601  for (const auto &ArgDI : ArgData) {
602  if (ArgDI.Flags.isByVal() && ArgDI.Flags.getByValSize()) {
603  unsigned Size = ArgDI.Flags.getByValSize();
604  Align Alignment =
605  std::max(Align(StackSlotSize), ArgDI.Flags.getNonZeroByValAlign());
606  // Create a new object on the stack and copy the pointee into it.
607  int FI = MFI.CreateStackObject(Size, Alignment, false);
608  SDValue FIN = DAG.getFrameIndex(FI, MVT::i32);
609  InVals.push_back(FIN);
610  MemOps.push_back(DAG.getMemcpy(
611  Chain, dl, FIN, ArgDI.SDV, DAG.getConstant(Size, dl, MVT::i32),
612  Alignment, false, false, false, MachinePointerInfo(),
613  MachinePointerInfo()));
614  } else {
615  InVals.push_back(ArgDI.SDV);
616  }
617  }
618 
619  // 4. Chain mem ops nodes into a TokenFactor.
620  if (!MemOps.empty()) {
621  MemOps.push_back(Chain);
622  Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, MemOps);
623  }
624 
625  return Chain;
626 }
627 
628 //===----------------------------------------------------------------------===//
629 // Return Value Calling Convention Implementation
630 //===----------------------------------------------------------------------===//
631 
632 bool ARCTargetLowering::CanLowerReturn(
633  CallingConv::ID CallConv, MachineFunction &MF, bool IsVarArg,
636  CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
637  if (!CCInfo.CheckReturn(Outs, RetCC_ARC))
638  return false;
639  if (CCInfo.getNextStackOffset() != 0 && IsVarArg)
640  return false;
641  return true;
642 }
643 
644 SDValue
645 ARCTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv,
646  bool IsVarArg,
648  const SmallVectorImpl<SDValue> &OutVals,
649  const SDLoc &dl, SelectionDAG &DAG) const {
650  auto *AFI = DAG.getMachineFunction().getInfo<ARCFunctionInfo>();
652 
653  // CCValAssign - represent the assignment of
654  // the return value to a location
656 
657  // CCState - Info about the registers and stack slot.
658  CCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), RVLocs,
659  *DAG.getContext());
660 
661  // Analyze return values.
662  if (!IsVarArg)
663  CCInfo.AllocateStack(AFI->getReturnStackOffset(), Align(4));
664 
665  CCInfo.AnalyzeReturn(Outs, RetCC_ARC);
666 
667  SDValue Flag;
668  SmallVector<SDValue, 4> RetOps(1, Chain);
669  SmallVector<SDValue, 4> MemOpChains;
670  // Handle return values that must be copied to memory.
671  for (unsigned i = 0, e = RVLocs.size(); i != e; ++i) {
672  CCValAssign &VA = RVLocs[i];
673  if (VA.isRegLoc())
674  continue;
675  assert(VA.isMemLoc());
676  if (IsVarArg) {
677  report_fatal_error("Can't return value from vararg function in memory");
678  }
679 
680  int Offset = VA.getLocMemOffset();
681  unsigned ObjSize = VA.getLocVT().getStoreSize();
682  // Create the frame index object for the memory location.
683  int FI = MFI.CreateFixedObject(ObjSize, Offset, false);
684 
685  // Create a SelectionDAG node corresponding to a store
686  // to this memory location.
687  SDValue FIN = DAG.getFrameIndex(FI, MVT::i32);
688  MemOpChains.push_back(DAG.getStore(
689  Chain, dl, OutVals[i], FIN,
691  }
692 
693  // Transform all store nodes into one single node because
694  // all stores are independent of each other.
695  if (!MemOpChains.empty())
696  Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, MemOpChains);
697 
698  // Now handle return values copied to registers.
699  for (unsigned i = 0, e = RVLocs.size(); i != e; ++i) {
700  CCValAssign &VA = RVLocs[i];
701  if (!VA.isRegLoc())
702  continue;
703  // Copy the result values into the output registers.
704  Chain = DAG.getCopyToReg(Chain, dl, VA.getLocReg(), OutVals[i], Flag);
705 
706  // guarantee that all emitted copies are
707  // stuck together, avoiding something bad
708  Flag = Chain.getValue(1);
709  RetOps.push_back(DAG.getRegister(VA.getLocReg(), VA.getLocVT()));
710  }
711 
712  RetOps[0] = Chain; // Update chain.
713 
714  // Add the flag if we have it.
715  if (Flag.getNode())
716  RetOps.push_back(Flag);
717 
718  // What to do with the RetOps?
719  return DAG.getNode(ARCISD::RET, dl, MVT::Other, RetOps);
720 }
721 
722 //===----------------------------------------------------------------------===//
723 // Target Optimization Hooks
724 //===----------------------------------------------------------------------===//
725 
726 SDValue ARCTargetLowering::PerformDAGCombine(SDNode *N,
727  DAGCombinerInfo &DCI) const {
728  return {};
729 }
730 
731 //===----------------------------------------------------------------------===//
732 // Addressing mode description hooks
733 //===----------------------------------------------------------------------===//
734 
735 /// Return true if the addressing mode represented by AM is legal for this
736 /// target, for a load/store of the specified type.
738  const AddrMode &AM, Type *Ty,
739  unsigned AS,
740  Instruction *I) const {
741  return AM.Scale == 0;
742 }
743 
744 // Don't emit tail calls for the time being.
745 bool ARCTargetLowering::mayBeEmittedAsTailCall(const CallInst *CI) const {
746  return false;
747 }
748 
749 SDValue ARCTargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const {
750  const ARCRegisterInfo &ARI = *Subtarget.getRegisterInfo();
752  MachineFrameInfo &MFI = MF.getFrameInfo();
753  MFI.setFrameAddressIsTaken(true);
754 
755  EVT VT = Op.getValueType();
756  SDLoc dl(Op);
757  assert(cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue() == 0 &&
758  "Only support lowering frame addr of current frame.");
759  Register FrameReg = ARI.getFrameRegister(MF);
760  return DAG.getCopyFromReg(DAG.getEntryNode(), dl, FrameReg, VT);
761 }
762 
763 SDValue ARCTargetLowering::LowerGlobalAddress(SDValue Op,
764  SelectionDAG &DAG) const {
765  const GlobalAddressSDNode *GN = cast<GlobalAddressSDNode>(Op);
766  const GlobalValue *GV = GN->getGlobal();
767  SDLoc dl(GN);
768  int64_t Offset = GN->getOffset();
769  SDValue GA = DAG.getTargetGlobalAddress(GV, dl, MVT::i32, Offset);
770  return DAG.getNode(ARCISD::GAWRAPPER, dl, MVT::i32, GA);
771 }
772 
775  auto *FuncInfo = MF.getInfo<ARCFunctionInfo>();
776 
777  // vastart just stores the address of the VarArgsFrameIndex slot into the
778  // memory location argument.
779  SDLoc dl(Op);
781  SDValue FR = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), PtrVT);
782  const Value *SV = cast<SrcValueSDNode>(Op.getOperand(2))->getValue();
783  return DAG.getStore(Op.getOperand(0), dl, FR, Op.getOperand(1),
784  MachinePointerInfo(SV));
785 }
786 
788  switch (Op.getOpcode()) {
789  case ISD::GlobalAddress:
790  return LowerGlobalAddress(Op, DAG);
791  case ISD::FRAMEADDR:
792  return LowerFRAMEADDR(Op, DAG);
793  case ISD::SELECT_CC:
794  return LowerSELECT_CC(Op, DAG);
795  case ISD::BR_CC:
796  return LowerBR_CC(Op, DAG);
798  return LowerSIGN_EXTEND_INREG(Op, DAG);
799  case ISD::JumpTable:
800  return LowerJumpTable(Op, DAG);
801  case ISD::VASTART:
802  return LowerVASTART(Op, DAG);
804  // As of LLVM 3.8, the lowering code insists that we customize it even
805  // though we've declared the i32 version as legal. This is because it only
806  // thinks i64 is the truly supported version. We've already converted the
807  // i64 version to a widened i32.
808  assert(Op.getSimpleValueType() == MVT::i32);
809  return Op;
810  default:
811  llvm_unreachable("unimplemented operand");
812  }
813 }
llvm::CallingConv::C
@ C
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
llvm::ISD::SUB
@ SUB
Definition: ISDOpcodes.h:240
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::CCValAssign::getLocVT
MVT getLocVT() const
Definition: CallingConvLower.h:153
llvm::MachineRegisterInfo::addLiveIn
void addLiveIn(MCRegister Reg, Register vreg=Register())
addLiveIn - Add the specified register as a live-in.
Definition: MachineRegisterInfo.h:944
i
i
Definition: README.txt:29
llvm::ISD::SETUGE
@ SETUGE
Definition: ISDOpcodes.h:1368
llvm::CCValAssign::ZExt
@ ZExt
Definition: CallingConvLower.h:38
ValueTypes.h
llvm::TargetLoweringBase::setSchedulingPreference
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
Definition: TargetLowering.h:2134
llvm::SelectionDAG::getCALLSEQ_START
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
Definition: SelectionDAG.h:923
llvm::ISD::SETLE
@ SETLE
Definition: ISDOpcodes.h:1379
llvm::MVT::getStoreSize
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
Definition: MachineValueType.h:1072
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::ISD::JumpTable
@ JumpTable
Definition: ISDOpcodes.h:81
llvm::SDLoc
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Definition: SelectionDAGNodes.h:1086
llvm::CCValAssign::Full
@ Full
Definition: CallingConvLower.h:36
llvm::TargetLoweringBase::Legal
@ Legal
Definition: TargetLowering.h:197
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::ISD::SETGT
@ SETGT
Definition: ISDOpcodes.h:1376
llvm::ISD::SETNE
@ SETNE
Definition: ISDOpcodes.h:1380
llvm::MachineRegisterInfo::createVirtualRegister
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
Definition: MachineRegisterInfo.cpp:158
llvm::ISD::BR_JT
@ BR_JT
BR_JT - Jumptable branch.
Definition: ISDOpcodes.h:946
llvm::CCState
CCState - This class holds information needed while lowering arguments and return values.
Definition: CallingConvLower.h:191
llvm::SelectionDAG::getCopyToReg
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
Definition: SelectionDAG.h:735
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
llvm::SDValue::getNode
SDNode * getNode() const
get the SDNode which holds the desired result
Definition: SelectionDAGNodes.h:152
llvm::ISD::ADDC
@ ADDC
Carry-setting nodes for multiple precision addition and subtraction.
Definition: ISDOpcodes.h:269
llvm::SelectionDAG::getFrameIndex
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
Definition: SelectionDAG.cpp:1603
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::ISD::SETEQ
@ SETEQ
Definition: ISDOpcodes.h:1375
llvm::ISD::STACKRESTORE
@ STACKRESTORE
STACKRESTORE has two operands, an input chain and a pointer to restore to it returns an output chain.
Definition: ISDOpcodes.h:1012
llvm::SelectionDAG::getVTList
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
Definition: SelectionDAG.cpp:8551
llvm::ARCISD::GAWRAPPER
@ GAWRAPPER
Definition: ARCISelLowering.h:49
llvm::ARCISD::BRcc
@ BRcc
Definition: ARCISelLowering.h:46
llvm::ISD::ANY_EXTEND
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition: ISDOpcodes.h:732
llvm::SDNode
Represents one node in the SelectionDAG.
Definition: SelectionDAGNodes.h:455
llvm::ARCCC::NE
@ NE
Definition: ARCInfo.h:27
llvm::MVT::Glue
@ Glue
Definition: MachineValueType.h:262
llvm::ARCCC::LE
@ LE
Definition: ARCInfo.h:37
R4
#define R4(n)
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:233
ARCSubtarget.h
llvm::ISD::SETULE
@ SETULE
Definition: ISDOpcodes.h:1370
MachineJumpTableInfo.h
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::SelectionDAG::getStore
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
Definition: SelectionDAG.cpp:7512
ARCISelLowering.h
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
Results
Function Alias Analysis Results
Definition: AliasAnalysis.cpp:847
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:892
llvm::codeview::EncodedFramePtrReg::StackPtr
@ StackPtr
llvm::ISD::VAEND
@ VAEND
VAEND, VASTART - VAEND and VASTART have three operands: an input chain, pointer, and a SRCVALUE.
Definition: ISDOpcodes.h:1041
llvm::ARCRegisterInfo::getFrameRegister
Register getFrameRegister(const MachineFunction &MF) const override
Definition: ARCRegisterInfo.cpp:221
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
llvm::ARCISD::BL
@ BL
Definition: ARCISelLowering.h:34
llvm::ISD::SETUEQ
@ SETUEQ
Definition: ISDOpcodes.h:1366
llvm::ISD::SMAX
@ SMAX
Definition: ISDOpcodes.h:627
llvm::SelectionDAG::getContext
LLVMContext * getContext() const
Definition: SelectionDAG.h:447
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
llvm::ARCCC::LS
@ LS
Definition: ARCInfo.h:39
llvm::ISD::BRCOND
@ BRCOND
BRCOND - Conditional branch.
Definition: ISDOpcodes.h:956
MachineRegisterInfo.h
llvm::SelectionDAG::getRegister
SDValue getRegister(unsigned Reg, EVT VT)
Definition: SelectionDAG.cpp:1985
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:206
llvm::ISD::BR_CC
@ BR_CC
BR_CC - Conditional branch.
Definition: ISDOpcodes.h:963
llvm::SelectionDAG::getLoad
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands,...
Definition: SelectionDAG.cpp:7462
R2
#define R2(n)
llvm::MVT::i1
@ i1
Definition: MachineValueType.h:43
llvm::TargetLowering::CallLoweringInfo::IsVarArg
bool IsVarArg
Definition: TargetLowering.h:3752
llvm::MachineFunction::getRegInfo
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Definition: MachineFunction.h:636
llvm::CCValAssign::AExt
@ AExt
Definition: CallingConvLower.h:39
LowerVASTART
static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG)
Definition: ARCISelLowering.cpp:773
llvm::ISD::GlobalAddress
@ GlobalAddress
Definition: ISDOpcodes.h:78
llvm::ISD::SELECT_CC
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
Definition: ISDOpcodes.h:694
llvm::SDValue::getValueType
EVT getValueType() const
Return the ValueType of the referenced return value.
Definition: SelectionDAGNodes.h:1121
llvm::CCValAssign
CCValAssign - Represent assignment of one arg/retval to a location.
Definition: CallingConvLower.h:33
llvm::ISD::CTLZ
@ CTLZ
Definition: ISDOpcodes.h:668
llvm::SelectionDAG
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:216
llvm::ARCCC::GT
@ GT
Definition: ARCInfo.h:34
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:76
llvm::ISD::ZERO_EXTEND
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Definition: ISDOpcodes.h:729
llvm::ARCTargetLowering::LowerOperation
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
Provide custom lowering hooks for some operations.
Definition: ARCISelLowering.cpp:787
llvm::ISD::SETGE
@ SETGE
Definition: ISDOpcodes.h:1377
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::CCValAssign::getLocReg
Register getLocReg() const
Definition: CallingConvLower.h:150
llvm::MachineFunction::getInfo
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Definition: MachineFunction.h:724
llvm::ISD::SIGN_EXTEND_INREG
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
Definition: ISDOpcodes.h:747
llvm::ARCSubtarget
Definition: ARCSubtarget.h:31
llvm::SelectionDAG::getTargetLoweringInfo
const TargetLowering & getTargetLoweringInfo() const
Definition: SelectionDAG.h:443
llvm::EVT
Extended Value Type.
Definition: ValueTypes.h:35
Intrinsics.h
llvm::SelectionDAG::getConstant
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
Definition: SelectionDAG.cpp:1373
llvm::TargetLowering
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Definition: TargetLowering.h:3189
llvm::MVT::SimpleTy
SimpleValueType SimpleTy
Definition: MachineValueType.h:321
llvm::ISD::SRA
@ SRA
Definition: ISDOpcodes.h:658
llvm::TargetLoweringBase::addRegisterClass
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
Definition: TargetLowering.h:2181
llvm::Instruction
Definition: Instruction.h:45
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:146
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:140
llvm::ISD::AND
@ AND
Bitwise operators - logical and, logical or, logical xor.
Definition: ISDOpcodes.h:632
llvm::CCValAssign::getLocInfo
LocInfo getLocInfo() const
Definition: CallingConvLower.h:155
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::GlobalAddressSDNode::getGlobal
const GlobalValue * getGlobal() const
Definition: SelectionDAGNodes.h:1730
ARCInfo.h
llvm::CCValAssign::getLocMemOffset
unsigned getLocMemOffset() const
Definition: CallingConvLower.h:151
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::TargetLoweringBase::setBooleanVectorContents
void setBooleanVectorContents(BooleanContent Ty)
Specify how the target extends the result of a vector boolean value from a vector of i1 to a wider ty...
Definition: TargetLowering.h:2129
llvm::ARCISD::JL
@ JL
Definition: ARCISelLowering.h:37
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
llvm::array_lengthof
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
Definition: STLExtras.h:1390
llvm::CCValAssign::isRegLoc
bool isRegLoc() const
Definition: CallingConvLower.h:145
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::ARCTargetLowering::isLegalAddressingMode
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
Return true if the addressing mode represented by AM is legal for this target, for a load/store of th...
Definition: ARCISelLowering.cpp:737
llvm::ISD::SETUGT
@ SETUGT
Definition: ISDOpcodes.h:1367
llvm::SelectionDAG::getTargetGlobalAddress
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
Definition: SelectionDAG.h:683
llvm::TargetLowering::CallLoweringInfo::Outs
SmallVector< ISD::OutputArg, 32 > Outs
Definition: TargetLowering.h:3775
llvm::ISD::SETUNE
@ SETUNE
Definition: ISDOpcodes.h:1371
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::TargetLoweringBase::setOperationAction
void setOperationAction(unsigned Op, MVT VT, LegalizeAction Action)
Indicate that the specified operation does not work with the specified type and indicate what to do a...
Definition: TargetLowering.h:2198
llvm::ISD::SMIN
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
Definition: ISDOpcodes.h:626
ARCMachineFunctionInfo.h
llvm::ARCCC::EQ
@ EQ
Definition: ARCInfo.h:26
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::CCValAssign::SExt
@ SExt
Definition: CallingConvLower.h:37
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::TargetLoweringBase::isTypeLegal
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
Definition: TargetLowering.h:895
llvm::ARCCC::LO
@ LO
Definition: ARCInfo.h:30
llvm::ISD::LOAD
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
Definition: ISDOpcodes.h:921
llvm::TargetLowering::CallLoweringInfo::Chain
SDValue Chain
Definition: TargetLowering.h:3748
llvm::SelectionDAG::getIntPtrConstant
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
Definition: SelectionDAG.cpp:1496
llvm::MachinePointerInfo
This class contains a discriminated union of information about pointers in memory operands,...
Definition: MachineMemOperand.h:38
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::SelectionDAG::getCopyFromReg
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
Definition: SelectionDAG.h:761
llvm::TargetLowering::CallLoweringInfo::CallConv
CallingConv::ID CallConv
Definition: TargetLowering.h:3769
llvm::TargetLoweringBase::setStackPointerRegisterToSaveRestore
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
Definition: TargetLowering.h:2147
llvm::ARCCC::CondCode
CondCode
Definition: ARCInfo.h:24
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::MCPhysReg
uint16_t MCPhysReg
An unsigned integer type large enough to represent all physical registers, but not necessarily virtua...
Definition: MCRegister.h:20
llvm::SelectionDAG::getNode
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
Definition: SelectionDAG.cpp:8316
llvm::TargetLowering::CallLoweringInfo::DL
SDLoc DL
Definition: TargetLowering.h:3773
llvm::GlobalAddressSDNode::getOffset
int64_t getOffset() const
Definition: SelectionDAGNodes.h:1731
llvm::SDValue::getValue
SDValue getValue(unsigned R) const
Definition: SelectionDAGNodes.h:172
llvm::TargetLowering::CallLoweringInfo
This structure contains all information that is necessary for lowering calls.
Definition: TargetLowering.h:3747
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:79
llvm::ISD::MULHS
@ MULHS
Definition: ISDOpcodes.h:615
llvm::MachineFrameInfo::CreateFixedObject
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
Definition: MachineFrameInfo.cpp:83
llvm::MVT::Other
@ Other
Definition: MachineValueType.h:42
llvm::ARCCC::GE
@ GE
Definition: ARCInfo.h:35
llvm::MachineFunction::getFrameInfo
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Definition: MachineFunction.h:642
llvm::ISD::SETULT
@ SETULT
Definition: ISDOpcodes.h:1369
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::ISD::CondCode
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
Definition: ISDOpcodes.h:1355
llvm::ARCISD::CMOV
@ CMOV
Definition: ARCISelLowering.h:43
R6
#define R6(n)
llvm::ISD::VASTART
@ VASTART
Definition: ISDOpcodes.h:1042
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::SelectionDAG::getCALLSEQ_END
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd).
Definition: SelectionDAG.h:935
llvm::TargetLowering::CallLoweringInfo::Ins
SmallVector< ISD::InputArg, 32 > Ins
Definition: TargetLowering.h:3777
llvm::ARCSubtarget::getRegisterInfo
const ARCRegisterInfo * getRegisterInfo() const override
Definition: ARCSubtarget.h:57
llvm::TargetLowering::CallLoweringInfo::DAG
SelectionDAG & DAG
Definition: TargetLowering.h:3772
llvm::Sched::Source
@ Source
Definition: TargetLowering.h:100
ISDCCtoARCCC
static ARCCC::CondCode ISDCCtoARCCC(ISD::CondCode isdCC)
Definition: ARCISelLowering.cpp:40
llvm::MVT::i64
@ i64
Definition: MachineValueType.h:47
llvm::MachineFrameInfo::CreateStackObject
int CreateStackObject(uint64_t Size, Align Alignment, bool isSpillSlot, const AllocaInst *Alloca=nullptr, uint8_t ID=0)
Create a new statically sized stack object, returning a nonnegative identifier to represent it.
Definition: MachineFrameInfo.cpp:51
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
ARCTargetMachine.h
uint32_t
llvm::ISD::ArgFlagsTy
Definition: TargetCallingConv.h:27
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::ISD::UNDEF
@ UNDEF
UNDEF - An undefined node.
Definition: ISDOpcodes.h:211
llvm::ISD::BUILTIN_OP_END
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:1249
llvm::SDVTList
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
Definition: SelectionDAGNodes.h:79
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::SelectionDAG::getTargetJumpTable
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
Definition: SelectionDAG.h:693
llvm::ISD::FRAMEADDR
@ FRAMEADDR
FRAMEADDR, RETURNADDR - These nodes represent llvm.frameaddress and llvm.returnaddress on the DAG.
Definition: ISDOpcodes.h:94
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:206
CallingConv.h
llvm::TargetLowering::CallLoweringInfo::IsTailCall
bool IsTailCall
Definition: TargetLowering.h:3763
llvm::ISD::SETLT
@ SETLT
Definition: ISDOpcodes.h:1378
llvm::CCValAssign::isMemLoc
bool isMemLoc() const
Definition: CallingConvLower.h:146
llvm::GlobalAddressSDNode
Definition: SelectionDAGNodes.h:1718
llvm::TargetLoweringBase::AddrMode::Scale
int64_t Scale
Definition: TargetLowering.h:2366
CallingConvLower.h
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:321
MachineFrameInfo.h
llvm::SelectionDAG::getEntryNode
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
Definition: SelectionDAG.h:516
llvm::ARCISD::RET
@ RET
Definition: ARCISelLowering.h:52
llvm::SelectionDAG::getDataLayout
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:440
llvm::AArch64CC::LS
@ LS
Definition: AArch64BaseInfo.h:264
llvm::ARCRegisterInfo
Definition: ARCRegisterInfo.h:25
llvm::TargetLoweringBase::Custom
@ Custom
Definition: TargetLowering.h:201
llvm::ISD::SUBC
@ SUBC
Definition: ISDOpcodes.h:270
llvm::SelectionDAG::getTargetExternalSymbol
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
Definition: SelectionDAG.cpp:1753
llvm::MVT::i32
@ i32
Definition: MachineValueType.h:46
llvm::ARCTargetLowering::getTargetNodeName
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
Definition: ARCISelLowering.cpp:179
llvm::SDValue
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
Definition: SelectionDAGNodes.h:138
llvm::SDNode::getNumValues
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
Definition: SelectionDAGNodes.h:963
llvm::TargetLoweringBase::ZeroOrOneBooleanContent
@ ZeroOrOneBooleanContent
Definition: TargetLowering.h:233
llvm::ISD::STORE
@ STORE
Definition: ISDOpcodes.h:922
llvm::ISD::VACOPY
@ VACOPY
VACOPY - VACOPY has 5 operands: an input chain, a destination pointer, a source pointer,...
Definition: ISDOpcodes.h:1037
llvm::AMDGPU::Hwreg::Width
Width
Definition: SIDefines.h:410
llvm::ISD::ADD
@ ADD
Simple integer binary arithmetic operators.
Definition: ISDOpcodes.h:239
llvm::CallingConv::Fast
@ Fast
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:42
llvm::TargetLoweringBase::setBooleanContents
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
Definition: TargetLowering.h:2115
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition: MachineFrameInfo.h:107
llvm::ISD::SHL
@ SHL
Shift and rotation operations.
Definition: ISDOpcodes.h:657
llvm::ISD::READCYCLECOUNTER
@ READCYCLECOUNTER
READCYCLECOUNTER - This corresponds to the readcyclecounter intrinsic.
Definition: ISDOpcodes.h:1068
llvm::MachinePointerInfo::getFixedStack
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Definition: MachineOperand.cpp:1003
MachineInstrBuilder.h
llvm::ISD::MUL
@ MUL
Definition: ISDOpcodes.h:241
llvm::TargetLoweringBase::Expand
@ Expand
Definition: TargetLowering.h:199
llvm::ARCTargetLowering::ARCTargetLowering
ARCTargetLowering(const TargetMachine &TM, const ARCSubtarget &Subtarget)
Definition: ARCISelLowering.cpp:96
llvm::CCValAssign::getValVT
MVT getValVT() const
Definition: CallingConvLower.h:143
llvm::ARCISD::CMP
@ CMP
Definition: ARCISelLowering.h:40
N
#define N
llvm::TargetLoweringBase::computeRegisterProperties
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
Definition: TargetLoweringBase.cpp:1287
llvm::ISD::SUBE
@ SUBE
Definition: ISDOpcodes.h:280
llvm::ISD::SRL
@ SRL
Definition: ISDOpcodes.h:659
llvm::SelectionDAG::getRegisterMask
SDValue getRegisterMask(const uint32_t *RegMask)
Definition: SelectionDAG.cpp:2000
ARC.h
llvm::max
Align max(MaybeAlign Lhs, Align Rhs)
Definition: Alignment.h:340
llvm::ISD::CTTZ
@ CTTZ
Definition: ISDOpcodes.h:667
llvm::TargetLoweringBase::AddrMode
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
Definition: TargetLowering.h:2362
llvm::ARCCC::HI
@ HI
Definition: ARCInfo.h:38
llvm::MipsISD::Ins
@ Ins
Definition: MipsISelLowering.h:157
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::ISD::MULHU
@ MULHU
MULHU/MULHS - Multiply high - Multiply two integers of type iN, producing an unsigned/signed value of...
Definition: ISDOpcodes.h:614
llvm::TargetLowering::CallLoweringInfo::OutVals
SmallVector< SDValue, 32 > OutVals
Definition: TargetLowering.h:3776
lowerCallResult
static SDValue lowerCallResult(SDValue Chain, SDValue InFlag, const SmallVectorImpl< CCValAssign > &RVLocs, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals)
Lower the result values of a call into the appropriate copies out of physical registers / memory loca...
Definition: ARCISelLowering.cpp:408
TM
const char LLVMTargetMachineRef TM
Definition: PassBuilderBindings.cpp:47
llvm::TargetLowering::CallLoweringInfo::Callee
SDValue Callee
Definition: TargetLowering.h:3770
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition: Instructions.h:1475
llvm::SelectionDAG::getMachineFunction
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:437
llvm::ISD::VAARG
@ VAARG
VAARG - VAARG has four operands: an input chain, a pointer, a SRCVALUE, and the alignment.
Definition: ISDOpcodes.h:1032
llvm::ARCCC::LT
@ LT
Definition: ARCInfo.h:36
llvm::MachineFrameInfo::setFrameAddressIsTaken
void setFrameAddressIsTaken(bool T)
Definition: MachineFrameInfo.h:369
llvm::ISD::SIGN_EXTEND
@ SIGN_EXTEND
Conversion operators.
Definition: ISDOpcodes.h:726
llvm::SelectionDAG::getMemcpy
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes())
Definition: SelectionDAG.cpp:6837
MachineFunction.h
llvm::ISD::STACKSAVE
@ STACKSAVE
STACKSAVE - STACKSAVE has one operand, an input chain.
Definition: ISDOpcodes.h:1008
llvm::ISD::ADDE
@ ADDE
Carry-using nodes for multiple precision addition and subtraction.
Definition: ISDOpcodes.h:279
llvm::ARCFunctionInfo
ARCFunctionInfo - This class is derived from MachineFunction private ARC target-specific information ...
Definition: ARCMachineFunctionInfo.h:23
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::ISD::ROTR
@ ROTR
Definition: ISDOpcodes.h:661
Debug.h
llvm::TargetRegisterInfo::getCallPreservedMask
virtual const uint32_t * getCallPreservedMask(const MachineFunction &MF, CallingConv::ID) const
Return a mask of call-preserved registers for the given calling convention on the current function.
Definition: TargetRegisterInfo.h:487
llvm::TargetLoweringBase::getPointerTy
virtual MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
Definition: TargetLowering.h:346
llvm::ISD::TokenFactor
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
Definition: ISDOpcodes.h:52
llvm::EVT::getSimpleVT
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:289
llvm::ARCCC::HS
@ HS
Definition: ARCInfo.h:31