2023-05-26 13:52:09 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-07-26 15:31:53 +01:00
|
|
|
namespace oi::detail::type_graph {
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-08-15 15:27:20 +01:00
|
|
|
class NodeTrackerHolder;
|
|
|
|
class NodeTracker;
|
2023-05-26 13:52:09 +01:00
|
|
|
class TypeGraph;
|
|
|
|
class Type;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass
|
|
|
|
*
|
|
|
|
* TODO
|
|
|
|
*/
|
|
|
|
class Pass {
|
2023-08-15 15:27:20 +01:00
|
|
|
using PassFn =
|
|
|
|
std::function<void(TypeGraph& typeGraph, NodeTracker& tracker)>;
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
Pass(std::string name, PassFn fn) : name_(std::move(name)), fn_(fn) {
|
|
|
|
}
|
2023-08-15 15:27:20 +01:00
|
|
|
void run(TypeGraph& typeGraph, NodeTrackerHolder tracker);
|
2023-05-26 13:52:09 +01:00
|
|
|
std::string& name() {
|
|
|
|
return name_;
|
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string name_;
|
|
|
|
PassFn fn_;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* PassManager
|
|
|
|
*
|
|
|
|
* TODO
|
|
|
|
*/
|
|
|
|
class PassManager {
|
|
|
|
public:
|
|
|
|
void addPass(Pass p);
|
|
|
|
void run(TypeGraph& typeGraph);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Pass> passes_;
|
|
|
|
};
|
|
|
|
|
2023-07-26 15:31:53 +01:00
|
|
|
} // namespace oi::detail::type_graph
|