LLVM 22.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
32namespace HexagonISD {
33
34// clang-format off
35enum NodeType : unsigned {
37
39 CONST32_GP, // For marking data present in GP.
40 ADDC, // Add with carry: (X, Y, Cin) -> (X+Y, Cout).
41 SUBC, // Sub with carry: (X, Y, Cin) -> (X+~Y+Cin, Cout).
43
44 AT_GOT, // Index in GOT.
45 AT_PCREL, // Offset relative to PC.
46
47 CALL, // Function call.
48 CALLnr, // Function call that does not return.
50
51 RET_GLUE, // Return with a glue operand.
52 BARRIER, // Memory barrier.
53 JT, // Jump table.
54 CP, // Constant pool.
55
57 VASL, // Vector shifts by a scalar value
60 MFSHL, // Funnel shifts with the shift amount guaranteed to be
61 MFSHR, // within the range of the bit width of the element.
62
63 SSAT, // Signed saturate.
64 USAT, // Unsigned saturate.
65 SMUL_LOHI, // Same as ISD::SMUL_LOHI, but opaque to the combiner.
66 UMUL_LOHI, // Same as ISD::UMUL_LOHI, but opaque to the combiner.
67 // We want to legalize MULH[SU] to [SU]MUL_LOHI, but the
68 // combiner will keep rewriting it back to MULH[SU].
69 USMUL_LOHI, // Like SMUL_LOHI, but unsigned*signed.
70
85 D2P, // Convert 8-byte value to 8-bit predicate register. [*]
86 P2D, // Convert 8-bit predicate register to 8-byte value. [*]
87 V2Q, // Convert HVX vector to a vector predicate reg. [*]
88 Q2V, // Convert vector predicate to an HVX vector. [*]
89 // [*] The equivalence is defined as "Q <=> (V != 0)",
90 // where the != operation compares bytes.
91 // Note: V != 0 is implemented as V >u 0.
95
96 TL_EXTEND, // Wrappers for ISD::*_EXTEND and ISD::TRUNCATE to prevent DAG
97 TL_TRUNCATE, // from auto-folding operations, e.g.
98 // (i32 ext (i16 ext i8)) would be folded to (i32 ext i8).
99 // To simplify the type legalization, we want to keep these
100 // single steps separate during type legalization.
101 // TL_[EXTEND|TRUNCATE] Inp, i128 _, i32 Opc
102 // * Inp is the original input to extend/truncate,
103 // * _ is a dummy operand with an illegal type (can be undef),
104 // * Opc is the original opcode.
105 // The legalization process (in Hexagon lowering code) will
106 // first deal with the "real" types (i.e. Inp and the result),
107 // and once all of them are processed, the wrapper node will
108 // be replaced with the original ISD node. The dummy illegal
109 // operand is there to make sure that the legalization hooks
110 // are called again after everything else is legal, giving
111 // us the opportunity to undo the wrapping.
112
113 TYPECAST, // No-op that's used to convert between different legal
114 // types in a register.
115 VALIGN, // Align two vectors (in Op0, Op1) to one that would have
116 // been loaded from address in Op2.
117 VALIGNADDR, // Align vector address: Op0 & -Op1, except when it is
118 // an address in a vector load, then it's a no-op.
119 ISEL, // Marker for nodes that were created during ISel, and
120 // which need explicit selection (would have been left
121 // unselected otherwise).
122 OP_END
124
125} // end namespace HexagonISD
126// clang-format on
127
128class HexagonSubtarget;
129
131 int VarArgsFrameOffset; // Frame offset to start of varargs area.
132 const HexagonTargetMachine &HTM;
133 const HexagonSubtarget &Subtarget;
134
135public:
136 explicit HexagonTargetLowering(const TargetMachine &TM,
137 const HexagonSubtarget &ST);
138
139 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
140 /// for tail call optimization. Targets which want to do tail call
141 /// optimization should implement this function.
143 CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet,
144 bool isCallerStructRet, const SmallVectorImpl<ISD::OutputArg> &Outs,
145 const SmallVectorImpl<SDValue> &OutVals,
146 const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG& DAG) const;
147
149 MachineFunction &MF,
150 unsigned Intrinsic) const override;
151
152 bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
153 bool isTruncateFree(EVT VT1, EVT VT2) const override;
154
155 bool isCheapToSpeculateCttz(Type *) const override { return true; }
156 bool isCheapToSpeculateCtlz(Type *) const override { return true; }
157 bool isCtlzFast() const override { return true; }
158
159 bool hasBitTest(SDValue X, SDValue Y) const override;
160
161 bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
162
163 /// Return true if an FMA operation is faster than a pair of mul and add
164 /// instructions. fmuladd intrinsics will be expanded to FMAs when this
165 /// method returns true (and FMAs are legal), otherwise fmuladd is
166 /// expanded to mul + add.
168 EVT) const override;
169
170 // Should we expand the build vector with shuffles?
172 unsigned DefinedValues) const override;
173 bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT,
174 unsigned Index) const override;
175
176 bool isTargetCanonicalConstantNode(SDValue Op) const override;
177
178 bool isShuffleMaskLegal(ArrayRef<int> Mask, EVT VT) const override;
181
182 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
184 SelectionDAG &DAG) const override;
186 SelectionDAG &DAG) const override;
187
188 const char *getTargetNodeName(unsigned Opcode) const override;
189 std::pair<MVT, unsigned>
191 EVT VT) const;
192
211
220 SDValue
221 LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
223 const SDLoc &dl, SelectionDAG &DAG,
224 SmallVectorImpl<SDValue> &InVals) const override;
229 SelectionDAG &DAG) const;
231 SelectionDAG &DAG) const;
233 SelectionDAG &DAG) const;
235 GlobalAddressSDNode *GA, SDValue InGlue, EVT PtrVT,
236 unsigned ReturnReg, unsigned char OperandGlues) const;
238
240 SmallVectorImpl<SDValue> &InVals) const override;
242 CallingConv::ID CallConv, bool isVarArg,
244 const SDLoc &dl, SelectionDAG &DAG,
246 const SmallVectorImpl<SDValue> &OutVals,
247 SDValue Callee) const;
248
254
255 bool CanLowerReturn(CallingConv::ID CallConv,
256 MachineFunction &MF, bool isVarArg,
258 LLVMContext &Context, const Type *RetTy) const override;
259
260 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
262 const SmallVectorImpl<SDValue> &OutVals,
263 const SDLoc &dl, SelectionDAG &DAG) const override;
264
265 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
266
267 bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
268
269 Register getRegisterByName(const char* RegName, LLT VT,
270 const MachineFunction &MF) const override;
271
273 CallingConv::ID CC, EVT VT,
274 EVT &IntermediateVT,
275 unsigned &NumIntermediates,
276 MVT &RegisterVT) const override;
277
279 EVT VT) const override;
280 /// If a physical register, this returns the register that receives the
281 /// exception address on entry to an EH pad.
283 getExceptionPointerRegister(const Constant *PersonalityFn) const override {
284 return Hexagon::R0;
285 }
286
287 /// If a physical register, this returns the register that receives the
288 /// exception typeid on entry to a landing pad.
290 getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
291 return Hexagon::R1;
292 }
293
298
300 EVT VT) const override {
301 if (!VT.isVector())
302 return MVT::i1;
303 else
304 return EVT::getVectorVT(C, MVT::i1, VT.getVectorNumElements());
305 }
306
310 SelectionDAG &DAG) const override;
311
312 ConstraintType getConstraintType(StringRef Constraint) const override;
313
314 std::pair<unsigned, const TargetRegisterClass *>
316 StringRef Constraint, MVT VT) const override;
317
318 // Intrinsics
321 /// isLegalAddressingMode - Return true if the addressing mode represented
322 /// by AM is legal for this target, for a load/store of the specified type.
323 /// The type may be VoidTy, in which case only return true if the addressing
324 /// mode is legal for a load/store of any legal type.
325 /// TODO: Handle pre/postinc as well.
326 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
327 Type *Ty, unsigned AS,
328 Instruction *I = nullptr) const override;
329 /// Return true if folding a constant offset with the given GlobalAddress
330 /// is legal. It is frequently not legal in PIC relocation models.
331 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
332
333 bool isFPImmLegal(const APFloat &Imm, EVT VT,
334 bool ForCodeSize) const override;
335
336 /// isLegalICmpImmediate - Return true if the specified immediate is legal
337 /// icmp immediate, that is the target has icmp instructions which can
338 /// compare a register against the immediate without having to materialize
339 /// the immediate into a register.
340 bool isLegalICmpImmediate(int64_t Imm) const override;
341
342 EVT getOptimalMemOpType(LLVMContext &Context, const MemOp &Op,
343 const AttributeList &FuncAttributes) const override;
344
345 bool allowsMemoryAccess(LLVMContext &Context, const DataLayout &DL, EVT VT,
346 unsigned AddrSpace, Align Alignment,
348 unsigned *Fast) const override;
349
350 bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
351 Align Alignment,
353 unsigned *Fast) const override;
354
355 /// Returns relocation base for the given PIC jumptable.
357 const override;
358
359 /// Returns true if it is beneficial to convert a load of a constant
360 /// to just the constant itself.
362 Type *Ty) const override;
363
364 bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy, EVT NewVT,
365 std::optional<unsigned> ByteOffset) const override;
366
368 SDNode *Node) const override;
369
370 // Handling of atomic RMW instructions.
371 Value *emitLoadLinked(IRBuilderBase &Builder, Type *ValueTy, Value *Addr,
372 AtomicOrdering Ord) const override;
374 AtomicOrdering Ord) const override;
379
383 }
384 bool softPromoteHalfType() const override { return true; }
385
386private:
387 void initializeHVXLowering();
388 unsigned getPreferredHvxVectorAction(MVT VecTy) const;
389 unsigned getCustomHvxOperationAction(SDNode &Op) const;
390
391 bool validateConstPtrAlignment(SDValue Ptr, Align NeedAlign, const SDLoc &dl,
392 SelectionDAG &DAG) const;
393 SDValue replaceMemWithUndef(SDValue Op, SelectionDAG &DAG) const;
394
395 std::pair<SDValue,int> getBaseAndOffset(SDValue Addr) const;
396
397 bool getBuildVectorConstInts(ArrayRef<SDValue> Values, MVT VecTy,
398 SelectionDAG &DAG,
399 MutableArrayRef<ConstantInt*> Consts) const;
400 SDValue buildVector32(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
401 SelectionDAG &DAG) const;
402 SDValue buildVector64(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
403 SelectionDAG &DAG) const;
404 SDValue extractVector(SDValue VecV, SDValue IdxV, const SDLoc &dl,
405 MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
406 SDValue extractVectorPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
407 MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
408 SDValue insertVector(SDValue VecV, SDValue ValV, SDValue IdxV,
409 const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
410 SDValue insertVectorPred(SDValue VecV, SDValue ValV, SDValue IdxV,
411 const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
412 SDValue expandPredicate(SDValue Vec32, const SDLoc &dl,
413 SelectionDAG &DAG) const;
414 SDValue contractPredicate(SDValue Vec64, const SDLoc &dl,
415 SelectionDAG &DAG) const;
416 SDValue getSplatValue(SDValue Op, SelectionDAG &DAG) const;
417 SDValue getVectorShiftByInt(SDValue Op, SelectionDAG &DAG) const;
418 SDValue appendUndef(SDValue Val, MVT ResTy, SelectionDAG &DAG) const;
419 SDValue getCombine(SDValue Hi, SDValue Lo, const SDLoc &dl, MVT ResTy,
420 SelectionDAG &DAG) const;
421
422 bool isUndef(SDValue Op) const {
423 if (Op.isMachineOpcode())
424 return Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF;
425 return Op.getOpcode() == ISD::UNDEF;
426 }
427 SDValue getInstr(unsigned MachineOpc, const SDLoc &dl, MVT Ty,
428 ArrayRef<SDValue> Ops, SelectionDAG &DAG) const {
429 SDNode *N = DAG.getMachineNode(MachineOpc, dl, Ty, Ops);
430 return SDValue(N, 0);
431 }
432 SDValue getZero(const SDLoc &dl, MVT Ty, SelectionDAG &DAG) const;
433
434 using VectorPair = std::pair<SDValue, SDValue>;
435 using TypePair = std::pair<MVT, MVT>;
436
437 SDValue getInt(unsigned IntId, MVT ResTy, ArrayRef<SDValue> Ops,
438 const SDLoc &dl, SelectionDAG &DAG) const;
439
440 MVT ty(SDValue Op) const {
441 return Op.getValueType().getSimpleVT();
442 }
443 TypePair ty(const VectorPair &Ops) const {
444 return { Ops.first.getValueType().getSimpleVT(),
445 Ops.second.getValueType().getSimpleVT() };
446 }
447 MVT tyScalar(MVT Ty) const {
448 if (!Ty.isVector())
449 return Ty;
450 return MVT::getIntegerVT(Ty.getSizeInBits());
451 }
452 MVT tyVector(MVT Ty, MVT ElemTy) const {
453 if (Ty.isVector() && Ty.getVectorElementType() == ElemTy)
454 return Ty;
455 unsigned TyWidth = Ty.getSizeInBits();
456 unsigned ElemWidth = ElemTy.getSizeInBits();
457 assert((TyWidth % ElemWidth) == 0);
458 return MVT::getVectorVT(ElemTy, TyWidth/ElemWidth);
459 }
460
461 MVT typeJoin(const TypePair &Tys) const;
462 TypePair typeSplit(MVT Ty) const;
463 MVT typeExtElem(MVT VecTy, unsigned Factor) const;
464 MVT typeTruncElem(MVT VecTy, unsigned Factor) const;
465 TypePair typeExtendToWider(MVT Ty0, MVT Ty1) const;
466 TypePair typeWidenToWider(MVT Ty0, MVT Ty1) const;
467 MVT typeLegalize(MVT Ty, SelectionDAG &DAG) const;
468 MVT typeWidenToHvx(MVT Ty) const;
469
470 SDValue opJoin(const VectorPair &Ops, const SDLoc &dl,
471 SelectionDAG &DAG) const;
472 VectorPair opSplit(SDValue Vec, const SDLoc &dl, SelectionDAG &DAG) const;
473 SDValue opCastElem(SDValue Vec, MVT ElemTy, SelectionDAG &DAG) const;
474
475 SDValue LoHalf(SDValue V, SelectionDAG &DAG) const {
476 MVT Ty = ty(V);
477 const SDLoc &dl(V);
478 if (!Ty.isVector()) {
479 assert(Ty.getSizeInBits() == 64);
480 return DAG.getTargetExtractSubreg(Hexagon::isub_lo, dl, MVT::i32, V);
481 }
482 MVT HalfTy = typeSplit(Ty).first;
483 SDValue Idx = getZero(dl, MVT::i32, DAG);
484 return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, HalfTy, V, Idx);
485 }
486 SDValue HiHalf(SDValue V, SelectionDAG &DAG) const {
487 MVT Ty = ty(V);
488 const SDLoc &dl(V);
489 if (!Ty.isVector()) {
490 assert(Ty.getSizeInBits() == 64);
491 return DAG.getTargetExtractSubreg(Hexagon::isub_hi, dl, MVT::i32, V);
492 }
493 MVT HalfTy = typeSplit(Ty).first;
494 SDValue Idx = DAG.getConstant(HalfTy.getVectorNumElements(), dl, MVT::i32);
495 return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, HalfTy, V, Idx);
496 }
497
498 bool allowsHvxMemoryAccess(MVT VecTy, MachineMemOperand::Flags Flags,
499 unsigned *Fast) const;
500 bool allowsHvxMisalignedMemoryAccesses(MVT VecTy,
502 unsigned *Fast) const;
503 void AdjustHvxInstrPostInstrSelection(MachineInstr &MI, SDNode *Node) const;
504
505 bool isHvxSingleTy(MVT Ty) const;
506 bool isHvxPairTy(MVT Ty) const;
507 bool isHvxBoolTy(MVT Ty) const;
508 SDValue convertToByteIndex(SDValue ElemIdx, MVT ElemTy,
509 SelectionDAG &DAG) const;
510 SDValue getIndexInWord32(SDValue Idx, MVT ElemTy, SelectionDAG &DAG) const;
511 SDValue getByteShuffle(const SDLoc &dl, SDValue Op0, SDValue Op1,
512 ArrayRef<int> Mask, SelectionDAG &DAG) const;
513
514 SDValue buildHvxVectorReg(ArrayRef<SDValue> Values, const SDLoc &dl,
515 MVT VecTy, SelectionDAG &DAG) const;
516 SDValue buildHvxVectorPred(ArrayRef<SDValue> Values, const SDLoc &dl,
517 MVT VecTy, SelectionDAG &DAG) const;
518 SDValue createHvxPrefixPred(SDValue PredV, const SDLoc &dl,
519 unsigned BitBytes, bool ZeroFill,
520 SelectionDAG &DAG) const;
521 SDValue extractHvxElementReg(SDValue VecV, SDValue IdxV, const SDLoc &dl,
522 MVT ResTy, SelectionDAG &DAG) const;
523 SDValue extractHvxElementPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
524 MVT ResTy, SelectionDAG &DAG) const;
525 SDValue insertHvxElementReg(SDValue VecV, SDValue IdxV, SDValue ValV,
526 const SDLoc &dl, SelectionDAG &DAG) const;
527 SDValue insertHvxElementPred(SDValue VecV, SDValue IdxV, SDValue ValV,
528 const SDLoc &dl, SelectionDAG &DAG) const;
529 SDValue extractHvxSubvectorReg(SDValue OrigOp, SDValue VecV, SDValue IdxV,
530 const SDLoc &dl, MVT ResTy, SelectionDAG &DAG)
531 const;
532 SDValue extractHvxSubvectorPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
533 MVT ResTy, SelectionDAG &DAG) const;
534 SDValue insertHvxSubvectorReg(SDValue VecV, SDValue SubV, SDValue IdxV,
535 const SDLoc &dl, SelectionDAG &DAG) const;
536 SDValue insertHvxSubvectorPred(SDValue VecV, SDValue SubV, SDValue IdxV,
537 const SDLoc &dl, SelectionDAG &DAG) const;
538 SDValue extendHvxVectorPred(SDValue VecV, const SDLoc &dl, MVT ResTy,
539 bool ZeroExt, SelectionDAG &DAG) const;
540 SDValue compressHvxPred(SDValue VecQ, const SDLoc &dl, MVT ResTy,
541 SelectionDAG &DAG) const;
542 SDValue resizeToWidth(SDValue VecV, MVT ResTy, bool Signed, const SDLoc &dl,
543 SelectionDAG &DAG) const;
544 SDValue extractSubvector(SDValue Vec, MVT SubTy, unsigned SubIdx,
545 SelectionDAG &DAG) const;
546 VectorPair emitHvxAddWithOverflow(SDValue A, SDValue B, const SDLoc &dl,
547 bool Signed, SelectionDAG &DAG) const;
548 VectorPair emitHvxShiftRightRnd(SDValue Val, unsigned Amt, bool Signed,
549 SelectionDAG &DAG) const;
550 SDValue emitHvxMulHsV60(SDValue A, SDValue B, const SDLoc &dl,
551 SelectionDAG &DAG) const;
552 SDValue emitHvxMulLoHiV60(SDValue A, bool SignedA, SDValue B, bool SignedB,
553 const SDLoc &dl, SelectionDAG &DAG) const;
554 SDValue emitHvxMulLoHiV62(SDValue A, bool SignedA, SDValue B, bool SignedB,
555 const SDLoc &dl, SelectionDAG &DAG) const;
556
557 SDValue LowerHvxBuildVector(SDValue Op, SelectionDAG &DAG) const;
558 SDValue LowerHvxSplatVector(SDValue Op, SelectionDAG &DAG) const;
559 SDValue LowerHvxConcatVectors(SDValue Op, SelectionDAG &DAG) const;
560 SDValue LowerHvxExtractElement(SDValue Op, SelectionDAG &DAG) const;
561 SDValue LowerHvxInsertElement(SDValue Op, SelectionDAG &DAG) const;
562 SDValue LowerHvxExtractSubvector(SDValue Op, SelectionDAG &DAG) const;
563 SDValue LowerHvxInsertSubvector(SDValue Op, SelectionDAG &DAG) const;
564 SDValue LowerHvxBitcast(SDValue Op, SelectionDAG &DAG) const;
565 SDValue LowerHvxAnyExt(SDValue Op, SelectionDAG &DAG) const;
566 SDValue LowerHvxSignExt(SDValue Op, SelectionDAG &DAG) const;
567 SDValue LowerHvxZeroExt(SDValue Op, SelectionDAG &DAG) const;
568 SDValue LowerHvxCttz(SDValue Op, SelectionDAG &DAG) const;
569 SDValue LowerHvxMulh(SDValue Op, SelectionDAG &DAG) const;
570 SDValue LowerHvxMulLoHi(SDValue Op, SelectionDAG &DAG) const;
571 SDValue LowerHvxExtend(SDValue Op, SelectionDAG &DAG) const;
572 SDValue LowerHvxSelect(SDValue Op, SelectionDAG &DAG) const;
573 SDValue LowerHvxShift(SDValue Op, SelectionDAG &DAG) const;
574 SDValue LowerHvxFunnelShift(SDValue Op, SelectionDAG &DAG) const;
575 SDValue LowerHvxIntrinsic(SDValue Op, SelectionDAG &DAG) const;
576 SDValue LowerHvxMaskedOp(SDValue Op, SelectionDAG &DAG) const;
577 SDValue LowerHvxFpExtend(SDValue Op, SelectionDAG &DAG) const;
578 SDValue LowerHvxFpToInt(SDValue Op, SelectionDAG &DAG) const;
579 SDValue LowerHvxIntToFp(SDValue Op, SelectionDAG &DAG) const;
580 SDValue ExpandHvxFpToInt(SDValue Op, SelectionDAG &DAG) const;
581 SDValue ExpandHvxIntToFp(SDValue Op, SelectionDAG &DAG) const;
582
583 VectorPair SplitVectorOp(SDValue Op, SelectionDAG &DAG) const;
584
585 SDValue SplitHvxMemOp(SDValue Op, SelectionDAG &DAG) const;
586 SDValue WidenHvxLoad(SDValue Op, SelectionDAG &DAG) const;
587 SDValue WidenHvxStore(SDValue Op, SelectionDAG &DAG) const;
588 SDValue WidenHvxSetCC(SDValue Op, SelectionDAG &DAG) const;
589 SDValue LegalizeHvxResize(SDValue Op, SelectionDAG &DAG) const;
590 SDValue ExpandHvxResizeIntoSteps(SDValue Op, SelectionDAG &DAG) const;
591 SDValue EqualizeFpIntConversion(SDValue Op, SelectionDAG &DAG) const;
592
593 SDValue CreateTLWrapper(SDValue Op, SelectionDAG &DAG) const;
594 SDValue RemoveTLWrapper(SDValue Op, SelectionDAG &DAG) const;
595
596 std::pair<const TargetRegisterClass*, uint8_t>
597 findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT)
598 const override;
599
600 bool shouldSplitToHvx(MVT Ty, SelectionDAG &DAG) const;
601 bool shouldWidenToHvx(MVT Ty, SelectionDAG &DAG) const;
602 bool isHvxOperation(SDNode *N, SelectionDAG &DAG) const;
603 SDValue LowerHvxOperation(SDValue Op, SelectionDAG &DAG) const;
604 void LowerHvxOperationWrapper(SDNode *N, SmallVectorImpl<SDValue> &Results,
605 SelectionDAG &DAG) const;
606 void ReplaceHvxNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
607 SelectionDAG &DAG) const;
608
609 SDValue combineTruncateBeforeLegal(SDValue Op, DAGCombinerInfo &DCI) const;
610 SDValue combineConcatVectorsBeforeLegal(SDValue Op, DAGCombinerInfo & DCI)
611 const;
612 SDValue combineVectorShuffleBeforeLegal(SDValue Op, DAGCombinerInfo & DCI)
613 const;
614
615 SDValue PerformHvxDAGCombine(SDNode * N, DAGCombinerInfo & DCI) const;
616};
617
618} // end namespace llvm
619
620#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
return RetTy
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint64_t Addr
uint32_t Index
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
IRTranslator LLVM IR MI
#define RegName(no)
#define I(x, y, z)
Definition: MD5.cpp:58
Register const TargetRegisterInfo * TRI
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
Definition: APInt.h:78
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
An instruction that atomically checks whether a specified value is in a memory location,...
Definition: Instructions.h:506
an instruction that atomically reads a memory location, combines it with another value,...
Definition: Instructions.h:709
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
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG) const override
Returns relocation base for the given PIC jumptable.
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const
SDValue LowerZERO_EXTEND(SDValue Op, SelectionDAG &DAG) const
SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const
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...
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const
SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const
SDValue LowerUAddSubO(SDValue Op, SelectionDAG &DAG) const
SDValue LowerANY_EXTEND(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...
SDValue LowerEH_LABEL(SDValue Op, SelectionDAG &DAG) const
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 isCheapToSpeculateCttz(Type *) const override
Return true if it is cheap to speculate a call to intrinsic cttz.
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
bool softPromoteHalfType() const override
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
bool isExtractSubvectorCheap(EVT ResVT, EVT SrcVT, unsigned Index) const override
Return true if EXTRACT_SUBVECTOR is cheap for extracting this result type from this source type with ...
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
SDValue LowerSIGN_EXTEND(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.
SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const
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.
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override
Returns how the IR-level AtomicExpand pass should expand the given AtomicRMW, if at all.
SDValue LowerStore(SDValue Op, SelectionDAG &DAG) const
SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) const
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...
Register getExceptionPointerRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception address on entry to an ...
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...
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
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &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(AtomicCmpXchgInst *AI) const override
Returns how the given atomic cmpxchg should be expanded by the IR-level AtomicExpand pass.
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
Register getExceptionSelectorRegister(const Constant *PersonalityFn) const override
If a physical register, this returns the register that receives the exception typeid on entry to a la...
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.
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
SDValue LowerREADSTEADYCOUNTER(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.
Definition: Instructions.h:180
Machine Value Type.
static MVT getVectorVT(MVT VT, unsigned NumElements)
static MVT getIntegerVT(unsigned BitWidth)
Representation of each machine instruction.
Definition: MachineInstr.h:72
Flags
Flags values. These may be or'd together.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:303
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.
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...
Definition: SelectionDAG.h:229
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
An instruction for storing to memory.
Definition: Instructions.h:296
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
LegalizeAction
This enum indicates whether operations are valid for a target, and if not, what action should be used...
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
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
LLVM Value Representation.
Definition: Value.h:75
@ Fast
Attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:41
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:1568
@ UNDEF
UNDEF - An undefined node.
Definition: ISDOpcodes.h:228
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
Definition: ISDOpcodes.h:601
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
Definition: ISDOpcodes.h:1634
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Definition: ISDOpcodes.h:1665
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
AtomicOrdering
Atomic ordering for LLVM's memory model.
DWARFExpression::Operation Op
#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:74
bool isVector() const
Return true if this is a vector value type.
Definition: ValueTypes.h:168
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition: ValueTypes.h:331
This structure contains all information that is necessary for lowering calls.