LLVM 24.0.0git
NVPTXAtomicLower.cpp
Go to the documentation of this file.
1//===-- NVPTXAtomicLower.cpp - Lower atomics of local memory ----*- 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// Lower atomics of local memory to simple load/stores
10//
11//===----------------------------------------------------------------------===//
12
13#include "NVPTX.h"
15#include "llvm/IR/Function.h"
19
21using namespace llvm;
22
24 SmallVector<AtomicRMWInst *> LocalMemoryAtomics;
25 for (Instruction &I : instructions(F))
27 if (RMWI->getPointerAddressSpace() == ADDRESS_SPACE_LOCAL)
28 LocalMemoryAtomics.push_back(RMWI);
29
30 bool Changed = false;
31 for (AtomicRMWInst *RMWI : LocalMemoryAtomics)
33 return Changed;
34}
35
36namespace {
37class NVPTXAtomicLowerLegacyPass : public FunctionPass {
38public:
39 static char ID; // Pass ID
40 NVPTXAtomicLowerLegacyPass() : FunctionPass(ID) {}
41
42 void getAnalysisUsage(AnalysisUsage &AU) const override {
43 AU.setPreservesCFG();
44 }
45
46 StringRef getPassName() const override {
47 return "NVPTX lower atomics of local memory";
48 }
49
50 bool runOnFunction(Function &F) override {
52 }
53};
54} // namespace
55
56char NVPTXAtomicLowerLegacyPass::ID = 0;
57
58INITIALIZE_PASS(NVPTXAtomicLowerLegacyPass, "nvptx-atomic-lower",
59 "Lower atomics of local memory to simple load/stores", false,
60 false)
61
63 return new NVPTXAtomicLowerLegacyPass();
64}
65
Expand Atomic instructions
static bool runOnFunction(Function &F, bool PostInlining)
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
static bool lowerLocalMemoryAtomics(Function &F)
FunctionAnalysisManager FAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Definition Pass.cpp:275
an instruction that atomically reads a memory location, combines it with another value,...
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition Analysis.h:115
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Changed
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createNVPTXAtomicLowerLegacyPass()
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
LLVM_ABI bool lowerAtomicRMWInst(AtomicRMWInst *RMWI)
Convert the given RMWI into primitive load and stores, assuming that doing so is legal.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.