summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2025-02-18 15:42:14 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2025-02-18 09:30:51 -0800
commit21cd7790cb66e29670e85a8733c8ee35aa18bbd6 (patch)
tree69f55803d983342f7fb7aba382eecea043a76f59
parent9a4f8f8fe5133f7c3b17d2ad9d502f64b40f6033 (diff)
Optimizing: Remove dead Partial LSE test helpers.
Test: m test-art-host-gtest Bug: 298176183 Change-Id: I25a047e20dd4b0388c639c90634e74a5a626d2ac
-rw-r--r--compiler/optimizing/optimizing_unit_test.h150
1 files changed, 0 insertions, 150 deletions
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index c40b918fee..8dc17f1618 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -1034,156 +1034,6 @@ inline std::ostream& operator<<(std::ostream& oss, const AdjacencyListGraph& alg
return alg.Dump(oss);
}
-class PatternMatchGraphVisitor final : public HGraphVisitor {
- private:
- struct HandlerWrapper {
- public:
- virtual ~HandlerWrapper() {}
- virtual void operator()(HInstruction* h) = 0;
- };
-
- template <HInstruction::InstructionKind kKind, typename F>
- struct KindWrapper;
-
-#define GEN_HANDLER(nm, unused) \
- template <typename F> \
- struct KindWrapper<HInstruction::InstructionKind::k##nm, F> : public HandlerWrapper { \
- public: \
- explicit KindWrapper(F f) : f_(f) {} \
- void operator()(HInstruction* h) override { \
- if constexpr (std::is_invocable_v<F, H##nm*>) { \
- f_(h->As##nm()); \
- } else { \
- LOG(FATAL) << "Incorrect call with " << #nm; \
- } \
- } \
- \
- private: \
- F f_; \
- };
-
- FOR_EACH_CONCRETE_INSTRUCTION(GEN_HANDLER)
-#undef GEN_HANDLER
-
- template <typename F>
- std::unique_ptr<HandlerWrapper> GetWrapper(HInstruction::InstructionKind kind, F f) {
- switch (kind) {
-#define GEN_GETTER(nm, unused) \
- case HInstruction::InstructionKind::k##nm: \
- return std::unique_ptr<HandlerWrapper>( \
- new KindWrapper<HInstruction::InstructionKind::k##nm, F>(f));
- FOR_EACH_CONCRETE_INSTRUCTION(GEN_GETTER)
-#undef GEN_GETTER
- default:
- LOG(FATAL) << "Unable to handle kind " << kind;
- return nullptr;
- }
- }
-
- public:
- template <typename... Inst>
- explicit PatternMatchGraphVisitor(HGraph* graph, Inst... handlers) : HGraphVisitor(graph) {
- FillHandlers(handlers...);
- }
-
- void VisitInstruction(HInstruction* instruction) override {
- auto& h = handlers_[instruction->GetKind()];
- if (h.get() != nullptr) {
- (*h)(instruction);
- }
- }
-
- private:
- template <typename Func>
- constexpr HInstruction::InstructionKind GetKind() {
-#define CHECK_INST(nm, unused) \
- if constexpr (std::is_invocable_v<Func, H##nm*>) { \
- return HInstruction::InstructionKind::k##nm; \
- }
- FOR_EACH_CONCRETE_INSTRUCTION(CHECK_INST);
-#undef CHECK_INST
- static_assert(!std::is_invocable_v<Func, HInstruction*>,
- "Use on generic HInstruction not allowed");
-#define STATIC_ASSERT_ABSTRACT(nm, unused) && !std::is_invocable_v<Func, H##nm*>
- static_assert(true FOR_EACH_ABSTRACT_INSTRUCTION(STATIC_ASSERT_ABSTRACT),
- "Must not be abstract instruction");
-#undef STATIC_ASSERT_ABSTRACT
-#define STATIC_ASSERT_CONCRETE(nm, unused) || std::is_invocable_v<Func, H##nm*>
- static_assert(false FOR_EACH_CONCRETE_INSTRUCTION(STATIC_ASSERT_CONCRETE),
- "Must be a concrete instruction");
-#undef STATIC_ASSERT_CONCRETE
- return HInstruction::InstructionKind::kLastInstructionKind;
- }
- template <typename First>
- void FillHandlers(First h1) {
- HInstruction::InstructionKind type = GetKind<First>();
- CHECK_NE(type, HInstruction::kLastInstructionKind)
- << "Unknown instruction kind. Only concrete ones please.";
- handlers_[type] = GetWrapper(type, h1);
- }
-
- template <typename First, typename... Inst>
- void FillHandlers(First h1, Inst... handlers) {
- FillHandlers(h1);
- FillHandlers<Inst...>(handlers...);
- }
-
- std::array<std::unique_ptr<HandlerWrapper>, HInstruction::InstructionKind::kLastInstructionKind>
- handlers_;
-};
-
-template <typename... Target>
-std::tuple<std::vector<Target*>...> FindAllInstructions(
- HGraph* graph,
- std::variant<std::nullopt_t, HBasicBlock*, std::initializer_list<HBasicBlock*>> blks =
- std::nullopt) {
- std::tuple<std::vector<Target*>...> res;
- PatternMatchGraphVisitor vis(
- graph, [&](Target* t) { std::get<std::vector<Target*>>(res).push_back(t); }...);
-
- if (std::holds_alternative<std::initializer_list<HBasicBlock*>>(blks)) {
- for (HBasicBlock* blk : std::get<std::initializer_list<HBasicBlock*>>(blks)) {
- vis.VisitBasicBlock(blk);
- }
- } else if (std::holds_alternative<std::nullopt_t>(blks)) {
- vis.VisitInsertionOrder();
- } else {
- vis.VisitBasicBlock(std::get<HBasicBlock*>(blks));
- }
- return res;
-}
-
-template <typename... Target>
-std::tuple<Target*...> FindSingleInstructions(
- HGraph* graph,
- std::variant<std::nullopt_t, HBasicBlock*, std::initializer_list<HBasicBlock*>> blks =
- std::nullopt) {
- std::tuple<Target*...> res;
- PatternMatchGraphVisitor vis(graph, [&](Target* t) {
- EXPECT_EQ(std::get<Target*>(res), nullptr)
- << *std::get<Target*>(res) << " already found but found " << *t << "!";
- std::get<Target*>(res) = t;
- }...);
- if (std::holds_alternative<std::initializer_list<HBasicBlock*>>(blks)) {
- for (HBasicBlock* blk : std::get<std::initializer_list<HBasicBlock*>>(blks)) {
- vis.VisitBasicBlock(blk);
- }
- } else if (std::holds_alternative<std::nullopt_t>(blks)) {
- vis.VisitInsertionOrder();
- } else {
- vis.VisitBasicBlock(std::get<HBasicBlock*>(blks));
- }
- return res;
-}
-
-template <typename Target>
-Target* FindSingleInstruction(
- HGraph* graph,
- std::variant<std::nullopt_t, HBasicBlock*, std::initializer_list<HBasicBlock*>> blks =
- std::nullopt) {
- return std::get<Target*>(FindSingleInstructions<Target>(graph, blks));
-}
-
} // namespace art
#endif // ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_