Skip to content

Commit ad5c203

Browse files
committed
[SandboxIR][SandboxVectorizer][NFC] Move Region to SandboxVectorizer.
When I first added the Region class I was unclear whether it was SandboxVectorizer-specific or something more general that could go in SandboxIR (as evidenced by the fact that I got the Region.h include guard wrong and didn't have to update it for this commit :) Now I'm convinced that it belongs in SandboxVectorizer, so I'd like to move it back. This change does just that: - Region.h, Region.cpp and RegionTest.cpp are moved into the right directories for SandboxVectorizer. - The RegionPass and RegionPassManager classes are moved into Region.h. - All the other touched files are just mechanical changes to make everything work. Mainly updating include paths and qualifying some names in tests.
1 parent be6bc6a commit ad5c203

File tree

17 files changed

+170
-162
lines changed

17 files changed

+170
-162
lines changed

llvm/include/llvm/SandboxIR/Pass.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class ScalarEvolution;
2020
namespace sandboxir {
2121

2222
class Function;
23-
class Region;
2423

2524
class Analyses {
2625
AAResults *AA = nullptr;
@@ -76,15 +75,6 @@ class FunctionPass : public Pass {
7675
virtual bool runOnFunction(Function &F, const Analyses &A) = 0;
7776
};
7877

79-
/// A pass that runs on a sandbox::Region.
80-
class RegionPass : public Pass {
81-
public:
82-
/// \p Name can't contain any spaces or start with '-'.
83-
RegionPass(StringRef Name) : Pass(Name) {}
84-
/// \Returns true if it modifies \p R.
85-
virtual bool runOnRegion(Region &R, const Analyses &A) = 0;
86-
};
87-
8878
} // namespace sandboxir
8979
} // namespace llvm
9080

llvm/include/llvm/SandboxIR/PassManager.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,6 @@ class FunctionPassManager final
211211
bool runOnFunction(Function &F, const Analyses &A) final;
212212
};
213213

214-
class RegionPassManager final : public PassManager<RegionPass, RegionPass> {
215-
public:
216-
RegionPassManager(StringRef Name) : PassManager(Name) {}
217-
RegionPassManager(StringRef Name, StringRef Pipeline,
218-
CreatePassFunc CreatePass)
219-
: PassManager(Name, Pipeline, CreatePass) {}
220-
bool runOnRegion(Region &R, const Analyses &A) final;
221-
};
222-
223214
} // namespace llvm::sandboxir
224215

225216
#endif // LLVM_SANDBOXIR_PASSMANAGER_H

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/BottomUpVec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/SandboxIR/PassManager.h"
2020
#include "llvm/Support/raw_ostream.h"
2121
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h"
22+
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Region.h"
2223

2324
namespace llvm::sandboxir {
2425

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/NullPass.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_NULLPASS_H
22
#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_NULLPASS_H
33

4-
#include "llvm/SandboxIR/Pass.h"
4+
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Region.h"
55

66
namespace llvm::sandboxir {
77

8-
class Region;
9-
108
/// A Region pass that does nothing, for use as a placeholder in tests.
119
class NullPass final : public RegionPass {
1210
public:

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/PrintInstructionCount.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
#ifndef LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_PRINTINSTRUCTIONCOUNT_H
22
#define LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_PASSES_PRINTINSTRUCTIONCOUNT_H
33

4-
#include "llvm/SandboxIR/Pass.h"
5-
#include "llvm/SandboxIR/Region.h"
4+
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Region.h"
65

76
namespace llvm::sandboxir {
87

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Passes/RegionsFromMetadata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/StringRef.h"
1818
#include "llvm/SandboxIR/Pass.h"
1919
#include "llvm/SandboxIR/PassManager.h"
20+
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Region.h"
2021

2122
namespace llvm::sandboxir {
2223

llvm/include/llvm/SandboxIR/Region.h renamed to llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Region.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "llvm/ADT/SetVector.h"
1515
#include "llvm/ADT/iterator_range.h"
1616
#include "llvm/SandboxIR/Instruction.h"
17+
#include "llvm/SandboxIR/Pass.h"
18+
#include "llvm/SandboxIR/PassManager.h"
1719
#include "llvm/Support/raw_ostream.h"
1820

1921
namespace llvm::sandboxir {
@@ -107,6 +109,26 @@ class Region {
107109
#endif
108110
};
109111

112+
/// A pass that runs on a Region.
113+
class RegionPass : public Pass {
114+
public:
115+
/// \p Name can't contain any spaces or start with '-'.
116+
RegionPass(StringRef Name) : Pass(Name) {}
117+
/// \Returns true if it modifies \p R.
118+
virtual bool runOnRegion(Region &R, const Analyses &A) = 0;
119+
};
120+
121+
/// A PassManager for passes that operate on Regions.
122+
class RegionPassManager final : public PassManager<RegionPass, RegionPass> {
123+
public:
124+
RegionPassManager(StringRef Name) : PassManager(Name) {}
125+
RegionPassManager(StringRef Name, StringRef Pipeline,
126+
CreatePassFunc CreatePass)
127+
: PassManager(Name, Pipeline, CreatePass) {}
128+
bool runOnRegion(Region &R, const Analyses &A) final;
129+
};
130+
131+
110132
} // namespace llvm::sandboxir
111133

112134
#endif // LLVM_TRANSFORMS_VECTORIZE_SANDBOXVECTORIZER_REGION_H

llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizerPassBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "llvm/ADT/StringRef.h"
1616
#include "llvm/SandboxIR/Pass.h"
17+
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Region.h"
1718

1819
#include <memory>
1920

llvm/lib/SandboxIR/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ add_llvm_component_library(LLVMSandboxIR
88
Module.cpp
99
Pass.cpp
1010
PassManager.cpp
11-
Region.cpp
1211
Tracker.cpp
1312
Type.cpp
1413
User.cpp

llvm/lib/SandboxIR/PassManager.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,4 @@ bool FunctionPassManager::runOnFunction(Function &F, const Analyses &A) {
2020
return Change;
2121
}
2222

23-
bool RegionPassManager::runOnRegion(Region &R, const Analyses &A) {
24-
bool Change = false;
25-
for (auto &Pass : Passes) {
26-
Change |= Pass->runOnRegion(R, A);
27-
// TODO: run the verifier.
28-
}
29-
// TODO: Check ChangeAll against hashes before/after.
30-
return Change;
31-
}
32-
3323
} // namespace llvm::sandboxir

0 commit comments

Comments
 (0)