LLVM  14.0.0git
LegalizerHelper.h
Go to the documentation of this file.
1 //== llvm/CodeGen/GlobalISel/LegalizerHelper.h ---------------- -*- 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 /// \file A pass to convert the target-illegal operations created by IR -> MIR
10 /// translation into ones the target expects to be able to select. This may
11 /// occur in multiple phases, for example G_ADD <2 x i8> -> G_ADD <2 x i16> ->
12 /// G_ADD <4 x i16>.
13 ///
14 /// The LegalizerHelper class is where most of the work happens, and is
15 /// designed to be callable from other passes that find themselves with an
16 /// illegal instruction.
17 //
18 //===----------------------------------------------------------------------===//
19 
20 #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZERHELPER_H
21 #define LLVM_CODEGEN_GLOBALISEL_LEGALIZERHELPER_H
22 
29 
30 namespace llvm {
31 // Forward declarations.
32 class LegalizerInfo;
33 class Legalizer;
34 class MachineRegisterInfo;
35 class GISelChangeObserver;
36 class LostDebugLocObserver;
37 class TargetLowering;
38 
40 public:
41  /// Expose MIRBuilder so clients can set their own RecordInsertInstruction
42  /// functions
44 
45  /// To keep track of changes made by the LegalizerHelper.
47 
48 private:
50  const LegalizerInfo &LI;
51  const TargetLowering &TLI;
52 
53 public:
55  /// Instruction was already legal and no change was made to the
56  /// MachineFunction.
58 
59  /// Instruction has been legalized and the MachineFunction changed.
61 
62  /// Some kind of error has occurred and we could not legalize this
63  /// instruction.
65  };
66 
67  /// Expose LegalizerInfo so the clients can re-use.
68  const LegalizerInfo &getLegalizerInfo() const { return LI; }
69  const TargetLowering &getTargetLowering() const { return TLI; }
70 
75 
76  /// Replace \p MI by a sequence of legal instructions that can implement the
77  /// same operation. Note that this means \p MI may be deleted, so any iterator
78  /// steps should be performed before calling this function. \p Helper should
79  /// be initialized to the MachineFunction containing \p MI.
80  ///
81  /// Considered as an opaque blob, the legal code will use and define the same
82  /// registers as \p MI.
84  LostDebugLocObserver &LocObserver);
85 
86  /// Legalize an instruction by emiting a runtime library call instead.
88 
89  /// Legalize an instruction by reducing the width of the underlying scalar
90  /// type.
91  LegalizeResult narrowScalar(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy);
92 
93  /// Legalize an instruction by performing the operation on a wider scalar type
94  /// (for example a 16-bit addition can be safely performed at 32-bits
95  /// precision, ignoring the unused bits).
96  LegalizeResult widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
97 
98  /// Legalize an instruction by replacing the value type
99  LegalizeResult bitcast(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
100 
101  /// Legalize an instruction by splitting it into simpler parts, hopefully
102  /// understood by the target.
103  LegalizeResult lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
104 
105  /// Legalize a vector instruction by splitting into multiple components, each
106  /// acting on the same scalar type as the original but with fewer elements.
108  LLT NarrowTy);
109 
110  /// Legalize a vector instruction by increasing the number of vector elements
111  /// involved and ignoring the added elements later.
113  LLT MoreTy);
114 
115  /// Cast the given value to an LLT::scalar with an equivalent size. Returns
116  /// the register to use if an instruction was inserted. Returns the original
117  /// register if no coercion was necessary.
118  //
119  // This may also fail and return Register() if there is no legal way to cast.
121 
122  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
123  /// Use by extending the operand's type to \p WideTy using the specified \p
124  /// ExtOpcode for the extension instruction, and replacing the vreg of the
125  /// operand in place.
126  void widenScalarSrc(MachineInstr &MI, LLT WideTy, unsigned OpIdx,
127  unsigned ExtOpcode);
128 
129  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
130  /// Use by truncating the operand's type to \p NarrowTy using G_TRUNC, and
131  /// replacing the vreg of the operand in place.
132  void narrowScalarSrc(MachineInstr &MI, LLT NarrowTy, unsigned OpIdx);
133 
134  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
135  /// Def by extending the operand's type to \p WideTy and truncating it back
136  /// with the \p TruncOpcode, and replacing the vreg of the operand in place.
137  void widenScalarDst(MachineInstr &MI, LLT WideTy, unsigned OpIdx = 0,
138  unsigned TruncOpcode = TargetOpcode::G_TRUNC);
139 
140  // Legalize a single operand \p OpIdx of the machine instruction \p MI as a
141  // Def by truncating the operand's type to \p NarrowTy, replacing in place and
142  // extending back with \p ExtOpcode.
143  void narrowScalarDst(MachineInstr &MI, LLT NarrowTy, unsigned OpIdx,
144  unsigned ExtOpcode);
145  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
146  /// Def by performing it with additional vector elements and extracting the
147  /// result elements, and replacing the vreg of the operand in place.
148  void moreElementsVectorDst(MachineInstr &MI, LLT MoreTy, unsigned OpIdx);
149 
150  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
151  /// Use by producing a vector with undefined high elements, extracting the
152  /// original vector type, and replacing the vreg of the operand in place.
153  void moreElementsVectorSrc(MachineInstr &MI, LLT MoreTy, unsigned OpIdx);
154 
155  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
156  /// use by inserting a G_BITCAST to \p CastTy
157  void bitcastSrc(MachineInstr &MI, LLT CastTy, unsigned OpIdx);
158 
159  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
160  /// def by inserting a G_BITCAST from \p CastTy
161  void bitcastDst(MachineInstr &MI, LLT CastTy, unsigned OpIdx);
162 
163  /// Widen \p OrigReg to \p WideTy by merging to a wider type, padding with
164  /// G_IMPLICIT_DEF, and producing dead results.
165  Register widenWithUnmerge(LLT WideTy, Register OrigReg);
166 
167 private:
169  widenScalarMergeValues(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
171  widenScalarUnmergeValues(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
173  widenScalarExtract(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
175  widenScalarInsert(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
176  LegalizeResult widenScalarAddSubOverflow(MachineInstr &MI, unsigned TypeIdx,
177  LLT WideTy);
178  LegalizeResult widenScalarAddSubShlSat(MachineInstr &MI, unsigned TypeIdx,
179  LLT WideTy);
180  LegalizeResult widenScalarMulo(MachineInstr &MI, unsigned TypeIdx,
181  LLT WideTy);
182 
183  /// Helper function to split a wide generic register into bitwise blocks with
184  /// the given Type (which implies the number of blocks needed). The generic
185  /// registers created are appended to Ops, starting at bit 0 of Reg.
186  void extractParts(Register Reg, LLT Ty, int NumParts,
188 
189  /// Version which handles irregular splits.
190  bool extractParts(Register Reg, LLT RegTy, LLT MainTy,
191  LLT &LeftoverTy,
193  SmallVectorImpl<Register> &LeftoverVRegs);
194 
195  /// Helper function to build a wide generic register \p DstReg of type \p
196  /// RegTy from smaller parts. This will produce a G_MERGE_VALUES,
197  /// G_BUILD_VECTOR, G_CONCAT_VECTORS, or sequence of G_INSERT as appropriate
198  /// for the types.
199  ///
200  /// \p PartRegs must be registers of type \p PartTy.
201  ///
202  /// If \p ResultTy does not evenly break into \p PartTy sized pieces, the
203  /// remainder must be specified with \p LeftoverRegs of type \p LeftoverTy.
204  void insertParts(Register DstReg, LLT ResultTy,
205  LLT PartTy, ArrayRef<Register> PartRegs,
206  LLT LeftoverTy = LLT(), ArrayRef<Register> LeftoverRegs = {});
207 
208  /// Unmerge \p SrcReg into smaller sized values, and append them to \p
209  /// Parts. The elements of \p Parts will be the greatest common divisor type
210  /// of \p DstTy, \p NarrowTy and the type of \p SrcReg. This will compute and
211  /// return the GCD type.
212  LLT extractGCDType(SmallVectorImpl<Register> &Parts, LLT DstTy,
213  LLT NarrowTy, Register SrcReg);
214 
215  /// Unmerge \p SrcReg into \p GCDTy typed registers. This will append all of
216  /// the unpacked registers to \p Parts. This version is if the common unmerge
217  /// type is already known.
218  void extractGCDType(SmallVectorImpl<Register> &Parts, LLT GCDTy,
219  Register SrcReg);
220 
221  /// Produce a merge of values in \p VRegs to define \p DstReg. Perform a merge
222  /// from the least common multiple type, and convert as appropriate to \p
223  /// DstReg.
224  ///
225  /// \p VRegs should each have type \p GCDTy. This type should be greatest
226  /// common divisor type of \p DstReg, \p NarrowTy, and an undetermined source
227  /// type.
228  ///
229  /// \p NarrowTy is the desired result merge source type. If the source value
230  /// needs to be widened to evenly cover \p DstReg, inserts high bits
231  /// corresponding to the extension opcode \p PadStrategy.
232  ///
233  /// \p VRegs will be cleared, and the the result \p NarrowTy register pieces
234  /// will replace it. Returns The complete LCMTy that \p VRegs will cover when
235  /// merged.
236  LLT buildLCMMergePieces(LLT DstTy, LLT NarrowTy, LLT GCDTy,
237  SmallVectorImpl<Register> &VRegs,
238  unsigned PadStrategy = TargetOpcode::G_ANYEXT);
239 
240  /// Merge the values in \p RemergeRegs to an \p LCMTy typed value. Extract the
241  /// low bits into \p DstReg. This is intended to use the outputs from
242  /// buildLCMMergePieces after processing.
243  void buildWidenedRemergeToDst(Register DstReg, LLT LCMTy,
244  ArrayRef<Register> RemergeRegs);
245 
246  /// Perform generic multiplication of values held in multiple registers.
247  /// Generated instructions use only types NarrowTy and i1.
248  /// Destination can be same or two times size of the source.
249  void multiplyRegisters(SmallVectorImpl<Register> &DstRegs,
250  ArrayRef<Register> Src1Regs,
251  ArrayRef<Register> Src2Regs, LLT NarrowTy);
252 
253  void changeOpcode(MachineInstr &MI, unsigned NewOpcode);
254 
255  LegalizeResult tryNarrowPow2Reduction(MachineInstr &MI, Register SrcReg,
256  LLT SrcTy, LLT NarrowTy,
257  unsigned ScalarOpc);
258 
259  // Memcpy family legalization helpers.
260  LegalizeResult lowerMemset(MachineInstr &MI, Register Dst, Register Val,
261  uint64_t KnownLen, Align Alignment,
262  bool IsVolatile);
263  LegalizeResult lowerMemcpyInline(MachineInstr &MI, Register Dst, Register Src,
264  uint64_t KnownLen, Align DstAlign,
265  Align SrcAlign, bool IsVolatile);
266  LegalizeResult lowerMemcpy(MachineInstr &MI, Register Dst, Register Src,
267  uint64_t KnownLen, uint64_t Limit, Align DstAlign,
268  Align SrcAlign, bool IsVolatile);
269  LegalizeResult lowerMemmove(MachineInstr &MI, Register Dst, Register Src,
270  uint64_t KnownLen, Align DstAlign, Align SrcAlign,
271  bool IsVolatile);
272 
273 public:
274  /// Return the alignment to use for a stack temporary object with the given
275  /// type.
276  Align getStackTemporaryAlignment(LLT Type, Align MinAlign = Align()) const;
277 
278  /// Create a stack temporary based on the size in bytes and the alignment
279  MachineInstrBuilder createStackTemporary(TypeSize Bytes, Align Alignment,
280  MachinePointerInfo &PtrInfo);
281 
282  /// Get a pointer to vector element \p Index located in memory for a vector of
283  /// type \p VecTy starting at a base address of \p VecPtr. If \p Index is out
284  /// of bounds the returned pointer is unspecified, but will be within the
285  /// vector bounds.
286  Register getVectorElementPointer(Register VecPtr, LLT VecTy, Register Index);
287 
289  unsigned TypeIdx, LLT NarrowTy);
290 
291  /// Legalize a instruction with a vector type where each operand may have a
292  /// different element type. All type indexes must have the same number of
293  /// elements.
295  unsigned TypeIdx, LLT NarrowTy);
296 
297  LegalizeResult fewerElementsVectorCasts(MachineInstr &MI, unsigned TypeIdx,
298  LLT NarrowTy);
299 
301  fewerElementsVectorCmp(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy);
302 
304  fewerElementsVectorSelect(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy);
305 
307  unsigned TypeIdx, LLT NarrowTy);
308 
309  LegalizeResult moreElementsVectorPhi(MachineInstr &MI, unsigned TypeIdx,
310  LLT MoreTy);
311  LegalizeResult moreElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx,
312  LLT MoreTy);
313 
315  unsigned TypeIdx,
316  LLT NarrowTy);
317  LegalizeResult fewerElementsVectorMerge(MachineInstr &MI, unsigned TypeIdx,
318  LLT NarrowTy);
320  unsigned TypeIdx,
321  LLT NarrowTy);
322 
323  LegalizeResult fewerElementsVectorMulo(MachineInstr &MI, unsigned TypeIdx,
324  LLT NarrowTy);
325 
326  LegalizeResult reduceLoadStoreWidth(GLoadStore &MI, unsigned TypeIdx,
327  LLT NarrowTy);
328 
329  /// Legalize an instruction by reducing the operation width, either by
330  /// narrowing the type of the operation or by reducing the number of elements
331  /// of a vector.
332  /// The used strategy (narrow vs. fewerElements) is decided by \p NarrowTy.
333  /// Narrow is used if the scalar type of \p NarrowTy and \p DstTy differ,
334  /// fewerElements is used when the scalar type is the same but the number of
335  /// elements between \p NarrowTy and \p DstTy differ.
336  LegalizeResult reduceOperationWidth(MachineInstr &MI, unsigned TypeIdx,
337  LLT NarrowTy);
338 
339  LegalizeResult fewerElementsVectorSextInReg(MachineInstr &MI, unsigned TypeIdx,
340  LLT NarrowTy);
341 
342  LegalizeResult narrowScalarShiftByConstant(MachineInstr &MI, const APInt &Amt,
343  LLT HalfTy, LLT ShiftAmtTy);
344 
346  unsigned TypeIdx, LLT NarrowTy);
347 
348  LegalizeResult fewerElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx,
349  LLT NarrowTy);
350 
351  LegalizeResult narrowScalarShift(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
352  LegalizeResult narrowScalarAddSub(MachineInstr &MI, unsigned TypeIdx,
353  LLT NarrowTy);
354  LegalizeResult narrowScalarMul(MachineInstr &MI, LLT Ty);
355  LegalizeResult narrowScalarFPTOI(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
356  LegalizeResult narrowScalarExtract(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
357  LegalizeResult narrowScalarInsert(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
358 
359  LegalizeResult narrowScalarBasic(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
360  LegalizeResult narrowScalarExt(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
361  LegalizeResult narrowScalarSelect(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
362  LegalizeResult narrowScalarCTLZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
363  LegalizeResult narrowScalarCTTZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
364  LegalizeResult narrowScalarCTPOP(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
365 
366  /// Perform Bitcast legalize action on G_EXTRACT_VECTOR_ELT.
367  LegalizeResult bitcastExtractVectorElt(MachineInstr &MI, unsigned TypeIdx,
368  LLT CastTy);
369 
370  /// Perform Bitcast legalize action on G_INSERT_VECTOR_ELT.
371  LegalizeResult bitcastInsertVectorElt(MachineInstr &MI, unsigned TypeIdx,
372  LLT CastTy);
373 
374  LegalizeResult lowerBitcast(MachineInstr &MI);
375  LegalizeResult lowerLoad(GAnyLoad &MI);
376  LegalizeResult lowerStore(GStore &MI);
377  LegalizeResult lowerBitCount(MachineInstr &MI);
380  LegalizeResult lowerFunnelShift(MachineInstr &MI);
382  LegalizeResult lowerRotate(MachineInstr &MI);
383 
384  LegalizeResult lowerU64ToF32BitOps(MachineInstr &MI);
385  LegalizeResult lowerUITOFP(MachineInstr &MI);
386  LegalizeResult lowerSITOFP(MachineInstr &MI);
387  LegalizeResult lowerFPTOUI(MachineInstr &MI);
388  LegalizeResult lowerFPTOSI(MachineInstr &MI);
389 
391  LegalizeResult lowerFPTRUNC(MachineInstr &MI);
392  LegalizeResult lowerFPOWI(MachineInstr &MI);
393 
394  LegalizeResult lowerMinMax(MachineInstr &MI);
395  LegalizeResult lowerFCopySign(MachineInstr &MI);
396  LegalizeResult lowerFMinNumMaxNum(MachineInstr &MI);
397  LegalizeResult lowerFMad(MachineInstr &MI);
398  LegalizeResult lowerIntrinsicRound(MachineInstr &MI);
399  LegalizeResult lowerFFloor(MachineInstr &MI);
400  LegalizeResult lowerMergeValues(MachineInstr &MI);
401  LegalizeResult lowerUnmergeValues(MachineInstr &MI);
403  LegalizeResult lowerShuffleVector(MachineInstr &MI);
404  LegalizeResult lowerDynStackAlloc(MachineInstr &MI);
405  LegalizeResult lowerExtract(MachineInstr &MI);
406  LegalizeResult lowerInsert(MachineInstr &MI);
407  LegalizeResult lowerSADDO_SSUBO(MachineInstr &MI);
410  LegalizeResult lowerShlSat(MachineInstr &MI);
411  LegalizeResult lowerBswap(MachineInstr &MI);
412  LegalizeResult lowerBitreverse(MachineInstr &MI);
414  LegalizeResult lowerSMULH_UMULH(MachineInstr &MI);
415  LegalizeResult lowerSelect(MachineInstr &MI);
416  LegalizeResult lowerDIVREM(MachineInstr &MI);
417  LegalizeResult lowerAbsToAddXor(MachineInstr &MI);
418  LegalizeResult lowerAbsToMaxNeg(MachineInstr &MI);
419  LegalizeResult lowerVectorReduction(MachineInstr &MI);
420  LegalizeResult lowerMemcpyInline(MachineInstr &MI);
421  LegalizeResult lowerMemCpyFamily(MachineInstr &MI, unsigned MaxLen = 0);
422 };
423 
424 /// Helper function that creates a libcall to the given \p Name using the given
425 /// calling convention \p CC.
427 createLibcall(MachineIRBuilder &MIRBuilder, const char *Name,
428  const CallLowering::ArgInfo &Result,
429  ArrayRef<CallLowering::ArgInfo> Args, CallingConv::ID CC);
430 
431 /// Helper function that creates the given libcall.
433 createLibcall(MachineIRBuilder &MIRBuilder, RTLIB::Libcall Libcall,
434  const CallLowering::ArgInfo &Result,
435  ArrayRef<CallLowering::ArgInfo> Args);
436 
437 /// Create a libcall to memcpy et al.
439 createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
440  MachineInstr &MI, LostDebugLocObserver &LocObserver);
441 
442 } // End namespace llvm.
443 
444 #endif
llvm::LegalizerHelper::createStackTemporary
MachineInstrBuilder createStackTemporary(TypeSize Bytes, Align Alignment, MachinePointerInfo &PtrInfo)
Create a stack temporary based on the size in bytes and the alignment.
Definition: LegalizerHelper.cpp:3512
llvm::LegalizerHelper::narrowScalarShiftByConstant
LegalizeResult narrowScalarShiftByConstant(MachineInstr &MI, const APInt &Amt, LLT HalfTy, LLT ShiftAmtTy)
Definition: LegalizerHelper.cpp:4816
LowLevelType.h
llvm::LegalizerHelper::narrowScalarBasic
LegalizeResult narrowScalarBasic(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5542
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:103
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::LegalizerHelper::moreElementsVectorPhi
LegalizeResult moreElementsVectorPhi(MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
Definition: LegalizerHelper.cpp:5014
llvm::LostDebugLocObserver
Definition: LostDebugLocObserver.h:19
llvm::LegalizerHelper::lowerFPTOSI
LegalizeResult lowerFPTOSI(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6310
llvm::LegalizerHelper::libcall
LegalizeResult libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver)
Legalize an instruction by emiting a runtime library call instead.
Definition: LegalizerHelper.cpp:714
llvm::LegalizerHelper::lowerFPTRUNC_F64_TO_F16
LegalizeResult lowerFPTRUNC_F64_TO_F16(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6379
CallLowering.h
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:52
llvm::LegalizerHelper::lowerFCopySign
LegalizeResult lowerFCopySign(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6544
llvm::LegalizerHelper::lowerBitreverse
LegalizeResult lowerBitreverse(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7267
llvm::LegalizerHelper::widenScalarSrc
void widenScalarSrc(MachineInstr &MI, LLT WideTy, unsigned OpIdx, unsigned ExtOpcode)
Legalize a single operand OpIdx of the machine instruction MI as a Use by extending the operand's typ...
Definition: LegalizerHelper.cpp:1339
llvm::LegalizerHelper::lowerBitcast
LegalizeResult lowerBitcast(MachineInstr &MI)
Definition: LegalizerHelper.cpp:2590
llvm::LegalizerHelper::lowerExtract
LegalizeResult lowerExtract(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6921
llvm::LegalizerHelper::lowerFPTOUI
LegalizeResult lowerFPTOUI(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6267
llvm::LegalizerHelper::bitcastSrc
void bitcastSrc(MachineInstr &MI, LLT CastTy, unsigned OpIdx)
Legalize a single operand OpIdx of the machine instruction MI as a use by inserting a G_BITCAST to Ca...
Definition: LegalizerHelper.cpp:1408
llvm::LegalizerHelper::fewerElementsVectorMultiEltType
LegalizeResult fewerElementsVectorMultiEltType(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Legalize a instruction with a vector type where each operand may have a different element type.
Definition: LegalizerHelper.cpp:3590
llvm::RTLIB::Libcall
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit.
Definition: RuntimeLibcalls.h:30
llvm::LegalizerHelper::lowerFMad
LegalizeResult lowerFMad(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6618
llvm::LegalizerHelper::UnableToLegalize
@ UnableToLegalize
Some kind of error has occurred and we could not legalize this instruction.
Definition: LegalizerHelper.h:64
GenericMachineInstrs.h
llvm::LegalizerHelper::lowerShlSat
LegalizeResult lowerShlSat(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7187
llvm::LegalizerHelper::lower
LegalizeResult lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Legalize an instruction by splitting it into simpler parts, hopefully understood by the target.
Definition: LegalizerHelper.cpp:3203
llvm::LegalizerHelper::lowerSelect
LegalizeResult lowerSelect(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7345
llvm::LegalizerHelper::lowerDIVREM
LegalizeResult lowerDIVREM(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7383
MachineIRBuilder.h
llvm::LegalizerHelper
Definition: LegalizerHelper.h:39
llvm::LegalizerHelper::lowerAbsToAddXor
LegalizeResult lowerAbsToAddXor(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7400
llvm::LegalizerHelper::lowerFFloor
LegalizeResult lowerFFloor(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6665
llvm::LegalizerHelper::LegalizerHelper
LegalizerHelper(MachineFunction &MF, GISelChangeObserver &Observer, MachineIRBuilder &B)
Definition: LegalizerHelper.cpp:95
llvm::LegalizerHelper::lowerVectorReduction
LegalizeResult lowerVectorReduction(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7432
llvm::LegalizerHelper::moreElementsVectorSrc
void moreElementsVectorSrc(MachineInstr &MI, LLT MoreTy, unsigned OpIdx)
Legalize a single operand OpIdx of the machine instruction MI as a Use by producing a vector with und...
Definition: LegalizerHelper.cpp:1378
llvm::LegalizerHelper::getStackTemporaryAlignment
Align getStackTemporaryAlignment(LLT Type, Align MinAlign=Align()) const
Return the alignment to use for a stack temporary object with the given type.
Definition: LegalizerHelper.cpp:3501
llvm::MinAlign
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
Definition: MathExtras.h:672
llvm::LegalizerHelper::lowerBswap
LegalizeResult lowerBswap(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7221
llvm::LegalizerHelper::lowerFunnelShiftAsShifts
LegalizeResult lowerFunnelShiftAsShifts(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5966
llvm::LegalizerHelper::fewerElementsVectorCmp
LegalizeResult fewerElementsVectorCmp(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3720
llvm::LegalizerHelper::narrowScalarSelect
LegalizeResult narrowScalarSelect(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5605
llvm::LegalizerHelper::lowerSITOFP
LegalizeResult lowerSITOFP(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6221
llvm::LegalizerHelper::narrowScalarMul
LegalizeResult narrowScalarMul(MachineInstr &MI, LLT Ty)
Definition: LegalizerHelper.cpp:5331
llvm::LegalizerHelper::narrowScalarCTPOP
LegalizeResult narrowScalarCTPOP(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5723
llvm::LegalizerHelper::lowerSADDO_SSUBO
LegalizeResult lowerSADDO_SSUBO(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7006
llvm::LegalizerHelper::lowerShuffleVector
LegalizeResult lowerShuffleVector(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6828
llvm::LegalizerHelper::fewerElementsVectorImplicitDef
LegalizeResult fewerElementsVectorImplicitDef(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3561
llvm::LegalizerHelper::lowerFPTRUNC
LegalizeResult lowerFPTRUNC(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6484
llvm::LegalizerHelper::narrowScalarCTLZ
LegalizeResult narrowScalarCTLZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5651
llvm::LegalizerHelper::moreElementsVectorDst
void moreElementsVectorDst(MachineInstr &MI, LLT MoreTy, unsigned OpIdx)
Legalize a single operand OpIdx of the machine instruction MI as a Def by performing it with addition...
Definition: LegalizerHelper.cpp:1371
llvm::LegalizerHelper::fewerElementsVectorSelect
LegalizeResult fewerElementsVectorSelect(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3787
llvm::LegalizerHelper::fewerElementsVectorPhi
LegalizeResult fewerElementsVectorPhi(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3860
llvm::TargetLowering
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Definition: TargetLowering.h:3189
llvm::LegalizerHelper::narrowScalar
LegalizeResult narrowScalar(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Legalize an instruction by reducing the width of the underlying scalar type.
Definition: LegalizerHelper.cpp:823
llvm::LegalizerHelper::bitcast
LegalizeResult bitcast(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Legalize an instruction by replacing the value type.
Definition: LegalizerHelper.cpp:3126
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::LegalizerHelper::lowerU64ToF32BitOps
LegalizeResult lowerU64ToF32BitOps(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6137
llvm::LegalizerHelper::fewerElementsVectorSextInReg
LegalizeResult fewerElementsVectorSextInReg(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4349
llvm::LegalizerHelper::lowerInsert
LegalizeResult lowerInsert(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6953
llvm::LegalizerHelper::fewerElementsVectorMulo
LegalizeResult fewerElementsVectorMulo(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3967
llvm::LegalizerHelper::lowerAddSubSatToMinMax
LegalizeResult lowerAddSubSatToMinMax(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7042
Align
uint64_t Align
Definition: ELFObjHandler.cpp:83
llvm::LegalizerHelper::lowerUITOFP
LegalizeResult lowerUITOFP(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6193
llvm::LegalizerHelper::narrowScalarCTTZ
LegalizeResult narrowScalarCTTZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5687
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::LegalizerHelper::fewerElementsVector
LegalizeResult fewerElementsVector(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Legalize a vector instruction by splitting into multiple components, each acting on the same scalar t...
Definition: LegalizerHelper.cpp:4371
llvm::LegalizerHelper::lowerIntrinsicRound
LegalizeResult lowerIntrinsicRound(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6632
llvm::LegalizerHelper::lowerExtractInsertVectorElt
LegalizeResult lowerExtractInsertVectorElt(MachineInstr &MI)
Lower a vector extract or insert by writing the vector to a stack temporary and reloading the element...
Definition: LegalizerHelper.cpp:6773
llvm::LegalizerHelper::reduceOperationWidth
LegalizeResult reduceOperationWidth(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Legalize an instruction by reducing the operation width, either by narrowing the type of the operatio...
Definition: LegalizerHelper.cpp:4221
llvm::LegalizerHelper::getVectorElementPointer
Register getVectorElementPointer(Register VecPtr, LLT VecTy, Register Index)
Get a pointer to vector element Index located in memory for a vector of type VecTy starting at a base...
Definition: LegalizerHelper.cpp:3542
llvm::LegalizerHelper::lowerAbsToMaxNeg
LegalizeResult lowerAbsToMaxNeg(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7417
llvm::LegalizerHelper::lowerFunnelShift
LegalizeResult lowerFunnelShift(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6024
llvm::LegalizerHelper::lowerReadWriteRegister
LegalizeResult lowerReadWriteRegister(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7298
llvm::LegalizerHelper::lowerFunnelShiftWithInverse
LegalizeResult lowerFunnelShiftWithInverse(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5924
llvm::LegalizerHelper::getLegalizerInfo
const LegalizerInfo & getLegalizerInfo() const
Expose LegalizerInfo so the clients can re-use.
Definition: LegalizerHelper.h:68
llvm::MachineIRBuilder
Helper class to build MachineInstr.
Definition: MachineIRBuilder.h:212
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
uint64_t
RuntimeLibcalls.h
llvm::createLibcall
LegalizerHelper::LegalizeResult createLibcall(MachineIRBuilder &MIRBuilder, const char *Name, const CallLowering::ArgInfo &Result, ArrayRef< CallLowering::ArgInfo > Args, CallingConv::ID CC)
Helper function that creates a libcall to the given Name using the given calling convention CC.
Definition: LegalizerHelper.cpp:553
llvm::LegalizerHelper::narrowScalarAddSub
LegalizeResult narrowScalarAddSub(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:5237
llvm::LegalizerHelper::lowerMergeValues
LegalizeResult lowerMergeValues(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6692
llvm::LegalizerHelper::lowerSMULH_UMULH
LegalizeResult lowerSMULH_UMULH(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7324
llvm::LegalizerHelper::lowerMinMax
LegalizeResult lowerMinMax(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6528
MachineFunctionPass.h
llvm::LegalizerHelper::moreElementsVectorShuffle
LegalizeResult moreElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
Definition: LegalizerHelper.cpp:5131
llvm::LegalizerHelper::fewerElementsVectorShuffle
LegalizeResult fewerElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4504
llvm::LegalizerHelper::narrowScalarDst
void narrowScalarDst(MachineInstr &MI, LLT NarrowTy, unsigned OpIdx, unsigned ExtOpcode)
Definition: LegalizerHelper.cpp:1362
llvm::LegalizerHelper::lowerStore
LegalizeResult lowerStore(GStore &MI)
Definition: LegalizerHelper.cpp:3026
llvm::LegalizerHelper::fewerElementsVectorExtractInsertVectorElt
LegalizeResult fewerElementsVectorExtractInsertVectorElt(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4055
llvm::LegalizerHelper::fewerElementsVectorUnmergeValues
LegalizeResult fewerElementsVectorUnmergeValues(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3927
llvm::LegalizerHelper::widenScalar
LegalizeResult widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy)
Legalize an instruction by performing the operation on a wider scalar type (for example a 16-bit addi...
Definition: LegalizerHelper.cpp:1971
llvm::LegalizerHelper::narrowScalarExtract
LegalizeResult narrowScalarExtract(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5391
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::LegalizerHelper::AlreadyLegal
@ AlreadyLegal
Instruction was already legal and no change was made to the MachineFunction.
Definition: LegalizerHelper.h:57
llvm::LegalizerHelper::lowerLoad
LegalizeResult lowerLoad(GAnyLoad &MI)
Definition: LegalizerHelper.cpp:2889
llvm::LegalizerHelper::lowerBitCount
LegalizeResult lowerBitCount(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5748
llvm::LegalizerHelper::narrowScalarExt
LegalizeResult narrowScalarExt(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5583
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::LegalizerHelper::widenWithUnmerge
Register widenWithUnmerge(LLT WideTy, Register OrigReg)
Widen OrigReg to WideTy by merging to a wider type, padding with G_IMPLICIT_DEF, and producing dead r...
Definition: LegalizerHelper.cpp:1543
llvm::LegalizerHelper::Observer
GISelChangeObserver & Observer
To keep track of changes made by the LegalizerHelper.
Definition: LegalizerHelper.h:46
llvm::LegalizerHelper::narrowScalarSrc
void narrowScalarSrc(MachineInstr &MI, LLT NarrowTy, unsigned OpIdx)
Legalize a single operand OpIdx of the machine instruction MI as a Use by truncating the operand's ty...
Definition: LegalizerHelper.cpp:1346
llvm::AMDGPU::HSAMD::Kernel::Arg::Key::IsVolatile
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
Definition: AMDGPUMetadata.h:194
llvm::LegalizerHelper::lowerUnmergeValues
LegalizeResult lowerUnmergeValues(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6733
llvm::GISelChangeObserver
Abstract class that contains various methods for clients to notify about changes.
Definition: GISelChangeObserver.h:29
llvm::LegalizerHelper::bitcastDst
void bitcastDst(MachineInstr &MI, LLT CastTy, unsigned OpIdx)
Legalize a single operand OpIdx of the machine instruction MI as a def by inserting a G_BITCAST from ...
Definition: LegalizerHelper.cpp:1413
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::LegalizerHelper::getTargetLowering
const TargetLowering & getTargetLowering() const
Definition: LegalizerHelper.h:69
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::LegalizerHelper::widenScalarDst
void widenScalarDst(MachineInstr &MI, LLT WideTy, unsigned OpIdx=0, unsigned TruncOpcode=TargetOpcode::G_TRUNC)
Legalize a single operand OpIdx of the machine instruction MI as a Def by extending the operand's typ...
Definition: LegalizerHelper.cpp:1353
llvm::LegalizerHelper::bitcastInsertVectorElt
LegalizeResult bitcastInsertVectorElt(MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
Perform Bitcast legalize action on G_INSERT_VECTOR_ELT.
Definition: LegalizerHelper.cpp:2826
llvm::LegalizerHelper::lowerMemCpyFamily
LegalizeResult lowerMemCpyFamily(MachineInstr &MI, unsigned MaxLen=0)
Definition: LegalizerHelper.cpp:7930
llvm::LegalizerHelper::narrowScalarShift
LegalizeResult narrowScalarShift(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:4905
llvm::LegalizerHelper::fewerElementsVectorCasts
LegalizeResult fewerElementsVectorCasts(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3672
llvm::LegalizerHelper::lowerAddSubSatToAddoSubo
LegalizeResult lowerAddSubSatToAddoSubo(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7119
llvm::LegalizerHelper::narrowScalarFPTOI
LegalizeResult narrowScalarFPTOI(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5366
llvm::LegalizerHelper::lowerFMinNumMaxNum
LegalizeResult lowerFMinNumMaxNum(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6588
llvm::LegalizerHelper::fewerElementsVectorReductions
LegalizeResult fewerElementsVectorReductions(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4694
llvm::LegalizerHelper::narrowScalarInsert
LegalizeResult narrowScalarInsert(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5458
llvm::LegalizerHelper::lowerFPOWI
LegalizeResult lowerFPOWI(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6501
llvm::LegalizerHelper::lowerDynStackAlloc
LegalizeResult lowerDynStackAlloc(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6884
llvm::LegalizerHelper::LegalizeResult
LegalizeResult
Definition: LegalizerHelper.h:54
llvm::createMemLibcall
LegalizerHelper::LegalizeResult createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstr &MI, LostDebugLocObserver &LocObserver)
Create a libcall to memcpy et al.
Definition: LegalizerHelper.cpp:595
llvm::LegalizerHelper::lowerRotateWithReverseRotate
LegalizeResult lowerRotateWithReverseRotate(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6048
llvm::LegalizerHelper::MIRBuilder
MachineIRBuilder & MIRBuilder
Expose MIRBuilder so clients can set their own RecordInsertInstruction functions.
Definition: LegalizerHelper.h:43
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::LegalizerHelper::reduceLoadStoreWidth
LegalizeResult reduceLoadStoreWidth(GLoadStore &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4130
llvm::LegalizerInfo
Definition: LegalizerInfo.h:1110
llvm::LegalizerHelper::coerceToScalar
Register coerceToScalar(Register Val)
Cast the given value to an LLT::scalar with an equivalent size.
Definition: LegalizerHelper.cpp:1317
llvm::LegalizerHelper::fewerElementsVectorMerge
LegalizeResult fewerElementsVectorMerge(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4031
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:389
llvm::LegalizerHelper::moreElementsVector
LegalizeResult moreElementsVector(MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
Legalize a vector instruction by increasing the number of vector elements involved and ignoring the a...
Definition: LegalizerHelper.cpp:5033
llvm::LegalizerHelper::lowerRotate
LegalizeResult lowerRotate(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6062
llvm::LegalizerHelper::legalizeInstrStep
LegalizeResult legalizeInstrStep(MachineInstr &MI, LostDebugLocObserver &LocObserver)
Replace MI by a sequence of legal instructions that can implement the same operation.
Definition: LegalizerHelper.cpp:109
llvm::LegalizerHelper::Legalized
@ Legalized
Instruction has been legalized and the MachineFunction changed.
Definition: LegalizerHelper.h:60
llvm::LegalizerHelper::bitcastExtractVectorElt
LegalizeResult bitcastExtractVectorElt(MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
Perform Bitcast legalize action on G_EXTRACT_VECTOR_ELT.
Definition: LegalizerHelper.cpp:2686
llvm::LLT
Definition: LowLevelTypeImpl.h:40