1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ra_opt.h"
17 #include "cgfunc.h"
18 #include "loop.h"
19 #include "cg.h"
20 #include "optimize_common.h"
21 #include "aarch64_ra_opt.h"
22
23 namespace maplebe {
24 using namespace maple;
25
PhaseRun(maplebe::CGFunc & f)26 bool CgRaOpt::PhaseRun(maplebe::CGFunc &f)
27 {
28 MemPool *memPool = GetPhaseMemPool();
29 RaOpt *raOpt = nullptr;
30 auto *dom = GET_ANALYSIS(CgDomAnalysis, f);
31 CHECK_FATAL(dom != nullptr, "null ptr check");
32 auto *loop = GET_ANALYSIS(CgLoopAnalysis, f);
33 CHECK_FATAL(loop != nullptr, "null ptr check");
34 raOpt = memPool->New<AArch64RaOpt>(f, *memPool, *dom, *loop);
35 if (raOpt) {
36 raOpt->Run();
37 }
38 return false;
39 }
40
GetAnalysisDependence(maple::AnalysisDep & aDep) const41 void CgRaOpt::GetAnalysisDependence(maple::AnalysisDep &aDep) const
42 {
43 aDep.AddRequired<CgDomAnalysis>();
44 aDep.AddRequired<CgPostDomAnalysis>();
45 aDep.AddRequired<CgLoopAnalysis>();
46 aDep.SetPreservedAll();
47 }
48 MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(CgRaOpt, raopt)
49 } /* namespace maplebe */
50