This action will force synchronization from 方舟编译器/OpenArkCompiler, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
At the Current stage, there are two phases classes provided for inheritance. Other level IR phase can be designed as a subclass of the MaplePhase class. They perform the optimizations or generate analysis results on the specific IR level.
If a phases is derived from MapleModulePhase, it indicates that this phase does transformation on the module. It can run lower level IR phases manager as well.
template <class funcT>
class MapleFunctionPhase : public MaplePhase
In constrast to MapleFunctionPhase, it is template class due to different Function level IRs in Maple. Both CodeGen Function level IR and MidEnd Function level IR derives this class.
Maple phase management is able to manage memory so that each phase can keep the information required by other phases and discard useless information. Each phase manager provides an analysisDataManager (In multithreading, each threads provides an analysisDataMangers) which takes responsibility for storing analysis data. To implement this functionality, the GetAnalysisDependence Method is required to be implemented be each phases.
void <OPT_PHASENAME>::GetAnalysisDependence(maple::AnalysisDep &aDep) const {
aDep.AddRequired<OPT_PHASENAME>(); // If a previous phase is requried to be executed
aDep.AddPreserved<OPT_PHASENAME>(); // preserve specific previous phase information
aDep.SetPreservedAll(); // preserve all previous phase information in analysisDataManager
}
GetPhasesMempool() in Analysis phase provides mempool from analysisDataManager. Any data that is put in analysis phase mempool is not deleted until it is declared to be discarded by other phases or the end of phase manager. If information generated during analysis phase need to be deleted after this analysis phase, it can be put in Temp mempool in MaplePhase.
GetPhasesMempool() in Transform phase provides mempool which lives until this transformation finish. If a transform phase does not implement the GetAnalysisDependence method, it defaults to not having any prerequisite phases, and invalidating all phases information in analysisDataManager. Transfrom phase default to be assumed to invalid all ananlysis results.
An example for function level transform
phase called 'MEHello' in me.
content in me_hello_opt.h
#ifndef MAPLE_ME_INCLUDE_ME_HELLO_OPT_H
#define MAPLE_ME_INCLUDE_ME_HELLO_OPT_H
#include "me_function.h" // in order to use MeFunction
#include "maple_phase.h" // in order to use the macro
namespace maple {
// always use this macro when you work with a transform phase.
MAPLE_FUNC_PHASE_DECLARE(MEHello, MeFunction)
} // namespace maple
#endif // MAPLE_ME_INCLUDE_ME_HELLO_OPT_H
content in me_hello_opt.cpp
#include "me_hello_opt.h"
// include the corresponding phasemanager in order to use information from other phase.
#include "me_phase_manager.h"
namespace maple {
// you need always keep in mind that which analysis results are needed and which results will be destroyed.
void MEHello::GetAnalysisDependence(maple::AnalysisDep &aDep) const {
aDep.AddRequired<MEDominance>(); // it is guaranteed that MEDominance's result is available in this phase.
aDep.SetPreservedAll(); // it means that this phase will not destroy any analysis results.
}
// the return value of this function indicates that whether this phase
// has modified the IR of this function, for now we do not use this value.
bool MEHello::PhaseRun(maple::MeFunction &f) {
// you can use this macro to get the result which is configured as Required
// in GetAnalysisDependence; or an error will be reported.
auto *dom = GET_ANALYSIS(MEDominance);
// do something using dom info.
LogInfo::MapleLogger() << "hello opt on function: " << f.GetName() << '\n';
return false;
}
} // namespace maple
MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(MEHdse, hdse)
// the macro suffix CANSKIP indicates that this phase can be skipped.
// first parameter tells the implement class and the second parameter is
// the phase name, which could be used in option like: dump-phase(s),
// skip-phases, skip-after; and it is used to configure the phase list that will run in phasemanager.
+MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(MEHello, hello)
MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(MELfoIVCanon, ivcanon)
...
ADDMAPLEMEPHASE("dse", MeOption::optLevel >= 2)
ADDMAPLEMEPHASE("hello", MeOption::optLevel >= 2)
ADDMAPLEMEPHASE("analyzector", JAVALANG)
...
>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Optimizing Function < VEC_invariant_p_base_space id=5471 >---
---Preparing Function < VEC_invariant_p_base_space > [1] ---
---Run Phase [ mecfgbuild ]---
---Run Phase [ cfgOpt ]---
---Run Phase [ loopcanon ]---
++ trigger phase [ dominance ]
++ trigger phase [ identloops ]
---Run Phase [ splitcriticaledge ]---
---Run Phase [ ssatab ]---
---Run Phase [ aliasclass ]---
---Run Phase [ ssa ]---
++ trigger phase [ dominance ]
---Run Phase [ dse ]---
++ trigger phase [ fsaa ]
---Run Phase [ hello ]---
hello opt on function: VEC_invariant_p_base_space
---Run Phase [ hprop ]---
++ trigger phase [ irmapbuild ]
---Run Phase [ valueRangePropagation ]---
++ trigger phase [ identloops ]
---Run Phase [ hdse ]---
---Run Phase [ epre ]---
++ trigger phase [ dominance ]
++ trigger phase [ identloops ]
== epre invokes [ hdse ] ==
---Run Phase [ rename2preg ]---
---Run Phase [ lpre ]---
---Run Phase [ storepre ]---
---Run Phase [ copyprop ]---
---Run Phase [ hdse ]---
---Run Phase [ pregrename ]---
---Run Phase [ bblayout ]---
---Run Phase [ meemit ]---
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。