arkcompiler_ets_runtime/ecmascript/compiler/verifier.h
wuzhefeng 65b62d6fc8 Refactor Circuit Construction
There are several inefficient circuit-ir construction operations such that copying the inputs and outputs from Gate and passing them to other vectors, which will slow the compilation speed.

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I617PE

Signed-off-by: wuzhefeng <wuzhefeng1@huawei.com>
Change-Id: Ib49fc4946443de8f2b6fedddecfd0d9efda3e96a
2022-11-15 03:42:35 -08:00

70 lines
3.2 KiB
C++

/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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.
*/
#ifndef ECMASCRIPT_COMPILER_VERIFIER_H
#define ECMASCRIPT_COMPILER_VERIFIER_H
#include <algorithm>
#include <deque>
#include <functional>
#include <numeric>
#include <unordered_map>
#include "ecmascript/compiler/circuit.h"
namespace panda::ecmascript::kungfu {
class Verifier {
public:
static bool RunDataIntegrityCheck(const Circuit *circuit);
static bool RunStateGatesCheck(const Circuit *circuit, const std::vector<GateRef> &bbGatesList);
static bool RunCFGSoundnessCheck(const Circuit *circuit, const std::vector<GateRef> &bbGatesList,
const std::unordered_map<GateRef, size_t> &bbGatesAddrToIdx);
static bool RunCFGIsDAGCheck(const Circuit *circuit);
static bool RunCFGReducibilityCheck(const Circuit *circuit, const std::vector<GateRef> &bbGatesList,
const std::unordered_map<GateRef, size_t> &bbGatesAddrToIdx,
const std::function<bool(size_t, size_t)> &isAncestor);
static bool RunFixedGatesCheck(const Circuit *circuit, const std::vector<GateRef> &fixedGatesList);
static bool RunFixedGatesRelationsCheck(const Circuit *circuit, const std::vector<GateRef> &fixedGatesList,
const std::unordered_map<GateRef, size_t> &bbGatesAddrToIdx,
const std::function<bool(size_t, size_t)> &isAncestor);
static bool RunFlowCyclesFind(const Circuit *circuit, std::vector<GateRef> *schedulableGatesListPtr,
const std::vector<GateRef> &bbGatesList,
const std::vector<GateRef> &fixedGatesList);
static bool RunSchedulableGatesCheck(const Circuit *circuit, const std::vector<GateRef> &schedulableGatesList);
static bool RunPrologGatesCheck(const Circuit *circuit, const std::vector<GateRef> &schedulableGatesList);
static bool RunSchedulingBoundsCheck(const Circuit *circuit, const std::vector<GateRef> &schedulableGatesList,
const std::unordered_map<GateRef, size_t> &bbGatesAddrToIdx,
const std::function<bool(size_t, size_t)> &isAncestor,
const std::function<size_t(size_t, size_t)> &lowestCommonAncestor);
static void FindFixedGates(const Circuit *circuit, const std::vector<GateRef> &bbGatesList,
std::vector<GateRef> &fixedGatesList);
static bool Run(const Circuit *circuit, const std::string& methodName = "", bool enableLog = false);
};
} // namespace panda::ecmascript::kungfu
#endif // ECMASCRIPT_COMPILER_VERIFIER_H