LLVM 24.0.0git
HexagonISelLowering.h
Go to the documentation of this file.
1//===-- HexagonISelLowering.h - Hexagon DAG Lowering Interface --*- 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 defines the interfaces that Hexagon uses to lower LLVM code into a
10// selection DAG.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
15#define LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
16
17#include "Hexagon.h"
19#include "llvm/ADT/StringRef.h"
25#include "llvm/IR/CallingConv.h"
26#include "llvm/IR/InlineAsm.h"
27#include <cstdint>
28#include <utility>
29
30namespace llvm {
31
33
35 int VarArgsFrameOffset; // Frame offset to start of varargs area.
36 const HexagonTargetMachine &HTM;
37 const HexagonSubtarget &Subtarget;
38
39public:
40 explicit HexagonTargetLowering(const TargetMachine &TM,
41 const HexagonSubtarget &ST);
42
43 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
44 /// for tail call optimization. Targets which want to do tail call
45 /// optimization should implement this function.
47 CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet,
48 bool isCallerStructRet, const SmallVectorImpl<ISD::OutputArg> &Outs,
49 const SmallVectorImpl<SDValue> &OutVals,
50 const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG& DAG) const;
51
53 const CallBase &I, MachineFunction &MF,
54 unsigned Intrinsic) const override;
55
56 bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
57 bool isTruncateFree(EVT VT1, EVT VT2) const override;
58
59 bool isCheapToSpeculateCttz(Type *) const override { return true; }
60 bool isCheapToSpeculateCtlz(Type *) const override { return true; }
61 bool isCtlzFast() const override { return true; }
62
63 bool hasBitTest(SDValue X, SDValue Y) const override;
64
65 bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
66
67 bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override;
68
69 bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override;
70
71 /// Return true if an FMA operation is faster than a pair of mul and add
72 /// instructions. fmuladd intrinsics will be expanded to FMAs when this
73 /// method returns true (and FMAs are legal), otherwise fmuladd is
74 /// expanded to mul + add.
76 EVT) const override;
77
78 // Should we expand the build vector with shuffles?
80 unsigned DefinedValues) const override;
82 unsigned Index) const override;
83
84 bool isTargetCanonicalConstantNode(SDValue Op) const override;
85
86 bool isShuffleMaskLegal(ArrayRef<int> Mask, EVT VT) const override;
87 LegalizeTypeAction getPreferredVectorAction(MVT VT) const override;
89
90 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
92 SelectionDAG &DAG) const override;
94 SelectionDAG &DAG) const override;
95
96 std::pair<MVT, unsigned>
98 EVT VT) const;
99
115
122 SDValue
123 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
125 const SDLoc &dl, SelectionDAG &DAG,
126 SmallVectorImpl<SDValue> &InVals) const override;
131 SelectionDAG &DAG) const;
133 SelectionDAG &DAG) const;
135 SelectionDAG &DAG) const;
137 GlobalAddressSDNode *GA, SDValue InGlue, EVT PtrVT,
138 unsigned ReturnReg, unsigned char OperandGlues) const;
140
142 SmallVectorImpl<SDValue> &InVals) const override;
144 CallingConv::ID CallConv, bool isVarArg,
146 const SDLoc &dl, SelectionDAG &DAG,
148 const SmallVectorImpl<SDValue> &OutVals,
149 SDValue Callee) const;
150
156
157 bool CanLowerReturn(CallingConv::ID CallConv,
158 MachineFunction &MF, bool isVarArg,
160 LLVMContext &Context, const Type *RetTy) const override;
161
162 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
164 const SmallVectorImpl<SDValue> &OutVals,
165 const SDLoc &dl, SelectionDAG &DAG) const override;
166
167 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
168
169 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
170
171 Register getRegisterByName(const char* RegName, LLT VT,
172 const MachineFunction &MF) const override;
173
175 CallingConv::ID CC, EVT VT,
176 EVT &IntermediateVT,
177 unsigned &NumIntermediates,
178 MVT &RegisterVT) const override;
179
181 EVT VT) const override;
182 /// If a physical register, this returns the register that receives the
183 /// exception address on entry to an EH pad.
186 const Constant *PersonalityFn) const override {
187 return Hexagon::R0;
188 }
189
190 /// If a physical register, this returns the register that receives the
191 /// exception typeid on entry to a landing pad.
194 const Constant *PersonalityFn) const override {
195 return Hexagon::R1;
196 }
197
202
204 EVT VT) const override {
205 if (!VT.isVector())
206 return MVT::i1;
207 else
208 return EVT::getVectorVT(C, MVT::i1, VT.getVectorNumElements());
209 }
210
214 SelectionDAG &DAG) const override;
215
216 ConstraintType getConstraintType(StringRef Constraint) const override;
217
218 std::pair<unsigned, const TargetRegisterClass *>
220 StringRef Constraint, MVT VT) const override;
221
222 // Intrinsics
225 /// isLegalAddressingMode - Return true if the addressing mode represented
226 /// by AM is legal for this target, for a load/store of the specified type.
227 /// The type may be VoidTy, in which case only return true if the addressing
228 /// mode is legal for a load/store of any legal type.
229 /// TODO: Handle pre/postinc as well.
230 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
231 Type *Ty, unsigned AS,
232 Instruction *I = nullptr) const override;
233 /// Return true if folding a constant offset with the given GlobalAddress
234 /// is legal. It is frequently not legal in PIC relocation models.
235 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
236
237 bool isFPImmLegal(const APFloat &Imm, EVT VT,
238 bool ForCodeSize) const override;
239
240 /// isLegalICmpImmediate - Return true if the specified immediate is legal
241 /// icmp immediate, that is the target has icmp instructions which can
242 /// compare a register against the immediate without having to materialize
243 /// the immediate into a register.
244 bool isLegalICmpImmediate(int64_t Imm) const override;
245
246 EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op,
247 const AttributeList &FuncAttributes) const override;
248
249 bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT,
250 unsigned AddrSpace, Align Alignment,
252 unsigned *Fast) const override;
253
254 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
255 Align Alignment,
257 unsigned *Fast) const override;
258
259 /// Returns relocation base for the given PIC jumptable.
261 const override;
262
263 /// Returns true if it is beneficial to convert a load of a constant
264 /// to just the constant itself.
266 Type *Ty) const override;
267
269 std::optional<unsigned> ByteOffset) const override;
270
272 SDNode *Node) const override;
273
274 // Handling of atomic RMW instructions.
275 Value *emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy, Value *Addr,
276 AtomicOrdering Ord) const override;
277 Value *emitStoreConditional(IRBuilderBase &Builder, Value *Val, Value *Addr,
278 AtomicOrdering Ord) const override;
282 shouldExpandAtomicCmpXchgInIR(const AtomicCmpXchgInst *AI) const override;
283
285 shouldExpandAtomicRMWInIR(const AtomicRMWInst *AI) const override {
287 }
288
291 MachineBasicBlock *BB) const override;
292
293 bool supportKCFIBundles() const override { return true; }
294
297 const TargetInstrInfo *TII) const override;
298
299 bool hasInlineStackProbe(const MachineFunction &MF) const override;
300 unsigned getStackProbeSize(const MachineFunction &MF, Align StackAlign) const;
301
302private:
303 void initializeHVXLowering();
304 unsigned getPreferredHvxVectorAction(MVT VecTy) const;
305 unsigned getCustomHvxOperationAction(SDNode &Op) const;
306
307 bool validateConstPtrAlignment(SDValue Ptr, Align NeedAlign, const SDLoc &dl,
308 SelectionDAG &DAG) const;
309 SDValue replaceMemWithUndef(SDValue Op, SelectionDAG &DAG) const;
310
311 std::pair<SDValue,int> getBaseAndOffset(SDValue Addr) const;
312
313 bool getBuildVectorConstInts(ArrayRef<SDValue> Values, MVT VecTy,
314 SelectionDAG &DAG,
315 MutableArrayRef<ConstantInt*> Consts) const;
316 SDValue buildVector32(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
317 SelectionDAG &DAG) const;
318 SDValue buildVector64(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
319 SelectionDAG &DAG) const;
320 SDValue extractVector(SDValue VecV, SDValue IdxV, const SDLoc &dl,
321 MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
322 SDValue extractVectorPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
323 MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
324 SDValue insertVector(SDValue VecV, SDValue ValV, SDValue IdxV,
325 const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
326 SDValue insertVectorPred(SDValue VecV, SDValue ValV, SDValue IdxV,
327 const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
328 SDValue expandPredicate(SDValue Vec32, const SDLoc &dl,
329 SelectionDAG &DAG) const;
330 SDValue contractPredicate(SDValue Vec64, const SDLoc &dl,
331 SelectionDAG &DAG) const;
333 SDValue getVectorShiftByInt(SDValue Op, SelectionDAG &DAG) const;
334 SDValue appendUndef(SDValue Val, MVT ResTy, SelectionDAG &DAG) const;
335 SDValue getCombine(SDValue Hi, SDValue Lo, const SDLoc &dl, MVT ResTy,
336 SelectionDAG &DAG) const;
337
338 bool isUndef(SDValue Op) const {
339 if (Op.isMachineOpcode())
340 return Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF;
341 return Op.getOpcode() == ISD::UNDEF;
342 }
343 SDValue getInstr(unsigned MachineOpc, const SDLoc &dl, MVT Ty,
344 ArrayRef<SDValue> Ops, SelectionDAG &DAG) const {
345 SDNode *N = DAG.getMachineNode(MachineOpc, dl, Ty, Ops);
346 return SDValue(N, 0);
347 }
348 SDValue getZero(const SDLoc &dl, MVT Ty, SelectionDAG &DAG) const;
349
350 using VectorPair = std::pair<SDValue, SDValue>;
351 using TypePair = std::pair<MVT, MVT>;
352
353 SDValue getInt(unsigned IntId, MVT ResTy, ArrayRef<SDValue> Ops,
354 const SDLoc &dl, SelectionDAG &DAG) const;
355
356 MVT ty(SDValue Op) const {
357 return Op.getValueType().getSimpleVT();
358 }
359 TypePair ty(const VectorPair &Ops) const {
360 return { Ops.first.getValueType().getSimpleVT(),
361 Ops.second.getValueType().getSimpleVT() };
362 }
363 MVT tyScalar(MVT Ty) const {
364 if (!Ty.isVector())
365 return Ty;
366 return MVT::getIntegerVT(Ty.getSizeInBits());
367 }
368 MVT tyVector(MVT Ty, MVT ElemTy) const {
369 if (Ty.isVectorOf(ElemTy))
370 return Ty;
371 unsigned TyWidth = Ty.getSizeInBits();
372 unsigned ElemWidth = ElemTy.getSizeInBits();
373 assert((TyWidth % ElemWidth) == 0);
374 return MVT::getVectorVT(ElemTy, TyWidth/ElemWidth);
375 }
376
377 MVT typeJoin(const TypePair &Tys) const;
378 TypePair typeSplit(MVT Ty) const;
379 MVT typeExtElem(MVT VecTy, unsigned Factor) const;
380 MVT typeTruncElem(MVT VecTy, unsigned Factor) const;
381 TypePair typeExtendToWider(MVT Ty0, MVT Ty1) const;
382 TypePair typeWidenToWider(MVT Ty0, MVT Ty1) const;
383 MVT typeLegalize(MVT Ty, SelectionDAG &DAG) const;
384 MVT typeWidenToHvx(MVT Ty) const;
385
386 SDValue opJoin(const VectorPair &Ops, const SDLoc &dl,
387 SelectionDAG &DAG) const;
388 VectorPair opSplit(SDValue Vec, const SDLoc &dl, SelectionDAG &DAG) const;
389 SDValue opCastElem(SDValue Vec, MVT ElemTy, SelectionDAG &DAG) const;
390
391 SDValue LoHalf(SDValue V, SelectionDAG &DAG) const {
392 MVT Ty = ty(V);
393 const SDLoc &dl(V);
394 if (!Ty.isVector()) {
395 assert(Ty.getSizeInBits() == 64);
396 return DAG.getTargetExtractSubreg(Hexagon::isub_lo, dl, MVT::i32, V);
397 }
398 MVT HalfTy = typeSplit(Ty).first;
399 SDValue Idx = getZero(dl, MVT::i32, DAG);
400 return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, HalfTy, V, Idx);
401 }
402 SDValue HiHalf(SDValue V, SelectionDAG &DAG) const {
403 MVT Ty = ty(V);
404 const SDLoc &dl(V);
405 if (!Ty.isVector()) {
406 assert(Ty.getSizeInBits() == 64);
407 return DAG.getTargetExtractSubreg(Hexagon::isub_hi, dl, MVT::i32, V);
408 }
409 MVT HalfTy = typeSplit(Ty).first;
410 SDValue Idx = DAG.getConstant(HalfTy.getVectorNumElements(), dl, MVT::i32);
411 return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, HalfTy, V, Idx);
412 }
413
414 bool allowsHvxMemoryAccess(MVT VecTy, MachineMemOperand::Flags Flags,
415 unsigned *Fast) const;
416 bool allowsHvxMisalignedMemoryAccesses(MVT VecTy,
418 unsigned *Fast) const;
419 void AdjustHvxInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const;
420
421 bool isHvxSingleTy(MVT Ty) const;
422 bool isHvxPairTy(MVT Ty) const;
423 bool isHvxBoolTy(MVT Ty) const;
424 SDValue convertToByteIndex(SDValue ElemIdx, MVT ElemTy,
425 SelectionDAG &DAG) const;
426 SDValue getIndexInWord32(SDValue Idx, MVT ElemTy, SelectionDAG &DAG) const;
427 SDValue getByteShuffle(const SDLoc &dl, SDValue Op0, SDValue Op1,
428 ArrayRef<int> Mask, SelectionDAG &DAG) const;
429
430 SDValue buildHvxVectorReg(ArrayRef<SDValue> Values, const SDLoc &dl,
431 MVT VecTy, SelectionDAG &DAG) const;
432 SDValue buildHvxVectorPred(ArrayRef<SDValue> Values, const SDLoc &dl,
433 MVT VecTy, SelectionDAG &DAG) const;
434 SDValue createHvxPrefixPred(SDValue PredV, const SDLoc &dl,
435 unsigned BitBytes, bool ZeroFill,
436 SelectionDAG &DAG) const;
437 SDValue extractHvxElementReg(SDValue VecV, SDValue IdxV, const SDLoc &dl,
438 MVT ResTy, SelectionDAG &DAG) const;
439 SDValue extractHvxElementPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
440 MVT ResTy, SelectionDAG &DAG) const;
441 SDValue insertHvxElementReg(SDValue VecV, SDValue IdxV, SDValue ValV,
442 const SDLoc &dl, SelectionDAG &DAG) const;
443 SDValue insertHvxElementPred(SDValue VecV, SDValue IdxV, SDValue ValV,
444 const SDLoc &dl, SelectionDAG &DAG) const;
445 SDValue extractHvxSubvectorReg(SDValue OrigOp, SDValue VecV, SDValue IdxV,
446 const SDLoc &dl, MVT ResTy, SelectionDAG &DAG)
447 const;
448 SDValue extractHvxSubvectorPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
449 MVT ResTy, SelectionDAG &DAG) const;
450 SDValue insertHvxSubvectorReg(SDValue VecV, SDValue SubV, SDValue IdxV,
451 const SDLoc &dl, SelectionDAG &DAG) const;
452 SDValue insertHvxSubvectorPred(SDValue VecV, SDValue SubV, SDValue IdxV,
453 const SDLoc &dl, SelectionDAG &DAG) const;
454 SDValue extendHvxVectorPred(SDValue VecV, const SDLoc &dl, MVT ResTy,
455 bool ZeroExt, SelectionDAG &DAG) const;
456 SDValue compressHvxPred(SDValue VecQ, const SDLoc &dl, MVT ResTy,
457 SelectionDAG &DAG) const;
458 SDValue resizeToWidth(SDValue VecV, MVT ResTy, bool Signed, const SDLoc &dl,
459 SelectionDAG &DAG) const;
460 SDValue extractSubvector(SDValue Vec, MVT SubTy, unsigned SubIdx,
461 SelectionDAG &DAG) const;
462 VectorPair emitHvxAddWithOverflow(SDValue A, SDValue B, const SDLoc &dl,
463 bool Signed, SelectionDAG &DAG) const;
464 VectorPair emitHvxShiftRightRnd(SDValue Val, unsigned Amt, bool Signed,
465 SelectionDAG &DAG) const;
466 SDValue emitHvxMulHsV60(SDValue A, SDValue B, const SDLoc &dl,
467 SelectionDAG &DAG) const;
468 SDValue emitHvxMulLoHiV60(SDValue A, bool SignedA, SDValue B, bool SignedB,
469 const SDLoc &dl, SelectionDAG &DAG) const;
470 SDValue emitHvxMulLoHiV62(SDValue A, bool SignedA, SDValue B, bool SignedB,
471 const SDLoc &dl, SelectionDAG &DAG) const;
472
473 SDValue LowerHvxBuildVector(SDValue Op, SelectionDAG &DAG) const;
474 SDValue LowerHvxSplatVector(SDValue Op, SelectionDAG &DAG) const;
475 SDValue LowerHvxConcatVectors(SDValue Op, SelectionDAG &DAG) const;
476 SDValue LowerHvxExtractElement(SDValue Op, SelectionDAG &DAG) const;
477 SDValue LowerHvxInsertElement(SDValue Op, SelectionDAG &DAG) const;
478 SDValue LowerHvxExtractSubvector(SDValue Op, SelectionDAG &DAG) const;
479 SDValue LowerHvxInsertSubvector(SDValue Op, SelectionDAG &DAG) const;
480 SDValue LowerHvxBitcast(SDValue Op, SelectionDAG &DAG) const;
481 SDValue LowerHvxAnyExt(SDValue Op, SelectionDAG &DAG) const;
482 SDValue LowerHvxSignExt(SDValue Op, SelectionDAG &DAG) const;
483 SDValue LowerHvxZeroExt(SDValue Op, SelectionDAG &DAG) const;
484 SDValue LowerHvxCttz(SDValue Op, SelectionDAG &DAG) const;
485 SDValue LowerHvxMulh(SDValue Op, SelectionDAG &DAG) const;
486 SDValue LowerHvxMulLoHi(SDValue Op, SelectionDAG &DAG) const;
487 SDValue LowerHvxExtend(SDValue Op, SelectionDAG &DAG) const;
488 SDValue LowerHvxSelect(SDValue Op, SelectionDAG &DAG) const;
489 SDValue LowerHvxShift(SDValue Op, SelectionDAG &DAG) const;
490 SDValue LowerHvxFunnelShift(SDValue Op, SelectionDAG &DAG) const;
491 SDValue LowerHvxIntrinsic(SDValue Op, SelectionDAG &DAG) const;
492 SDValue LowerHvxMaskedOp(SDValue Op, SelectionDAG &DAG) const;
493 SDValue LowerHvxFpExtend(SDValue Op, SelectionDAG &DAG) const;
494 SDValue LowerHvxFpToInt(SDValue Op, SelectionDAG &DAG) const;
495 SDValue LowerHvxIntToFp(SDValue Op, SelectionDAG &DAG) const;
496 SDValue LowerHvxPred32ToFp(SDValue Op, SelectionDAG &DAG) const;
497 SDValue LowerHvxPred64ToFp(SDValue Op, SelectionDAG &DAG) const;
498 SDValue LowerHvxPartialReduceMLA(SDValue Op, SelectionDAG &DAG) const;
499 SDValue LowerHvxFpSetoeq(SDValue Op, SelectionDAG &DAG) const;
500 SDValue LowerHvxVecReduceFMinMax(SDValue Op, unsigned PairwiseOpc,
501 bool IgnoreNaN, SelectionDAG &DAG) const;
502 SDValue LowerHvxVecReduceFMin(SDValue Op, SelectionDAG &DAG) const;
503 SDValue LowerHvxVecReduceFMax(SDValue Op, SelectionDAG &DAG) const;
504 SDValue LowerHvxVecReduceFMinimum(SDValue Op, SelectionDAG &DAG) const;
505 SDValue LowerHvxVecReduceFMaximum(SDValue Op, SelectionDAG &DAG) const;
506 SDValue LowerHvxFMinNum(SDValue Op, SelectionDAG &DAG) const;
507 SDValue LowerHvxFMaxNum(SDValue Op, SelectionDAG &DAG) const;
508 SDValue ExpandHvxFpToInt(SDValue Op, SelectionDAG &DAG) const;
509 SDValue ExpandHvxIntToFp(SDValue Op, SelectionDAG &DAG) const;
510 SDValue LowerHvxStore(SDValue Op, SelectionDAG &DAG) const;
511 SDValue LowerHvxLoad(SDValue Op, SelectionDAG &DAG) const;
512
513 VectorPair SplitVectorOp(SDValue Op, SelectionDAG &DAG) const;
514
515 SDValue SplitHvxMemOp(SDValue Op, SelectionDAG &DAG) const;
516 SDValue WidenHvxLoad(SDValue Op, SelectionDAG &DAG) const;
517 SDValue WidenHvxStore(SDValue Op, SelectionDAG &DAG) const;
518 SDValue WidenHvxSetCC(SDValue Op, SelectionDAG &DAG) const;
519 SDValue LegalizeHvxResize(SDValue Op, SelectionDAG &DAG) const;
520 SDValue ExpandHvxResizeIntoSteps(SDValue Op, SelectionDAG &DAG) const;
521 SDValue EqualizeFpIntConversion(SDValue Op, SelectionDAG &DAG) const;
522
523 SDValue CreateTLWrapper(SDValue Op, SelectionDAG &DAG) const;
524 SDValue RemoveTLWrapper(SDValue Op, SelectionDAG &DAG) const;
525 SDValue WidenHvxTruncateToBool(SDValue Op, SelectionDAG &DAG) const;
526
527 std::pair<const TargetRegisterClass*, uint8_t>
528 findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT)
529 const override;
530
531 bool shouldSplitToHvx(MVT Ty, SelectionDAG &DAG) const;
532 bool shouldWidenToHvx(MVT Ty, SelectionDAG &DAG) const;
533 bool isHvxOperation(SDNode *N, SelectionDAG &DAG) const;
534 SDValue LowerHvxOperation(SDValue Op, SelectionDAG &DAG) const;
535 void LowerHvxOperationWrapper(SDNode *N, SmallVectorImpl<SDValue> &Results,
536 SelectionDAG &DAG) const;
537 void ReplaceHvxNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
538 SelectionDAG &DAG) const;
539
540 SDValue combineTruncateBeforeLegal(SDValue Op, DAGCombinerInfo &DCI) const;
541
542 SDValue combineConcatOfShuffles(SDValue Op, SelectionDAG &DAG) const;
543 SDValue combineConcatOfScalarPreds(SDValue Op, unsigned BitBytes,
544 SelectionDAG &DAG) const;
545 SDValue combineConcatVectorsBeforeLegal(SDValue Op, DAGCombinerInfo & DCI)
546 const;
547 SDValue expandVecReduceAdd(SDNode *N, SelectionDAG &DAG) const;
548 SDValue createExtendingPartialReduceMLA(
549 unsigned Opcode, EVT AccEltType, unsigned AccNumElements, EVT InputType,
550 const SDValue &A, const SDValue &B, unsigned &RemainingReductionRatio,
551 const SDLoc &DL, SelectionDAG &DAG) const;
552 SDValue splitVecReduceAdd(SDNode *N, SelectionDAG &DAG) const;
553 SDValue splitExtendingPartialReduceMLA(SDNode *N, SelectionDAG &DAG) const;
554 SDValue PerformHvxDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
555};
556
557} // end namespace llvm
558
559#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned Imm
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Function Alias Analysis Results
#define X(NUM, ENUM, NAME)
Definition ELF.h:857
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define RegName(no)
#define I(x, y, z)
Definition MD5.cpp:57
static bool isUndef(const MachineInstr &MI)
Register const TargetRegisterInfo * TRI
static Value * extractVector(IRBuilderTy &IRB, Value *V, unsigned BeginIndex, unsigned EndIndex, const Twine &Name)
Definition SROA.cpp:2650
static Value * insertVector(IRBuilderTy &IRB, Value *Old, Value *V, unsigned BeginIndex, const Twine &Name)
Definition SROA.cpp:2671
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
Definition APInt.h:78
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
This class represents a function call, abstracting a target machine's calling convention.
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const override
Returns relocation base for the given PIC jumptable.
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFMINFMAX(SDValue Op, SelectionDAG &DAG) const
Register getExceptionSelectorRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
MachineInstr * EmitKCFICheck(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator &MBBI, const TargetInstrInfo *TII) const override
SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const
bool isMaskAndCmp0FoldingBeneficial(const Instruction &AndI) const override
Return if the target supports combining a chain like:
bool isCtlzFast() const override
Return true if ctlz instruction is fast.
SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const
void AdjustInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const override
This method should be implemented by targets that mark instructions with the 'hasPostISelHook' flag.
bool isTargetCanonicalConstantNode(SDValue Op) const override
Returns true if the given Opc is considered a canonical constant for the target, which should not be ...
ConstraintType getConstraintType(StringRef Constraint) const override
Given a constraint, return the type of constraint it is for this target.
bool isTruncateFree(Type *Ty1, Type *Ty2) const override
Return true if it's free to truncate a value of type FromTy to type ToTy.
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT) const override
Certain combinations of ABIs, Targets and features require that types are legal for some operations a...
unsigned getStackProbeSize(const MachineFunction &MF, Align StackAlign) const
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const
SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const
ExtractSubvectorCost getExtractSubvectorCost(EVT ResVT, EVT SrcVT, unsigned Index) const override
Return the cost of extracting a subvector of type ResVT from a vector of type SrcVT,...
SDValue LowerUAddSubO(SDValue Op, SelectionDAG &DAG) const
Value * emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy, Value *Addr, AtomicOrdering Ord) const override
Perform a load-linked operation on Addr, returning a "Value *" with the corresponding pointee type.
bool isLegalICmpImmediate(int64_t Imm) const override
isLegalICmpImmediate - Return true if the specified immediate is legal icmp immediate,...
bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT, std::optional< unsigned > ByteOffset) const override
Return true if it is profitable to reduce a load to a smaller type.
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, unsigned AS, Instruction *I=nullptr) const override
isLegalAddressingMode - Return true if the addressing mode represented by AM is legal for this target...
SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const
AtomicExpansionKind shouldExpandAtomicStoreInIR(StoreInst *SI) const override
Returns how the given (atomic) store should be expanded by the IR-level AtomicExpand pass into.
SDValue GetDynamicTLSAddr(SelectionDAG &DAG, SDValue Chain, GlobalAddressSDNode *GA, SDValue InGlue, EVT PtrVT, unsigned ReturnReg, unsigned char OperandGlues) const
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,...
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override
This method will be invoked for all target nodes and for any target-independent nodes that the target...
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
bool getPostIndexedAddressParts(SDNode *N, SDNode *Op, SDValue &Base, SDValue &Offset, ISD::MemIndexedMode &AM, SelectionDAG &DAG) const override
Returns true by value, base pointer and offset pointer and addressing mode by reference if this node ...
SDValue LowerUnalignedLoad(SDValue Op, SelectionDAG &DAG) const
SDValue LowerFDIV(SDValue Op, SelectionDAG &DAG) const
SDValue LowerVACOPY(SDValue Op, SelectionDAG &DAG) const
unsigned getVectorTypeBreakdownForCallingConv(LLVMContext &Context, CallingConv::ID CC, EVT VT, EVT &IntermediateVT, unsigned &NumIntermediates, MVT &RegisterVT) const override
Certain targets such as MIPS require that some types such as vectors are always broken down into scal...
bool isCheapToSpeculateCtlz(Type *) const override
Return true if it is cheap to speculate a call to intrinsic ctlz.
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,...
bool isFPImmLegal(const APFloat &Imm, EVT VT, bool ForCodeSize) const override
isFPImmLegal - Returns true if the target can instruction select the specified FP immediate natively.
bool mayBeEmittedAsTailCall(const CallInst *CI) const override
Return true if the target may be able emit the call instruction as a tail call.
AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override
Returns how the given (atomic) load should be expanded by the IR-level AtomicExpand pass.
bool supportKCFIBundles() const override
Return true if the target supports kcfi operand bundles.
bool isCheapToSpeculateCttz(Type *) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
bool isUsedByReturnOnly(SDNode *N, SDValue &Chain) const override
Return true if result of the specified node is used by a return node only.
SDValue LowerCallResult(SDValue Chain, SDValue InGlue, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &dl, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals, const SmallVectorImpl< SDValue > &OutVals, SDValue Callee) const
LowerCallResult - Lower the result values of an ISD::CALL into the appropriate copies out of appropri...
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const
SDValue LowerToTLSInitialExecModel(GlobalAddressSDNode *GA, SelectionDAG &DAG) const
SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA, SelectionDAG &DAG) const
bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT, unsigned AddrSpace, Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const override
Return true if the target supports a memory access of this type for the given address space and align...
SDValue LowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
SDValue LowerROTL(SDValue Op, SelectionDAG &DAG) const
SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const
SDValue LowerLoad(SDValue Op, SelectionDAG &DAG) const
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...
bool isShuffleMaskLegal(ArrayRef< int > Mask, EVT VT) const override
Targets can use this to indicate that they only support some VECTOR_SHUFFLE operations,...
LegalizeAction getCustomOperationAction(SDNode &Op) const override
How to legalize this custom operation?
SDValue LowerToTLSLocalExecModel(GlobalAddressSDNode *GA, SelectionDAG &DAG) const
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const
bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override
Return true if a truncation from FromTy to ToTy is permitted when deciding whether a call is in tail ...
SDValue LowerUAddSubOCarry(SDValue Op, SelectionDAG &DAG) const
bool shouldExpandBuildVectorWithShuffles(EVT VT, unsigned DefinedValues) const override
bool shouldConvertConstantLoadToIntImm(const APInt &Imm, Type *Ty) const override
Returns true if it is beneficial to convert a load of a constant to just the constant itself.
Register getExceptionPointerRegister(ExceptionHandling EH, const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl< SDValue > &InVals) const override
LowerCall - Functions arguments are copied from virtual regs to (physical regs)/(stack frame),...
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace, Align Alignment, MachineMemOperand::Flags Flags, unsigned *Fast) const override
Determine if the target supports unaligned memory accesses.
SDValue LowerStore(SDValue Op, SelectionDAG &DAG) const
SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) const
bool hasInlineStackProbe(const MachineFunction &MF) const override
SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const
EVT getSetCCResultType(const DataLayout &, LLVMContext &C, EVT VT) const override
Return the ValueType of the result of SETCC operations.
void ReplaceNodeResults(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked when a node result type is illegal for the target, and the operation was reg...
Value * emitStoreConditional(IRBuilderBase &Builder, Value *Val, Value *Addr, AtomicOrdering Ord) const override
Perform a store-conditional operation to Addr.
bool hasBitTest(SDValue X, SDValue Y) const override
Return true if the target has a bit-test instruction: (X & (1 << Y)) ==/!= 0 This knowledge can be us...
HexagonTargetLowering(const TargetMachine &TM, const HexagonSubtarget &ST)
SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
bool IsEligibleForTailCallOptimization(SDValue Callee, CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet, bool isCallerStructRet, const SmallVectorImpl< ISD::OutputArg > &Outs, const SmallVectorImpl< SDValue > &OutVals, const SmallVectorImpl< ISD::InputArg > &Ins, SelectionDAG &DAG) const
IsEligibleForTailCallOptimization - Check whether the call is eligible for tail call optimization.
SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const
void LowerOperationWrapper(SDNode *N, SmallVectorImpl< SDValue > &Results, SelectionDAG &DAG) const override
This callback is invoked by the type legalizer to legalize nodes with an illegal operand type but leg...
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const
SDValue LowerVECTOR_SHIFT(SDValue Op, SelectionDAG &DAG) const
SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const
AtomicExpansionKind shouldExpandAtomicRMWInIR(const AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
std::pair< unsigned, const TargetRegisterClass * > getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, StringRef Constraint, MVT VT) const override
Given a physical register constraint (e.g.
SDValue LowerBITCAST(SDValue Op, SelectionDAG &DAG) const
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &, EVT) const override
Return true if an FMA operation is faster than a pair of mul and add instructions.
SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const
EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op, const AttributeList &FuncAttributes) const override
Returns the target specific optimal type for load and store operations as a result of memset,...
SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const
LegalizeTypeAction getPreferredVectorAction(MVT VT) const override
Return the preferred vector type legalization action.
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, bool isVarArg, const SmallVectorImpl< ISD::OutputArg > &Outs, LLVMContext &Context, const Type *RetTy) const override
This hook should be implemented to check whether the return values described by the Outs array can fi...
SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const
Register getRegisterByName(const char *RegName, LLT VT, const MachineFunction &MF) const override
Return the register ID of the name passed in.
void getTgtMemIntrinsic(SmallVectorImpl< IntrinsicInfo > &Infos, const CallBase &I, MachineFunction &MF, unsigned Intrinsic) const override
Given an intrinsic, checks if on the target the intrinsic will need to map to a MemIntrinsicNode (tou...
AtomicExpansionKind shouldExpandAtomicCmpXchgInIR(const AtomicCmpXchgInst *AI) const override
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass.
std::pair< MVT, unsigned > handleMaskRegisterForCallingConv(const HexagonSubtarget &Subtarget, EVT VT) const
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const
SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const
Common base class shared among various IRBuilders.
Definition IRBuilder.h:114
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
An instruction for reading from memory.
Machine Value Type.
static MVT getVectorVT(MVT VT, unsigned NumElements)
static MVT getIntegerVT(unsigned BitWidth)
Instructions::iterator instr_iterator
Representation of each machine instruction.
Flags
Flags values. These may be or'd together.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:294
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
TargetInstrInfo - Interface to description of machine instruction set.
ExtractSubvectorCost
Enum that specifies how expensive lowering an EXTRACT_SUBVECTOR is.
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
TargetLowering(const TargetLowering &)=delete
Primary interface to the complete machine description for the target machine.
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:46
LLVM Value Representation.
Definition Value.h:75
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ UNDEF
UNDEF - An undefined node.
Definition ISDOpcodes.h:233
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
Definition ISDOpcodes.h:617
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
RelativeUniformCounterPtr Values
Definition InstrProf.h:91
@ Load
The value being inserted comes from a load (InsertElement only).
LLVM_ABI Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Fast
Assign the register banks as fast as possible (default).
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
ExceptionHandling
Definition CodeGen.h:54
#define N
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:35
static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, bool IsScalable=false)
Returns the EVT that represents a vector NumElements in length, where each element is of type VT.
Definition ValueTypes.h:70
bool isVector() const
Return true if this is a vector value type.
Definition ValueTypes.h:176
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition ValueTypes.h:359
This structure contains all information that is necessary for lowering calls.