From 4431d19ec135259772f8815a879ee264978efedf Mon Sep 17 00:00:00 2001 From: Fred Chow Date: Thu, 16 Dec 2021 17:39:16 -0800 Subject: [PATCH] Rename from lfo to pme/PreMe the files and classes that can be used by IPA, not exclusively for LFO --- .../maple_ipa/src/ipa_phase_manager.cpp | 4 +- src/mapleall/maple_me/BUILD.gn | 4 +- src/mapleall/maple_me/include/lfo_dep_test.h | 12 +- src/mapleall/maple_me/include/lfo_iv_canon.h | 6 +- src/mapleall/maple_me/include/lfo_loop_vec.h | 16 +- src/mapleall/maple_me/include/lfo_unroll.h | 12 +- src/mapleall/maple_me/include/me_function.h | 18 +- .../maple_me/include/me_phase_manager.h | 2 +- .../include/{lfo_pre_emit.h => pme_emit.h} | 102 +++--- .../{lfo_function.h => pme_function.h} | 60 ++-- .../{lfo_mir_nodes.h => pme_mir_extension.h} | 16 +- .../{lfo_mir_lower.h => pme_mir_lower.h} | 16 +- src/mapleall/maple_me/include/seqvec.h | 16 +- src/mapleall/maple_me/src/lfo_dep_test.cpp | 18 +- src/mapleall/maple_me/src/lfo_inject_iv.cpp | 10 +- src/mapleall/maple_me/src/lfo_iv_canon.cpp | 12 +- src/mapleall/maple_me/src/lfo_loop_vec.cpp | 12 +- src/mapleall/maple_me/src/lfo_unroll.cpp | 10 +- src/mapleall/maple_me/src/me_autovec.cpp | 4 +- src/mapleall/maple_me/src/me_cfg.cpp | 8 +- src/mapleall/maple_me/src/me_function.cpp | 12 +- src/mapleall/maple_me/src/me_hdse.cpp | 8 +- .../maple_me/src/me_phase_manager.cpp | 2 +- src/mapleall/maple_me/src/me_ssa.cpp | 8 +- .../src/{lfo_pre_emit.cpp => pme_emit.cpp} | 335 +++++++++--------- .../{lfo_mir_lower.cpp => pme_mir_lower.cpp} | 36 +- src/mapleall/maple_me/src/seqvec.cpp | 10 +- src/mapleall/maple_phase/include/phases.def | 2 +- 28 files changed, 383 insertions(+), 388 deletions(-) rename src/mapleall/maple_me/include/{lfo_pre_emit.h => pme_emit.h} (41%) rename src/mapleall/maple_me/include/{lfo_function.h => pme_function.h} (51%) rename src/mapleall/maple_me/include/{lfo_mir_nodes.h => pme_mir_extension.h} (69%) rename src/mapleall/maple_me/include/{lfo_mir_lower.h => pme_mir_lower.h} (75%) rename src/mapleall/maple_me/src/{lfo_pre_emit.cpp => pme_emit.cpp} (75%) rename src/mapleall/maple_me/src/{lfo_mir_lower.cpp => pme_mir_lower.cpp} (85%) diff --git a/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp b/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp index 9b19d67fef..f7bd02c777 100644 --- a/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp +++ b/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp @@ -13,7 +13,7 @@ * See the Mulan PSL v2 for more details. */ #include "ipa_phase_manager.h" -#include "lfo_pre_emit.h" +#include "pme_emit.h" #define JAVALANG (mirModule.IsJavaModule()) #define CLANG (mirModule.IsCModule()) @@ -145,7 +145,7 @@ bool SCCEmit::PhaseRun(SCCNode &scc) { } MIRModule &m = *func->GetModule(); m.SetCurFunction(func); - const MaplePhaseInfo *phase = MaplePhaseRegister::GetMaplePhaseRegister()->GetPhaseByID(&MELfoPreEmission::id); + const MaplePhaseInfo *phase = MaplePhaseRegister::GetMaplePhaseRegister()->GetPhaseByID(&MEPreMeEmission::id); if (!IsQuiet()) { LogInfo::MapleLogger() << "---Run " << (phase->IsAnalysis() ? "analysis" : "transform") << " Phase [ " << phase->PhaseName() << " ]---\n"; diff --git a/src/mapleall/maple_me/BUILD.gn b/src/mapleall/maple_me/BUILD.gn index cba3ab4c70..8c4d41e8f7 100755 --- a/src/mapleall/maple_me/BUILD.gn +++ b/src/mapleall/maple_me/BUILD.gn @@ -96,9 +96,9 @@ src_libmplme = [ "src/cast_opt.cpp", "src/me_merge_stmts.cpp", "src/me_fsaa.cpp", - "src/lfo_mir_lower.cpp", + "src/pme_mir_lower.cpp", "src/lfo_inject_iv.cpp", - "src/lfo_pre_emit.cpp", + "src/pme_emit.cpp", "src/lfo_iv_canon.cpp", "src/lfo_dep_test.cpp", "src/lfo_loop_vec.cpp", diff --git a/src/mapleall/maple_me/include/lfo_dep_test.h b/src/mapleall/maple_me/include/lfo_dep_test.h index 8c56132308..6adea69ca7 100644 --- a/src/mapleall/maple_me/include/lfo_dep_test.h +++ b/src/mapleall/maple_me/include/lfo_dep_test.h @@ -16,8 +16,8 @@ #ifndef MAPLE_ME_INCLUDE_LFO_DEP_TETS_H #define MAPLE_ME_INCLUDE_LFO_DEP_TETS_H -#include "lfo_function.h" -#include "lfo_pre_emit.h" +#include "pme_function.h" +#include "pme_emit.h" #include "orig_symbol.h" #include "maple_phase.h" #include "me_ir.h" @@ -112,16 +112,16 @@ class DoloopInfo { class LfoDepInfo : public AnalysisResult { public: MapleAllocator alloc; - LfoFunction *lfoFunc; + PreMeFunction *preMeFunc; Dominance *dom; - LfoPreEmitter *preEmit; + PreMeEmitter *preEmit; MapleVector outermostDoloopInfoVec; // outermost doloops' DoloopInfo in program order MapleMap doloopInfoMap; - LfoDepInfo(MemPool *mempool, LfoFunction *f, Dominance *dm, LfoPreEmitter *preemit) + LfoDepInfo(MemPool *mempool, PreMeFunction *f, Dominance *dm, PreMeEmitter *preemit) : AnalysisResult(mempool), alloc(mempool), - lfoFunc(f), + preMeFunc(f), dom(dm), preEmit(preemit), outermostDoloopInfoVec(alloc.Adapter()), diff --git a/src/mapleall/maple_me/include/lfo_iv_canon.h b/src/mapleall/maple_me/include/lfo_iv_canon.h index 405bd43b18..31a94bd7b2 100644 --- a/src/mapleall/maple_me/include/lfo_iv_canon.h +++ b/src/mapleall/maple_me/include/lfo_iv_canon.h @@ -16,7 +16,7 @@ #ifndef MAPLE_ME_INCLUDE_LFO_IV_CANON_H #define MAPLE_ME_INCLUDE_LFO_IV_CANON_H -#include "lfo_function.h" +#include "pme_function.h" #include "me_loop_analysis.h" #include "me_irmap_build.h" #include "maple_phase.h" @@ -48,13 +48,13 @@ class IVCanon { SSATab *ssatab; LoopDesc *aloop; uint32 loopID; - LfoWhileInfo *whileInfo; + PreMeWhileInfo *whileInfo; MapleVector ivvec; int32 idxPrimaryIV = -1; // the index in ivvec of the primary IV MeExpr *tripCount = nullptr; public: - IVCanon(MemPool *m, MeFunction *f, Dominance *dom, LoopDesc *ldesc, uint32 id, LfoWhileInfo *winfo) + IVCanon(MemPool *m, MeFunction *f, Dominance *dom, LoopDesc *ldesc, uint32 id, PreMeWhileInfo *winfo) : mp(m), alloc(m), func(f), dominance(dom), ssatab(f->GetMeSSATab()), aloop(ldesc), loopID(id), whileInfo(winfo), ivvec(alloc.Adapter()) {} virtual ~IVCanon() = default; diff --git a/src/mapleall/maple_me/include/lfo_loop_vec.h b/src/mapleall/maple_me/include/lfo_loop_vec.h index 7391345272..cf79e78c12 100644 --- a/src/mapleall/maple_me/include/lfo_loop_vec.h +++ b/src/mapleall/maple_me/include/lfo_loop_vec.h @@ -17,7 +17,7 @@ #include "me_function.h" #include "me_irmap.h" #include "me_ir.h" -#include "lfo_pre_emit.h" +#include "pme_emit.h" #include "lfo_dep_test.h" namespace maple { @@ -95,11 +95,11 @@ class LoopTransPlan { class LoopVectorization { public: - LoopVectorization(MemPool *localmp, LfoPreEmitter *lfoEmit, LfoDepInfo *depinfo, bool debug = false) + LoopVectorization(MemPool *localmp, PreMeEmitter *lfoEmit, LfoDepInfo *depinfo, bool debug = false) : localAlloc(localmp), vecPlans(localAlloc.Adapter()) { mirFunc = lfoEmit->GetMirFunction(); - lfoStmtParts = lfoEmit->GetLfoStmtMap(); - lfoExprParts = lfoEmit->GetLfoExprMap(); + PreMeStmtExtensionMap = lfoEmit->GetPreMeStmtExtensionMap(); + PreMeExprExtensionMap = lfoEmit->GetPreMeExprExtensionMap(); depInfo = depinfo; codeMP = lfoEmit->GetCodeMP(); codeMPAlloc = lfoEmit->GetCodeMPAlloc(); @@ -146,10 +146,10 @@ class LoopVectorization { static uint32_t vectorizedLoop; private: MIRFunction *mirFunc; - // point to lfoStmtParts of lfopreemit, map lfoinfo for StmtNode, key is stmtID - MapleMap *lfoStmtParts; - // point to lfoexprparts of lfopreemit, map lfoinfo for exprNode, key is mirnode - MapleMap *lfoExprParts; + // point to PreMeStmtExtensionMap of PreMeEmitter, key is stmtID + MapleMap *PreMeStmtExtensionMap; + // point to PreMeExprExtensionMap of PreMeEmitter, key is mirnode + MapleMap *PreMeExprExtensionMap; LfoDepInfo *depInfo; MemPool *codeMP; // point to mirfunction codeMp MapleAllocator *codeMPAlloc; diff --git a/src/mapleall/maple_me/include/lfo_unroll.h b/src/mapleall/maple_me/include/lfo_unroll.h index a7f43d23c7..bf4447f937 100644 --- a/src/mapleall/maple_me/include/lfo_unroll.h +++ b/src/mapleall/maple_me/include/lfo_unroll.h @@ -16,8 +16,8 @@ #ifndef MAPLE_ME_INCLUDE_LFO_UNROLL_H #define MAPLE_ME_INCLUDE_LFO_UNROLL_H -#include "lfo_function.h" -#include "lfo_pre_emit.h" +#include "pme_function.h" +#include "pme_emit.h" #include "lfo_dep_test.h" #include "orig_symbol.h" #include "me_ir.h" @@ -26,8 +26,8 @@ namespace maple { class LfoUnrollOneLoop { public: - LfoUnrollOneLoop(LfoFunction *f, LfoPreEmitter *preEm, DoloopInfo *doinfo) : - lfoFunc(f), preEmit(preEm), doloopInfo(doinfo), doloop(doinfo->doloop), + LfoUnrollOneLoop(PreMeFunction *f, PreMeEmitter *preEm, DoloopInfo *doinfo) : + preMeFunc(f), preEmit(preEm), doloopInfo(doinfo), doloop(doinfo->doloop), mirModule(&f->meFunc->GetMIRModule()), codeMP(preEm->GetCodeMP()), mirBuilder(mirModule->GetMIRBuilder()) {} ~LfoUnrollOneLoop() = default; @@ -38,8 +38,8 @@ class LfoUnrollOneLoop { BlockNode *DoUnroll(size_t times, size_t tripCount); void Process(); - LfoFunction *lfoFunc; - LfoPreEmitter *preEmit; + PreMeFunction *preMeFunc; + PreMeEmitter *preEmit; DoloopInfo *doloopInfo; DoloopNode *doloop; MIRModule *mirModule; diff --git a/src/mapleall/maple_me/include/me_function.h b/src/mapleall/maple_me/include/me_function.h index baa4477df7..062b0475ce 100644 --- a/src/mapleall/maple_me/include/me_function.h +++ b/src/mapleall/maple_me/include/me_function.h @@ -26,7 +26,7 @@ #include "func_emit.h" #include "me_ir.h" #include "profile.h" -#include "lfo_function.h" +#include "pme_function.h" namespace maple { class MeCFG; // circular dependency exists, no other choice @@ -158,8 +158,8 @@ class MeFunction : public FuncEmit { mirFunc(func), laidOutBBVec(alloc.Adapter()), fileName(fileName, memPool), - lfoFunc(nullptr), - lfoMp(nullptr) { + preMeFunc(nullptr), + preMeMp(nullptr) { isLfo = (MeOption::optLevel == 3); } @@ -335,10 +335,10 @@ class MeFunction : public FuncEmit { MIRFunction *CurFunction() const { return mirModule.CurFunction(); } - void SetLfoFunc(LfoFunction *lfoF) { lfoFunc = lfoF; } - LfoFunction *GetLfoFunc() { return lfoFunc; } - void SetLfoMempool(MemPool *mp) { lfoMp = mp; } - MemPool *GetLfoMempool() { return lfoMp; } + void SetPreMeFunc(PreMeFunction *lfoF) { preMeFunc = lfoF; } + PreMeFunction *GetPreMeFunc() { return preMeFunc; } + void SetLfoMempool(MemPool *mp) { preMeMp = mp; } + MemPool *GetLfoMempool() { return preMeMp; } bool IsLfo() const { return isLfo; } void SetLfo(bool islfo) { isLfo = islfo; } void CloneBBMeStmts(BB &srcBB, BB &destBB, std::map>> *ssaCands = nullptr, @@ -367,8 +367,8 @@ class MeFunction : public FuncEmit { uint32 frequency = 0; // lfo bool isLfo; - LfoFunction *lfoFunc; - MemPool *lfoMp; // used for lfo function + PreMeFunction *preMeFunc; + MemPool *preMeMp; // used for lfo function public: uint32 dseRuns = 0; // number of times dse phase has been run uint32 hdseRuns = 0; // number of times hdse phase has been run diff --git a/src/mapleall/maple_me/include/me_phase_manager.h b/src/mapleall/maple_me/include/me_phase_manager.h index 175ebc0301..5734500a73 100644 --- a/src/mapleall/maple_me/include/me_phase_manager.h +++ b/src/mapleall/maple_me/include/me_phase_manager.h @@ -78,7 +78,7 @@ #include "constantfold.h" #include "me_verify.h" #include "lfo_inject_iv.h" -#include "lfo_pre_emit.h" +#include "pme_emit.h" #include "lfo_iv_canon.h" #include "cfg_opt.h" #include "lfo_dep_test.h" diff --git a/src/mapleall/maple_me/include/lfo_pre_emit.h b/src/mapleall/maple_me/include/pme_emit.h similarity index 41% rename from src/mapleall/maple_me/include/lfo_pre_emit.h rename to src/mapleall/maple_me/include/pme_emit.h index 5184b012f5..8aeb77bb6d 100644 --- a/src/mapleall/maple_me/include/lfo_pre_emit.h +++ b/src/mapleall/maple_me/include/pme_emit.h @@ -13,107 +13,103 @@ * See the MulanPSL - 2.0 for more details. */ -#ifndef MAPLE_ME_INCLUDE_LFO_PRE_EMIT_H -#define MAPLE_ME_INCLUDE_LFO_PRE_EMIT_H +#ifndef MAPLE_ME_INCLUDE_PME_EMIT_H +#define MAPLE_ME_INCLUDE_PME_EMIT_H #include "mir_nodes.h" #include "me_irmap_build.h" namespace maple { -class LfoPreEmitter : public AnalysisResult { +class PreMeEmitter : public AnalysisResult { private: MeIRMap *meirmap; - LfoFunction *lfoFunc; + PreMeFunction *preMeFunc; MIRFunction *mirFunc; MemPool *codeMP; MapleAllocator *codeMPAlloc; - MemPool *lfoMP; - MapleAllocator lfoMPAlloc; - MapleMap lfoStmtParts; // map lfoinfo for StmtNode, key is stmtID - MapleMap lfoExprParts; // map lfoinfor for exprNode, key is mirnode + MemPool *preMeMP; + MapleAllocator preMeMPAlloc; + MapleMap PreMeStmtExtensionMap; // key is stmtID + MapleMap PreMeExprExtensionMap; // key is BaseNode* MeCFG *cfg; public: - LfoPreEmitter(MeIRMap *hmap, LfoFunction *f, MemPool *lfomp) - : AnalysisResult(lfomp), meirmap(hmap), - lfoFunc(f), + PreMeEmitter(MeIRMap *hmap, PreMeFunction *f, MemPool *premp) + : AnalysisResult(premp), meirmap(hmap), + preMeFunc(f), mirFunc(f->meFunc->GetMirFunc()), codeMP(f->meFunc->GetMirFunc()->GetCodeMempool()), codeMPAlloc(&f->meFunc->GetMirFunc()->GetCodeMemPoolAllocator()), - lfoMP(lfomp), - lfoMPAlloc(lfoMP), - lfoStmtParts(lfoMPAlloc.Adapter()), - lfoExprParts(lfoMPAlloc.Adapter()), + preMeMP(premp), + preMeMPAlloc(preMeMP), + PreMeStmtExtensionMap(preMeMPAlloc.Adapter()), + PreMeExprExtensionMap(preMeMPAlloc.Adapter()), cfg(f->meFunc->GetCfg()) {} - virtual ~LfoPreEmitter() = default; + virtual ~PreMeEmitter() = default; private: ArrayNode *ConvertToArray(BaseNode *x, TyIdx ptrTyIdx); - BaseNode *EmitLfoExpr(MeExpr*, BaseNode *); - StmtNode* EmitLfoStmt(MeStmt *, BaseNode *); + BaseNode *EmitPreMeExpr(MeExpr*, BaseNode *); + StmtNode* EmitPreMeStmt(MeStmt *, BaseNode *); void EmitBB(BB *, BlockNode *); - DoloopNode *EmitLfoDoloop(BB *, BlockNode *, LfoWhileInfo *); - WhileStmtNode *EmitLfoWhile(BB *, BlockNode *); - uint32 Raise2LfoWhile(uint32, BlockNode *); - uint32 Raise2LfoIf(uint32, BlockNode *); + DoloopNode *EmitPreMeDoloop(BB *, BlockNode *, PreMeWhileInfo *); + WhileStmtNode *EmitPreMeWhile(BB *, BlockNode *); + uint32 Raise2PreMeWhile(uint32, BlockNode *); + uint32 Raise2PreMeIf(uint32, BlockNode *); public: - uint32 EmitLfoBB(uint32, BlockNode *); - void InitFuncBodyLfoPart(BaseNode *funcbody) { - LfoPart *rootlfo = lfoMP->New(nullptr); - lfoExprParts[funcbody] = rootlfo; + uint32 EmitPreMeBB(uint32, BlockNode *); + void SetPreMeStmtExtension(uint32_t stmtID, PreMeMIRExtension* pmeExt) { + PreMeStmtExtensionMap[stmtID] = pmeExt; } - void SetLfoStmtPart(uint32_t stmtID, LfoPart* lfoInfo) { - lfoStmtParts[stmtID] = lfoInfo; + void SetPreMeExprExtension(BaseNode *expr, PreMeMIRExtension* pmeExt) { + PreMeExprExtensionMap[expr] = pmeExt; } - void SetLfoExprPart(BaseNode *expr, LfoPart* lfoInfo) { - lfoExprParts[expr] = lfoInfo; + PreMeMIRExtension* GetPreMeExprExtension(BaseNode *node) { + return PreMeExprExtensionMap[node]; } - LfoPart* GetLfoExprPart(BaseNode *node) { - return lfoExprParts[node]; - } - LfoPart* GetLfoStmtPart(uint32_t stmtID) { - return lfoStmtParts[stmtID]; + PreMeMIRExtension* GetPreMeStmtExtension(uint32_t stmtID) { + return PreMeStmtExtensionMap[stmtID]; } BaseNode *GetParent(BaseNode *node) { - LfoPart *lfopart = lfoExprParts[node]; - if (lfopart != nullptr) { - return lfopart->parent; + PreMeMIRExtension *pmeExt = PreMeExprExtensionMap[node]; + if (pmeExt != nullptr) { + return pmeExt->parent; } return nullptr; } BaseNode *GetParent(uint32_t stmtID) { - LfoPart *lfopart = lfoStmtParts[stmtID]; - if (lfopart != nullptr) { - return lfopart->parent; + PreMeMIRExtension *pmeExt = PreMeStmtExtensionMap[stmtID]; + if (pmeExt != nullptr) { + return pmeExt->parent; } return nullptr; } MeExpr *GetMexpr(BaseNode *node) { - MapleMap::iterator it = lfoExprParts.find(node); - if (it == lfoExprParts.end()) { + MapleMap::iterator it = PreMeExprExtensionMap.find(node); + if (it == PreMeExprExtensionMap.end()) { return nullptr; } - LfoPart *lfopart = it->second; - return lfopart->meexpr; + PreMeMIRExtension *pmeExt = it->second; + return pmeExt->meexpr; } MeStmt *GetMeStmt(uint32_t stmtID) { - LfoPart *lfopart = lfoStmtParts[stmtID]; - return lfopart->mestmt; + PreMeMIRExtension *pmeExt = PreMeStmtExtensionMap[stmtID]; + return pmeExt->mestmt; } MIRFunction *GetMirFunction() { return mirFunc; } MeIRMap *GetMeIRMap() { return meirmap; } MemPool *GetCodeMP() { return codeMP; } MapleAllocator* GetCodeMPAlloc() { return codeMPAlloc; } - MapleMap *GetLfoStmtMap() { return &lfoStmtParts; } - MapleMap *GetLfoExprMap() { return &lfoExprParts; } + MapleMap *GetPreMeStmtExtensionMap() { return &PreMeStmtExtensionMap; } + MapleMap *GetPreMeExprExtensionMap() { return &PreMeExprExtensionMap; } }; /* emit ir to specified file */ -MAPLE_FUNC_PHASE_DECLARE_BEGIN(MELfoPreEmission, MeFunction) - LfoPreEmitter *GetResult() { +MAPLE_FUNC_PHASE_DECLARE_BEGIN(MEPreMeEmission, MeFunction) + PreMeEmitter *GetResult() { return emitter; } - LfoPreEmitter *emitter = nullptr; + PreMeEmitter *emitter = nullptr; OVERRIDE_DEPENDENCE MAPLE_FUNC_PHASE_DECLARE_END } // namespace maple -#endif // MAPLE_ME_INCLUDE_LFO_PRE_EMIT_H +#endif // MAPLE_ME_INCLUDE_PME_EMIT_H diff --git a/src/mapleall/maple_me/include/lfo_function.h b/src/mapleall/maple_me/include/pme_function.h similarity index 51% rename from src/mapleall/maple_me/include/lfo_function.h rename to src/mapleall/maple_me/include/pme_function.h index 30c0c5509b..0fc6a67c22 100644 --- a/src/mapleall/maple_me/include/lfo_function.h +++ b/src/mapleall/maple_me/include/pme_function.h @@ -13,15 +13,15 @@ * See the MulanPSL - 2.0 for more details. */ -#ifndef MAPLE_LFO_INCLUDE_LFO_FUNCTION_H -#define MAPLE_LFO_INCLUDE_LFO_FUNCTION_H -#include "lfo_mir_nodes.h" +#ifndef MAPLE_ME_INCLUDE_PME_FUNCTION_H +#define MAPLE_ME_INCLUDE_PME_FUNCTION_H +#include "pme_mir_extension.h" #include "me_ir.h" namespace maple { class MeFunction; -class LfoWhileInfo { +class PreMeWhileInfo { public: MIRSymbol *injectedIVSym = nullptr; // the injected IV OriginalSt *ivOst = nullptr; // the primary IV @@ -31,51 +31,51 @@ class LfoWhileInfo { bool canConvertDoloop = false; }; -class LfoIfInfo { +class PreMeIfInfo { public: LabelIdx endLabel = 0; // the label that is out of the if statement LabelIdx elseLabel = 0; // the label that is the begin of else branch }; -class LfoFunction { +class PreMeFunction { public: - MemPool *lfomp; - MapleAllocator lfoAlloc; + MemPool *pmemp; + MapleAllocator pmeAlloc; MeFunction *meFunc; // key is label at beginning of lowered while code sequence - MapleMap label2WhileInfo; + MapleMap label2WhileInfo; // key is target label of first conditional branch of lowered if code sequence - MapleMap label2IfInfo; - // for the labels that were created by lfo, we won't emit it - MapleSet lfoCreatedIfLabelSet; - MapleSet lfoCreatedWhileLabelSet; + MapleMap label2IfInfo; + // for the labels that were created by PreMe, we won't emit it + MapleSet pmeCreatedIfLabelSet; + MapleSet pmeCreatedWhileLabelSet; public: - LfoFunction(MemPool *mp, MeFunction *func) - : lfomp(mp), - lfoAlloc(mp), + PreMeFunction(MemPool *mp, MeFunction *func) + : pmemp(mp), + pmeAlloc(mp), meFunc(func), - label2WhileInfo(lfoAlloc.Adapter()), - label2IfInfo(lfoAlloc.Adapter()), - lfoCreatedIfLabelSet(lfoAlloc.Adapter()), - lfoCreatedWhileLabelSet(lfoAlloc.Adapter()) {} - virtual ~LfoFunction() = default; + label2WhileInfo(pmeAlloc.Adapter()), + label2IfInfo(pmeAlloc.Adapter()), + pmeCreatedIfLabelSet(pmeAlloc.Adapter()), + pmeCreatedWhileLabelSet(pmeAlloc.Adapter()) {} + virtual ~PreMeFunction() = default; - void SetIfLabelCreatedByLfo(LabelIdx lbidx) { - lfoCreatedIfLabelSet.insert(lbidx); + void SetIfLabelCreatedByPreMe(LabelIdx lbidx) { + pmeCreatedIfLabelSet.insert(lbidx); } - bool IfLabelCreatedByLfo(LabelIdx lbidx) { - return lfoCreatedIfLabelSet.count(lbidx) != 0; + bool IfLabelCreatedByPreMe(LabelIdx lbidx) { + return pmeCreatedIfLabelSet.count(lbidx) != 0; } - void SetWhileLabelCreatedByLfo(LabelIdx lbidx) { - lfoCreatedWhileLabelSet.insert(lbidx); + void SetWhileLabelCreatedByPreMe(LabelIdx lbidx) { + pmeCreatedWhileLabelSet.insert(lbidx); } - bool WhileLabelCreatedByLfo(LabelIdx lbidx) { - return lfoCreatedWhileLabelSet.count(lbidx) != 0; + bool WhileLabelCreatedByPreMe(LabelIdx lbidx) { + return pmeCreatedWhileLabelSet.count(lbidx) != 0; } }; } // namespace maple -#endif // MAPLE_LFO_INCLUDE_LFO_FUNCTION_H +#endif // MAPLE_ME_INCLUDE_PME_FUNCTION_H diff --git a/src/mapleall/maple_me/include/lfo_mir_nodes.h b/src/mapleall/maple_me/include/pme_mir_extension.h similarity index 69% rename from src/mapleall/maple_me/include/lfo_mir_nodes.h rename to src/mapleall/maple_me/include/pme_mir_extension.h index 9f136c6cf4..697f6206cb 100644 --- a/src/mapleall/maple_me/include/lfo_mir_nodes.h +++ b/src/mapleall/maple_me/include/pme_mir_extension.h @@ -13,13 +13,13 @@ * See the MulanPSL - 2.0 for more details. */ -#ifndef MAPLE_ME_INCLUDE_LFO_MIR_NODES_H_ -#define MAPLE_ME_INCLUDE_LFO_MIR_NODES_H_ +#ifndef MAPLE_ME_INCLUDE_PME_MIR_EXTENSION_H_ +#define MAPLE_ME_INCLUDE_PME_MIR_EXTENSION_H_ #include "me_ir.h" #include "mir_nodes.h" namespace maple { -class LfoPart { +class PreMeMIRExtension { public: BaseNode *parent; union { @@ -27,14 +27,14 @@ class LfoPart { MeStmt *mestmt; }; - LfoPart (BaseNode *p) : parent(p), meexpr(nullptr) {} - LfoPart (BaseNode *p, MeExpr *expr) : parent(p), meexpr(expr) {} - LfoPart (BaseNode *p, MeStmt *stmt) : parent(p), mestmt(stmt) {} - virtual ~LfoPart() = default; + PreMeMIRExtension (BaseNode *p) : parent(p), meexpr(nullptr) {} + PreMeMIRExtension (BaseNode *p, MeExpr *expr) : parent(p), meexpr(expr) {} + PreMeMIRExtension (BaseNode *p, MeStmt *stmt) : parent(p), mestmt(stmt) {} + virtual ~PreMeMIRExtension() = default; BaseNode *GetParent() { return parent; } MeExpr *GetMeExpr() { return meexpr; } MeStmt *GetMeStmt() { return mestmt; } void SetParent(BaseNode *p) { parent = p; } }; } // namespace maple -#endif // MAPLE_LFO_INCLUDE_LFO_MIR_NODES_H_ +#endif // MAPLE_ME_INCLUDE_PME_MIR_EXTENSION_H_ diff --git a/src/mapleall/maple_me/include/lfo_mir_lower.h b/src/mapleall/maple_me/include/pme_mir_lower.h similarity index 75% rename from src/mapleall/maple_me/include/lfo_mir_lower.h rename to src/mapleall/maple_me/include/pme_mir_lower.h index 666404cf8f..30848b27a0 100644 --- a/src/mapleall/maple_me/include/lfo_mir_lower.h +++ b/src/mapleall/maple_me/include/pme_mir_lower.h @@ -13,26 +13,26 @@ * See the MulanPSL - 2.0 for more details. */ -#ifndef MAPLE_ME_INCLUDE_LFO_MIR_LOWER_H -#define MAPLE_ME_INCLUDE_LFO_MIR_LOWER_H +#ifndef MAPLE_ME_INCLUDE_PME_MIR_LOWER_H +#define MAPLE_ME_INCLUDE_PME_MIR_LOWER_H #include "mir_lower.h" #include "me_function.h" namespace maple { -class LFOMIRLower : public MIRLower { +class PreMeMIRLower : public MIRLower { public: MeFunction *func; - LfoFunction *lfoFunc; + PreMeFunction *preMeFunc; public: - LFOMIRLower(MIRModule &mod, MeFunction *f) + PreMeMIRLower(MIRModule &mod, MeFunction *f) : MIRLower(mod, f->GetMirFunc()), func(f), - lfoFunc(f->GetLfoFunc()) {} - virtual ~LFOMIRLower() = default; + preMeFunc(f->GetPreMeFunc()) {} + virtual ~PreMeMIRLower() = default; BlockNode *LowerWhileStmt(WhileStmtNode&) override; BlockNode *LowerIfStmt(IfStmtNode &ifstmt, bool recursive = true) override; bool InLFO() const override { return true; } }; } -#endif // MAPLE_ME_INCLUDE_LFO_MIR_LOWER_H +#endif // MAPLE_ME_INCLUDE_PME_MIR_LOWER_H diff --git a/src/mapleall/maple_me/include/seqvec.h b/src/mapleall/maple_me/include/seqvec.h index 410cb66860..e71e5b86e9 100644 --- a/src/mapleall/maple_me/include/seqvec.h +++ b/src/mapleall/maple_me/include/seqvec.h @@ -17,21 +17,21 @@ #include "me_function.h" #include "me_irmap.h" #include "me_ir.h" -#include "lfo_pre_emit.h" +#include "pme_emit.h" namespace maple { class SeqVectorize { using StoreList = MapleVector; using StoreListMap = MapleMap; public: - SeqVectorize(MemPool *localmp, LfoPreEmitter *lfoEmit, bool debug = false) + SeqVectorize(MemPool *localmp, PreMeEmitter *lfoEmit, bool debug = false) : localMP(localmp), localAlloc(localmp), codeMP(lfoEmit->GetCodeMP()), codeMPAlloc(lfoEmit->GetCodeMPAlloc()), mirFunc(lfoEmit->GetMirFunction()), meIRMap(lfoEmit->GetMeIRMap()), stores(localAlloc.Adapter()), enableDebug(debug) { - lfoStmtParts = lfoEmit->GetLfoStmtMap(); - lfoExprParts = lfoEmit->GetLfoExprMap(); + PreMeStmtExtensionMap = lfoEmit->GetPreMeStmtExtensionMap(); + PreMeExprExtensionMap = lfoEmit->GetPreMeExprExtensionMap(); } virtual ~SeqVectorize() = default; void Perform(); @@ -66,10 +66,10 @@ class SeqVectorize { MapleAllocator *codeMPAlloc; MIRFunction *mirFunc; MeIRMap *meIRMap; - // point to lfoStmtParts of lfopreemit, map lfoinfo for StmtNode, key is stmtID - MapleMap *lfoStmtParts; - // point to lfoexprparts of lfopreemit, map lfoinfo for exprNode, key is mirnode - MapleMap *lfoExprParts; + // point to PreMeStmtExtensionMap of PreMeEmitter, key is stmtID + MapleMap *PreMeStmtExtensionMap; + // point to PreMeExprExtensionMap of PreMeEmitter, key is mirnode + MapleMap *PreMeExprExtensionMap; StoreListMap stores; uint32_t currRhsStatus = 0; // unset bool enableDebug = true; diff --git a/src/mapleall/maple_me/src/lfo_dep_test.cpp b/src/mapleall/maple_me/src/lfo_dep_test.cpp index bffa5ed0e1..605e0a0df9 100644 --- a/src/mapleall/maple_me/src/lfo_dep_test.cpp +++ b/src/mapleall/maple_me/src/lfo_dep_test.cpp @@ -29,7 +29,7 @@ void LfoDepInfo::CreateDoloopInfo(BlockNode *block, DoloopInfo *parent) { } else { outermostDoloopInfoVec.push_back(doloopInfo); } - LfoPart *lfopart = preEmit->GetLfoStmtPart(doloop->GetStmtID()); + PreMeMIRExtension *lfopart = preEmit->GetPreMeStmtExtension(doloop->GetStmtID()); MeStmt *meStmt = lfopart->GetMeStmt(); doloopInfo->doloopBB = meStmt->GetBB(); CreateDoloopInfo(doloop->GetDoBody(), doloopInfo); @@ -295,7 +295,7 @@ ArrayAccessDesc *DoloopInfo::BuildOneArrayAccessDesc(ArrayNode *arr, BaseNode *p } else { MapleMap *chiList = iassMeStmt->GetChiList(); CHECK_FATAL(!chiList->empty(), "BuildOneArrayAccessDesc: no chi corresponding to iassign"); - arryOst = depInfo->lfoFunc->meFunc->GetMeSSATab()->GetOriginalStFromID(chiList->begin()->first); + arryOst = depInfo->preMeFunc->meFunc->GetMeSSATab()->GetOriginalStFromID(chiList->begin()->first); } } else { hasPtrAccess = true; @@ -584,7 +584,7 @@ void LfoDepInfo::PerformDepTest() { continue; } doloopInfo->CreateArrayAccessDesc(doloopInfo->doloop->GetDoBody()); - if (DEBUGFUNC(lfoFunc->meFunc)) { + if (DEBUGFUNC(preMeFunc->meFunc)) { LogInfo::MapleLogger() << "Innermost Doloop:"; if (doloopInfo->hasPtrAccess) { LogInfo::MapleLogger() << " hasPtrAccess"; @@ -653,7 +653,7 @@ void LfoDepInfo::PerformDepTest() { doloopInfo->CreateDepTestLists(); doloopInfo->TestDependences(&doloopInfo->outputDepTestList, true); doloopInfo->TestDependences(&doloopInfo->flowDepTestList, false); - if (DEBUGFUNC(lfoFunc->meFunc)) { + if (DEBUGFUNC(preMeFunc->meFunc)) { for (DepTestPair item : doloopInfo->outputDepTestList) { LogInfo::MapleLogger() << "Dep between L" << item.depTestPair.first << " and L" << item.depTestPair.second; if (!item.dependent) { @@ -695,11 +695,11 @@ void LfoDepInfo::PerformDepTest() { bool MELfoDepTest::PhaseRun(MeFunction &f) { Dominance *dom = GET_ANALYSIS(MEDominance, f); ASSERT(dom != nullptr, "dominance phase has problem"); - LfoPreEmitter *preEmit = GET_ANALYSIS(MELfoPreEmission, f); + PreMeEmitter *preEmit = GET_ANALYSIS(MEPreMeEmission, f); ASSERT(preEmit != nullptr, "lfo preemit phase has problem"); - LfoFunction *lfoFunc = f.GetLfoFunc(); + PreMeFunction *preMeFunc = f.GetPreMeFunc(); MemPool *depTestMp = GetPhaseMemPool(); - depInfo = depTestMp->New(depTestMp, lfoFunc, dom, preEmit); + depInfo = depTestMp->New(depTestMp, preMeFunc, dom, preEmit); if (DEBUGFUNC_NEWPM(f)) { LogInfo::MapleLogger() << "\n============== LFO_DEP_TEST =============" << '\n'; } @@ -707,14 +707,14 @@ bool MELfoDepTest::PhaseRun(MeFunction &f) { depInfo->PerformDepTest(); if (DEBUGFUNC_NEWPM(f)) { LogInfo::MapleLogger() << "________________" << std::endl; - lfoFunc->meFunc->GetMirFunc()->Dump(); + preMeFunc->meFunc->GetMirFunc()->Dump(); } return depInfo; } void MELfoDepTest::GetAnalysisDependence(maple::AnalysisDep &aDep) const { aDep.AddRequired(); - aDep.AddRequired(); + aDep.AddRequired(); aDep.SetPreservedAll(); } } // namespace maple diff --git a/src/mapleall/maple_me/src/lfo_inject_iv.cpp b/src/mapleall/maple_me/src/lfo_inject_iv.cpp index b802ba99f8..f10637fc0c 100644 --- a/src/mapleall/maple_me/src/lfo_inject_iv.cpp +++ b/src/mapleall/maple_me/src/lfo_inject_iv.cpp @@ -29,22 +29,22 @@ bool MELfoInjectIV::PhaseRun(MeFunction &f) { uint32 ivCount = 0; MIRBuilder *mirbuilder = f.GetMIRModule().GetMIRBuilder(); - LfoFunction *lfoFunc = f.GetLfoFunc(); + PreMeFunction *preMeFunc = f.GetPreMeFunc(); for (LoopDesc *aloop : identloops->GetMeLoops()) { BB *headbb = aloop->head; - // check if the label has associated LfoWhileInfo + // check if the label has associated PreMeWhileInfo if (headbb->GetBBLabel() == 0) { continue; } if (headbb->GetPred().size() != 2) { continue; // won't insert IV for loops with > 1 tail bbs } - MapleMap::iterator it = lfoFunc->label2WhileInfo.find(headbb->GetBBLabel()); - if (it == lfoFunc->label2WhileInfo.end()) { + MapleMap::iterator it = preMeFunc->label2WhileInfo.find(headbb->GetBBLabel()); + if (it == preMeFunc->label2WhileInfo.end()) { continue; } - LfoWhileInfo *whileInfo = it->second; + PreMeWhileInfo *whileInfo = it->second; // find the entry BB as the predecessor of headbb that dominates headbb MapleVector::iterator predit = headbb->GetPred().begin(); for (; predit != headbb->GetPred().end(); predit++) { diff --git a/src/mapleall/maple_me/src/lfo_iv_canon.cpp b/src/mapleall/maple_me/src/lfo_iv_canon.cpp index 1b693f1b75..6cdd31727a 100644 --- a/src/mapleall/maple_me/src/lfo_iv_canon.cpp +++ b/src/mapleall/maple_me/src/lfo_iv_canon.cpp @@ -16,7 +16,7 @@ #include #include "lfo_iv_canon.h" #include "me_option.h" -#include "lfo_function.h" +#include "pme_function.h" #include "me_dominance.h" // This phase implements Step 4 of the paper: @@ -535,24 +535,24 @@ bool MELfoIVCanon::PhaseRun(MeFunction &f) { IdentifyLoops *identLoops = GET_ANALYSIS(MELoopAnalysis, f); CHECK_FATAL(identLoops != nullptr, "identloops has problem"); - LfoFunction *lfoFunc = f.GetLfoFunc(); + PreMeFunction *preMeFunc = f.GetPreMeFunc(); // loop thru all the loops in reverse order so inner loops are processed first for (int32 i = identLoops->GetMeLoops().size()-1; i >= 0; i--) { LoopDesc *aloop = identLoops->GetMeLoops()[i]; BB *headbb = aloop->head; - // check if the label has associated LfoWhileInfo + // check if the label has associated PreMeWhileInfo if (headbb->GetBBLabel() == 0) { continue; } if (aloop->exitBB == nullptr || aloop->preheader == nullptr) { continue; } - MapleMap::iterator it = lfoFunc->label2WhileInfo.find(headbb->GetBBLabel()); - if (it == lfoFunc->label2WhileInfo.end()) { + MapleMap::iterator it = preMeFunc->label2WhileInfo.find(headbb->GetBBLabel()); + if (it == preMeFunc->label2WhileInfo.end()) { continue; } - LfoWhileInfo *whileInfo = it->second; + PreMeWhileInfo *whileInfo = it->second; if (whileInfo->injectedIVSym == nullptr) { continue; } diff --git a/src/mapleall/maple_me/src/lfo_loop_vec.cpp b/src/mapleall/maple_me/src/lfo_loop_vec.cpp index 730eabe426..3e4b2ec273 100644 --- a/src/mapleall/maple_me/src/lfo_loop_vec.cpp +++ b/src/mapleall/maple_me/src/lfo_loop_vec.cpp @@ -1368,7 +1368,7 @@ void LoopVectorization::VectorizeStmt(BaseNode *node, LoopTransPlan *tp) { // sum = sum +/- intrinsic_op vec_sum(t1) DassignNode *dassign = static_cast(node); MapleVector vecOpnd(localAlloc.Adapter()); - LfoPart *lfopart = (*lfoStmtParts)[dassign->GetStmtID()]; + PreMeMIRExtension *lfopart = (*PreMeStmtExtensionMap)[dassign->GetStmtID()]; BlockNode *doloopbody = static_cast(lfopart->GetParent()); RegreadNode *regReadlhsvec; if (tp->vecInfo->redVecNodes.find(dassign->GetStIdx()) != tp->vecInfo->redVecNodes.end()) { @@ -1462,14 +1462,14 @@ void LoopVectorization::VectorizeDoLoop(DoloopNode *doloop, LoopTransPlan *tp) { // step 2: insert dup stmt before doloop if (!tp->vecInfo->uniformNodes.empty()) { - LfoPart *lfopart = (*lfoStmtParts)[doloop->GetStmtID()]; + PreMeMIRExtension *lfopart = (*PreMeStmtExtensionMap)[doloop->GetStmtID()]; BaseNode *parent = lfopart->GetParent(); ASSERT(parent && (parent->GetOpCode() == OP_block), "nullptr check"); BlockNode *pblock = static_cast(parent); auto it = tp->vecInfo->uniformNodes.begin(); for (; it != tp->vecInfo->uniformNodes.end(); it++) { BaseNode *node = *it; - LfoPart *lfoP = (*lfoExprParts)[node]; + PreMeMIRExtension *lfoP = (*PreMeExprExtensionMap)[node]; // check node's parent, if they are binary node, skip the duplication if ((!lfoP->GetParent()->IsBinaryNode()) || (node->GetOpCode() == OP_iread)) { PrimType ptype = (node->GetOpCode() == OP_iread) ? @@ -1508,7 +1508,7 @@ void LoopVectorization::VectorizeDoLoop(DoloopNode *doloop, LoopTransPlan *tp) { // step 4: insert stmts before/after doloop if (!tp->vecInfo->beforeLoopStmts.empty() || !tp->vecInfo->afterLoopStmts.empty()) { - LfoPart *lfopart = (*lfoStmtParts)[doloop->GetStmtID()]; + PreMeMIRExtension *lfopart = (*PreMeStmtExtensionMap)[doloop->GetStmtID()]; BaseNode *parent = lfopart->GetParent(); ASSERT(parent && (parent->GetOpCode() == OP_block), "nullptr check"); BlockNode *pblock = static_cast(parent); @@ -1547,7 +1547,7 @@ DoloopNode *LoopVectorization::PrepareDoloop(DoloopNode *doloop, LoopTransPlan * // update loop low bound edoloop->SetStartExpr(tp->eBound->lowNode); // add epilog after doloop - LfoPart *lfoInfo = (*lfoStmtParts)[doloop->GetStmtID()]; + PreMeMIRExtension *lfoInfo = (*PreMeStmtExtensionMap)[doloop->GetStmtID()]; ASSERT(lfoInfo, "nullptr check"); BaseNode *parent = lfoInfo->GetParent(); ASSERT(parent && (parent->GetOpCode() == OP_block), "nullptr check"); @@ -1577,7 +1577,7 @@ bool LoopVectorization::ExprVectorizable(DoloopInfo *doloopInfo, LoopVecInfo* ve case OP_constval: case OP_dread: case OP_addrof: { - LfoPart* lfopart = (*lfoExprParts)[x]; + PreMeMIRExtension* lfopart = (*PreMeExprExtensionMap)[x]; CHECK_FATAL(lfopart, "nullptr check"); BaseNode *parent = lfopart->GetParent(); if (parent && parent->GetOpCode() == OP_array) { diff --git a/src/mapleall/maple_me/src/lfo_unroll.cpp b/src/mapleall/maple_me/src/lfo_unroll.cpp index 89bc5c97bf..9768055f12 100644 --- a/src/mapleall/maple_me/src/lfo_unroll.cpp +++ b/src/mapleall/maple_me/src/lfo_unroll.cpp @@ -220,7 +220,7 @@ void LfoUnrollOneLoop::Process() { } // replace doloop by the statements in unrolledBlk - LfoPart *lfopart = (*preEmit->GetLfoStmtMap())[doloop->GetStmtID()]; + PreMeMIRExtension *lfopart = (*preEmit->GetPreMeStmtExtensionMap())[doloop->GetStmtID()]; BaseNode *parent = lfopart->GetParent(); ASSERT(parent && (parent->GetOpCode() == OP_block), "LfoUnroll: parent of doloop is not OP_block"); BlockNode *pblock = static_cast(parent); @@ -231,25 +231,25 @@ void LfoUnrollOneLoop::Process() { }; bool MELfoUnroll::PhaseRun(MeFunction &f) { - LfoPreEmitter *preEmit = GET_ANALYSIS(MELfoPreEmission, f); + PreMeEmitter *preEmit = GET_ANALYSIS(MEPreMeEmission, f); ASSERT(preEmit != nullptr, "lfo preemit phase has problem"); LfoDepInfo *lfoDepInfo = GET_ANALYSIS(MELfoDepTest, f); ASSERT(lfoDepInfo != nullptr, "lfo dep test phase has problem"); - LfoFunction *lfoFunc = f.GetLfoFunc(); + PreMeFunction *preMeFunc = f.GetPreMeFunc(); MapleMap::iterator mapit = lfoDepInfo->doloopInfoMap.begin(); for (; mapit != lfoDepInfo->doloopInfoMap.end(); mapit++) { if (!mapit->second->children.empty() || mapit->second->hasBeenVectorized) { continue; } - LfoUnrollOneLoop unroll(lfoFunc, preEmit, mapit->second); + LfoUnrollOneLoop unroll(preMeFunc, preEmit, mapit->second); unroll.Process(); } return false; } void MELfoUnroll::GetAnalysisDependence(maple::AnalysisDep &aDep) const { - aDep.AddRequired(); + aDep.AddRequired(); aDep.AddRequired(); aDep.PreservedAllExcept(); aDep.PreservedAllExcept(); diff --git a/src/mapleall/maple_me/src/me_autovec.cpp b/src/mapleall/maple_me/src/me_autovec.cpp index 741fceb950..7b2fa79814 100644 --- a/src/mapleall/maple_me/src/me_autovec.cpp +++ b/src/mapleall/maple_me/src/me_autovec.cpp @@ -26,7 +26,7 @@ namespace maple { bool MEAutoVectorization::PhaseRun(MeFunction &f) { // generate lfo IR - LfoPreEmitter *lfoemit = GET_ANALYSIS(MELfoPreEmission, f); + PreMeEmitter *lfoemit = GET_ANALYSIS(MEPreMeEmission, f); CHECK_NULL_FATAL(lfoemit); if (MeOption::loopVec) { @@ -63,7 +63,7 @@ bool MEAutoVectorization::PhaseRun(MeFunction &f) { } void MEAutoVectorization::GetAnalysisDependence(maple::AnalysisDep &aDep) const { - aDep.AddRequired(); + aDep.AddRequired(); aDep.AddRequired(); aDep.PreservedAllExcept(); aDep.PreservedAllExcept(); diff --git a/src/mapleall/maple_me/src/me_cfg.cpp b/src/mapleall/maple_me/src/me_cfg.cpp index 1c4d6f02f3..36eca271cd 100644 --- a/src/mapleall/maple_me/src/me_cfg.cpp +++ b/src/mapleall/maple_me/src/me_cfg.cpp @@ -1218,7 +1218,7 @@ void MeCFG::CreateBasicBlocks() { } case OP_dassign: { DassignNode *dass = static_cast(stmt); - if (!func.IsLfo() && func.GetLfoFunc() != nullptr) { + if (!func.IsLfo() && func.GetPreMeFunc() != nullptr) { // delete identity assignments inserted by LFO if (dass->GetRHS()->GetOpCode() == OP_dread) { DreadNode *dread = static_cast(dass->GetRHS()); @@ -1452,8 +1452,8 @@ void MeCFG::CreateBasicBlocks() { SetBBTryNodeMap(*newBB, *tryStmt); } curBB = newBB; - } else if (func.GetLfoFunc() && - (func.GetLfoFunc()->label2WhileInfo.find(labelIdx) != func.GetLfoFunc()->label2WhileInfo.end())) { + } else if (func.GetPreMeFunc() && + (func.GetPreMeFunc()->label2WhileInfo.find(labelIdx) != func.GetPreMeFunc()->label2WhileInfo.end())) { curBB->SetKind(kBBFallthru); BB *newBB = NewBasicBlock(); if (tryStmt != nullptr) { @@ -1722,7 +1722,7 @@ void MeCFG::SwapBBId(BB &bb1, BB &bb2) { } bool MEMeCfg::PhaseRun(MeFunction &f) { - if (!f.IsLfo() && f.GetLfoFunc() != nullptr) { + if (!f.IsLfo() && f.GetPreMeFunc() != nullptr) { GetAnalysisInfoHook()->ForceEraseAllAnalysisPhase(); f.SetMeSSATab(nullptr); f.SetIRMap(nullptr); diff --git a/src/mapleall/maple_me/src/me_function.cpp b/src/mapleall/maple_me/src/me_function.cpp index fd83bd0bef..95f46900f4 100755 --- a/src/mapleall/maple_me/src/me_function.cpp +++ b/src/mapleall/maple_me/src/me_function.cpp @@ -21,7 +21,7 @@ #include "mir_builder.h" #include "constantfold.h" #include "me_irmap.h" -#include "lfo_mir_lower.h" +#include "pme_mir_lower.h" #include "me_ssa_update.h" namespace maple { @@ -134,11 +134,11 @@ void MeFunction::Dump(bool DumpSimpIr) const { void MeFunction::Prepare() { if (MeOption::optLevel >= 3) { - MemPool* lfomp = memPoolCtrler.NewMemPool("lfo", true); - SetLfoFunc(lfomp->New(lfomp, this)); - SetLfoMempool(lfomp); - LFOMIRLower lfomirlowerer(mirModule, this); - lfomirlowerer.LowerFunc(*CurFunction()); + MemPool* pmemp = memPoolCtrler.NewMemPool("lfo", true); + SetPreMeFunc(pmemp->New(pmemp, this)); + SetLfoMempool(pmemp); + PreMeMIRLower pmemirlowerer(mirModule, this); + pmemirlowerer.LowerFunc(*CurFunction()); } else { /* lower first */ MIRLower mirLowerer(mirModule, CurFunction()); diff --git a/src/mapleall/maple_me/src/me_hdse.cpp b/src/mapleall/maple_me/src/me_hdse.cpp index 6e2784a58c..3649d437c8 100644 --- a/src/mapleall/maple_me/src/me_hdse.cpp +++ b/src/mapleall/maple_me/src/me_hdse.cpp @@ -51,12 +51,12 @@ namespace maple { // mark initExpr in whileinfo live void MeHDSE::ProcessWhileInfos() { - LfoFunction *lfoFunc = func.GetLfoFunc(); - if (lfoFunc == nullptr) { + PreMeFunction *preMeFunc = func.GetPreMeFunc(); + if (preMeFunc == nullptr) { return; } - MapleMap::iterator it = lfoFunc->label2WhileInfo.begin(); - for (; it != lfoFunc->label2WhileInfo.end(); it++) { + MapleMap::iterator it = preMeFunc->label2WhileInfo.begin(); + for (; it != preMeFunc->label2WhileInfo.end(); it++) { if (it->second->initExpr != nullptr && (it->second->initExpr->GetMeOp() == maple::kMeOpVar || it->second->initExpr->GetMeOp() == maple::kMeOpReg)) { workList.push_front(it->second->initExpr); diff --git a/src/mapleall/maple_me/src/me_phase_manager.cpp b/src/mapleall/maple_me/src/me_phase_manager.cpp index 48f6650a68..ffa9354860 100644 --- a/src/mapleall/maple_me/src/me_phase_manager.cpp +++ b/src/mapleall/maple_me/src/me_phase_manager.cpp @@ -147,7 +147,7 @@ MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MEMeCfg, mecfgbuild) MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MEVerify, meverify) MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MEAliasClass, aliasclass) MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MESSATab, ssatab) -MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MELfoPreEmission, lfopreemit) +MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MEPreMeEmission, premeemit) MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MEAnalyzeCtor, analyzector) MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MEDominance, dominance) MAPLE_ANALYSIS_PHASE_REGISTER_CANSKIP(MELoopAnalysis, identloops) diff --git a/src/mapleall/maple_me/src/me_ssa.cpp b/src/mapleall/maple_me/src/me_ssa.cpp index cd4d608cd9..044469fd31 100644 --- a/src/mapleall/maple_me/src/me_ssa.cpp +++ b/src/mapleall/maple_me/src/me_ssa.cpp @@ -116,20 +116,20 @@ void MeSSA::VerifySSA() const { void MeSSA::InsertIdentifyAssignments(IdentifyLoops *identloops) { MIRBuilder *mirbuilder = func->GetMIRModule().GetMIRBuilder(); - LfoFunction *lfoFunc = func->GetLfoFunc(); + PreMeFunction *preMeFunc = func->GetPreMeFunc(); SSATab *ssatab = func->GetMeSSATab(); for (LoopDesc *aloop : identloops->GetMeLoops()) { BB *headbb = aloop->head; - // check if the label has associated LfoWhileInfo + // check if the label has associated PreMeWhileInfo if (headbb->GetBBLabel() == 0) { continue; } if (aloop->exitBB == nullptr) { continue; } - MapleMap::iterator it = lfoFunc->label2WhileInfo.find(headbb->GetBBLabel()); - if (it == lfoFunc->label2WhileInfo.end()) { + MapleMap::iterator it = preMeFunc->label2WhileInfo.find(headbb->GetBBLabel()); + if (it == preMeFunc->label2WhileInfo.end()) { continue; } if (headbb->GetPred().size() != 2) { diff --git a/src/mapleall/maple_me/src/lfo_pre_emit.cpp b/src/mapleall/maple_me/src/pme_emit.cpp similarity index 75% rename from src/mapleall/maple_me/src/lfo_pre_emit.cpp rename to src/mapleall/maple_me/src/pme_emit.cpp index 0b5d32315c..c92d6ca853 100755 --- a/src/mapleall/maple_me/src/lfo_pre_emit.cpp +++ b/src/mapleall/maple_me/src/pme_emit.cpp @@ -14,15 +14,15 @@ */ #include "me_irmap.h" -#include "lfo_function.h" -#include "lfo_pre_emit.h" +#include "pme_function.h" +#include "pme_emit.h" #include "mir_lower.h" #include "constantfold.h" namespace maple { // convert x to use OP_array if possible; return nullptr if unsuccessful; // ptrTyIdx is the high level pointer type of x -ArrayNode *LfoPreEmitter::ConvertToArray(BaseNode *x, TyIdx ptrTyIdx) { +ArrayNode *PreMeEmitter::ConvertToArray(BaseNode *x, TyIdx ptrTyIdx) { if (x->GetOpCode() != OP_add) { return nullptr; } @@ -68,24 +68,24 @@ ArrayNode *LfoPreEmitter::ConvertToArray(BaseNode *x, TyIdx ptrTyIdx) { arryNode->GetNopnd().push_back(opnd0); arryNode->GetNopnd().push_back(indexOpnd); arryNode->SetNumOpnds(2); - lfoExprParts[arryNode] = lfoExprParts[x]; + PreMeExprExtensionMap[arryNode] = PreMeExprExtensionMap[x]; // update opnds' parent info if it has - if (lfoExprParts[opnd0]) { - lfoExprParts[opnd0]->SetParent(arryNode); + if (PreMeExprExtensionMap[opnd0]) { + PreMeExprExtensionMap[opnd0]->SetParent(arryNode); } - if (lfoExprParts[indexOpnd]) { - lfoExprParts[indexOpnd]->SetParent(arryNode); + if (PreMeExprExtensionMap[indexOpnd]) { + PreMeExprExtensionMap[indexOpnd]->SetParent(arryNode); } return arryNode; } -BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { - LfoPart *lfopart = lfoMP->New(parent, meexpr); +BaseNode *PreMeEmitter::EmitPreMeExpr(MeExpr *meexpr, BaseNode *parent) { + PreMeMIRExtension *pmeExt = preMeMP->New(parent, meexpr); switch (meexpr->GetOp()) { case OP_constval: { MIRConst *constval = static_cast(meexpr)->GetConstVal(); ConstvalNode *lcvlNode = codeMP->New(constval->GetType().GetPrimType(), constval); - lfoExprParts[lcvlNode] = lfopart; + PreMeExprExtensionMap[lcvlNode] = pmeExt; return lcvlNode; } case OP_dread: { @@ -96,7 +96,7 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { } AddrofNode *dreadnode = codeMP->New(OP_dread, varmeexpr->GetPrimType(), sym->GetStIdx(), varmeexpr->GetOst()->GetFieldID()); - lfoExprParts[dreadnode] = lfopart; + PreMeExprExtensionMap[dreadnode] = pmeExt; return dreadnode; } case OP_eq: @@ -111,12 +111,12 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { OpMeExpr *cmpexpr = static_cast(meexpr); CompareNode *cmpNode = codeMP->New(meexpr->GetOp(), cmpexpr->GetPrimType(), cmpexpr->GetOpndType(), nullptr, nullptr); - BaseNode *opnd0 = EmitLfoExpr(cmpexpr->GetOpnd(0), cmpNode); - BaseNode *opnd1 = EmitLfoExpr(cmpexpr->GetOpnd(1), cmpNode); + BaseNode *opnd0 = EmitPreMeExpr(cmpexpr->GetOpnd(0), cmpNode); + BaseNode *opnd1 = EmitPreMeExpr(cmpexpr->GetOpnd(1), cmpNode); cmpNode->SetBOpnd(opnd0, 0); cmpNode->SetBOpnd(opnd1, 1); cmpNode->SetOpndType(cmpNode->GetOpndType()); - lfoExprParts[cmpNode] = lfopart; + PreMeExprExtensionMap[cmpNode] = pmeExt; return cmpNode; } case OP_array: { @@ -125,11 +125,11 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { codeMP->New(*codeMPAlloc, arrExpr->GetPrimType(), arrExpr->GetTyIdx()); arrNode->SetBoundsCheck(arrExpr->GetBoundCheck()); for (uint32 i = 0; i < arrExpr->GetNumOpnds(); i++) { - BaseNode *opnd = EmitLfoExpr(arrExpr->GetOpnd(i), arrNode); + BaseNode *opnd = EmitPreMeExpr(arrExpr->GetOpnd(i), arrNode); arrNode->GetNopnd().push_back(opnd); } arrNode->SetNumOpnds(meexpr->GetNumOpnds()); - lfoExprParts[arrNode] = lfopart; + PreMeExprExtensionMap[arrNode] = pmeExt; return arrNode; } case OP_ashr: @@ -151,19 +151,19 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { case OP_add: { OpMeExpr *opExpr = static_cast(meexpr); BinaryNode *binNode = codeMP->New(meexpr->GetOp(), meexpr->GetPrimType()); - binNode->SetBOpnd(EmitLfoExpr(opExpr->GetOpnd(0), binNode), 0); - binNode->SetBOpnd(EmitLfoExpr(opExpr->GetOpnd(1), binNode), 1); - lfoExprParts[binNode] = lfopart; + binNode->SetBOpnd(EmitPreMeExpr(opExpr->GetOpnd(0), binNode), 0); + binNode->SetBOpnd(EmitPreMeExpr(opExpr->GetOpnd(1), binNode), 1); + PreMeExprExtensionMap[binNode] = pmeExt; return binNode; } case OP_iread: { IvarMeExpr *ivarExpr = static_cast(meexpr); IreadNode *irdNode = codeMP->New(meexpr->GetOp(), meexpr->GetPrimType()); ASSERT(ivarExpr->GetOffset() == 0, "offset in iread should be 0"); - irdNode->SetOpnd(EmitLfoExpr(ivarExpr->GetBase(), irdNode), 0); + irdNode->SetOpnd(EmitPreMeExpr(ivarExpr->GetBase(), irdNode), 0); irdNode->SetTyIdx(ivarExpr->GetTyIdx()); irdNode->SetFieldID(ivarExpr->GetFieldID()); - lfoExprParts[irdNode] = lfopart; + PreMeExprExtensionMap[irdNode] = pmeExt; if (irdNode->Opnd(0)->GetOpCode() != OP_array) { ArrayNode *arryNode = ConvertToArray(irdNode->Opnd(0), irdNode->GetTyIdx()); if (arryNode != nullptr) { @@ -177,21 +177,21 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { IreadNode *irdNode = codeMP->New(OP_iread, meexpr->GetPrimType()); MeExpr *baseexpr = ivarExpr->GetBase(); if (ivarExpr->GetOffset() == 0) { - irdNode->SetOpnd(EmitLfoExpr(baseexpr, irdNode), 0); + irdNode->SetOpnd(EmitPreMeExpr(baseexpr, irdNode), 0); } else { MIRType *mirType = GlobalTables::GetTypeTable().GetInt32(); MIRIntConst *mirConst = GlobalTables::GetIntConstTable().GetOrCreateIntConst(ivarExpr->GetOffset(), *mirType); ConstvalNode *constValNode = codeMP->New(mirType->GetPrimType(), mirConst); - LfoPart *lfopart2 = lfoMP->New(irdNode, baseexpr); - lfoExprParts[constValNode] = lfopart2; + PreMeMIRExtension *pmeExt2 = preMeMP->New(irdNode, baseexpr); + PreMeExprExtensionMap[constValNode] = pmeExt2; BinaryNode *newAddrNode = - codeMP->New(OP_add, baseexpr->GetPrimType(), EmitLfoExpr(baseexpr, irdNode), constValNode); - lfoExprParts[newAddrNode] = lfopart2; + codeMP->New(OP_add, baseexpr->GetPrimType(), EmitPreMeExpr(baseexpr, irdNode), constValNode); + PreMeExprExtensionMap[newAddrNode] = pmeExt2; irdNode->SetOpnd(newAddrNode, 0); } irdNode->SetTyIdx(ivarExpr->GetTyIdx()); irdNode->SetFieldID(ivarExpr->GetFieldID()); - lfoExprParts[irdNode] = lfopart; + PreMeExprExtensionMap[irdNode] = pmeExt; return irdNode; } case OP_addrof: { @@ -200,20 +200,20 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { MIRSymbol *sym = ost->GetMIRSymbol(); AddrofNode *addrofNode = codeMP->New(OP_addrof, addrMeexpr->GetPrimType(), sym->GetStIdx(), ost->GetFieldID()); - lfoExprParts[addrofNode] = lfopart; + PreMeExprExtensionMap[addrofNode] = pmeExt; return addrofNode; } case OP_addroflabel: { AddroflabelMeExpr *addroflabelexpr = static_cast(meexpr); AddroflabelNode *addroflabel = codeMP->New(addroflabelexpr->labelIdx); addroflabel->SetPrimType(meexpr->GetPrimType()); - lfoExprParts[addroflabel] = lfopart; + PreMeExprExtensionMap[addroflabel] = pmeExt; return addroflabel; } case OP_addroffunc: { AddroffuncMeExpr *addrMeexpr = static_cast(meexpr); AddroffuncNode *addrfunNode = codeMP->New(addrMeexpr->GetPrimType(), addrMeexpr->GetPuIdx()); - lfoExprParts[addrfunNode] = lfopart; + PreMeExprExtensionMap[addrfunNode] = pmeExt; return addrfunNode; } case OP_gcmalloc: @@ -223,7 +223,7 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { GCMallocNode *gcMnode = codeMP->New(meexpr->GetOp(), meexpr->GetPrimType(), gcMeexpr->GetTyIdx()); gcMnode->SetTyIdx(gcMeexpr->GetTyIdx()); - lfoExprParts[gcMnode] = lfopart; + PreMeExprExtensionMap[gcMnode] = pmeExt; return gcMnode; } case OP_retype: { @@ -231,8 +231,8 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { RetypeNode *retypeNode = codeMP->New(meexpr->GetPrimType()); retypeNode->SetFromType(opMeexpr->GetOpndType()); retypeNode->SetTyIdx(opMeexpr->GetTyIdx()); - retypeNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(0), retypeNode), 0); - lfoExprParts[retypeNode] = lfopart; + retypeNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(0), retypeNode), 0); + PreMeExprExtensionMap[retypeNode] = pmeExt; return retypeNode; } case OP_ceil: @@ -242,8 +242,8 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { OpMeExpr *opMeexpr = static_cast(meexpr); TypeCvtNode *tycvtNode = codeMP->New(meexpr->GetOp(), meexpr->GetPrimType()); tycvtNode->SetFromType(opMeexpr->GetOpndType()); - tycvtNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(0), tycvtNode), 0); - lfoExprParts[tycvtNode] = lfopart; + tycvtNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(0), tycvtNode), 0); + PreMeExprExtensionMap[tycvtNode] = pmeExt; return tycvtNode; } case OP_sext: @@ -251,10 +251,10 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { case OP_extractbits: { OpMeExpr *opMeexpr = static_cast(meexpr); ExtractbitsNode *extNode = codeMP->New(meexpr->GetOp(), meexpr->GetPrimType()); - extNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(0), extNode), 0); + extNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(0), extNode), 0); extNode->SetBitsOffset(opMeexpr->GetBitsOffSet()); extNode->SetBitsSize(opMeexpr->GetBitsSize()); - lfoExprParts[extNode] = lfopart; + PreMeExprExtensionMap[extNode] = pmeExt; return extNode; } case OP_regread: { @@ -262,14 +262,14 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { RegreadNode *regNode = codeMP->New(); regNode->SetPrimType(regMeexpr->GetPrimType()); regNode->SetRegIdx(regMeexpr->GetRegIdx()); - lfoExprParts[regNode] = lfopart; + PreMeExprExtensionMap[regNode] = pmeExt; return regNode; } case OP_sizeoftype: { SizeoftypeMeExpr *sizeofMeexpr = static_cast(meexpr); SizeoftypeNode *sizeofTynode = codeMP->New(sizeofMeexpr->GetPrimType(), sizeofMeexpr->GetTyIdx()); - lfoExprParts[sizeofTynode] = lfopart; + PreMeExprExtensionMap[sizeofTynode] = pmeExt; return sizeofTynode; } case OP_fieldsdist: { @@ -277,21 +277,21 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { FieldsDistNode *fieldsNode = codeMP->New(fdMeexpr->GetPrimType(), fdMeexpr->GetTyIdx(), fdMeexpr->GetFieldID1(), fdMeexpr->GetFieldID2()); - lfoExprParts[fieldsNode] = lfopart; + PreMeExprExtensionMap[fieldsNode] = pmeExt; return fieldsNode; } case OP_conststr: { ConststrMeExpr *constrMeexpr = static_cast(meexpr); ConststrNode *constrNode = codeMP->New(constrMeexpr->GetPrimType(), constrMeexpr->GetStrIdx()); - lfoExprParts[constrNode] = lfopart; + PreMeExprExtensionMap[constrNode] = pmeExt; return constrNode; } case OP_conststr16: { Conststr16MeExpr *constr16Meexpr = static_cast(meexpr); Conststr16Node *constr16Node = codeMP->New(constr16Meexpr->GetPrimType(), constr16Meexpr->GetStrIdx()); - lfoExprParts[constr16Node] = lfopart; + PreMeExprExtensionMap[constr16Node] = pmeExt; return constr16Node; } case OP_abs: @@ -304,26 +304,26 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { case OP_malloc: { OpMeExpr *opMeexpr = static_cast(meexpr); UnaryNode *unNode = codeMP->New(meexpr->GetOp(), meexpr->GetPrimType()); - unNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(0), unNode), 0); - lfoExprParts[unNode] = lfopart; + unNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(0), unNode), 0); + PreMeExprExtensionMap[unNode] = pmeExt; return unNode; } case OP_iaddrof: { OpMeExpr *opMeexpr = static_cast(meexpr); IreadNode *ireadNode = codeMP->New(meexpr->GetOp(), meexpr->GetPrimType()); - ireadNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(0), ireadNode), 0); + ireadNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(0), ireadNode), 0); ireadNode->SetTyIdx(opMeexpr->GetTyIdx()); ireadNode->SetFieldID(opMeexpr->GetFieldID()); - lfoExprParts[ireadNode] = lfopart; + PreMeExprExtensionMap[ireadNode] = pmeExt; return ireadNode; } case OP_select: { OpMeExpr *opMeexpr = static_cast(meexpr); TernaryNode *tNode = codeMP->New(OP_select, meexpr->GetPrimType()); - tNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(0), tNode), 0); - tNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(1), tNode), 1); - tNode->SetOpnd(EmitLfoExpr(opMeexpr->GetOpnd(2), tNode), 2); - lfoExprParts[tNode] = lfopart; + tNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(0), tNode), 0); + tNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(1), tNode), 1); + tNode->SetOpnd(EmitPreMeExpr(opMeexpr->GetOpnd(2), tNode), 2); + PreMeExprExtensionMap[tNode] = pmeExt; return tNode; } case OP_intrinsicop: @@ -333,11 +333,11 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { codeMP->New(*codeMPAlloc, meexpr->GetOp(), meexpr->GetPrimType(), nMeexpr->GetTyIdx()); intrnNode->SetIntrinsic(nMeexpr->GetIntrinsic()); for (uint32 i = 0; i < nMeexpr->GetNumOpnds(); i++) { - BaseNode *opnd = EmitLfoExpr(nMeexpr->GetOpnd(i), intrnNode); + BaseNode *opnd = EmitPreMeExpr(nMeexpr->GetOpnd(i), intrnNode); intrnNode->GetNopnd().push_back(opnd); } intrnNode->SetNumOpnds(nMeexpr->GetNumOpnds()); - lfoExprParts[intrnNode] = lfopart; + PreMeExprExtensionMap[intrnNode] = pmeExt; return intrnNode; } default: @@ -345,8 +345,8 @@ BaseNode *LfoPreEmitter::EmitLfoExpr(MeExpr *meexpr, BaseNode *parent) { } } -StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { - LfoPart *lfopart = lfoMP->New(parent, mestmt); +StmtNode* PreMeEmitter::EmitPreMeStmt(MeStmt *mestmt, BaseNode *parent) { + PreMeMIRExtension *pmeExt = preMeMP->New(parent, mestmt); switch (mestmt->GetOp()) { case OP_dassign: { DassignMeStmt *dsmestmt = static_cast(mestmt); @@ -354,11 +354,11 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { MIRSymbol *sym = dsmestmt->GetLHS()->GetOst()->GetMIRSymbol(); dass->SetStIdx(sym->GetStIdx()); dass->SetFieldID(static_cast(dsmestmt->GetLHS())->GetOst()->GetFieldID()); - dass->SetOpnd(EmitLfoExpr(dsmestmt->GetRHS(), dass), 0); + dass->SetOpnd(EmitPreMeExpr(dsmestmt->GetRHS(), dass), 0); dass->SetSrcPos(dsmestmt->GetSrcPosition()); dass->CopySafeRegionAttr(mestmt->GetStmtAttr()); dass->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[dass->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[dass->GetStmtID()] = pmeExt; return dass; } case OP_regassign: { @@ -366,11 +366,11 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { RegassignNode *rssnode = codeMP->New(); rssnode->SetPrimType(asMestmt->GetLHS()->GetPrimType()); rssnode->SetRegIdx(asMestmt->GetLHS()->GetRegIdx()); - rssnode->SetOpnd(EmitLfoExpr(asMestmt->GetRHS(), rssnode), 0); + rssnode->SetOpnd(EmitPreMeExpr(asMestmt->GetRHS(), rssnode), 0); rssnode->SetSrcPos(asMestmt->GetSrcPosition()); rssnode->CopySafeRegionAttr(mestmt->GetStmtAttr()); rssnode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[rssnode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[rssnode->GetStmtID()] = pmeExt; return rssnode; } case OP_iassign: { @@ -380,14 +380,14 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { iassignNode->SetTyIdx(iass->GetTyIdx()); iassignNode->SetFieldID(lhsVar->GetFieldID()); if (lhsVar->GetOffset() == 0) { - iassignNode->SetAddrExpr(EmitLfoExpr(lhsVar->GetBase(), iassignNode)); + iassignNode->SetAddrExpr(EmitPreMeExpr(lhsVar->GetBase(), iassignNode)); } else { auto *mirType = GlobalTables::GetTypeTable().GetInt32(); auto *mirConst = GlobalTables::GetIntConstTable().GetOrCreateIntConst(lhsVar->GetOffset(), *mirType); auto *constValNode = codeMP->New(mirType->GetPrimType(), mirConst); auto *newAddrNode = codeMP->New(OP_add, lhsVar->GetBase()->GetPrimType(), - EmitLfoExpr(lhsVar->GetBase(), iassignNode), constValNode); + EmitPreMeExpr(lhsVar->GetBase(), iassignNode), constValNode); iassignNode->SetAddrExpr(newAddrNode); } if (iassignNode->Opnd(0)->GetOpCode() != OP_array) { @@ -396,32 +396,32 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { iassignNode->SetAddrExpr(arryNode); } } - iassignNode->rhs = EmitLfoExpr(iass->GetRHS(), iassignNode); + iassignNode->rhs = EmitPreMeExpr(iass->GetRHS(), iassignNode); iassignNode->SetSrcPos(iass->GetSrcPosition()); iassignNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); iassignNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[iassignNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[iassignNode->GetStmtID()] = pmeExt; return iassignNode; } case OP_return: { RetMeStmt *retMestmt = static_cast(mestmt); NaryStmtNode *retNode = codeMP->New(*codeMPAlloc, OP_return); for (uint32 i = 0; i < retMestmt->GetOpnds().size(); i++) { - retNode->GetNopnd().push_back(EmitLfoExpr(retMestmt->GetOpnd(i), retNode)); + retNode->GetNopnd().push_back(EmitPreMeExpr(retMestmt->GetOpnd(i), retNode)); } retNode->SetNumOpnds(retMestmt->GetOpnds().size()); retNode->SetSrcPos(retMestmt->GetSrcPosition()); retNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); retNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[retNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[retNode->GetStmtID()] = pmeExt; return retNode; } case OP_goto: { GotoMeStmt *gotoStmt = static_cast(mestmt); - if (lfoFunc->WhileLabelCreatedByLfo(gotoStmt->GetOffset())) { + if (preMeFunc->WhileLabelCreatedByPreMe(gotoStmt->GetOffset())) { return nullptr; } - if (lfoFunc->IfLabelCreatedByLfo(gotoStmt->GetOffset())) { + if (preMeFunc->IfLabelCreatedByPreMe(gotoStmt->GetOffset())) { return nullptr; } GotoNode *gto = codeMP->New(OP_goto); @@ -429,17 +429,17 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { gto->SetSrcPos(gotoStmt->GetSrcPosition()); gto->CopySafeRegionAttr(mestmt->GetStmtAttr()); gto->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[gto->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[gto->GetStmtID()] = pmeExt; return gto; } case OP_igoto: { UnaryMeStmt *igotoMeStmt = static_cast(mestmt); UnaryStmtNode *igto = codeMP->New(OP_igoto); - igto->SetOpnd(EmitLfoExpr(igotoMeStmt->GetOpnd(), igto), 0); + igto->SetOpnd(EmitPreMeExpr(igotoMeStmt->GetOpnd(), igto), 0); igto->SetSrcPos(igotoMeStmt->GetSrcPosition()); igto->CopySafeRegionAttr(mestmt->GetStmtAttr()); igto->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[igto->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[igto->GetStmtID()] = pmeExt; return igto; } case OP_comment: { @@ -449,7 +449,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { cmtNode->SetSrcPos(cmtmeNode->GetSrcPosition()); cmtNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); cmtNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[cmtNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[cmtNode->GetStmtID()] = pmeExt; return cmtNode; } case OP_call: @@ -476,11 +476,11 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { callnode->SetSrcPos(callMeStmt->GetSrcPosition()); mestmt->EmitCallReturnVector(callnode->GetReturnVec()); for (uint32 i = 0; i < callMeStmt->GetOpnds().size(); i++) { - callnode->GetNopnd().push_back(EmitLfoExpr(callMeStmt->GetOpnd(i), callnode)); + callnode->GetNopnd().push_back(EmitPreMeExpr(callMeStmt->GetOpnd(i), callnode)); } callnode->CopySafeRegionAttr(mestmt->GetStmtAttr()); callnode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[callnode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[callnode->GetStmtID()] = pmeExt; return callnode; } case OP_icall: @@ -489,7 +489,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { IcallNode *icallnode = codeMP->New(*codeMPAlloc, OP_icallassigned, icallMeStmt->GetRetTyIdx()); for (uint32 i = 0; i < icallMeStmt->GetOpnds().size(); i++) { - icallnode->GetNopnd().push_back(EmitLfoExpr(icallMeStmt->GetOpnd(i), icallnode)); + icallnode->GetNopnd().push_back(EmitPreMeExpr(icallMeStmt->GetOpnd(i), icallnode)); } icallnode->SetNumOpnds(icallMeStmt->GetOpnds().size()); icallnode->SetSrcPos(mestmt->GetSrcPosition()); @@ -510,7 +510,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { } icallnode->CopySafeRegionAttr(mestmt->GetStmtAttr()); icallnode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[icallnode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[icallnode->GetStmtID()] = pmeExt; return icallnode; } case OP_intrinsiccall: @@ -525,7 +525,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { callnode->SetIntrinsic(callMeStmt->GetIntrinsic()); callnode->SetTyIdx(callMeStmt->GetTyIdx()); for (uint32 i = 0; i < callMeStmt->GetOpnds().size(); i++) { - callnode->GetNopnd().push_back(EmitLfoExpr(callMeStmt->GetOpnd(i), callnode)); + callnode->GetNopnd().push_back(EmitPreMeExpr(callMeStmt->GetOpnd(i), callnode)); } callnode->SetNumOpnds(callnode->GetNopndSize()); callnode->SetSrcPos(mestmt->GetSrcPosition()); @@ -534,14 +534,14 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { } callnode->CopySafeRegionAttr(mestmt->GetStmtAttr()); callnode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[callnode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[callnode->GetStmtID()] = pmeExt; return callnode; } case OP_asm: { AsmMeStmt *asmMeStmt = static_cast(mestmt); AsmNode *asmNode = codeMP->New(codeMPAlloc); for (size_t i = 0; i < asmMeStmt->NumMeStmtOpnds(); ++i) { - asmNode->GetNopnd().push_back(EmitLfoExpr(asmMeStmt->GetOpnd(i), asmNode)); + asmNode->GetNopnd().push_back(EmitPreMeExpr(asmMeStmt->GetOpnd(i), asmNode)); } asmNode->SetNumOpnds(asmNode->GetNopndSize()); asmNode->SetSrcPos(mestmt->GetSrcPosition()); @@ -567,7 +567,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { stmtNode->SetSrcPos(mestmt->GetSrcPosition()); stmtNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); stmtNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[stmtNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[stmtNode->GetStmtID()] = pmeExt; return stmtNode; } case OP_retsub: { @@ -575,7 +575,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { usesStmtNode->SetSrcPos(mestmt->GetSrcPosition()); usesStmtNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); usesStmtNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[usesStmtNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[usesStmtNode->GetStmtID()] = pmeExt; return usesStmtNode; } case OP_brfalse: @@ -584,10 +584,10 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { CondGotoMeStmt *condMeStmt = static_cast (mestmt); CondNode->SetOffset(condMeStmt->GetOffset()); CondNode->SetSrcPos(mestmt->GetSrcPosition()); - CondNode->SetOpnd(EmitLfoExpr(condMeStmt->GetOpnd(), CondNode), 0); + CondNode->SetOpnd(EmitPreMeExpr(condMeStmt->GetOpnd(), CondNode), 0); CondNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); CondNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[CondNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[CondNode->GetStmtID()] = pmeExt; return CondNode; } case OP_cpptry: @@ -602,7 +602,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { jvTryNode->SetSrcPos(tryMeStmt->GetSrcPosition()); jvTryNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); jvTryNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[jvTryNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[jvTryNode->GetStmtID()] = pmeExt; return jvTryNode; } case OP_cppcatch: { @@ -612,7 +612,7 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { cppCatchNode->SetSrcPos(catchMestmt->GetSrcPosition()); cppCatchNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); cppCatchNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[cppCatchNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[cppCatchNode->GetStmtID()] = pmeExt; return cppCatchNode; } case OP_catch: { @@ -622,17 +622,17 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { jvCatchNode->SetSrcPos(catchMestmt->GetSrcPosition()); jvCatchNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); jvCatchNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[jvCatchNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[jvCatchNode->GetStmtID()] = pmeExt; return jvCatchNode; } case OP_throw: { UnaryStmtNode *throwStmtNode = codeMP->New(mestmt->GetOp()); ThrowMeStmt *throwMeStmt = static_cast(mestmt); - throwStmtNode->SetOpnd(EmitLfoExpr(throwMeStmt->GetOpnd(), throwStmtNode), 0); + throwStmtNode->SetOpnd(EmitPreMeExpr(throwMeStmt->GetOpnd(), throwStmtNode), 0); throwStmtNode->SetSrcPos(throwMeStmt->GetSrcPosition()); throwStmtNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); throwStmtNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[throwStmtNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[throwStmtNode->GetStmtID()] = pmeExt; return throwStmtNode; } case OP_callassertnonnull: { @@ -640,11 +640,11 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { CallAssertNonnullStmtNode *assertNullNode = codeMP->New( mestmt->GetOp(), assertNullStmt->GetFuncNameIdx(), assertNullStmt->GetParamIndex()); assertNullNode->SetSrcPos(mestmt->GetSrcPosition()); - assertNullNode->SetOpnd(EmitLfoExpr(assertNullStmt->GetOpnd(), assertNullNode), 0); + assertNullNode->SetOpnd(EmitPreMeExpr(assertNullStmt->GetOpnd(), assertNullNode), 0); assertNullNode->SetNumOpnds(1); assertNullNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); assertNullNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[assertNullNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[assertNullNode->GetStmtID()] = pmeExt; return assertNullNode; } case OP_callassertle: { @@ -653,12 +653,12 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { *codeMPAlloc, mestmt->GetOp(), assertBoundaryStmt->GetFuncNameIdx(), assertBoundaryStmt->GetParamIndex()); assertBoundaryNode->SetSrcPos(mestmt->GetSrcPosition()); for (uint32 i = 0; i < assertBoundaryStmt->GetOpnds().size(); i++) { - assertBoundaryNode->GetNopnd().push_back(EmitLfoExpr(assertBoundaryStmt->GetOpnd(i), assertBoundaryNode)); + assertBoundaryNode->GetNopnd().push_back(EmitPreMeExpr(assertBoundaryStmt->GetOpnd(i), assertBoundaryNode)); } assertBoundaryNode->SetNumOpnds(assertBoundaryNode->GetNopndSize()); assertBoundaryNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); assertBoundaryNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[assertBoundaryNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[assertBoundaryNode->GetStmtID()] = pmeExt; return assertBoundaryNode; } case OP_assertge: @@ -668,12 +668,12 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { NaryStmtNode *assertBoundaryNode = codeMP->New(*codeMPAlloc, mestmt->GetOp()); assertBoundaryNode->SetSrcPos(mestmt->GetSrcPosition()); for (uint32 i = 0; i < assertBoundaryStmt->GetOpnds().size(); i++) { - assertBoundaryNode->GetNopnd().push_back(EmitLfoExpr(assertBoundaryStmt->GetOpnd(i), assertBoundaryNode)); + assertBoundaryNode->GetNopnd().push_back(EmitPreMeExpr(assertBoundaryStmt->GetOpnd(i), assertBoundaryNode)); } assertBoundaryNode->SetNumOpnds(assertBoundaryNode->GetNopndSize()); assertBoundaryNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); assertBoundaryNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[assertBoundaryNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[assertBoundaryNode->GetStmtID()] = pmeExt; return assertBoundaryNode; } case OP_assertnonnull: @@ -682,23 +682,23 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { case OP_free: { UnaryStmtNode *unaryStmtNode = codeMP->New(mestmt->GetOp()); UnaryMeStmt *uMeStmt = static_cast(mestmt); - unaryStmtNode->SetOpnd(EmitLfoExpr(uMeStmt->GetOpnd(), unaryStmtNode), 0); + unaryStmtNode->SetOpnd(EmitPreMeExpr(uMeStmt->GetOpnd(), unaryStmtNode), 0); unaryStmtNode->SetSrcPos(uMeStmt->GetSrcPosition()); unaryStmtNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); unaryStmtNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[unaryStmtNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[unaryStmtNode->GetStmtID()] = pmeExt; return unaryStmtNode; } case OP_switch: { SwitchNode *switchNode = codeMP->New(*codeMPAlloc); SwitchMeStmt *meSwitch = static_cast(mestmt); - switchNode->SetSwitchOpnd(EmitLfoExpr(meSwitch->GetOpnd(), switchNode)); + switchNode->SetSwitchOpnd(EmitPreMeExpr(meSwitch->GetOpnd(), switchNode)); switchNode->SetDefaultLabel(meSwitch->GetDefaultLabel()); switchNode->SetSwitchTable(meSwitch->GetSwitchTable()); switchNode->SetSrcPos(meSwitch->GetSrcPosition()); switchNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); switchNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[switchNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[switchNode->GetStmtID()] = pmeExt; return switchNode; } case OP_returnassertnonnull: { @@ -706,11 +706,11 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { ReturnAssertNonnullStmtNode *assertNullNode = codeMP->New( mestmt->GetOp(), assertNullStmt->GetFuncNameIdx()); assertNullNode->SetSrcPos(mestmt->GetSrcPosition()); - assertNullNode->SetOpnd(EmitLfoExpr(assertNullStmt->GetOpnd(), assertNullNode), 0); + assertNullNode->SetOpnd(EmitPreMeExpr(assertNullStmt->GetOpnd(), assertNullNode), 0); assertNullNode->SetNumOpnds(1); assertNullNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); assertNullNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[assertNullNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[assertNullNode->GetStmtID()] = pmeExt; return assertNullNode; } case OP_returnassertle: { @@ -719,12 +719,12 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { *codeMPAlloc, mestmt->GetOp(), assertBoundaryStmt->GetFuncNameIdx()); assertBoundaryNode->SetSrcPos(mestmt->GetSrcPosition()); for (uint32 i = 0; i < assertBoundaryStmt->GetOpnds().size(); i++) { - assertBoundaryNode->GetNopnd().push_back(EmitLfoExpr(assertBoundaryStmt->GetOpnd(i), assertBoundaryNode)); + assertBoundaryNode->GetNopnd().push_back(EmitPreMeExpr(assertBoundaryStmt->GetOpnd(i), assertBoundaryNode)); } assertBoundaryNode->SetNumOpnds(assertBoundaryNode->GetNopndSize()); assertBoundaryNode->CopySafeRegionAttr(mestmt->GetStmtAttr()); assertBoundaryNode->SetOriginalID(mestmt->GetOriginalId()); - lfoStmtParts[assertBoundaryNode->GetStmtID()] = lfopart; + PreMeStmtExtensionMap[assertBoundaryNode->GetStmtID()] = pmeExt; return assertBoundaryNode; } default: @@ -732,20 +732,20 @@ StmtNode* LfoPreEmitter::EmitLfoStmt(MeStmt *mestmt, BaseNode *parent) { } } -void LfoPreEmitter::EmitBB(BB *bb, BlockNode *curblk) { +void PreMeEmitter::EmitBB(BB *bb, BlockNode *curblk) { CHECK_FATAL(curblk != nullptr, "null ptr check"); // emit head. label LabelIdx labidx = bb->GetBBLabel(); - if (labidx != 0 && !lfoFunc->WhileLabelCreatedByLfo(labidx) && !lfoFunc->IfLabelCreatedByLfo(labidx)) { + if (labidx != 0 && !preMeFunc->WhileLabelCreatedByPreMe(labidx) && !preMeFunc->IfLabelCreatedByPreMe(labidx)) { // not a empty bb LabelNode *lbnode = codeMP->New(); lbnode->SetLabelIdx(labidx); curblk->AddStatement(lbnode); - LfoPart *lfopart = lfoMP->New(curblk); - lfoStmtParts[lbnode->GetStmtID()] = lfopart; + PreMeMIRExtension *pmeExt = preMeMP->New(curblk); + PreMeStmtExtensionMap[lbnode->GetStmtID()] = pmeExt; } for (auto& mestmt : bb->GetMeStmts()) { - StmtNode *stmt = EmitLfoStmt(&mestmt, curblk); + StmtNode *stmt = EmitPreMeStmt(&mestmt, curblk); if (!stmt) // can be null i.e, a goto to a label that was created by lno lower continue; curblk->AddStatement(stmt); @@ -754,59 +754,59 @@ void LfoPreEmitter::EmitBB(BB *bb, BlockNode *curblk) { /* generate op_endtry */ StmtNode *endtry = codeMP->New(OP_endtry); curblk->AddStatement(endtry); - LfoPart *lfopart = lfoMP->New(curblk); - lfoStmtParts[endtry->GetStmtID()] = lfopart; + PreMeMIRExtension *pmeExt = preMeMP->New(curblk); + PreMeStmtExtensionMap[endtry->GetStmtID()] = pmeExt; } } -DoloopNode *LfoPreEmitter::EmitLfoDoloop(BB *mewhilebb, BlockNode *curblk, LfoWhileInfo *whileInfo) { +DoloopNode *PreMeEmitter::EmitPreMeDoloop(BB *mewhilebb, BlockNode *curblk, PreMeWhileInfo *whileInfo) { MeStmt *lastmestmt = mewhilebb->GetLastMe(); CHECK_FATAL(lastmestmt->GetPrev() == nullptr || dynamic_cast(lastmestmt->GetPrev()) == nullptr, - "EmitLfoDoLoop: there are other statements at while header bb"); + "EmitPreMeDoLoop: there are other statements at while header bb"); DoloopNode *Doloopnode = codeMP->New(); - LfoPart *lfopart = lfoMP->New(curblk); - lfopart->mestmt = lastmestmt; - lfoStmtParts[Doloopnode->GetStmtID()] = lfopart; + PreMeMIRExtension *pmeExt = preMeMP->New(curblk); + pmeExt->mestmt = lastmestmt; + PreMeStmtExtensionMap[Doloopnode->GetStmtID()] = pmeExt; Doloopnode->SetDoVarStIdx(whileInfo->ivOst->GetMIRSymbol()->GetStIdx()); CondGotoMeStmt *condGotostmt = static_cast(lastmestmt); - Doloopnode->SetStartExpr(EmitLfoExpr(whileInfo->initExpr, Doloopnode)); - Doloopnode->SetContExpr(EmitLfoExpr(condGotostmt->GetOpnd(), Doloopnode)); + Doloopnode->SetStartExpr(EmitPreMeExpr(whileInfo->initExpr, Doloopnode)); + Doloopnode->SetContExpr(EmitPreMeExpr(condGotostmt->GetOpnd(), Doloopnode)); BlockNode *dobodyNode = codeMP->New(); Doloopnode->SetDoBody(dobodyNode); - LfoPart *dolooplfopart = lfoMP->New(Doloopnode); - lfoStmtParts[dobodyNode->GetStmtID()] = dolooplfopart; + PreMeMIRExtension *doloopExt = preMeMP->New(Doloopnode); + PreMeStmtExtensionMap[dobodyNode->GetStmtID()] = doloopExt; MIRIntConst *intConst = mirFunc->GetModule()->GetMemPool()->New(whileInfo->stepValue, *whileInfo->ivOst->GetType()); ConstvalNode *constnode = codeMP->New(intConst->GetType().GetPrimType(), intConst); - lfoExprParts[constnode] = dolooplfopart; + PreMeExprExtensionMap[constnode] = doloopExt; Doloopnode->SetIncrExpr(constnode); Doloopnode->SetIsPreg(false); curblk->AddStatement(Doloopnode); return Doloopnode; } -WhileStmtNode *LfoPreEmitter::EmitLfoWhile(BB *meWhilebb, BlockNode *curblk) { +WhileStmtNode *PreMeEmitter::EmitPreMeWhile(BB *meWhilebb, BlockNode *curblk) { MeStmt *lastmestmt = meWhilebb->GetLastMe(); CHECK_FATAL(lastmestmt->GetPrev() == nullptr || dynamic_cast(lastmestmt->GetPrev()) == nullptr, - "EmitLfoWhile: there are other statements at while header bb"); + "EmitPreMeWhile: there are other statements at while header bb"); WhileStmtNode *Whilestmt = codeMP->New(OP_while); - LfoPart *lfopart = lfoMP->New(curblk); - lfoStmtParts[Whilestmt->GetStmtID()] = lfopart; + PreMeMIRExtension *pmeExt = preMeMP->New(curblk); + PreMeStmtExtensionMap[Whilestmt->GetStmtID()] = pmeExt; CondGotoMeStmt *condGotostmt = static_cast(lastmestmt); - Whilestmt->SetOpnd(EmitLfoExpr(condGotostmt->GetOpnd(), Whilestmt), 0); + Whilestmt->SetOpnd(EmitPreMeExpr(condGotostmt->GetOpnd(), Whilestmt), 0); BlockNode *whilebodyNode = codeMP->New(); - LfoPart *whilenodelfopart = lfoMP->New(Whilestmt); - lfoStmtParts[whilebodyNode->GetStmtID()] = whilenodelfopart; + PreMeMIRExtension *whilenodeExt = preMeMP->New(Whilestmt); + PreMeStmtExtensionMap[whilebodyNode->GetStmtID()] = whilenodeExt; Whilestmt->SetBody(whilebodyNode); curblk->AddStatement(Whilestmt); return Whilestmt; } -uint32 LfoPreEmitter::Raise2LfoWhile(uint32 curj, BlockNode *curblk) { +uint32 PreMeEmitter::Raise2PreMeWhile(uint32 curj, BlockNode *curblk) { MapleVector &bbvec = cfg->GetAllBBs(); BB *curbb = bbvec[curj]; LabelIdx whilelabidx = curbb->GetBBLabel(); - LfoWhileInfo *whileInfo = lfoFunc->label2WhileInfo[whilelabidx]; + PreMeWhileInfo *whileInfo = preMeFunc->label2WhileInfo[whilelabidx]; // find the end label bb BB *suc0 = curbb->GetSucc(0); @@ -817,91 +817,91 @@ uint32 LfoPreEmitter::Raise2LfoWhile(uint32 curj, BlockNode *curblk) { BB *endlblbb = condgotomestmt->GetOffset() == suc1->GetBBLabel() ? suc1 : suc0; BlockNode *Dobody = nullptr; if (whileInfo->canConvertDoloop) { // emit doloop - DoloopNode *doloopnode = EmitLfoDoloop(curbb, curblk, whileInfo); + DoloopNode *doloopnode = EmitPreMeDoloop(curbb, curblk, whileInfo); ++curj; Dobody = static_cast(doloopnode->GetDoBody()); } else { // emit while loop - WhileStmtNode *whileNode = EmitLfoWhile(curbb, curblk); + WhileStmtNode *whileNode = EmitPreMeWhile(curbb, curblk); ++curj; Dobody = static_cast (whileNode->GetBody()); } // emit loop body while (bbvec[curj]->GetBBId() != endlblbb->GetBBId()) { - curj = EmitLfoBB(curj, Dobody); + curj = EmitPreMeBB(curj, Dobody); while (bbvec[curj] == nullptr) { curj++; } } if (whileInfo->canConvertDoloop) { // delete the increment statement StmtNode *bodylaststmt = Dobody->GetLast(); - CHECK_FATAL(bodylaststmt->GetOpCode() == OP_dassign, "Raise2LfoWhile: cannot find increment stmt"); + CHECK_FATAL(bodylaststmt->GetOpCode() == OP_dassign, "Raise2PreMeWhile: cannot find increment stmt"); DassignNode *dassnode = static_cast(bodylaststmt); CHECK_FATAL(dassnode->GetStIdx() == whileInfo->ivOst->GetMIRSymbol()->GetStIdx(), - "Raise2LfoWhile: cannot find IV increment"); + "Raise2PreMeWhile: cannot find IV increment"); Dobody->RemoveStmt(dassnode); } return curj; } -uint32 LfoPreEmitter::Raise2LfoIf(uint32 curj, BlockNode *curblk) { +uint32 PreMeEmitter::Raise2PreMeIf(uint32 curj, BlockNode *curblk) { MapleVector &bbvec = cfg->GetAllBBs(); BB *curbb = bbvec[curj]; // emit BB contents before the if statement LabelIdx labidx = curbb->GetBBLabel(); - if (labidx != 0 && !lfoFunc->IfLabelCreatedByLfo(labidx)) { + if (labidx != 0 && !preMeFunc->IfLabelCreatedByPreMe(labidx)) { LabelNode *lbnode = mirFunc->GetCodeMempool()->New(); lbnode->SetLabelIdx(labidx); curblk->AddStatement(lbnode); - LfoPart *lfopart = lfoMP->New(curblk); - lfoStmtParts[lbnode->GetStmtID()] = lfopart; + PreMeMIRExtension *pmeExt = preMeMP->New(curblk); + PreMeStmtExtensionMap[lbnode->GetStmtID()] = pmeExt; } MeStmt *mestmt = curbb->GetFirstMe(); while (mestmt->GetOp() != OP_brfalse && mestmt->GetOp() != OP_brtrue) { - StmtNode *stmt = EmitLfoStmt(mestmt, curblk); + StmtNode *stmt = EmitPreMeStmt(mestmt, curblk); curblk->AddStatement(stmt); mestmt = mestmt->GetNext(); } // emit the if statement CHECK_FATAL(mestmt != nullptr && (mestmt->GetOp() == OP_brfalse || mestmt->GetOp() == OP_brtrue), - "Raise2LfoIf: cannot find conditional branch"); + "Raise2PreMeIf: cannot find conditional branch"); CondGotoMeStmt *condgoto = static_cast (mestmt); - LfoIfInfo *ifInfo = lfoFunc->label2IfInfo[condgoto->GetOffset()]; - CHECK_FATAL(ifInfo->endLabel != 0, "Raise2LfoIf: endLabel not found"); + PreMeIfInfo *ifInfo = preMeFunc->label2IfInfo[condgoto->GetOffset()]; + CHECK_FATAL(ifInfo->endLabel != 0, "Raise2PreMeIf: endLabel not found"); //IfStmtNode *lnoIfstmtNode = mirFunc->GetCodeMempool()->New(curblk); IfStmtNode *IfstmtNode = mirFunc->GetCodeMempool()->New(); - LfoPart *lfopart = lfoMP->New(curblk); - lfoStmtParts[IfstmtNode->GetStmtID()] = lfopart; - BaseNode *condnode = EmitLfoExpr(condgoto->GetOpnd(), IfstmtNode); + PreMeMIRExtension *pmeExt = preMeMP->New(curblk); + PreMeStmtExtensionMap[IfstmtNode->GetStmtID()] = pmeExt; + BaseNode *condnode = EmitPreMeExpr(condgoto->GetOpnd(), IfstmtNode); IfstmtNode->SetOpnd(condnode, 0); curblk->AddStatement(IfstmtNode); - LfoPart *iflfopart = lfoMP->New(IfstmtNode); + PreMeMIRExtension *ifpmeExt = preMeMP->New(IfstmtNode); if (ifInfo->elseLabel != 0) { // both else and then are not empty; BlockNode *elseBlk = codeMP->New(); - lfoStmtParts[elseBlk->GetStmtID()] = iflfopart; + PreMeStmtExtensionMap[elseBlk->GetStmtID()] = ifpmeExt; BlockNode *thenBlk = codeMP->New(); - lfoStmtParts[thenBlk->GetStmtID()] = iflfopart; + PreMeStmtExtensionMap[thenBlk->GetStmtID()] = ifpmeExt; IfstmtNode->SetThenPart(thenBlk); IfstmtNode->SetElsePart(elseBlk); BB *elsemebb = cfg->GetLabelBBAt(ifInfo->elseLabel); BB *endmebb = cfg->GetLabelBBAt(ifInfo->endLabel); - CHECK_FATAL(elsemebb, "Raise2LfoIf: cannot find else BB"); - CHECK_FATAL(endmebb, "Raise2LfoIf: cannot find BB at end of IF"); + CHECK_FATAL(elsemebb, "Raise2PreMeIf: cannot find else BB"); + CHECK_FATAL(endmebb, "Raise2PreMeIf: cannot find BB at end of IF"); // emit then branch; uint32 j = curj + 1; while (j != elsemebb->GetBBId()) { - j = EmitLfoBB(j, thenBlk); + j = EmitPreMeBB(j, thenBlk); } CHECK_FATAL(j < bbvec.size(), ""); while (j != endmebb->GetBBId()) { - j = EmitLfoBB(j, elseBlk); + j = EmitPreMeBB(j, elseBlk); } CHECK_FATAL(j < bbvec.size(), ""); return j; } else { // there is only then or else part in this if stmt BlockNode *branchBlock = codeMP->New(); - lfoStmtParts[branchBlock->GetStmtID()] = iflfopart; + PreMeStmtExtensionMap[branchBlock->GetStmtID()] = ifpmeExt; BlockNode *emptyBlock = codeMP->New(); - lfoStmtParts[emptyBlock->GetStmtID()] = iflfopart; + PreMeStmtExtensionMap[emptyBlock->GetStmtID()] = ifpmeExt; if (condgoto->GetOp() == OP_brtrue) { IfstmtNode->SetElsePart(branchBlock); IfstmtNode->SetThenPart(emptyBlock); @@ -912,27 +912,27 @@ uint32 LfoPreEmitter::Raise2LfoIf(uint32 curj, BlockNode *curblk) { BB *endmebb = cfg->GetLabelBBAt(ifInfo->endLabel); uint32 j = curj + 1; while (j != endmebb->GetBBId()) { - j = EmitLfoBB(j, branchBlock); + j = EmitPreMeBB(j, branchBlock); } CHECK_FATAL(j < bbvec.size(), ""); return j; } } -uint32 LfoPreEmitter::EmitLfoBB(uint32 curj, BlockNode *curblk) { +uint32 PreMeEmitter::EmitPreMeBB(uint32 curj, BlockNode *curblk) { MapleVector &bbvec = cfg->GetAllBBs(); BB *mebb = bbvec[curj]; if (!mebb || mebb == cfg->GetCommonEntryBB() || mebb == cfg->GetCommonEntryBB()) { return curj + 1; } if (mebb->GetBBLabel() != 0) { - MapleMap::iterator it = lfoFunc->label2WhileInfo.find(mebb->GetBBLabel()); - if (it != lfoFunc->label2WhileInfo.end()) { + MapleMap::iterator it = preMeFunc->label2WhileInfo.find(mebb->GetBBLabel()); + if (it != preMeFunc->label2WhileInfo.end()) { if (mebb->GetSucc().size() == 2) { - curj = Raise2LfoWhile(curj, curblk); + curj = Raise2PreMeWhile(curj, curblk); return curj; } else { - lfoFunc->lfoCreatedWhileLabelSet.erase(mebb->GetBBLabel()); + preMeFunc->pmeCreatedWhileLabelSet.erase(mebb->GetBBLabel()); } } } @@ -940,9 +940,9 @@ uint32 LfoPreEmitter::EmitLfoBB(uint32 curj, BlockNode *curblk) { (mebb->GetLastMe()->GetOp() == OP_brfalse || mebb->GetLastMe()->GetOp() == OP_brtrue)) { CondGotoMeStmt *condgoto = static_cast(mebb->GetLastMe()); - MapleMap::iterator it = lfoFunc->label2IfInfo.find(condgoto->GetOffset()); - if (it != lfoFunc->label2IfInfo.end()) { - curj = Raise2LfoIf(curj, curblk); + MapleMap::iterator it = preMeFunc->label2IfInfo.find(condgoto->GetOffset()); + if (it != preMeFunc->label2IfInfo.end()) { + curj = Raise2PreMeIf(curj, curblk); return curj; } } @@ -950,7 +950,7 @@ uint32 LfoPreEmitter::EmitLfoBB(uint32 curj, BlockNode *curblk) { return ++curj; } -bool MELfoPreEmission::PhaseRun(MeFunction &f) { +bool MEPreMeEmission::PhaseRun(MeFunction &f) { if (f.GetCfg()->NumBBs() == 0) { f.SetLfo(false); return false; @@ -963,14 +963,13 @@ bool MELfoPreEmission::PhaseRun(MeFunction &f) { memPoolCtrler.DeleteMemPool(mirfunction->GetCodeMempool()); } mirfunction->SetMemPool(new ThreadLocalMemPool(memPoolCtrler, "IR from preemission::Emit()")); - MemPool *lfoMP = GetPhaseMemPool(); - emitter = lfoMP->New(hmap, f.GetLfoFunc(), lfoMP); + MemPool *preMeMP = GetPhaseMemPool(); + emitter = preMeMP->New(hmap, f.GetPreMeFunc(), preMeMP); BlockNode *curblk = mirfunction->GetCodeMempool()->New(); mirfunction->SetBody(curblk); - emitter->InitFuncBodyLfoPart(curblk); // set lfopart for curblk uint32 i = 0; while (i < f.GetCfg()->GetAllBBs().size()) { - i = emitter->EmitLfoBB(i, curblk); + i = emitter->EmitPreMeBB(i, curblk); } f.SetLfo(false); @@ -979,14 +978,14 @@ bool MELfoPreEmission::PhaseRun(MeFunction &f) { cf.Simplify(mirfunction->GetBody()); if (DEBUGFUNC_NEWPM(f)) { - LogInfo::MapleLogger() << "\n**** After lfopreemit phase ****\n"; + LogInfo::MapleLogger() << "\n**** After premeemit phase ****\n"; mirfunction->Dump(false); } return emitter; } -void MELfoPreEmission::GetAnalysisDependence(maple::AnalysisDep &aDep) const { +void MEPreMeEmission::GetAnalysisDependence(maple::AnalysisDep &aDep) const { aDep.AddRequired(); aDep.SetPreservedAll(); } diff --git a/src/mapleall/maple_me/src/lfo_mir_lower.cpp b/src/mapleall/maple_me/src/pme_mir_lower.cpp similarity index 85% rename from src/mapleall/maple_me/src/lfo_mir_lower.cpp rename to src/mapleall/maple_me/src/pme_mir_lower.cpp index 89e76a7c12..7c5f870f64 100644 --- a/src/mapleall/maple_me/src/lfo_mir_lower.cpp +++ b/src/mapleall/maple_me/src/pme_mir_lower.cpp @@ -14,7 +14,7 @@ */ #include "mir_builder.h" -#include "lfo_mir_lower.h" +#include "pme_mir_lower.h" using namespace maple; @@ -24,7 +24,7 @@ using namespace maple; // // goto // label -BlockNode *LFOMIRLower::LowerWhileStmt(WhileStmtNode &whilestmt) { +BlockNode *PreMeMIRLower::LowerWhileStmt(WhileStmtNode &whilestmt) { MIRBuilder *mirbuilder = mirModule.GetMIRBuilder(); whilestmt.SetBody(LowerBlock(*whilestmt.GetBody())); BlockNode *blk = mirModule.CurFuncCodeMemPool()->New(); @@ -32,9 +32,9 @@ BlockNode *LFOMIRLower::LowerWhileStmt(WhileStmtNode &whilestmt) { mirModule.CurFunction()->GetLabelTab()->AddToStringLabelMap(whilelblidx); LabelNode *whilelblstmt = mirModule.CurFuncCodeMemPool()->New(); whilelblstmt->SetLabelIdx(whilelblidx); - LfoWhileInfo *whileInfo = lfoFunc->lfomp->New(); - lfoFunc->SetWhileLabelCreatedByLfo(whilelblidx); - lfoFunc->label2WhileInfo.insert(std::make_pair(whilelblidx, whileInfo)); + PreMeWhileInfo *whileInfo = preMeFunc->pmemp->New(); + preMeFunc->SetWhileLabelCreatedByPreMe(whilelblidx); + preMeFunc->label2WhileInfo.insert(std::make_pair(whilelblidx, whileInfo)); blk->AddStatement(whilelblstmt); CondGotoNode *brfalsestmt = mirModule.CurFuncCodeMemPool()->New(OP_brfalse); brfalsestmt->SetOpnd(whilestmt.Opnd(), 0); @@ -49,7 +49,7 @@ BlockNode *LFOMIRLower::LowerWhileStmt(WhileStmtNode &whilestmt) { blk->AddStatement(whilegotonode); // create endlabel LabelIdx endlblidx = mirModule.CurFunction()->GetLabelTab()->CreateLabelWithPrefix('w'); - lfoFunc->SetWhileLabelCreatedByLfo(endlblidx); + preMeFunc->SetWhileLabelCreatedByPreMe(endlblidx); mirModule.CurFunction()->GetLabelTab()->AddToStringLabelMap(endlblidx); LabelNode *endlblstmt = mirModule.CurFuncCodeMemPool()->New(); endlblstmt->SetLabelIdx(endlblidx); @@ -67,7 +67,7 @@ static bool BlockHasLabel(BlockNode *blk) { return false; } -BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { +BlockNode *PreMeMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { bool thenempty = ifstmt.GetThenPart() == nullptr || ifstmt.GetThenPart()->GetFirst() == nullptr; bool elseempty = ifstmt.GetElsePart() == nullptr || ifstmt.GetElsePart()->GetFirst() == nullptr; bool canRaiseBack = true; @@ -107,9 +107,9 @@ BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { LabelIdx endlabelidx = mirFunc->GetLabelTab()->CreateLabelWithPrefix('e'); mirFunc->GetLabelTab()->AddToStringLabelMap(endlabelidx); if (canRaiseBack) { - lfoFunc->SetIfLabelCreatedByLfo(endlabelidx); + preMeFunc->SetIfLabelCreatedByPreMe(endlabelidx); } - LfoIfInfo *ifInfo = lfoFunc->lfomp->New(); + PreMeIfInfo *ifInfo = preMeFunc->pmemp->New(); brfalsestmt->SetOffset(endlabelidx); blk->AddStatement(brfalsestmt); @@ -119,7 +119,7 @@ BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { labstmt->SetLabelIdx(endlabelidx); ifInfo->endLabel = endlabelidx; if (canRaiseBack) { - lfoFunc->label2IfInfo.insert(std::make_pair(endlabelidx, ifInfo)); + preMeFunc->label2IfInfo.insert(std::make_pair(endlabelidx, ifInfo)); } blk->AddStatement(labstmt); } else if (thenempty) { @@ -131,9 +131,9 @@ BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { brtruestmt->SetSrcPos(ifstmt.GetSrcPos()); LabelIdx endlabelidx = mirFunc->GetLabelTab()->CreateLabelWithPrefix('e'); if (canRaiseBack) { - lfoFunc->SetIfLabelCreatedByLfo(endlabelidx); + preMeFunc->SetIfLabelCreatedByPreMe(endlabelidx); } - LfoIfInfo *ifInfo = lfoFunc->lfomp->New(); + PreMeIfInfo *ifInfo = preMeFunc->pmemp->New(); mirFunc->GetLabelTab()->AddToStringLabelMap(endlabelidx); brtruestmt->SetOffset(endlabelidx); blk->AddStatement(brtruestmt); @@ -143,7 +143,7 @@ BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { labstmt->SetLabelIdx(endlabelidx); ifInfo->endLabel = endlabelidx; if (canRaiseBack) { - lfoFunc->label2IfInfo.insert(std::make_pair(endlabelidx, ifInfo)); + preMeFunc->label2IfInfo.insert(std::make_pair(endlabelidx, ifInfo)); } blk->AddStatement(labstmt); } else { @@ -159,14 +159,14 @@ BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { LabelIdx elselabelidx = mirFunc->GetLabelTab()->CreateLabelWithPrefix('s'); mirFunc->GetLabelTab()->AddToStringLabelMap(elselabelidx); if (canRaiseBack) { - lfoFunc->SetIfLabelCreatedByLfo(elselabelidx); + preMeFunc->SetIfLabelCreatedByPreMe(elselabelidx); } - LfoIfInfo *ifInfo = lfoFunc->lfomp->New(); + PreMeIfInfo *ifInfo = preMeFunc->pmemp->New(); brfalsestmt->SetOffset(elselabelidx); blk->AddStatement(brfalsestmt); ifInfo->elseLabel = elselabelidx; if (canRaiseBack) { - lfoFunc->label2IfInfo.insert(std::make_pair(elselabelidx, ifInfo)); + preMeFunc->label2IfInfo.insert(std::make_pair(elselabelidx, ifInfo)); } blk->AppendStatementsFromBlock(*ifstmt.GetThenPart()); @@ -178,7 +178,7 @@ BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { endlabelidx = mirFunc->GetLabelTab()->CreateLabelWithPrefix('e'); mirFunc->GetLabelTab()->AddToStringLabelMap(endlabelidx); if (canRaiseBack) { - lfoFunc->SetIfLabelCreatedByLfo(endlabelidx); + preMeFunc->SetIfLabelCreatedByPreMe(endlabelidx); } gotostmt->SetOffset(endlabelidx); blk->AddStatement(gotostmt); @@ -198,7 +198,7 @@ BlockNode *LFOMIRLower::LowerIfStmt(IfStmtNode &ifstmt, bool recursive) { if (endlabelidx == 0) { // create end label endlabelidx = mirFunc->GetLabelTab()->CreateLabelWithPrefix('e'); if (canRaiseBack) { - lfoFunc->SetIfLabelCreatedByLfo(endlabelidx); + preMeFunc->SetIfLabelCreatedByPreMe(endlabelidx); } LabelNode *endlabelnode = mirbuilder->CreateStmtLabel(endlabelidx); blk->AddStatement(endlabelnode); diff --git a/src/mapleall/maple_me/src/seqvec.cpp b/src/mapleall/maple_me/src/seqvec.cpp index b59c1c9a0b..1aafc8f2a1 100644 --- a/src/mapleall/maple_me/src/seqvec.cpp +++ b/src/mapleall/maple_me/src/seqvec.cpp @@ -277,7 +277,7 @@ void SeqVectorize::DumpCandidates(MeExpr *base, StoreList *storelist) { void SeqVectorize::CollectStores(IassignNode *iassign) { // if no hass information, the node may be changed by loopvec, skip - if ((*lfoStmtParts)[iassign->GetStmtID()] == nullptr) return; + if ((*PreMeStmtExtensionMap)[iassign->GetStmtID()] == nullptr) return; // if point to type is not integer, skip MIRType &mirType = GetTypeFromTyIdx(iassign->GetTyIdx()); CHECK_FATAL(mirType.GetKind() == kTypePointer, "iassign must have pointer type"); @@ -291,7 +291,7 @@ void SeqVectorize::CollectStores(IassignNode *iassign) { return; } // compare base address with store list - LfoPart *lfoP = (*lfoStmtParts)[iassign->GetStmtID()]; + PreMeMIRExtension *lfoP = (*PreMeStmtExtensionMap)[iassign->GetStmtID()]; IassignMeStmt *iassMeStmt = static_cast(lfoP->GetMeStmt()); IvarMeExpr *ivarMeExpr = iassMeStmt->GetLHSVal(); MeExpr *base = ivarMeExpr->GetBase(); @@ -441,10 +441,10 @@ bool SeqVectorize::IsIvarExprConsecutiveMem(IvarMeExpr *ivar1, IvarMeExpr *ivar2 } bool SeqVectorize::CanSeqVec(IassignNode *s1, IassignNode *s2) { - LfoPart *lfoP1 = (*lfoStmtParts)[s1->GetStmtID()]; + PreMeMIRExtension *lfoP1 = (*PreMeStmtExtensionMap)[s1->GetStmtID()]; IassignMeStmt *iassMeStmt1 = static_cast(lfoP1->GetMeStmt()); IvarMeExpr *lhsMeExpr1 = iassMeStmt1->GetLHSVal(); - LfoPart *lfoP2 = (*lfoStmtParts)[s2->GetStmtID()]; + PreMeMIRExtension *lfoP2 = (*PreMeStmtExtensionMap)[s2->GetStmtID()]; IassignMeStmt *iassMeStmt2 = static_cast(lfoP2->GetMeStmt()); IvarMeExpr *lhsMeExpr2 = iassMeStmt2->GetLHSVal(); MIRType &mirType = GetTypeFromTyIdx(s1->GetTyIdx()); @@ -488,7 +488,7 @@ void SeqVectorize::MergeIassigns(MapleVector &cands) { MIRType *pvecType = GlobalTables::GetTypeTable().GetOrCreatePointerType(*vecType, PTY_ptr); iassign->SetTyIdx(pvecType->GetTypeIndex()); - LfoPart *lfoP = (*lfoStmtParts)[iassign->GetStmtID()]; + PreMeMIRExtension *lfoP = (*PreMeStmtExtensionMap)[iassign->GetStmtID()]; BaseNode *parent = lfoP->GetParent(); CHECK_FATAL(parent && parent->GetOpCode() == OP_block, "unexpect parent type"); BlockNode *blockParent = static_cast(parent); diff --git a/src/mapleall/maple_phase/include/phases.def b/src/mapleall/maple_phase/include/phases.def index 4045527e72..a257834eba 100644 --- a/src/mapleall/maple_phase/include/phases.def +++ b/src/mapleall/maple_phase/include/phases.def @@ -36,7 +36,7 @@ ADDMAPLEMEPHASE("irmapbuild", CLANG && MeOption::optLevel >= 3) ADDMAPLEMEPHASE("ivcanon", CLANG && MeOption::optLevel >= 3) ADDMAPLEMEPHASE("hprop", CLANG && MeOption::optLevel >= 3) ADDMAPLEMEPHASE("hdse", CLANG && MeOption::optLevel >= 3) -ADDMAPLEMEPHASE("lfopreemit", CLANG && MeOption::optLevel >= 3) +ADDMAPLEMEPHASE("premeemit", CLANG && MeOption::optLevel >= 3) ADDMAPLEMEPHASE("deptest", CLANG && MeOption::optLevel >= 3) ADDMAPLEMEPHASE("autovec", CLANG && MeOption::optLevel >= 3) ADDMAPLEMEPHASE("lfounroll", CLANG && MeOption::optLevel >= 3) -- Gitee