LLVM 19.0.0git
XtensaISelLowering.cpp
Go to the documentation of this file.
1//===- XtensaISelLowering.cpp - Xtensa DAG Lowering Implementation --------===//
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 defines the interfaces that Xtensa uses to lower LLVM code into a
10// selection DAG.
11//
12//===----------------------------------------------------------------------===//
13
14#include "XtensaISelLowering.h"
16#include "XtensaSubtarget.h"
17#include "XtensaTargetMachine.h"
24#include "llvm/Support/Debug.h"
28#include <deque>
29
30using namespace llvm;
31
32#define DEBUG_TYPE "xtensa-lower"
33
34// Return true if we must use long (in fact, indirect) function call.
35// It's simplified version, production implimentation must
36// resolve a functions in ROM (usually glibc functions)
37static bool isLongCall(const char *str) {
38 // Currently always use long calls
39 return true;
40}
41
43 const XtensaSubtarget &STI)
44 : TargetLowering(TM), Subtarget(STI) {
45 MVT PtrVT = MVT::i32;
46 // Set up the register classes.
47 addRegisterClass(MVT::i32, &Xtensa::ARRegClass);
48
49 // Set up special registers.
51
53
55
58
60
64
71
72 // No sign extend instructions for i1
73 for (MVT VT : MVT::integer_valuetypes()) {
77 }
78
80
81 // Compute derived properties from the register classes
83}
84
85//===----------------------------------------------------------------------===//
86// Calling conventions
87//===----------------------------------------------------------------------===//
88
89#include "XtensaGenCallingConv.inc"
90
91static bool CC_Xtensa_Custom(unsigned ValNo, MVT ValVT, MVT LocVT,
93 ISD::ArgFlagsTy ArgFlags, CCState &State) {
94 static const MCPhysReg IntRegs[] = {Xtensa::A2, Xtensa::A3, Xtensa::A4,
95 Xtensa::A5, Xtensa::A6, Xtensa::A7};
96
97 if (ArgFlags.isByVal()) {
98 Align ByValAlign = ArgFlags.getNonZeroByValAlign();
99 unsigned ByValSize = ArgFlags.getByValSize();
100 if (ByValSize < 4) {
101 ByValSize = 4;
102 }
103 if (ByValAlign < Align(4)) {
104 ByValAlign = Align(4);
105 }
106 unsigned Offset = State.AllocateStack(ByValSize, ByValAlign);
107 State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
108 // Mark all unused registers as allocated to avoid misuse
109 // of such registers.
110 while (State.AllocateReg(IntRegs))
111 ;
112 return false;
113 }
114
115 // Promote i8 and i16
116 if (LocVT == MVT::i8 || LocVT == MVT::i16) {
117 LocVT = MVT::i32;
118 if (ArgFlags.isSExt())
119 LocInfo = CCValAssign::SExt;
120 else if (ArgFlags.isZExt())
121 LocInfo = CCValAssign::ZExt;
122 else
123 LocInfo = CCValAssign::AExt;
124 }
125
126 unsigned Register;
127
128 Align OrigAlign = ArgFlags.getNonZeroOrigAlign();
129 bool needs64BitAlign = (ValVT == MVT::i32 && OrigAlign == Align(8));
130 bool needs128BitAlign = (ValVT == MVT::i32 && OrigAlign == Align(16));
131
132 if (ValVT == MVT::i32) {
134 // If this is the first part of an i64 arg,
135 // the allocated register must be either A2, A4 or A6.
136 if (needs64BitAlign && (Register == Xtensa::A3 || Register == Xtensa::A5 ||
137 Register == Xtensa::A7))
139 // arguments with 16byte alignment must be passed in the first register or
140 // passed via stack
141 if (needs128BitAlign && (Register != Xtensa::A2))
142 while ((Register = State.AllocateReg(IntRegs)))
143 ;
144 LocVT = MVT::i32;
145 } else if (ValVT == MVT::f64) {
146 // Allocate int register and shadow next int register.
148 if (Register == Xtensa::A3 || Register == Xtensa::A5 ||
149 Register == Xtensa::A7)
151 State.AllocateReg(IntRegs);
152 LocVT = MVT::i32;
153 } else {
154 report_fatal_error("Cannot handle this ValVT.");
155 }
156
157 if (!Register) {
158 unsigned Offset = State.AllocateStack(ValVT.getStoreSize(), OrigAlign);
159 State.addLoc(CCValAssign::getMem(ValNo, ValVT, Offset, LocVT, LocInfo));
160 } else {
161 State.addLoc(CCValAssign::getReg(ValNo, ValVT, Register, LocVT, LocInfo));
162 }
163
164 return false;
165}
166
167CCAssignFn *XtensaTargetLowering::CCAssignFnForCall(CallingConv::ID CC,
168 bool IsVarArg) const {
169 return CC_Xtensa_Custom;
170}
171
173 SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
174 const SmallVectorImpl<ISD::InputArg> &Ins, const SDLoc &DL,
175 SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals) const {
177 MachineFrameInfo &MFI = MF.getFrameInfo();
178
179 // Used with vargs to acumulate store chains.
180 std::vector<SDValue> OutChains;
181
182 if (IsVarArg)
183 report_fatal_error("Var arg not supported by FormalArguments Lowering");
184
185 // Assign locations to all of the incoming arguments.
187 CCState CCInfo(CallConv, IsVarArg, DAG.getMachineFunction(), ArgLocs,
188 *DAG.getContext());
189
190 CCInfo.AnalyzeFormalArguments(Ins, CCAssignFnForCall(CallConv, IsVarArg));
191
192 for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) {
193 CCValAssign &VA = ArgLocs[i];
194 // Arguments stored on registers
195 if (VA.isRegLoc()) {
196 EVT RegVT = VA.getLocVT();
197 const TargetRegisterClass *RC;
198
199 if (RegVT == MVT::i32)
200 RC = &Xtensa::ARRegClass;
201 else
202 report_fatal_error("RegVT not supported by FormalArguments Lowering");
203
204 // Transform the arguments stored on
205 // physical registers into virtual ones
206 unsigned Register = MF.addLiveIn(VA.getLocReg(), RC);
207 SDValue ArgValue = DAG.getCopyFromReg(Chain, DL, Register, RegVT);
208
209 // If this is an 8 or 16-bit value, it has been passed promoted
210 // to 32 bits. Insert an assert[sz]ext to capture this, then
211 // truncate to the right size.
212 if (VA.getLocInfo() != CCValAssign::Full) {
213 unsigned Opcode = 0;
214 if (VA.getLocInfo() == CCValAssign::SExt)
215 Opcode = ISD::AssertSext;
216 else if (VA.getLocInfo() == CCValAssign::ZExt)
217 Opcode = ISD::AssertZext;
218 if (Opcode)
219 ArgValue = DAG.getNode(Opcode, DL, RegVT, ArgValue,
220 DAG.getValueType(VA.getValVT()));
221 ArgValue = DAG.getNode((VA.getValVT() == MVT::f32) ? ISD::BITCAST
223 DL, VA.getValVT(), ArgValue);
224 }
225
226 InVals.push_back(ArgValue);
227
228 } else {
229 assert(VA.isMemLoc());
230
231 EVT ValVT = VA.getValVT();
232
233 // The stack pointer offset is relative to the caller stack frame.
234 int FI = MFI.CreateFixedObject(ValVT.getStoreSize(), VA.getLocMemOffset(),
235 true);
236
237 if (Ins[VA.getValNo()].Flags.isByVal()) {
238 // Assume that in this case load operation is created
239 SDValue FIN = DAG.getFrameIndex(FI, MVT::i32);
240 InVals.push_back(FIN);
241 } else {
242 // Create load nodes to retrieve arguments from the stack
243 SDValue FIN =
245 InVals.push_back(DAG.getLoad(
246 ValVT, DL, Chain, FIN,
248 }
249 }
250 }
251
252 // All stores are grouped in one node to allow the matching between
253 // the size of Ins and InVals. This only happens when on varg functions
254 if (!OutChains.empty()) {
255 OutChains.push_back(Chain);
256 Chain = DAG.getNode(ISD::TokenFactor, DL, MVT::Other, OutChains);
257 }
258
259 return Chain;
260}
261
264 SmallVectorImpl<SDValue> &InVals) const {
265 SelectionDAG &DAG = CLI.DAG;
266 SDLoc &DL = CLI.DL;
268 SmallVector<SDValue, 32> &OutVals = CLI.OutVals;
270 SDValue Chain = CLI.Chain;
271 SDValue Callee = CLI.Callee;
272 bool &IsTailCall = CLI.IsTailCall;
273 CallingConv::ID CallConv = CLI.CallConv;
274 bool IsVarArg = CLI.IsVarArg;
275
277 EVT PtrVT = getPointerTy(DAG.getDataLayout());
278 const TargetFrameLowering *TFL = Subtarget.getFrameLowering();
279
280 // TODO: Support tail call optimization.
281 IsTailCall = false;
282
283 // Analyze the operands of the call, assigning locations to each operand.
285 CCState CCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext());
286
287 CCAssignFn *CC = CCAssignFnForCall(CallConv, IsVarArg);
288
289 CCInfo.AnalyzeCallOperands(Outs, CC);
290
291 // Get a count of how many bytes are to be pushed on the stack.
292 unsigned NumBytes = CCInfo.getStackSize();
293
294 Align StackAlignment = TFL->getStackAlign();
295 unsigned NextStackOffset = alignTo(NumBytes, StackAlignment);
296
297 Chain = DAG.getCALLSEQ_START(Chain, NextStackOffset, 0, DL);
298
299 // Copy argument values to their designated locations.
300 std::deque<std::pair<unsigned, SDValue>> RegsToPass;
301 SmallVector<SDValue, 8> MemOpChains;
302 SDValue StackPtr;
303 for (unsigned I = 0, E = ArgLocs.size(); I != E; ++I) {
304 CCValAssign &VA = ArgLocs[I];
305 SDValue ArgValue = OutVals[I];
306 ISD::ArgFlagsTy Flags = Outs[I].Flags;
307
308 if (VA.isRegLoc())
309 // Queue up the argument copies and emit them at the end.
310 RegsToPass.push_back(std::make_pair(VA.getLocReg(), ArgValue));
311 else if (Flags.isByVal()) {
312 assert(VA.isMemLoc());
313 assert(Flags.getByValSize() &&
314 "ByVal args of size 0 should have been ignored by front-end.");
315 assert(!IsTailCall &&
316 "Do not tail-call optimize if there is a byval argument.");
317
318 if (!StackPtr.getNode())
319 StackPtr = DAG.getCopyFromReg(Chain, DL, Xtensa::SP, PtrVT);
320 unsigned Offset = VA.getLocMemOffset();
321 SDValue Address = DAG.getNode(ISD::ADD, DL, PtrVT, StackPtr,
323 SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), DL, MVT::i32);
324 SDValue Memcpy = DAG.getMemcpy(
325 Chain, DL, Address, ArgValue, SizeNode, Flags.getNonZeroByValAlign(),
326 /*isVolatile=*/false, /*AlwaysInline=*/false,
327 /*isTailCall=*/false, MachinePointerInfo(), MachinePointerInfo());
328 MemOpChains.push_back(Memcpy);
329 } else {
330 assert(VA.isMemLoc() && "Argument not register or memory");
331
332 // Work out the address of the stack slot. Unpromoted ints and
333 // floats are passed as right-justified 8-byte values.
334 if (!StackPtr.getNode())
335 StackPtr = DAG.getCopyFromReg(Chain, DL, Xtensa::SP, PtrVT);
336 unsigned Offset = VA.getLocMemOffset();
337 SDValue Address = DAG.getNode(ISD::ADD, DL, PtrVT, StackPtr,
339
340 // Emit the store.
341 MemOpChains.push_back(
342 DAG.getStore(Chain, DL, ArgValue, Address, MachinePointerInfo()));
343 }
344 }
345
346 // Join the stores, which are independent of one another.
347 if (!MemOpChains.empty())
348 Chain = DAG.getNode(ISD::TokenFactor, DL, MVT::Other, MemOpChains);
349
350 // Build a sequence of copy-to-reg nodes, chained and glued together.
351 SDValue Glue;
352 for (unsigned I = 0, E = RegsToPass.size(); I != E; ++I) {
353 unsigned Reg = RegsToPass[I].first;
354 Chain = DAG.getCopyToReg(Chain, DL, Reg, RegsToPass[I].second, Glue);
355 Glue = Chain.getValue(1);
356 }
357 std::string name;
358 unsigned char TF = 0;
359
360 // Accept direct calls by converting symbolic call addresses to the
361 // associated Target* opcodes.
362 if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(Callee)) {
363 name = E->getSymbol();
364 TF = E->getTargetFlags();
365 if (isPositionIndependent()) {
366 report_fatal_error("PIC relocations is not supported");
367 } else
368 Callee = DAG.getTargetExternalSymbol(E->getSymbol(), PtrVT, TF);
369 } else if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
370 const GlobalValue *GV = G->getGlobal();
371 name = GV->getName().str();
372 }
373
374 if ((!name.empty()) && isLongCall(name.c_str())) {
375 // Create a constant pool entry for the callee address
377
379 *DAG.getContext(), name.c_str(), 0 /* XtensaCLabelIndex */, false,
380 Modifier);
381
382 // Get the address of the callee into a register
383 SDValue CPAddr = DAG.getTargetConstantPool(CPV, PtrVT, Align(4), 0, TF);
384 SDValue CPWrap = getAddrPCRel(CPAddr, DAG);
385 Callee = CPWrap;
386 }
387
388 // The first call operand is the chain and the second is the target address.
390 Ops.push_back(Chain);
391 Ops.push_back(Callee);
392
393 // Add a register mask operand representing the call-preserved registers.
394 const TargetRegisterInfo *TRI = Subtarget.getRegisterInfo();
395 const uint32_t *Mask = TRI->getCallPreservedMask(MF, CallConv);
396 assert(Mask && "Missing call preserved mask for calling convention");
397 Ops.push_back(DAG.getRegisterMask(Mask));
398
399 // Add argument registers to the end of the list so that they are
400 // known live into the call.
401 for (unsigned I = 0, E = RegsToPass.size(); I != E; ++I) {
402 unsigned Reg = RegsToPass[I].first;
403 Ops.push_back(DAG.getRegister(Reg, RegsToPass[I].second.getValueType()));
404 }
405
406 // Glue the call to the argument copies, if any.
407 if (Glue.getNode())
408 Ops.push_back(Glue);
409
410 SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue);
411 Chain = DAG.getNode(XtensaISD::CALL, DL, NodeTys, Ops);
412 Glue = Chain.getValue(1);
413
414 // Mark the end of the call, which is glued to the call itself.
415 Chain = DAG.getCALLSEQ_END(Chain, DAG.getConstant(NumBytes, DL, PtrVT, true),
416 DAG.getConstant(0, DL, PtrVT, true), Glue, DL);
417 Glue = Chain.getValue(1);
418
419 // Assign locations to each value returned by this call.
421 CCState RetCCInfo(CallConv, IsVarArg, MF, RetLocs, *DAG.getContext());
422 RetCCInfo.AnalyzeCallResult(Ins, RetCC_Xtensa);
423
424 // Copy all of the result registers out of their specified physreg.
425 for (unsigned I = 0, E = RetLocs.size(); I != E; ++I) {
426 CCValAssign &VA = RetLocs[I];
427
428 // Copy the value out, gluing the copy to the end of the call sequence.
429 unsigned Reg = VA.getLocReg();
430 SDValue RetValue = DAG.getCopyFromReg(Chain, DL, Reg, VA.getLocVT(), Glue);
431 Chain = RetValue.getValue(1);
432 Glue = RetValue.getValue(2);
433
434 InVals.push_back(RetValue);
435 }
436 return Chain;
437}
438
440 CallingConv::ID CallConv, MachineFunction &MF, bool IsVarArg,
441 const SmallVectorImpl<ISD::OutputArg> &Outs, LLVMContext &Context) const {
443 CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, Context);
444 return CCInfo.CheckReturn(Outs, RetCC_Xtensa);
445}
446
449 bool IsVarArg,
451 const SmallVectorImpl<SDValue> &OutVals,
452 const SDLoc &DL, SelectionDAG &DAG) const {
453 if (IsVarArg)
454 report_fatal_error("VarArg not supported");
455
457
458 // Assign locations to each returned value.
460 CCState RetCCInfo(CallConv, IsVarArg, MF, RetLocs, *DAG.getContext());
461 RetCCInfo.AnalyzeReturn(Outs, RetCC_Xtensa);
462
463 SDValue Glue;
464 // Quick exit for void returns
465 if (RetLocs.empty())
466 return DAG.getNode(XtensaISD::RET, DL, MVT::Other, Chain);
467
468 // Copy the result values into the output registers.
470 RetOps.push_back(Chain);
471 for (unsigned I = 0, E = RetLocs.size(); I != E; ++I) {
472 CCValAssign &VA = RetLocs[I];
473 SDValue RetValue = OutVals[I];
474
475 // Make the return register live on exit.
476 assert(VA.isRegLoc() && "Can only return in registers!");
477
478 // Chain and glue the copies together.
479 unsigned Register = VA.getLocReg();
480 Chain = DAG.getCopyToReg(Chain, DL, Register, RetValue, Glue);
481 Glue = Chain.getValue(1);
482 RetOps.push_back(DAG.getRegister(Register, VA.getLocVT()));
483 }
484
485 // Update chain and glue.
486 RetOps[0] = Chain;
487 if (Glue.getNode())
488 RetOps.push_back(Glue);
489
490 return DAG.getNode(XtensaISD::RET, DL, MVT::Other, RetOps);
491}
492
493SDValue XtensaTargetLowering::LowerImmediate(SDValue Op,
494 SelectionDAG &DAG) const {
495 const ConstantSDNode *CN = cast<ConstantSDNode>(Op);
496 SDLoc DL(CN);
497 APInt APVal = CN->getAPIntValue();
498 int64_t Value = APVal.getSExtValue();
499 if (Op.getValueType() == MVT::i32) {
500 // Check if use node maybe lowered to the MOVI instruction
501 if (Value > -2048 && Value <= 2047)
502 return Op;
503 // Check if use node maybe lowered to the ADDMI instruction
504 SDNode &OpNode = *Op.getNode();
505 if ((OpNode.hasOneUse() && OpNode.use_begin()->getOpcode() == ISD::ADD) &&
506 isShiftedInt<16, 8>(Value))
507 return Op;
508 Type *Ty = Type::getInt32Ty(*DAG.getContext());
509 Constant *CV = ConstantInt::get(Ty, Value);
510 SDValue CP = DAG.getConstantPool(CV, MVT::i32);
511 return CP;
512 }
513 return Op;
514}
515
516SDValue XtensaTargetLowering::getAddrPCRel(SDValue Op,
517 SelectionDAG &DAG) const {
518 SDLoc DL(Op);
519 EVT Ty = Op.getValueType();
520 return DAG.getNode(XtensaISD::PCREL_WRAPPER, DL, Ty, Op);
521}
522
523SDValue XtensaTargetLowering::LowerConstantPool(ConstantPoolSDNode *CP,
524 SelectionDAG &DAG) const {
525 EVT PtrVT = getPointerTy(DAG.getDataLayout());
527 if (!CP->isMachineConstantPoolEntry()) {
528 Result = DAG.getTargetConstantPool(CP->getConstVal(), PtrVT, CP->getAlign(),
529 CP->getOffset());
530 } else {
531 report_fatal_error("This constantpool type is not supported yet");
532 }
533
534 return getAddrPCRel(Result, DAG);
535}
536
538 SelectionDAG &DAG) const {
539 switch (Op.getOpcode()) {
540 case ISD::Constant:
541 return LowerImmediate(Op, DAG);
543 return LowerConstantPool(cast<ConstantPoolSDNode>(Op), DAG);
544 default:
545 report_fatal_error("Unexpected node to lower");
546 }
547}
548
549const char *XtensaTargetLowering::getTargetNodeName(unsigned Opcode) const {
550 switch (Opcode) {
551 case XtensaISD::CALL:
552 return "XtensaISD::CALL";
554 return "XtensaISD::PCREL_WRAPPER";
555 case XtensaISD::RET:
556 return "XtensaISD::RET";
557 }
558 return nullptr;
559}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define I(x, y, z)
Definition: MD5.cpp:58
#define G(x, y, z)
Definition: MD5.cpp:56
unsigned const TargetRegisterInfo * TRI
LLVMContext & Context
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char * name
Definition: SMEABIPass.cpp:49
static const MCPhysReg IntRegs[32]
static bool CC_Xtensa_Custom(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
static bool isLongCall(const char *str)
Class for arbitrary precision integers.
Definition: APInt.h:76
int64_t getSExtValue() const
Get sign extended value.
Definition: APInt.h:1513
CCState - This class holds information needed while lowering arguments and return values.
void AnalyzeCallResult(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeCallResult - Analyze the return values of a call, incorporating info about the passed values i...
MCRegister AllocateReg(MCPhysReg Reg)
AllocateReg - Attempt to allocate one register.
bool CheckReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
CheckReturn - Analyze the return values of a function, returning true if the return can be performed ...
void AnalyzeReturn(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeReturn - Analyze the returned values of a return, incorporating info about the result values i...
int64_t AllocateStack(unsigned Size, Align Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
void AnalyzeCallOperands(const SmallVectorImpl< ISD::OutputArg > &Outs, CCAssignFn Fn)
AnalyzeCallOperands - Analyze the outgoing arguments to a call, incorporating info about the passed v...
uint64_t getStackSize() const
Returns the size of the currently allocated portion of the stack.
void AnalyzeFormalArguments(const SmallVectorImpl< ISD::InputArg > &Ins, CCAssignFn Fn)
AnalyzeFormalArguments - Analyze an array of argument values, incorporating info about the formals in...
void addLoc(const CCValAssign &V)
CCValAssign - Represent assignment of one arg/retval to a location.
bool isRegLoc() const
Register getLocReg() const
LocInfo getLocInfo() const
static CCValAssign getMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP, bool IsCustom=false)
bool isMemLoc() const
int64_t getLocMemOffset() const
unsigned getValNo() const
const APInt & getAPIntValue() const
This is an important base class in LLVM.
Definition: Constant.h:41
This class represents an Operation in the Expression.
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
Machine Value Type.
static auto integer_valuetypes()
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool IsImmutable, bool isAliased=false)
Create a new object at a fixed location on the stack.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
Register addLiveIn(MCRegister PReg, const TargetRegisterClass *RC)
addLiveIn - Add the specified physical register as a live-in value and create a corresponding virtual...
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
bool hasOneUse() const
Return true if there is exactly one use of this node.
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
SDValue getValue(unsigned R) const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:225
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offs=0, bool isT=false, unsigned TargetFlags=0)
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,...
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).
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(), AAResults *AA=nullptr)
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:472
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
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.
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 ...
SDValue getRegister(unsigned Reg, EVT VT)
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
Definition: SelectionDAG.h:773
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
SDValue getValueType(EVT)
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:469
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
Definition: SelectionDAG.h:799
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
SDValue getRegisterMask(const uint32_t *RegMask)
LLVMContext * getContext() const
Definition: SelectionDAG.h:485
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
SDValue getTargetConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
Definition: SelectionDAG.h:739
bool empty() const
Definition: SmallVector.h:94
size_t size() const
Definition: SmallVector.h:91
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:222
Information about stack frame layout on the target.
Align getStackAlign() const
getStackAlignment - This method returns the number of bytes to which the stack pointer must be aligne...
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...
void setMinFunctionAlignment(Align Alignment)
Set the target's minimum function alignment.
void setBooleanContents(BooleanContent Ty)
Specify how the target extends the result of integer and floating point boolean values from i1 to a w...
void computeRegisterProperties(const TargetRegisterInfo *TRI)
Once all of the register classes are added, this allows us to compute derived properties we expose.
void addRegisterClass(MVT VT, const TargetRegisterClass *RC)
Add the specified register class as an available regclass for the specified value type.
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...
void setStackPointerRegisterToSaveRestore(Register R)
If set to a physical register, this specifies the register that llvm.savestack/llvm....
void setLoadExtAction(unsigned ExtType, MVT ValVT, MVT MemVT, LegalizeAction Action)
Indicate that the specified load with extension does not work with the specified type and indicate wh...
MVT getFrameIndexTy(const DataLayout &DL) const
Return the type for frame index, which is determined by the alloca address space specified through th...
void setSchedulingPreference(Sched::Preference Pref)
Specify the target scheduling preference.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool isPositionIndependent() const
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:76
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
Definition: Value.h:74
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
static XtensaConstantPoolSymbol * Create(LLVMContext &C, const char *S, unsigned ID, bool PrivLinkage, XtensaCP::XtensaCPModifier Modifier=XtensaCP::no_modifier)
XtensaConstantPoolValue - Xtensa specific constantpool value.
const XtensaRegisterInfo * getRegisterInfo() const override
const TargetFrameLowering * getFrameLowering() const override
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower the incoming (formal) arguments, described by the Ins array,...
SDValue LowerCall(CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
This hook must be implemented to lower calls into the specified DAG.
XtensaTargetLowering(const TargetMachine &TM, const XtensaSubtarget &STI)
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SDLoc &DL, SelectionDAG &DAG) const override
This hook must be implemented to lower outgoing return values, described by the Outs array,...
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...
@ ADD
Simple integer binary arithmetic operators.
Definition: ISDOpcodes.h:240
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
Definition: ISDOpcodes.h:791
@ BITCAST
BITCAST - This operator converts between integer, vector and FP values, as if the value was stored to...
Definition: ISDOpcodes.h:904
@ ConstantPool
Definition: ISDOpcodes.h:82
@ SIGN_EXTEND_INREG
SIGN_EXTEND_INREG - This operator atomically performs a SHL/SRA pair to sign extend a small value in ...
Definition: ISDOpcodes.h:799
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
Definition: ISDOpcodes.h:837
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
Definition: ISDOpcodes.h:52
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
Definition: ISDOpcodes.h:787
@ AssertSext
AssertSext, AssertZext - These nodes record if a register contains a value that has already been zero...
Definition: ISDOpcodes.h:61
@ AssertZext
Definition: ISDOpcodes.h:62
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:456
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:156
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
Definition: Alignment.h:155
DWARFExpression::Operation Op
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
Extended Value Type.
Definition: ValueTypes.h:34
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
Definition: ValueTypes.h:380
Align getNonZeroOrigAlign() const
unsigned getByValSize() const
Align getNonZeroByValAlign() const
This class contains a discriminated union of information about pointers in memory operands,...
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
This structure contains all information that is necessary for lowering calls.
SmallVector< ISD::InputArg, 32 > Ins
SmallVector< ISD::OutputArg, 32 > Outs
SmallVector< SDValue, 32 > OutVals