LLVM  15.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 
26 
27 namespace llvm {
28 // Forward declarations.
29 class APInt;
30 class GAnyLoad;
31 class GLoadStore;
32 class GStore;
33 class GenericMachineInstr;
34 class MachineFunction;
35 class MachineIRBuilder;
36 class MachineInstr;
37 class MachineInstrBuilder;
38 struct MachinePointerInfo;
39 template <typename T> class SmallVectorImpl;
40 class LegalizerInfo;
41 class MachineRegisterInfo;
42 class GISelChangeObserver;
43 class LostDebugLocObserver;
44 class TargetLowering;
45 
47 public:
48  /// Expose MIRBuilder so clients can set their own RecordInsertInstruction
49  /// functions
51 
52  /// To keep track of changes made by the LegalizerHelper.
54 
55 private:
57  const LegalizerInfo &LI;
58  const TargetLowering &TLI;
59 
60 public:
62  /// Instruction was already legal and no change was made to the
63  /// MachineFunction.
65 
66  /// Instruction has been legalized and the MachineFunction changed.
68 
69  /// Some kind of error has occurred and we could not legalize this
70  /// instruction.
72  };
73 
74  /// Expose LegalizerInfo so the clients can re-use.
75  const LegalizerInfo &getLegalizerInfo() const { return LI; }
76  const TargetLowering &getTargetLowering() const { return TLI; }
77 
82 
83  /// Replace \p MI by a sequence of legal instructions that can implement the
84  /// same operation. Note that this means \p MI may be deleted, so any iterator
85  /// steps should be performed before calling this function. \p Helper should
86  /// be initialized to the MachineFunction containing \p MI.
87  ///
88  /// Considered as an opaque blob, the legal code will use and define the same
89  /// registers as \p MI.
91  LostDebugLocObserver &LocObserver);
92 
93  /// Legalize an instruction by emiting a runtime library call instead.
95 
96  /// Legalize an instruction by reducing the width of the underlying scalar
97  /// type.
98  LegalizeResult narrowScalar(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy);
99 
100  /// Legalize an instruction by performing the operation on a wider scalar type
101  /// (for example a 16-bit addition can be safely performed at 32-bits
102  /// precision, ignoring the unused bits).
103  LegalizeResult widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
104 
105  /// Legalize an instruction by replacing the value type
106  LegalizeResult bitcast(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
107 
108  /// Legalize an instruction by splitting it into simpler parts, hopefully
109  /// understood by the target.
110  LegalizeResult lower(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
111 
112  /// Legalize a vector instruction by splitting into multiple components, each
113  /// acting on the same scalar type as the original but with fewer elements.
115  LLT NarrowTy);
116 
117  /// Legalize a vector instruction by increasing the number of vector elements
118  /// involved and ignoring the added elements later.
120  LLT MoreTy);
121 
122  /// Cast the given value to an LLT::scalar with an equivalent size. Returns
123  /// the register to use if an instruction was inserted. Returns the original
124  /// register if no coercion was necessary.
125  //
126  // This may also fail and return Register() if there is no legal way to cast.
128 
129  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
130  /// Use by extending the operand's type to \p WideTy using the specified \p
131  /// ExtOpcode for the extension instruction, and replacing the vreg of the
132  /// operand in place.
133  void widenScalarSrc(MachineInstr &MI, LLT WideTy, unsigned OpIdx,
134  unsigned ExtOpcode);
135 
136  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
137  /// Use by truncating the operand's type to \p NarrowTy using G_TRUNC, and
138  /// replacing the vreg of the operand in place.
139  void narrowScalarSrc(MachineInstr &MI, LLT NarrowTy, unsigned OpIdx);
140 
141  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
142  /// Def by extending the operand's type to \p WideTy and truncating it back
143  /// with the \p TruncOpcode, and replacing the vreg of the operand in place.
144  void widenScalarDst(MachineInstr &MI, LLT WideTy, unsigned OpIdx = 0,
145  unsigned TruncOpcode = TargetOpcode::G_TRUNC);
146 
147  // Legalize a single operand \p OpIdx of the machine instruction \p MI as a
148  // Def by truncating the operand's type to \p NarrowTy, replacing in place and
149  // extending back with \p ExtOpcode.
150  void narrowScalarDst(MachineInstr &MI, LLT NarrowTy, unsigned OpIdx,
151  unsigned ExtOpcode);
152  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
153  /// Def by performing it with additional vector elements and extracting the
154  /// result elements, and replacing the vreg of the operand in place.
155  void moreElementsVectorDst(MachineInstr &MI, LLT MoreTy, unsigned OpIdx);
156 
157  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
158  /// Use by producing a vector with undefined high elements, extracting the
159  /// original vector type, and replacing the vreg of the operand in place.
160  void moreElementsVectorSrc(MachineInstr &MI, LLT MoreTy, unsigned OpIdx);
161 
162  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
163  /// use by inserting a G_BITCAST to \p CastTy
164  void bitcastSrc(MachineInstr &MI, LLT CastTy, unsigned OpIdx);
165 
166  /// Legalize a single operand \p OpIdx of the machine instruction \p MI as a
167  /// def by inserting a G_BITCAST from \p CastTy
168  void bitcastDst(MachineInstr &MI, LLT CastTy, unsigned OpIdx);
169 
170 private:
172  widenScalarMergeValues(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
174  widenScalarUnmergeValues(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
176  widenScalarExtract(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
178  widenScalarInsert(MachineInstr &MI, unsigned TypeIdx, LLT WideTy);
179  LegalizeResult widenScalarAddSubOverflow(MachineInstr &MI, unsigned TypeIdx,
180  LLT WideTy);
181  LegalizeResult widenScalarAddSubShlSat(MachineInstr &MI, unsigned TypeIdx,
182  LLT WideTy);
183  LegalizeResult widenScalarMulo(MachineInstr &MI, unsigned TypeIdx,
184  LLT WideTy);
185 
186  /// Helper function to split a wide generic register into bitwise blocks with
187  /// the given Type (which implies the number of blocks needed). The generic
188  /// registers created are appended to Ops, starting at bit 0 of Reg.
189  void extractParts(Register Reg, LLT Ty, int NumParts,
191 
192  /// Version which handles irregular splits.
193  bool extractParts(Register Reg, LLT RegTy, LLT MainTy,
194  LLT &LeftoverTy,
196  SmallVectorImpl<Register> &LeftoverVRegs);
197 
198  /// Version which handles irregular sub-vector splits.
199  void extractVectorParts(Register Reg, unsigned NumElst,
201 
202  /// Helper function to build a wide generic register \p DstReg of type \p
203  /// RegTy from smaller parts. This will produce a G_MERGE_VALUES,
204  /// G_BUILD_VECTOR, G_CONCAT_VECTORS, or sequence of G_INSERT as appropriate
205  /// for the types.
206  ///
207  /// \p PartRegs must be registers of type \p PartTy.
208  ///
209  /// If \p ResultTy does not evenly break into \p PartTy sized pieces, the
210  /// remainder must be specified with \p LeftoverRegs of type \p LeftoverTy.
211  void insertParts(Register DstReg, LLT ResultTy,
212  LLT PartTy, ArrayRef<Register> PartRegs,
213  LLT LeftoverTy = LLT(), ArrayRef<Register> LeftoverRegs = {});
214 
215  /// Merge \p PartRegs with different types into \p DstReg.
216  void mergeMixedSubvectors(Register DstReg, ArrayRef<Register> PartRegs);
217 
218  void appendVectorElts(SmallVectorImpl<Register> &Elts, Register Reg);
219 
220  /// Unmerge \p SrcReg into smaller sized values, and append them to \p
221  /// Parts. The elements of \p Parts will be the greatest common divisor type
222  /// of \p DstTy, \p NarrowTy and the type of \p SrcReg. This will compute and
223  /// return the GCD type.
224  LLT extractGCDType(SmallVectorImpl<Register> &Parts, LLT DstTy,
225  LLT NarrowTy, Register SrcReg);
226 
227  /// Unmerge \p SrcReg into \p GCDTy typed registers. This will append all of
228  /// the unpacked registers to \p Parts. This version is if the common unmerge
229  /// type is already known.
230  void extractGCDType(SmallVectorImpl<Register> &Parts, LLT GCDTy,
231  Register SrcReg);
232 
233  /// Produce a merge of values in \p VRegs to define \p DstReg. Perform a merge
234  /// from the least common multiple type, and convert as appropriate to \p
235  /// DstReg.
236  ///
237  /// \p VRegs should each have type \p GCDTy. This type should be greatest
238  /// common divisor type of \p DstReg, \p NarrowTy, and an undetermined source
239  /// type.
240  ///
241  /// \p NarrowTy is the desired result merge source type. If the source value
242  /// needs to be widened to evenly cover \p DstReg, inserts high bits
243  /// corresponding to the extension opcode \p PadStrategy.
244  ///
245  /// \p VRegs will be cleared, and the the result \p NarrowTy register pieces
246  /// will replace it. Returns The complete LCMTy that \p VRegs will cover when
247  /// merged.
248  LLT buildLCMMergePieces(LLT DstTy, LLT NarrowTy, LLT GCDTy,
249  SmallVectorImpl<Register> &VRegs,
250  unsigned PadStrategy = TargetOpcode::G_ANYEXT);
251 
252  /// Merge the values in \p RemergeRegs to an \p LCMTy typed value. Extract the
253  /// low bits into \p DstReg. This is intended to use the outputs from
254  /// buildLCMMergePieces after processing.
255  void buildWidenedRemergeToDst(Register DstReg, LLT LCMTy,
256  ArrayRef<Register> RemergeRegs);
257 
258  /// Perform generic multiplication of values held in multiple registers.
259  /// Generated instructions use only types NarrowTy and i1.
260  /// Destination can be same or two times size of the source.
261  void multiplyRegisters(SmallVectorImpl<Register> &DstRegs,
262  ArrayRef<Register> Src1Regs,
263  ArrayRef<Register> Src2Regs, LLT NarrowTy);
264 
265  void changeOpcode(MachineInstr &MI, unsigned NewOpcode);
266 
267  LegalizeResult tryNarrowPow2Reduction(MachineInstr &MI, Register SrcReg,
268  LLT SrcTy, LLT NarrowTy,
269  unsigned ScalarOpc);
270 
271  // Memcpy family legalization helpers.
272  LegalizeResult lowerMemset(MachineInstr &MI, Register Dst, Register Val,
273  uint64_t KnownLen, Align Alignment,
274  bool IsVolatile);
275  LegalizeResult lowerMemcpyInline(MachineInstr &MI, Register Dst, Register Src,
276  uint64_t KnownLen, Align DstAlign,
277  Align SrcAlign, bool IsVolatile);
278  LegalizeResult lowerMemcpy(MachineInstr &MI, Register Dst, Register Src,
279  uint64_t KnownLen, uint64_t Limit, Align DstAlign,
280  Align SrcAlign, bool IsVolatile);
281  LegalizeResult lowerMemmove(MachineInstr &MI, Register Dst, Register Src,
282  uint64_t KnownLen, Align DstAlign, Align SrcAlign,
283  bool IsVolatile);
284 
285 public:
286  /// Return the alignment to use for a stack temporary object with the given
287  /// type.
288  Align getStackTemporaryAlignment(LLT Type, Align MinAlign = Align()) const;
289 
290  /// Create a stack temporary based on the size in bytes and the alignment
291  MachineInstrBuilder createStackTemporary(TypeSize Bytes, Align Alignment,
292  MachinePointerInfo &PtrInfo);
293 
294  /// Get a pointer to vector element \p Index located in memory for a vector of
295  /// type \p VecTy starting at a base address of \p VecPtr. If \p Index is out
296  /// of bounds the returned pointer is unspecified, but will be within the
297  /// vector bounds.
298  Register getVectorElementPointer(Register VecPtr, LLT VecTy, Register Index);
299 
300  /// Handles most opcodes. Split \p MI into same instruction on sub-vectors or
301  /// scalars with \p NumElts elements (1 for scalar). Supports uneven splits:
302  /// there can be leftover sub-vector with fewer then \p NumElts or a leftover
303  /// scalar. To avoid this use moreElements first and set MI number of elements
304  /// to multiple of \p NumElts. Non-vector operands that should be used on all
305  /// sub-instructions without split are listed in \p NonVecOpIndices.
307  GenericMachineInstr &MI, unsigned NumElts,
308  std::initializer_list<unsigned> NonVecOpIndices = {});
309 
310  LegalizeResult fewerElementsVectorPhi(GenericMachineInstr &MI,
311  unsigned NumElts);
312 
313  LegalizeResult moreElementsVectorPhi(MachineInstr &MI, unsigned TypeIdx,
314  LLT MoreTy);
315  LegalizeResult moreElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx,
316  LLT MoreTy);
317 
319  unsigned TypeIdx,
320  LLT NarrowTy);
321  LegalizeResult fewerElementsVectorMerge(MachineInstr &MI, unsigned TypeIdx,
322  LLT NarrowTy);
324  unsigned TypeIdx,
325  LLT NarrowTy);
326 
327  LegalizeResult reduceLoadStoreWidth(GLoadStore &MI, unsigned TypeIdx,
328  LLT NarrowTy);
329 
330  LegalizeResult fewerElementsVectorSextInReg(MachineInstr &MI, unsigned TypeIdx,
331  LLT NarrowTy);
332 
333  LegalizeResult narrowScalarShiftByConstant(MachineInstr &MI, const APInt &Amt,
334  LLT HalfTy, LLT ShiftAmtTy);
335 
337  unsigned TypeIdx, LLT NarrowTy);
338 
339  LegalizeResult fewerElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx,
340  LLT NarrowTy);
341 
342  LegalizeResult narrowScalarShift(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
343  LegalizeResult narrowScalarAddSub(MachineInstr &MI, unsigned TypeIdx,
344  LLT NarrowTy);
345  LegalizeResult narrowScalarMul(MachineInstr &MI, LLT Ty);
346  LegalizeResult narrowScalarFPTOI(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
347  LegalizeResult narrowScalarExtract(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
348  LegalizeResult narrowScalarInsert(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
349 
350  LegalizeResult narrowScalarBasic(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
351  LegalizeResult narrowScalarExt(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
352  LegalizeResult narrowScalarSelect(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
353  LegalizeResult narrowScalarCTLZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
354  LegalizeResult narrowScalarCTTZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
355  LegalizeResult narrowScalarCTPOP(MachineInstr &MI, unsigned TypeIdx, LLT Ty);
356 
357  /// Perform Bitcast legalize action on G_EXTRACT_VECTOR_ELT.
358  LegalizeResult bitcastExtractVectorElt(MachineInstr &MI, unsigned TypeIdx,
359  LLT CastTy);
360 
361  /// Perform Bitcast legalize action on G_INSERT_VECTOR_ELT.
362  LegalizeResult bitcastInsertVectorElt(MachineInstr &MI, unsigned TypeIdx,
363  LLT CastTy);
364 
365  LegalizeResult lowerBitcast(MachineInstr &MI);
366  LegalizeResult lowerLoad(GAnyLoad &MI);
367  LegalizeResult lowerStore(GStore &MI);
368  LegalizeResult lowerBitCount(MachineInstr &MI);
371  LegalizeResult lowerFunnelShift(MachineInstr &MI);
373  LegalizeResult lowerRotate(MachineInstr &MI);
374 
375  LegalizeResult lowerU64ToF32BitOps(MachineInstr &MI);
376  LegalizeResult lowerUITOFP(MachineInstr &MI);
377  LegalizeResult lowerSITOFP(MachineInstr &MI);
378  LegalizeResult lowerFPTOUI(MachineInstr &MI);
379  LegalizeResult lowerFPTOSI(MachineInstr &MI);
380 
382  LegalizeResult lowerFPTRUNC(MachineInstr &MI);
383  LegalizeResult lowerFPOWI(MachineInstr &MI);
384 
385  LegalizeResult lowerMinMax(MachineInstr &MI);
386  LegalizeResult lowerFCopySign(MachineInstr &MI);
387  LegalizeResult lowerFMinNumMaxNum(MachineInstr &MI);
388  LegalizeResult lowerFMad(MachineInstr &MI);
389  LegalizeResult lowerIntrinsicRound(MachineInstr &MI);
390  LegalizeResult lowerFFloor(MachineInstr &MI);
391  LegalizeResult lowerMergeValues(MachineInstr &MI);
392  LegalizeResult lowerUnmergeValues(MachineInstr &MI);
394  LegalizeResult lowerShuffleVector(MachineInstr &MI);
395  LegalizeResult lowerDynStackAlloc(MachineInstr &MI);
396  LegalizeResult lowerExtract(MachineInstr &MI);
397  LegalizeResult lowerInsert(MachineInstr &MI);
398  LegalizeResult lowerSADDO_SSUBO(MachineInstr &MI);
401  LegalizeResult lowerShlSat(MachineInstr &MI);
402  LegalizeResult lowerBswap(MachineInstr &MI);
403  LegalizeResult lowerBitreverse(MachineInstr &MI);
405  LegalizeResult lowerSMULH_UMULH(MachineInstr &MI);
406  LegalizeResult lowerSelect(MachineInstr &MI);
407  LegalizeResult lowerDIVREM(MachineInstr &MI);
408  LegalizeResult lowerAbsToAddXor(MachineInstr &MI);
409  LegalizeResult lowerAbsToMaxNeg(MachineInstr &MI);
410  LegalizeResult lowerVectorReduction(MachineInstr &MI);
411  LegalizeResult lowerMemcpyInline(MachineInstr &MI);
412  LegalizeResult lowerMemCpyFamily(MachineInstr &MI, unsigned MaxLen = 0);
413 };
414 
415 /// Helper function that creates a libcall to the given \p Name using the given
416 /// calling convention \p CC.
418 createLibcall(MachineIRBuilder &MIRBuilder, const char *Name,
419  const CallLowering::ArgInfo &Result,
420  ArrayRef<CallLowering::ArgInfo> Args, CallingConv::ID CC);
421 
422 /// Helper function that creates the given libcall.
424 createLibcall(MachineIRBuilder &MIRBuilder, RTLIB::Libcall Libcall,
425  const CallLowering::ArgInfo &Result,
426  ArrayRef<CallLowering::ArgInfo> Args);
427 
428 /// Create a libcall to memcpy et al.
430 createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
431  MachineInstr &MI, LostDebugLocObserver &LocObserver);
432 
433 } // End namespace llvm.
434 
435 #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:3565
llvm::LegalizerHelper::narrowScalarShiftByConstant
LegalizeResult narrowScalarShiftByConstant(MachineInstr &MI, const APInt &Amt, LLT HalfTy, LLT ShiftAmtTy)
Definition: LegalizerHelper.cpp:4581
llvm::LegalizerHelper::narrowScalarBasic
LegalizeResult narrowScalarBasic(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5350
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:104
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::LegalizerHelper::moreElementsVectorPhi
LegalizeResult moreElementsVectorPhi(MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
Definition: LegalizerHelper.cpp:4779
llvm::LostDebugLocObserver
Definition: LostDebugLocObserver.h:19
llvm::LegalizerHelper::lowerFPTOSI
LegalizeResult lowerFPTOSI(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6118
llvm::LegalizerHelper::libcall
LegalizeResult libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver)
Legalize an instruction by emiting a runtime library call instead.
Definition: LegalizerHelper.cpp:790
llvm::LegalizerHelper::lowerFPTRUNC_F64_TO_F16
LegalizeResult lowerFPTRUNC_F64_TO_F16(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6187
CallLowering.h
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:50
llvm::LegalizerHelper::lowerFCopySign
LegalizeResult lowerFCopySign(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6352
llvm::LegalizerHelper::lowerBitreverse
LegalizeResult lowerBitreverse(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7157
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
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:1433
llvm::LegalizerHelper::lowerBitcast
LegalizeResult lowerBitcast(MachineInstr &MI)
Definition: LegalizerHelper.cpp:2643
llvm::LegalizerHelper::lowerExtract
LegalizeResult lowerExtract(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6746
llvm::LegalizerHelper::lowerFPTOUI
LegalizeResult lowerFPTOUI(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6075
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:1482
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:6426
llvm::LegalizerHelper::UnableToLegalize
@ UnableToLegalize
Some kind of error has occurred and we could not legalize this instruction.
Definition: LegalizerHelper.h:71
llvm::LegalizerHelper::lowerShlSat
LegalizeResult lowerShlSat(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7077
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:3256
llvm::LegalizerHelper::lowerSelect
LegalizeResult lowerSelect(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7235
llvm::LegalizerHelper::lowerDIVREM
LegalizeResult lowerDIVREM(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7280
llvm::LegalizerHelper
Definition: LegalizerHelper.h:46
llvm::LegalizerHelper::lowerAbsToAddXor
LegalizeResult lowerAbsToAddXor(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7297
llvm::LegalizerHelper::lowerFFloor
LegalizeResult lowerFFloor(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6473
llvm::LegalizerHelper::LegalizerHelper
LegalizerHelper(MachineFunction &MF, GISelChangeObserver &Observer, MachineIRBuilder &B)
Definition: LegalizerHelper.cpp:98
llvm::LegalizerHelper::lowerVectorReduction
LegalizeResult lowerVectorReduction(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7329
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:1475
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:3554
llvm::MinAlign
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
A and B are either alignments or offsets.
Definition: MathExtras.h:699
llvm::LegalizerHelper::lowerBswap
LegalizeResult lowerBswap(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7111
llvm::LegalizerHelper::lowerFunnelShiftAsShifts
LegalizeResult lowerFunnelShiftAsShifts(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5774
llvm::LegalizerHelper::narrowScalarSelect
LegalizeResult narrowScalarSelect(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5413
llvm::LegalizerHelper::lowerSITOFP
LegalizeResult lowerSITOFP(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6029
llvm::LegalizerHelper::narrowScalarMul
LegalizeResult narrowScalarMul(MachineInstr &MI, LLT Ty)
Definition: LegalizerHelper.cpp:5142
llvm::LegalizerHelper::narrowScalarCTPOP
LegalizeResult narrowScalarCTPOP(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5531
llvm::LegalizerHelper::lowerSADDO_SSUBO
LegalizeResult lowerSADDO_SSUBO(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6896
llvm::LegalizerHelper::lowerShuffleVector
LegalizeResult lowerShuffleVector(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6653
llvm::LegalizerHelper::lowerFPTRUNC
LegalizeResult lowerFPTRUNC(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6292
llvm::LegalizerHelper::narrowScalarCTLZ
LegalizeResult narrowScalarCTLZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5459
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:1465
llvm::TargetLowering
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Definition: TargetLowering.h:3412
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:899
llvm::LegalizerHelper::bitcast
LegalizeResult bitcast(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Legalize an instruction by replacing the value type.
Definition: LegalizerHelper.cpp:3179
TargetOpcodes.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::LegalizerHelper::lowerU64ToF32BitOps
LegalizeResult lowerU64ToF32BitOps(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5945
llvm::LegalizerHelper::fewerElementsVectorMultiEltType
LegalizeResult fewerElementsVectorMultiEltType(GenericMachineInstr &MI, unsigned NumElts, std::initializer_list< unsigned > NonVecOpIndices={})
Handles most opcodes.
Definition: LegalizerHelper.cpp:3705
llvm::LegalizerHelper::lowerInsert
LegalizeResult lowerInsert(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6804
llvm::LegalizerHelper::lowerAddSubSatToMinMax
LegalizeResult lowerAddSubSatToMinMax(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6932
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
llvm::LegalizerHelper::lowerUITOFP
LegalizeResult lowerUITOFP(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6001
llvm::LegalizerHelper::narrowScalarCTTZ
LegalizeResult narrowScalarCTTZ(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5495
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:4128
llvm::LegalizerHelper::lowerIntrinsicRound
LegalizeResult lowerIntrinsicRound(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6440
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:6581
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:3595
llvm::LegalizerHelper::lowerAbsToMaxNeg
LegalizeResult lowerAbsToMaxNeg(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7314
llvm::LegalizerHelper::lowerFunnelShift
LegalizeResult lowerFunnelShift(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5832
llvm::LegalizerHelper::lowerReadWriteRegister
LegalizeResult lowerReadWriteRegister(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7188
llvm::LegalizerHelper::lowerFunnelShiftWithInverse
LegalizeResult lowerFunnelShiftWithInverse(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5732
llvm::LegalizerHelper::getLegalizerInfo
const LegalizerInfo & getLegalizerInfo() const
Expose LegalizerInfo so the clients can re-use.
Definition: LegalizerHelper.h:75
llvm::LegalizerHelper::fewerElementsVectorPhi
LegalizeResult fewerElementsVectorPhi(GenericMachineInstr &MI, unsigned NumElts)
Definition: LegalizerHelper.cpp:3775
llvm::MachineIRBuilder
Helper class to build MachineInstr.
Definition: MachineIRBuilder.h:219
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:66
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:629
llvm::LegalizerHelper::narrowScalarAddSub
LegalizeResult narrowScalarAddSub(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:5048
llvm::LegalizerHelper::lowerMergeValues
LegalizeResult lowerMergeValues(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6500
llvm::LegalizerHelper::lowerSMULH_UMULH
LegalizeResult lowerSMULH_UMULH(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7214
llvm::LegalizerHelper::lowerMinMax
LegalizeResult lowerMinMax(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6336
llvm::LegalizerHelper::moreElementsVectorShuffle
LegalizeResult moreElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx, LLT MoreTy)
Definition: LegalizerHelper.cpp:4942
llvm::LegalizerHelper::fewerElementsVectorShuffle
LegalizeResult fewerElementsVectorShuffle(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4269
llvm::LegalizerHelper::narrowScalarDst
void narrowScalarDst(MachineInstr &MI, LLT NarrowTy, unsigned OpIdx, unsigned ExtOpcode)
Definition: LegalizerHelper.cpp:1456
llvm::LegalizerHelper::lowerStore
LegalizeResult lowerStore(GStore &MI)
Definition: LegalizerHelper.cpp:3079
llvm::LegalizerHelper::fewerElementsVectorExtractInsertVectorElt
LegalizeResult fewerElementsVectorExtractInsertVectorElt(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3958
llvm::LegalizerHelper::fewerElementsVectorUnmergeValues
LegalizeResult fewerElementsVectorUnmergeValues(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3823
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:2024
llvm::LegalizerHelper::narrowScalarExtract
LegalizeResult narrowScalarExtract(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5199
llvm::MachineFunction
Definition: MachineFunction.h:257
llvm::LegalizerHelper::AlreadyLegal
@ AlreadyLegal
Instruction was already legal and no change was made to the MachineFunction.
Definition: LegalizerHelper.h:64
llvm::LegalizerHelper::lowerLoad
LegalizeResult lowerLoad(GAnyLoad &MI)
Definition: LegalizerHelper.cpp:2942
llvm::LegalizerHelper::lowerBitCount
LegalizeResult lowerBitCount(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5556
llvm::LegalizerHelper::narrowScalarExt
LegalizeResult narrowScalarExt(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5391
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::LegalizerHelper::fewerElementsVectorSextInReg
LegalizeResult fewerElementsVectorSextInReg(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
llvm::LegalizerHelper::Observer
GISelChangeObserver & Observer
To keep track of changes made by the LegalizerHelper.
Definition: LegalizerHelper.h:53
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:1440
llvm::AMDGPU::HSAMD::Kernel::Arg::Key::IsVolatile
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
Definition: AMDGPUMetadata.h:199
llvm::LegalizerHelper::lowerUnmergeValues
LegalizeResult lowerUnmergeValues(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6541
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:1487
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:76
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
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:1447
llvm::LegalizerHelper::bitcastInsertVectorElt
LegalizeResult bitcastInsertVectorElt(MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
Perform Bitcast legalize action on G_INSERT_VECTOR_ELT.
Definition: LegalizerHelper.cpp:2879
llvm::LegalizerHelper::lowerMemCpyFamily
LegalizeResult lowerMemCpyFamily(MachineInstr &MI, unsigned MaxLen=0)
Definition: LegalizerHelper.cpp:7831
llvm::LegalizerHelper::narrowScalarShift
LegalizeResult narrowScalarShift(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:4670
llvm::LegalizerHelper::lowerAddSubSatToAddoSubo
LegalizeResult lowerAddSubSatToAddoSubo(MachineInstr &MI)
Definition: LegalizerHelper.cpp:7009
llvm::LegalizerHelper::narrowScalarFPTOI
LegalizeResult narrowScalarFPTOI(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5174
llvm::LegalizerHelper::lowerFMinNumMaxNum
LegalizeResult lowerFMinNumMaxNum(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6396
llvm::LegalizerHelper::fewerElementsVectorReductions
LegalizeResult fewerElementsVectorReductions(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4459
llvm::LegalizerHelper::narrowScalarInsert
LegalizeResult narrowScalarInsert(MachineInstr &MI, unsigned TypeIdx, LLT Ty)
Definition: LegalizerHelper.cpp:5266
llvm::LegalizerHelper::lowerFPOWI
LegalizeResult lowerFPOWI(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6309
llvm::LegalizerHelper::lowerDynStackAlloc
LegalizeResult lowerDynStackAlloc(MachineInstr &MI)
Definition: LegalizerHelper.cpp:6709
llvm::LegalizerHelper::LegalizeResult
LegalizeResult
Definition: LegalizerHelper.h:61
llvm::createMemLibcall
LegalizerHelper::LegalizeResult createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI, MachineInstr &MI, LostDebugLocObserver &LocObserver)
Create a libcall to memcpy et al.
Definition: LegalizerHelper.cpp:671
llvm::LegalizerHelper::lowerRotateWithReverseRotate
LegalizeResult lowerRotateWithReverseRotate(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5856
llvm::LegalizerHelper::MIRBuilder
MachineIRBuilder & MIRBuilder
Expose MIRBuilder so clients can set their own RecordInsertInstruction functions.
Definition: LegalizerHelper.h:50
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::LegalizerHelper::reduceLoadStoreWidth
LegalizeResult reduceLoadStoreWidth(GLoadStore &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:4033
llvm::LegalizerInfo
Definition: LegalizerInfo.h:1180
llvm::LegalizerHelper::coerceToScalar
Register coerceToScalar(Register Val)
Cast the given value to an LLT::scalar with an equivalent size.
Definition: LegalizerHelper.cpp:1411
llvm::LegalizerHelper::fewerElementsVectorMerge
LegalizeResult fewerElementsVectorMerge(MachineInstr &MI, unsigned TypeIdx, LLT NarrowTy)
Definition: LegalizerHelper.cpp:3872
llvm::AMDGPU::HSAMD::Kernel::Key::Args
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Definition: AMDGPUMetadata.h:394
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:4798
llvm::LegalizerHelper::lowerRotate
LegalizeResult lowerRotate(MachineInstr &MI)
Definition: LegalizerHelper.cpp:5870
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:112
llvm::LegalizerHelper::Legalized
@ Legalized
Instruction has been legalized and the MachineFunction changed.
Definition: LegalizerHelper.h:67
llvm::LegalizerHelper::bitcastExtractVectorElt
LegalizeResult bitcastExtractVectorElt(MachineInstr &MI, unsigned TypeIdx, LLT CastTy)
Perform Bitcast legalize action on G_EXTRACT_VECTOR_ELT.
Definition: LegalizerHelper.cpp:2739
llvm::LLT
Definition: LowLevelTypeImpl.h:39