LLVM 23.0.0git
R600ISelLowering.h
Go to the documentation of this file.
1//===-- R600ISelLowering.h - R600 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/// \file
10/// R600 DAG Lowering interface definition
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_AMDGPU_R600ISELLOWERING_H
15#define LLVM_LIB_TARGET_AMDGPU_R600ISELLOWERING_H
16
17#include "AMDGPUISelLowering.h"
19
20namespace llvm {
21
22class R600Subtarget;
23
25
26 const R600Subtarget *Subtarget;
27public:
28 R600TargetLowering(const TargetMachine &TM, const R600Subtarget &STI);
29
31
34 MachineBasicBlock *BB) const override;
35 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
36 SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
39 SelectionDAG &DAG) const override;
40 CCAssignFn *CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const;
42 bool isVarArg,
44 const SDLoc &DL, SelectionDAG &DAG,
45 SmallVectorImpl<SDValue> &InVals) const override;
47 EVT VT) const override;
48
49 bool canMergeStoresTo(unsigned AS, EVT MemVT,
50 const MachineFunction &MF) const override;
51
53 EVT VT, unsigned AS, Align Alignment,
55 unsigned *IsFast = nullptr) const override;
56
57 bool canCombineTruncStore(EVT ValVT, EVT MemVT, Align Alignment,
58 unsigned AddrSpace,
59 bool LegalOperations) const override {
60 // R600 has "custom" lowering for truncating stores despite not supporting
61 // those instructions. If we allow that custom lowering in the DAG combiner
62 // then all truncates are merged into truncating stores, giving worse code
63 // generation. This hook prevents the DAG combiner performing that combine.
64 return isTruncStoreLegal(ValVT, MemVT, Alignment, AddrSpace);
65 }
66
67private:
68 unsigned Gen;
69 /// Each OpenCL kernel has nine implicit parameters that are stored in the
70 /// first nine dwords of a Vertex Buffer. These implicit parameters are
71 /// lowered to load instructions which retrieve the values from the Vertex
72 /// Buffer.
73 SDValue LowerImplicitParameter(SelectionDAG &DAG, EVT VT, const SDLoc &DL,
74 unsigned DwordOffset) const;
75
76 void lowerImplicitParameter(MachineInstr *MI, MachineBasicBlock &BB,
77 MachineRegisterInfo & MRI, unsigned dword_offset) const;
78 SDValue OptimizeSwizzle(SDValue BuildVector, SDValue Swz[],
79 SelectionDAG &DAG, const SDLoc &DL) const;
80 SDValue vectorToVerticalVector(SelectionDAG &DAG, SDValue Vector) const;
81
82 SDValue lowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
84 SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
85 SDValue LowerGlobalAddress(AMDGPUMachineFunctionInfo *MFI, SDValue Op,
86 SelectionDAG &DAG) const override;
88
89 SDValue lowerPrivateTruncStore(StoreSDNode *Store, SelectionDAG &DAG) const;
91 SDValue lowerFP_TO_UINT(SDValue Op, SelectionDAG &DAG) const;
92 SDValue lowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG) const;
93
94 SDValue lowerPrivateExtLoad(SDValue Op, SelectionDAG &DAG) const;
96 SDValue lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const;
98 SDValue LowerTrig(SDValue Op, SelectionDAG &DAG) const;
100 SDValue LowerUADDSUBO(SDValue Op, SelectionDAG &DAG,
101 unsigned mainop, unsigned ovf) const;
102
103 SDValue stackPtrToRegIndex(SDValue Ptr, unsigned StackWidth,
104 SelectionDAG &DAG) const;
105 void getStackAddress(unsigned StackWidth, unsigned ElemIdx,
106 unsigned &Channel, unsigned &PtrIncr) const;
107 bool isZero(SDValue Op) const;
108 bool isHWTrueValue(SDValue Op) const;
109 bool isHWFalseValue(SDValue Op) const;
110
111 bool FoldOperand(SDNode *ParentNode, unsigned SrcIdx, SDValue &Src,
112 SDValue &Neg, SDValue &Abs, SDValue &Sel, SDValue &Imm,
113 SelectionDAG &DAG) const;
114 SDValue constBufferLoad(LoadSDNode *LoadNode, int Block,
115 SelectionDAG &DAG) const;
116
117 SDNode *PostISelFolding(MachineSDNode *N, SelectionDAG &DAG) const override;
118
120 shouldExpandAtomicRMWInIR(const AtomicRMWInst *RMW) const override;
121};
122
123} // End namespace llvm;
124
125#endif
static SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG)
Interface definition of the TargetLowering class that is common to all AMD GPUs.
static SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG, const ARMSubtarget *ST)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
IRTranslator LLVM IR MI
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
Definition Lint.cpp:539
static SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG)
static SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, bool hasHardQuad, bool isV9, bool is64Bit)
static SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG)
static SDValue LowerShiftParts(SDValue Op, SelectionDAG &DAG)
Lower SRA_PARTS and friends, which return two i32 values and take a 2 x i32 value to shift plus a shi...
AMDGPUTargetLowering(const TargetMachine &TM, const TargetSubtargetInfo &STI, const AMDGPUSubtarget &AMDGPUSTI)
an instruction that atomically reads a memory location, combines it with another value,...
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
This class is used to represent ISD::LOAD nodes.
Representation of each machine instruction.
Flags
Flags values. These may be or'd together.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
An SDNode that represents everything that will be needed to construct a MachineInstr.
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...
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
const R600Subtarget * getSubtarget() const
bool canMergeStoresTo(unsigned AS, EVT MemVT, const MachineFunction &MF) const override
Returns if it's reasonable to merge stores to MemVT size.
R600TargetLowering(const TargetMachine &TM, const R600Subtarget &STI)
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &, 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...
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AS, Align Alignment, MachineMemOperand::Flags Flags=MachineMemOperand::MONone, unsigned *IsFast=nullptr) const override
Determine if the target supports unaligned memory accesses.
bool canCombineTruncStore(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace, bool LegalOperations) const override
CCAssignFn * CCAssignFnForCall(CallingConv::ID CC, bool IsVarArg) const
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl< ISD::InputArg > &Ins, const SDLoc &DL, SelectionDAG &DAG, SmallVectorImpl< SDValue > &InVals) const override
XXX Only kernel functions are supported, so we can assume for now that every function is a kernel fun...
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...
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This class is used to represent ISD::STORE nodes.
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
bool isTruncStoreLegal(EVT ValVT, EVT MemVT, Align Alignment, unsigned AddrSpace) const
Return true if the specified store with truncation is legal on this target.
Primary interface to the complete machine description for the target machine.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
bool CCAssignFn(unsigned ValNo, MVT ValVT, MVT LocVT, CCValAssign::LocInfo LocInfo, ISD::ArgFlagsTy ArgFlags, Type *OrigTy, CCState &State)
CCAssignFn - This function assigns a location for Val, updating State to reflect the change.
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