LLVM 22.0.0git
NVPTXISelDAGToDAG.h
Go to the documentation of this file.
1//===-- NVPTXISelDAGToDAG.h - A dag to dag inst selector for NVPTX --------===//
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 an instruction selector for the NVPTX target.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
14#define LLVM_LIB_TARGET_NVPTX_NVPTXISELDAGTODAG_H
15
17#include "NVPTX.h"
18#include "NVPTXISelLowering.h"
19#include "NVPTXRegisterInfo.h"
20#include "NVPTXTargetMachine.h"
21#include "llvm/ADT/MapVector.h"
23#include "llvm/IR/InlineAsm.h"
24#include "llvm/IR/Intrinsics.h"
25#include "llvm/IR/LLVMContext.h"
27
28namespace llvm {
29
31 NVPTXScopes() = default;
34 bool empty() const;
35
36private:
38};
39
41 const NVPTXTargetMachine &TM;
42
43 NVPTX::DivPrecisionLevel getDivF32Level(const SDNode *N) const;
44 bool usePrecSqrtF32(const SDNode *N) const;
45 bool useF32FTZ() const;
46 bool allowFMA() const;
47 bool doRsqrtOpt() const;
48
49 NVPTXScopes Scopes{};
50
51public:
53
55
57 const NVPTXSubtarget *Subtarget = nullptr;
58
60 InlineAsm::ConstraintCode ConstraintID,
61 std::vector<SDValue> &OutOps) override;
62
63private:
64// Include the pieces autogenerated from the target description.
65#include "NVPTXGenDAGISel.inc"
66
67 void Select(SDNode *N) override;
68 bool tryIntrinsicChain(SDNode *N);
69 bool tryIntrinsicVoid(SDNode *N);
70 void SelectTexSurfHandle(SDNode *N);
71 bool tryLoad(SDNode *N);
72 bool tryLoadVector(SDNode *N);
73 bool tryLDU(SDNode *N);
74 bool tryLDG(MemSDNode *N);
75 bool tryStore(SDNode *N);
76 bool tryStoreVector(SDNode *N);
77 bool tryFence(SDNode *N);
78 void SelectAddrSpaceCast(SDNode *N);
79 bool tryBFE(SDNode *N);
80 bool tryBF16ArithToFMA(SDNode *N);
81 bool tryConstantFP(SDNode *N);
82 bool SelectSETP_F16X2(SDNode *N);
83 bool SelectSETP_BF16X2(SDNode *N);
84 bool tryUNPACK_VECTOR(SDNode *N);
85 bool tryEXTRACT_VECTOR_ELEMENT(SDNode *N);
86 void SelectV2I64toI128(SDNode *N);
87 void SelectI128toV2I64(SDNode *N);
88 void SelectCpAsyncBulkTensorG2SCommon(SDNode *N, bool IsIm2Col = false);
89 void SelectCpAsyncBulkTensorReduceCommon(SDNode *N, unsigned RedOp,
90 bool IsIm2Col = false);
91 void SelectTcgen05Ld(SDNode *N, bool hasOffset = false);
92 void SelectTcgen05St(SDNode *N, bool hasOffset = false);
93 void selectAtomicSwap128(SDNode *N);
94
95 inline SDValue getI32Imm(unsigned Imm, const SDLoc &DL) {
96 return CurDAG->getTargetConstant(Imm, DL, MVT::i32);
97 }
98 NVPTX::Ordering getMemOrder(const MemSDNode *N) const;
99 NVPTX::Scope getAtomicScope(const MemSDNode *N) const;
100
101 bool SelectADDR(SDValue Addr, SDValue &Base, SDValue &Offset);
102 SDValue getPTXCmpMode(const CondCodeSDNode &CondCode);
103 SDValue selectPossiblyImm(SDValue V);
104
105 // Returns the Memory Order and Scope that the PTX memory instruction should
106 // use, and inserts appropriate fence instruction before the memory
107 // instruction, if needed to implement the instructions memory order. Required
108 // fences after the instruction need to be handled elsewhere.
109 std::pair<NVPTX::Ordering, NVPTX::Scope>
110 insertMemoryInstructionFence(SDLoc DL, SDValue &Chain, MemSDNode *N);
111 NVPTX::Scope getOperationScope(MemSDNode *N, NVPTX::Ordering O) const;
112
113public:
114 static NVPTX::AddressSpace getAddrSpace(const MemSDNode *N);
115 static unsigned getFromTypeWidthForLoad(const MemSDNode *Mem);
116};
117
119public:
120 static char ID;
122 CodeGenOptLevel OptLevel);
123};
124} // end namespace llvm
125
126#endif
AMDGPU Register Bank Select
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_LIBRARY_VISIBILITY
Definition Compiler.h:137
This file implements a map that provides insertion order iteration.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
This is an abstract virtual class for memory operations.
NVPTXDAGToDAGISelLegacy(NVPTXTargetMachine &tm, CodeGenOptLevel OptLevel)
bool runOnMachineFunction(MachineFunction &MF) override
bool SelectInlineAsmMemoryOperand(const SDValue &Op, InlineAsm::ConstraintCode ConstraintID, std::vector< SDValue > &OutOps) override
SelectInlineAsmMemoryOperand - Implement addressing mode selection for inline asm expressions.
const NVPTXSubtarget * Subtarget
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.
SelectionDAGISelLegacy(char &ID, std::unique_ptr< SelectionDAGISel > S)
SelectionDAGISel(TargetMachine &tm, CodeGenOptLevel OL=CodeGenOptLevel::Default)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
DivPrecisionLevel
Definition NVPTX.h:251
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:477
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
DWARFExpression::Operation Op
#define N
NVPTXScopes()=default
NVPTX::Scope operator[](SyncScope::ID ID) const
A MapVector that performs no allocations if smaller than a certain size.
Definition MapVector.h:249