diff --git a/src/BUILD.gn b/src/BUILD.gn index 329c86e775bc6ee8ee1676bccb9c4876de677d69..6403e41afb00a8c86becc75e0a6b04cfc5338662 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -17,6 +17,7 @@ config("mapleallcompilecfg") { cflags_cc += [ "-std=c++14", "-Werror", + "-DTARGAARCH64", ] if (GN_BUILD_TYPE == "DEBUG") { diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index 67487ccb3ad3f68e5bca7c212bc9e44e21081265..08574f1cc75e2325c1e041dbc68ddea59d9052cd 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index 96b6d0b42c654e05304de5ff8633fa34f92781b7..bf36b16beff6c70e3dc45a68daa15ef2586a5f7f 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/deplibs/libmplphase.a b/src/deplibs/libmplphase.a index 1af676b0f7d2bb15f08d3d89ccbc79b4317d1998..d98a9bb6defcfa1ed8d7cda606caec939ec40bf7 100644 Binary files a/src/deplibs/libmplphase.a and b/src/deplibs/libmplphase.a differ diff --git a/src/deplibs/libmplutil.a b/src/deplibs/libmplutil.a index 8689ac831edd35563952ded02797f38a6fa1fce5..aa25a671ba6a7204a0258d076428a06fa265c7a4 100644 Binary files a/src/deplibs/libmplutil.a and b/src/deplibs/libmplutil.a differ diff --git a/src/maple_be/include/ad/mad.h b/src/maple_be/include/ad/mad.h index d8cba355e1b78ca3db681e6060fc35d6bb52fa67..e86f00483dc1624c95cb1d2e5051382c4d3b3a51 100644 --- a/src/maple_be/include/ad/mad.h +++ b/src/maple_be/include/ad/mad.h @@ -173,7 +173,7 @@ class MAD { Reservation *FindReservation(const Insn &insn) const; void AdvanceCycle(); void ReleaseAllUnits(); - void SaveStates(std::vector &occupyTable, int size); + void SaveStates(std::vector &occupyTable, int size) const; void RestoreStates(std::vector &occupyTable, int size); int GetMaxParallelism() const { diff --git a/src/maple_be/include/ad/target/mplad_reservation_define.def b/src/maple_be/include/ad/target/mplad_reservation_define.def index d0591b70162898690b676c83d7c75bce201c0b95..a327e79c13bfa9545ac9139e2467efa2ffbc347f 100644 --- a/src/maple_be/include/ad/target/mplad_reservation_define.def +++ b/src/maple_be/include/ad/target/mplad_reservation_define.def @@ -1,14 +1,14 @@ /* cortex_a55 reservations definition : */ Reservation *resvInstkLtUndef = new Reservation(kLtUndef, 0, 0); if(resvInstkLtUndef == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtUndef failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtUndef failed." << std::endl; } ASSERT(resvInstkLtUndef, "Reservation allocation for kLtUndef failed."); Reservation *resvInstkLtShift = new Reservation(kLtShift, 2, 1, GetUnitByUnitId(kUnitIdSlotS)); if(resvInstkLtShift == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtShift failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtShift failed." << std::endl; } ASSERT(resvInstkLtShift, "Reservation allocation for kLtShift failed."); @@ -16,21 +16,21 @@ Reservation *resvInstkLtShiftReg = new Reservation(kLtShiftReg, 2, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdHazard)); if(resvInstkLtShiftReg == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtShiftReg failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtShiftReg failed." << std::endl; } ASSERT(resvInstkLtShiftReg, "Reservation allocation for kLtShiftReg failed."); Reservation *resvInstkLtAlu = new Reservation(kLtAlu, 3, 1, GetUnitByUnitId(kUnitIdSlotS)); if(resvInstkLtAlu == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAlu failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAlu failed." << std::endl; } ASSERT(resvInstkLtAlu, "Reservation allocation for kLtAlu failed."); Reservation *resvInstkLtAluShift = new Reservation(kLtAluShift, 3, 1, GetUnitByUnitId(kUnitIdSlotS)); if(resvInstkLtAluShift == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAluShift failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAluShift failed." << std::endl; } ASSERT(resvInstkLtAluShift, "Reservation allocation for kLtAluShift failed."); @@ -38,14 +38,14 @@ Reservation *resvInstkLtAluShiftReg = new Reservation(kLtAluShiftReg, 3, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdHazard)); if(resvInstkLtAluShiftReg == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAluShiftReg failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAluShiftReg failed." << std::endl; } ASSERT(resvInstkLtAluShiftReg, "Reservation allocation for kLtAluShiftReg failed."); Reservation *resvInstkLtAluExtr = new Reservation(kLtAluExtr, 3, 1, GetUnitByUnitId(kUnitIdSlot1)); if(resvInstkLtAluExtr == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAluExtr failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAluExtr failed." << std::endl; } ASSERT(resvInstkLtAluExtr, "Reservation allocation for kLtAluExtr failed."); @@ -53,7 +53,7 @@ Reservation *resvInstkLtMul = new Reservation(kLtMul, 4, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdMul)); if(resvInstkLtMul == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtMul failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtMul failed." << std::endl; } ASSERT(resvInstkLtMul, "Reservation allocation for kLtMul failed."); @@ -62,7 +62,7 @@ Reservation *resvInstkLtDiv = new Reservation(kLtDiv, 4, 3, GetUnitByUnitId(kUnitIdDiv), GetUnitByUnitId(kUnitIdDiv)); if(resvInstkLtDiv == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtDiv failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtDiv failed." << std::endl; } ASSERT(resvInstkLtDiv, "Reservation allocation for kLtDiv failed."); @@ -70,7 +70,7 @@ Reservation *resvInstkLtLoad1 = new Reservation(kLtLoad1, 4, 2, GetUnitByUnitId(kUnitIdSlotSAgen), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtLoad1 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtLoad1 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtLoad1 failed." << std::endl; } ASSERT(resvInstkLtLoad1, "Reservation allocation for kLtLoad1 failed."); @@ -78,7 +78,7 @@ Reservation *resvInstkLtStore1 = new Reservation(kLtStore1, 2, 2, GetUnitByUnitId(kUnitIdSlotSAgen), GetUnitByUnitId(kUnitIdStAgu)); if(resvInstkLtStore1 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtStore1 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtStore1 failed." << std::endl; } ASSERT(resvInstkLtStore1, "Reservation allocation for kLtStore1 failed."); @@ -87,7 +87,7 @@ Reservation *resvInstkLtLoad2 = new Reservation(kLtLoad2, 4, 3, GetUnitByUnitId(kUnitIdSlot0LdAgu), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtLoad2 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtLoad2 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtLoad2 failed." << std::endl; } ASSERT(resvInstkLtLoad2, "Reservation allocation for kLtLoad2 failed."); @@ -95,7 +95,7 @@ Reservation *resvInstkLtStore2 = new Reservation(kLtStore2, 2, 2, GetUnitByUnitId(kUnitIdSlotSAgen), GetUnitByUnitId(kUnitIdStAgu)); if(resvInstkLtStore2 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtStore2 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtStore2 failed." << std::endl; } ASSERT(resvInstkLtStore2, "Reservation allocation for kLtStore2 failed."); @@ -104,7 +104,7 @@ Reservation *resvInstkLtLoad3plus = new Reservation(kLtLoad3plus, 6, 3, GetUnitByUnitId(kUnitIdSlot0LdAgu), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtLoad3plus == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtLoad3plus failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtLoad3plus failed." << std::endl; } ASSERT(resvInstkLtLoad3plus, "Reservation allocation for kLtLoad3plus failed."); @@ -113,14 +113,14 @@ Reservation *resvInstkLtStore3plus = new Reservation(kLtStore3plus, 2, 3, GetUnitByUnitId(kUnitIdSlot0StAgu), GetUnitByUnitId(kUnitIdStAgu)); if(resvInstkLtStore3plus == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtStore3plus failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtStore3plus failed." << std::endl; } ASSERT(resvInstkLtStore3plus, "Reservation allocation for kLtStore3plus failed."); Reservation *resvInstkLtBranch = new Reservation(kLtBranch, 0, 1, GetUnitByUnitId(kUnitIdSlotSBranch)); if(resvInstkLtBranch == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtBranch failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtBranch failed." << std::endl; } ASSERT(resvInstkLtBranch, "Reservation allocation for kLtBranch failed."); @@ -128,7 +128,7 @@ Reservation *resvInstkLtFpalu = new Reservation(kLtFpalu, 4, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtFpalu == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFpalu failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFpalu failed." << std::endl; } ASSERT(resvInstkLtFpalu, "Reservation allocation for kLtFpalu failed."); @@ -136,7 +136,7 @@ Reservation *resvInstkLtFconst = new Reservation(kLtFconst, 2, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtFconst == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFconst failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFconst failed." << std::endl; } ASSERT(resvInstkLtFconst, "Reservation allocation for kLtFconst failed."); @@ -144,7 +144,7 @@ Reservation *resvInstkLtFpmul = new Reservation(kLtFpmul, 4, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpMulS)); if(resvInstkLtFpmul == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFpmul failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFpmul failed." << std::endl; } ASSERT(resvInstkLtFpmul, "Reservation allocation for kLtFpmul failed."); @@ -156,7 +156,7 @@ Reservation *resvInstkLtFpmac = new Reservation(kLtFpmac, 8, 6, nullptr, GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtFpmac == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFpmac failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFpmac failed." << std::endl; } ASSERT(resvInstkLtFpmac, "Reservation allocation for kLtFpmac failed."); @@ -164,7 +164,7 @@ Reservation *resvInstkLtR2f = new Reservation(kLtR2f, 2, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtR2f == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtR2f failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtR2f failed." << std::endl; } ASSERT(resvInstkLtR2f, "Reservation allocation for kLtR2f failed."); @@ -172,7 +172,7 @@ Reservation *resvInstkLtF2r = new Reservation(kLtF2r, 4, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtF2r == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtF2r failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtF2r failed." << std::endl; } ASSERT(resvInstkLtF2r, "Reservation allocation for kLtF2r failed."); @@ -180,7 +180,7 @@ Reservation *resvInstkLtR2fCvt = new Reservation(kLtR2fCvt, 4, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtR2fCvt == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtR2fCvt failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtR2fCvt failed." << std::endl; } ASSERT(resvInstkLtR2fCvt, "Reservation allocation for kLtR2fCvt failed."); @@ -188,14 +188,14 @@ Reservation *resvInstkLtF2rCvt = new Reservation(kLtF2rCvt, 5, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtF2rCvt == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtF2rCvt failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtF2rCvt failed." << std::endl; } ASSERT(resvInstkLtF2rCvt, "Reservation allocation for kLtF2rCvt failed."); Reservation *resvInstkLtFFlags = new Reservation(kLtFFlags, 5, 1, GetUnitByUnitId(kUnitIdSlotS)); if(resvInstkLtFFlags == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFFlags failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFFlags failed." << std::endl; } ASSERT(resvInstkLtFFlags, "Reservation allocation for kLtFFlags failed."); @@ -203,7 +203,7 @@ Reservation *resvInstkLtFLoad64 = new Reservation(kLtFLoad64, 3, 2, GetUnitByUnitId(kUnitIdSlotSAgen), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtFLoad64 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFLoad64 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFLoad64 failed." << std::endl; } ASSERT(resvInstkLtFLoad64, "Reservation allocation for kLtFLoad64 failed."); @@ -212,7 +212,7 @@ Reservation *resvInstkLtFLoadMany = new Reservation(kLtFLoadMany, 4, 3, GetUnitByUnitId(kUnitIdSlot0LdAgu), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtFLoadMany == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFLoadMany failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFLoadMany failed." << std::endl; } ASSERT(resvInstkLtFLoadMany, "Reservation allocation for kLtFLoadMany failed."); @@ -220,7 +220,7 @@ Reservation *resvInstkLtFStore64 = new Reservation(kLtFStore64, 0, 2, GetUnitByUnitId(kUnitIdSlotSAgen), GetUnitByUnitId(kUnitIdStAgu)); if(resvInstkLtFStore64 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFStore64 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFStore64 failed." << std::endl; } ASSERT(resvInstkLtFStore64, "Reservation allocation for kLtFStore64 failed."); @@ -229,7 +229,7 @@ Reservation *resvInstkLtFStoreMany = new Reservation(kLtFStoreMany, 0, 3, GetUnitByUnitId(kUnitIdSlot0StAgu), GetUnitByUnitId(kUnitIdStAgu)); if(resvInstkLtFStoreMany == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFStoreMany failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtFStoreMany failed." << std::endl; } ASSERT(resvInstkLtFStoreMany, "Reservation allocation for kLtFStoreMany failed."); @@ -237,7 +237,7 @@ Reservation *resvInstkLtAdvsimdAlu = new Reservation(kLtAdvsimdAlu, 4, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpAluS)); if(resvInstkLtAdvsimdAlu == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdAlu failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdAlu failed." << std::endl; } ASSERT(resvInstkLtAdvsimdAlu, "Reservation allocation for kLtAdvsimdAlu failed."); @@ -245,7 +245,7 @@ Reservation *resvInstkLtAdvsimdAluQ = new Reservation(kLtAdvsimdAluQ, 4, 2, GetUnitByUnitId(kUnitIdSlot0), GetUnitByUnitId(kUnitIdFpAluD)); if(resvInstkLtAdvsimdAluQ == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdAluQ failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdAluQ failed." << std::endl; } ASSERT(resvInstkLtAdvsimdAluQ, "Reservation allocation for kLtAdvsimdAluQ failed."); @@ -253,7 +253,7 @@ Reservation *resvInstkLtAdvsimdMul = new Reservation(kLtAdvsimdMul, 4, 2, GetUnitByUnitId(kUnitIdSlotS), GetUnitByUnitId(kUnitIdFpMulS)); if(resvInstkLtAdvsimdMul == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdMul failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdMul failed." << std::endl; } ASSERT(resvInstkLtAdvsimdMul, "Reservation allocation for kLtAdvsimdMul failed."); @@ -261,7 +261,7 @@ Reservation *resvInstkLtAdvsimdMulQ = new Reservation(kLtAdvsimdMulQ, 4, 2, GetUnitByUnitId(kUnitIdSlot0), GetUnitByUnitId(kUnitIdFpMulD)); if(resvInstkLtAdvsimdMulQ == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdMulQ failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdMulQ failed." << std::endl; } ASSERT(resvInstkLtAdvsimdMulQ, "Reservation allocation for kLtAdvsimdMulQ failed."); @@ -270,7 +270,7 @@ Reservation *resvInstkLtAdvsimdDivS = new Reservation(kLtAdvsimdDivS, 14, 3, GetUnitByUnitId(kUnitIdFpMulS), GetUnitByUnitId(kUnitIdFpDivS)); if(resvInstkLtAdvsimdDivS == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivS failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivS failed." << std::endl; } ASSERT(resvInstkLtAdvsimdDivS, "Reservation allocation for kLtAdvsimdDivS failed."); @@ -279,7 +279,7 @@ Reservation *resvInstkLtAdvsimdDivD = new Reservation(kLtAdvsimdDivD, 29, 3, GetUnitByUnitId(kUnitIdFpMulS), GetUnitByUnitId(kUnitIdFpDivS)); if(resvInstkLtAdvsimdDivD == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivD failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivD failed." << std::endl; } ASSERT(resvInstkLtAdvsimdDivD, "Reservation allocation for kLtAdvsimdDivD failed."); @@ -288,7 +288,7 @@ Reservation *resvInstkLtAdvsimdDivSQ = new Reservation(kLtAdvsimdDivSQ, 14, 3, GetUnitByUnitId(kUnitIdFpMulD), GetUnitByUnitId(kUnitIdFpDivD)); if(resvInstkLtAdvsimdDivSQ == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivSQ failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivSQ failed." << std::endl; } ASSERT(resvInstkLtAdvsimdDivSQ, "Reservation allocation for kLtAdvsimdDivSQ failed."); @@ -297,21 +297,21 @@ Reservation *resvInstkLtAdvsimdDivdQ = new Reservation(kLtAdvsimdDivdQ, 29, 3, GetUnitByUnitId(kUnitIdFpMulD), GetUnitByUnitId(kUnitIdFpDivD)); if(resvInstkLtAdvsimdDivdQ == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivdQ failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdvsimdDivdQ failed." << std::endl; } ASSERT(resvInstkLtAdvsimdDivdQ, "Reservation allocation for kLtAdvsimdDivdQ failed."); Reservation *resvInstkLtCryptoAese = new Reservation(kLtCryptoAese, 3, 1, GetUnitByUnitId(kUnitIdSlot0)); if(resvInstkLtCryptoAese == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtCryptoAese failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtCryptoAese failed." << std::endl; } ASSERT(resvInstkLtCryptoAese, "Reservation allocation for kLtCryptoAese failed."); Reservation *resvInstkLtCryptoAesmc = new Reservation(kLtCryptoAesmc, 3, 1, GetUnitByUnitId(kUnitIdSlotS)); if(resvInstkLtCryptoAesmc == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtCryptoAesmc failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtCryptoAesmc failed." << std::endl; } ASSERT(resvInstkLtCryptoAesmc, "Reservation allocation for kLtCryptoAesmc failed."); @@ -330,7 +330,7 @@ Reservation *resvInstkLtClinit = new Reservation(kLtClinit, 14, 13, GetUnitByUnitId(kUnitIdSlot0LdAgu), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtClinit == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtClinit failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtClinit failed." << std::endl; } ASSERT(resvInstkLtClinit, "Reservation allocation for kLtClinit failed."); @@ -341,7 +341,7 @@ Reservation *resvInstkLtAdrpLdr = new Reservation(kLtAdrpLdr, 6, 5, GetUnitByUnitId(kUnitIdSlot0LdAgu), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtAdrpLdr == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdrpLdr failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtAdrpLdr failed." << std::endl; } ASSERT(resvInstkLtAdrpLdr, "Reservation allocation for kLtAdrpLdr failed."); @@ -354,7 +354,7 @@ Reservation *resvInstkLtClinitTail = new Reservation(kLtClinitTail, 8, 7, GetUnitByUnitId(kUnitIdSlot0LdAgu), GetUnitByUnitId(kUnitIdLdAgu)); if(resvInstkLtClinitTail == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Reservation allocation for kLtClinitTail failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Reservation allocation for kLtClinitTail failed." << std::endl; } ASSERT(resvInstkLtClinitTail, "Reservation allocation for kLtClinitTail failed."); diff --git a/src/maple_be/include/ad/target/mplad_unit_define.def b/src/maple_be/include/ad/target/mplad_unit_define.def index 3c8e9157e508c997b58007252e87efcb87d46a9d..62233a365dbda980ad1d6e6ee2377a58931e61b3 100644 --- a/src/maple_be/include/ad/target/mplad_unit_define.def +++ b/src/maple_be/include/ad/target/mplad_unit_define.def @@ -3,202 +3,202 @@ const unsigned int kunitNum = 2; Unit *instancekUnitIdSlot0 = new Unit(kUnitIdSlot0); if(instancekUnitIdSlot0 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot0 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot0 failed." << std::endl; } ASSERT(instancekUnitIdSlot0, "Unit allocation for kUnitIdSlot0 failed."); Unit *instancekUnitIdSlot1 = new Unit(kUnitIdSlot1); if(instancekUnitIdSlot1 == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot1 failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot1 failed." << std::endl; } ASSERT(instancekUnitIdSlot1, "Unit allocation for kUnitIdSlot1 failed."); Unit *instancekUnitIdAgen = new Unit(kUnitIdAgen); if(instancekUnitIdAgen == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdAgen failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdAgen failed." << std::endl; } ASSERT(instancekUnitIdAgen, "Unit allocation for kUnitIdAgen failed."); Unit *instancekUnitIdHazard = new Unit(kUnitIdHazard); if(instancekUnitIdHazard == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdHazard failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdHazard failed." << std::endl; } ASSERT(instancekUnitIdHazard, "Unit allocation for kUnitIdHazard failed."); Unit *instancekUnitIdCrypto = new Unit(kUnitIdCrypto); if(instancekUnitIdCrypto == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdCrypto failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdCrypto failed." << std::endl; } ASSERT(instancekUnitIdCrypto, "Unit allocation for kUnitIdCrypto failed."); Unit *instancekUnitIdMul = new Unit(kUnitIdMul); if(instancekUnitIdMul == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdMul failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdMul failed." << std::endl; } ASSERT(instancekUnitIdMul, "Unit allocation for kUnitIdMul failed."); Unit *instancekUnitIdDiv = new Unit(kUnitIdDiv); if(instancekUnitIdDiv == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdDiv failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdDiv failed." << std::endl; } ASSERT(instancekUnitIdDiv, "Unit allocation for kUnitIdDiv failed."); Unit *instancekUnitIdBranch = new Unit(kUnitIdBranch); if(instancekUnitIdBranch == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdBranch failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdBranch failed." << std::endl; } ASSERT(instancekUnitIdBranch, "Unit allocation for kUnitIdBranch failed."); Unit *instancekUnitIdStAgu = new Unit(kUnitIdStAgu); if(instancekUnitIdStAgu == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdStAgu failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdStAgu failed." << std::endl; } ASSERT(instancekUnitIdStAgu, "Unit allocation for kUnitIdStAgu failed."); Unit *instancekUnitIdLdAgu = new Unit(kUnitIdLdAgu); if(instancekUnitIdLdAgu == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdLdAgu failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdLdAgu failed." << std::endl; } ASSERT(instancekUnitIdLdAgu, "Unit allocation for kUnitIdLdAgu failed."); Unit *instancekUnitIdFpAluLo = new Unit(kUnitIdFpAluLo); if(instancekUnitIdFpAluLo == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluLo failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluLo failed." << std::endl; } ASSERT(instancekUnitIdFpAluLo, "Unit allocation for kUnitIdFpAluLo failed."); Unit *instancekUnitIdFpAluHi = new Unit(kUnitIdFpAluHi); if(instancekUnitIdFpAluHi == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluHi failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluHi failed." << std::endl; } ASSERT(instancekUnitIdFpAluHi, "Unit allocation for kUnitIdFpAluHi failed."); Unit *instancekUnitIdFpMulLo = new Unit(kUnitIdFpMulLo); if(instancekUnitIdFpMulLo == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulLo failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulLo failed." << std::endl; } ASSERT(instancekUnitIdFpMulLo, "Unit allocation for kUnitIdFpMulLo failed."); Unit *instancekUnitIdFpMulHi = new Unit(kUnitIdFpMulHi); if(instancekUnitIdFpMulHi == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulHi failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulHi failed." << std::endl; } ASSERT(instancekUnitIdFpMulHi, "Unit allocation for kUnitIdFpMulHi failed."); Unit *instancekUnitIdFpDivLo = new Unit(kUnitIdFpDivLo); if(instancekUnitIdFpDivLo == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivLo failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivLo failed." << std::endl; } ASSERT(instancekUnitIdFpDivLo, "Unit allocation for kUnitIdFpDivLo failed."); Unit *instancekUnitIdFpDivHi = new Unit(kUnitIdFpDivHi); if(instancekUnitIdFpDivHi == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivHi failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivHi failed." << std::endl; } ASSERT(instancekUnitIdFpDivHi, "Unit allocation for kUnitIdFpDivHi failed."); Unit *instancekUnitIdSlotS = new Unit(kUnitTypeOr, kUnitIdSlotS, kunitNum, instancekUnitIdSlot0, instancekUnitIdSlot1); if(instancekUnitIdSlotS == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotS failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotS failed." << std::endl; } ASSERT(instancekUnitIdSlotS, "Unit allocation for kUnitIdSlotS failed."); Unit *instancekUnitIdFpAluS = new Unit(kUnitTypeOr, kUnitIdFpAluS, kunitNum, instancekUnitIdFpAluLo, instancekUnitIdFpAluHi); if(instancekUnitIdFpAluS == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluS failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluS failed." << std::endl; } ASSERT(instancekUnitIdFpAluS, "Unit allocation for kUnitIdFpAluS failed."); Unit *instancekUnitIdFpMulS = new Unit(kUnitTypeOr, kUnitIdFpMulS, kunitNum, instancekUnitIdFpMulLo, instancekUnitIdFpMulHi); if(instancekUnitIdFpMulS == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulS failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulS failed." << std::endl; } ASSERT(instancekUnitIdFpMulS, "Unit allocation for kUnitIdFpMulS failed."); Unit *instancekUnitIdFpDivS = new Unit(kUnitTypeOr, kUnitIdFpDivS, kunitNum, instancekUnitIdFpDivLo, instancekUnitIdFpDivHi); if(instancekUnitIdFpDivS == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivS failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivS failed." << std::endl; } ASSERT(instancekUnitIdFpDivS, "Unit allocation for kUnitIdFpDivS failed."); Unit *instancekUnitIdSlotD = new Unit(kUnitTypeAnd, kUnitIdSlotD, kunitNum, instancekUnitIdSlot0, instancekUnitIdSlot1); if(instancekUnitIdSlotD == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotD failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotD failed." << std::endl; } ASSERT(instancekUnitIdSlotD, "Unit allocation for kUnitIdSlotD failed."); Unit *instancekUnitIdFpAluD = new Unit(kUnitTypeAnd, kUnitIdFpAluD, kunitNum, instancekUnitIdFpAluLo, instancekUnitIdFpAluHi); if(instancekUnitIdFpAluD == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluD failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpAluD failed." << std::endl; } ASSERT(instancekUnitIdFpAluD, "Unit allocation for kUnitIdFpAluD failed."); Unit *instancekUnitIdFpMulD = new Unit(kUnitTypeAnd, kUnitIdFpMulD, kunitNum, instancekUnitIdFpMulLo, instancekUnitIdFpMulHi); if(instancekUnitIdFpMulD == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulD failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpMulD failed." << std::endl; } ASSERT(instancekUnitIdFpMulD, "Unit allocation for kUnitIdFpMulD failed."); Unit *instancekUnitIdFpDivD = new Unit(kUnitTypeAnd, kUnitIdFpDivD, kunitNum, instancekUnitIdFpDivLo, instancekUnitIdFpDivHi); if(instancekUnitIdFpDivD == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivD failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdFpDivD failed." << std::endl; } ASSERT(instancekUnitIdFpDivD, "Unit allocation for kUnitIdFpDivD failed."); Unit *instancekUnitIdSlotSHazard = new Unit(kUnitTypeAnd, kUnitIdSlotSHazard, kunitNum, instancekUnitIdSlotS, instancekUnitIdHazard); if(instancekUnitIdSlotSHazard == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSHazard failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSHazard failed." << std::endl; } ASSERT(instancekUnitIdSlotSHazard, "Unit allocation for kUnitIdSlotSHazard failed."); Unit *instancekUnitIdSlotSMul = new Unit(kUnitTypeAnd, kUnitIdSlotSMul, kunitNum, instancekUnitIdSlotS, instancekUnitIdMul); if(instancekUnitIdSlotSMul == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSMul failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSMul failed." << std::endl; } ASSERT(instancekUnitIdSlotSMul, "Unit allocation for kUnitIdSlotSMul failed."); Unit *instancekUnitIdSlotSBranch = new Unit(kUnitTypeAnd, kUnitIdSlotSBranch, kunitNum, instancekUnitIdSlotS, instancekUnitIdBranch); if(instancekUnitIdSlotSBranch == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSBranch failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSBranch failed." << std::endl; } ASSERT(instancekUnitIdSlotSBranch, "Unit allocation for kUnitIdSlotSBranch failed."); Unit *instancekUnitIdSlotSAgen = new Unit(kUnitTypeAnd, kUnitIdSlotSAgen, kunitNum, instancekUnitIdSlotS, instancekUnitIdAgen); if(instancekUnitIdSlotSAgen == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSAgen failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotSAgen failed." << std::endl; } ASSERT(instancekUnitIdSlotSAgen, "Unit allocation for kUnitIdSlotSAgen failed."); Unit *instancekUnitIdSlotDAgen = new Unit(kUnitTypeAnd, kUnitIdSlotDAgen, kunitNum, instancekUnitIdSlot0, instancekUnitIdSlot1, instancekUnitIdAgen); if(instancekUnitIdSlotDAgen == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotDAgen failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlotDAgen failed." << std::endl; } ASSERT(instancekUnitIdSlotDAgen, "Unit allocation for kUnitIdSlotDAgen failed."); Unit *instancekUnitIdSlot0LdAgu = new Unit(kUnitTypeAnd, kUnitIdSlot0LdAgu, kunitNum, instancekUnitIdSlot0, instancekUnitIdLdAgu); if(instancekUnitIdSlot0LdAgu == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot0LdAgu failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot0LdAgu failed." << std::endl; } ASSERT(instancekUnitIdSlot0LdAgu, "Unit allocation for kUnitIdSlot0LdAgu failed."); Unit *instancekUnitIdSlot0StAgu = new Unit(kUnitTypeAnd, kUnitIdSlot0StAgu, kunitNum, instancekUnitIdSlot0, instancekUnitIdStAgu); if(instancekUnitIdSlot0StAgu == nullptr) { - maple::logInfo.MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot0StAgu failed." << std::endl; + maple::LogInfo::MapleLogger(maple::kLlErr) << "Unit allocation for kUnitIdSlot0StAgu failed." << std::endl; } ASSERT(instancekUnitIdSlot0StAgu, "Unit allocation for kUnitIdSlot0StAgu failed."); diff --git a/src/maple_be/include/cg/aarch64/aarch64_cgfunc.h b/src/maple_be/include/cg/aarch64/aarch64_cgfunc.h index 07c52802632e6efc6e90a1579be4b7672996f4ec..c99eb86470a5e9b90d0c9c9b310d12fe4ca2462f 100644 --- a/src/maple_be/include/cg/aarch64/aarch64_cgfunc.h +++ b/src/maple_be/include/cg/aarch64/aarch64_cgfunc.h @@ -187,7 +187,7 @@ class AArch64CGFunc : public CGFunc { Operand *SelectGCMalloc(GCMallocNode &call) override; Operand *SelectJarrayMalloc(JarrayMallocNode &call, Operand &opnd0) override; void SelectSelect(Operand &resOpnd, Operand &condOpnd, Operand &trueOpnd, Operand &falseOpnd, PrimType dtype, - PrimType ctype) override; + PrimType ctype); void SelectAArch64Select(Operand &dest, Operand &opnd0, Operand &opnd1, CondOperand &cond, bool isIntType, uint32 is64bits); void SelectRangeGoto(RangeGotoNode &rangeGotoNode, Operand &opnd0) override; diff --git a/src/maple_be/include/cg/cgfunc.h b/src/maple_be/include/cg/cgfunc.h index 2ca42537c464a843448626063e3e654b4a07f696..4d898fc01da99ab32d656004dca05ce75432d7a9 100644 --- a/src/maple_be/include/cg/cgfunc.h +++ b/src/maple_be/include/cg/cgfunc.h @@ -214,8 +214,6 @@ class CGFunc { virtual Operand *SelectAlloca(UnaryNode &call, Operand &opnd0) = 0; virtual Operand *SelectGCMalloc(GCMallocNode &call) = 0; virtual Operand *SelectJarrayMalloc(JarrayMallocNode &call, Operand &opnd0) = 0; - virtual void SelectSelect(Operand &resOpnd, Operand &condOpnd, Operand &trueOpnd, Operand &falseOpnd, - PrimType dstType, PrimType primType) = 0; virtual void SelectRangeGoto(RangeGotoNode &rangeGotoNode, Operand &opnd0) = 0; virtual Operand *SelectLazyLoad(Operand &opnd0, PrimType primType) = 0; virtual Operand *SelectLazyLoadStatic(MIRSymbol &st, int64 offset, PrimType primType) = 0; @@ -246,6 +244,9 @@ class CGFunc { virtual void ClearUnreachableGotInfos(BB &bb) { (void)bb; }; + virtual void ClearUnreachableConstInfos(BB &bb) { + (void)bb; + }; virtual void SplitStrLdrPair() {} LabelIdx CreateLabel(); diff --git a/src/maple_be/mdgen/src/mdgenerator.cpp b/src/maple_be/mdgen/src/mdgenerator.cpp index 05781b805dd339e6659e4950cc177a161d60a03b..b79faea0cd9aac825d5464ce5ec5b6fd41fd3470 100644 --- a/src/maple_be/mdgen/src/mdgenerator.cpp +++ b/src/maple_be/mdgen/src/mdgenerator.cpp @@ -25,7 +25,7 @@ std::string MDCodeGen::targetArchName = ""; void MDCodeGen::EmitCheckPtr(std::ofstream &outputFile, const std::string &emitName, const std::string &name, const std::string &ptrType) { outputFile << "if(" << emitName << " == nullptr) {\n" << - " maple::logInfo.MapleLogger(maple::kLlErr) << \"" << ptrType << " allocation for " << name << + " maple::LogInfo::MapleLogger(maple::kLlErr) << \"" << ptrType << " allocation for " << name << " failed.\" << std::endl;\n" << "}\n" << "ASSERT(" << emitName << ", \"" << ptrType << " allocation for " << name << " failed.\");\n" << "\n"; diff --git a/src/maple_be/src/ad/mad.cpp b/src/maple_be/src/ad/mad.cpp index 5fa2149ede69b1b8ed0fadcdb3565f7bdd953898..ade0934edd5bac2bdd925ac3d5bd6072ba2dfec5 100644 --- a/src/maple_be/src/ad/mad.cpp +++ b/src/maple_be/src/ad/mad.cpp @@ -202,7 +202,7 @@ void MAD::ReleaseAllUnits() { } } -void MAD::SaveStates(std::vector &occupyTable, int size) { +void MAD::SaveStates(std::vector &occupyTable, int size) const { int i = 0; for (auto unit : allUnits) { CHECK_FATAL(i < size, "unit number error"); diff --git a/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 74f8bc7c6c6c86fdb7ee3a1c67cd038c23bdc22d..496b78e81e594025806876d38b0bd81223e050bd 100644 --- a/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -1098,7 +1098,7 @@ void AArch64CGFunc::SelectIassign(IassignNode &stmt) { } } if (pointedType->GetPrimType() == PTY_agg) { - maple::logInfo.MapleLogger(kLlErr) << "Error: cannot find field in " << + maple::LogInfo::MapleLogger(kLlErr) << "Error: cannot find field in " << GlobalTables::GetStrTable().GetStringFromStrIdx(pointedType->GetNameStrIdx()) << '\n'; exit(-1); } @@ -1333,7 +1333,7 @@ void AArch64CGFunc::SelectAddrof(Operand &result, StImmOperand &stImm) { const MIRSymbol *symbol = stImm.GetSymbol(); if ((symbol->GetStorageClass() == kScAuto) || (symbol->GetStorageClass() == kScFormal)) { if (!GetCG()->IsQuiet()) { - maple::logInfo.MapleLogger(kLlErr) << + maple::LogInfo::MapleLogger(kLlErr) << "Warning: we expect AddrOf with StImmOperand is not used for local variables"; } AArch64SymbolAlloc *symLoc = @@ -1469,7 +1469,7 @@ Operand *AArch64CGFunc::SelectIread(const BaseNode &parent, IreadNode &expr) { } } if (pointedType->GetPrimType() == PTY_agg) { - maple::logInfo.MapleLogger(kLlErr) << "Error: cannot find field in " << + maple::LogInfo::MapleLogger(kLlErr) << "Error: cannot find field in " << GlobalTables::GetStrTable().GetStringFromStrIdx(pointedType->GetNameStrIdx()) << '\n'; CHECK_FATAL(false, "cannot find field"); return nullptr; @@ -1497,7 +1497,7 @@ Operand *AArch64CGFunc::SelectIread(const BaseNode &parent, IreadNode &expr) { if ((pointedType->GetKind() == kTypeStructIncomplete) || (pointedType->GetKind() == kTypeClassIncomplete) || (pointedType->GetKind() == kTypeInterfaceIncomplete)) { bitSize = GetPrimTypeBitSize(expr.GetPrimType()); - maple::logInfo.MapleLogger(kLlErr) << "Warning: objsize is zero! \n"; + maple::LogInfo::MapleLogger(kLlErr) << "Warning: objsize is zero! \n"; } else { if (pointedType->IsStructType()) { MIRStructType *structType = static_cast(pointedType); @@ -4604,7 +4604,7 @@ Operand *AArch64CGFunc::SelectClearStackCallParam(const AddrofNode &expr, int64 Operand &result = CreateVirtualRegisterOperand(vRegNO); CHECK_FATAL(expr.GetFieldID() == 0, "the fieldID of parameter in clear stack reference call must be 0"); if (!GetCG()->IsQuiet()) { - maple::logInfo.MapleLogger(kLlErr) << + maple::LogInfo::MapleLogger(kLlErr) << "Warning: we expect AddrOf with StImmOperand is not used for local variables"; } auto *symLoc = static_cast(GetMemlayout()->GetSymAllocInfo(symbol->GetStIndex())); @@ -5959,7 +5959,7 @@ void AArch64CGFunc::SelectMPLProfCounterInc(IntrinsiccallNode &intrnNode) { MIRIntConst *mirIntConst = safe_cast(mirConst); uint32 idx = GetPrimTypeSize(PTY_u32) * mirIntConst->GetValue(); if (!GetCG()->IsQuiet()) { - maple::logInfo.MapleLogger(kLlErr) << "Id index " << idx << std::endl; + maple::LogInfo::MapleLogger(kLlErr) << "Id index " << idx << std::endl; } StImmOperand &stOpnd = CreateStImmOperand(*bbProfileTab, idx, 0); Insn &newInsn = GetCG()->BuildInstruction(MOP_counter, vReg1, stOpnd); diff --git a/src/maple_be/src/cg/aarch64/aarch64_reg_alloc.cpp b/src/maple_be/src/cg/aarch64/aarch64_reg_alloc.cpp index 95f13a391a9f856af0cce653c25c623dea91ef0c..d83c1cd9e6071ecf3156e882524cf037111cf975 100644 --- a/src/maple_be/src/cg/aarch64/aarch64_reg_alloc.cpp +++ b/src/maple_be/src/cg/aarch64/aarch64_reg_alloc.cpp @@ -624,7 +624,7 @@ AnalysisResult *CgDoRegAlloc::Run(CGFunc *cgFunc, CgFuncResultMgr *cgFuncResultM if (cgFunc->GetCG()->GetCGOptions().DoColoringBasedRegisterAllocation()) { regAllocator = phaseMp->New(*cgFunc, *phaseMp); } else { - maple::logInfo.MapleLogger(kLlErr) << "Warning: We only support Linear Scan and GraphColor register allocation\n"; + maple::LogInfo::MapleLogger(kLlErr) << "Warning: We only support Linear Scan and GraphColor register allocation\n"; } } diff --git a/src/maple_be/src/cg/cg.cpp b/src/maple_be/src/cg/cg.cpp index 12cc32fe27f61c42f03ec8a41880ac31adfc4a99..af4cf45d2dc1931ad9420f65592683070f9d6825 100644 --- a/src/maple_be/src/cg/cg.cpp +++ b/src/maple_be/src/cg/cg.cpp @@ -96,7 +96,7 @@ void CG::GenExtraTypeMetadata(const std::string &classListFileName, const std::s } if (cgOption.GenGctib()) { - maple::logInfo.MapleLogger(kLlErr) << "--gen-gctib-file option not implemented"; + maple::LogInfo::MapleLogger(kLlErr) << "--gen-gctib-file option not implemented"; } } diff --git a/src/maple_be/src/cg/cg_cfg.cpp b/src/maple_be/src/cg/cg_cfg.cpp index 440d7e82e32fa9b0818330e8d9f338ae4687fccb..c36627e2b640c049c3b1ca9767e4a19513200676 100644 --- a/src/maple_be/src/cg/cg_cfg.cpp +++ b/src/maple_be/src/cg/cg_cfg.cpp @@ -472,6 +472,7 @@ void CGCFG::UnreachCodeAnalysis() { /* Clear insns in GOT Map. */ cgFunc->ClearUnreachableGotInfos(*unreachBB); + cgFunc->ClearUnreachableConstInfos(*unreachBB); } } diff --git a/src/maple_be/src/cg/cg_option.cpp b/src/maple_be/src/cg/cg_option.cpp index a13af6ee754606942c726a631790b1177e95887c..a5249f9fde3af6c453aabf11affa8be33a3c6456 100644 --- a/src/maple_be/src/cg/cg_option.cpp +++ b/src/maple_be/src/cg/cg_option.cpp @@ -121,7 +121,7 @@ enum OptionIndex : uint64 { const Descriptor kUsage[] = { { kPie, kEnable, - nullptr, + "", "pie", kBuildTypeProduct, kArgCheckPolicyBool, @@ -131,7 +131,7 @@ const Descriptor kUsage[] = { {} }, { kPic, kEnable, - nullptr, + "", "fpic", kBuildTypeProduct, kArgCheckPolicyBool, @@ -141,7 +141,7 @@ const Descriptor kUsage[] = { {} }, { kCGVerbose, kEnable, - nullptr, + "", "verbose-asm", kBuildTypeProduct, kArgCheckPolicyBool, @@ -151,7 +151,7 @@ const Descriptor kUsage[] = { {} }, { kCGMapleLinker, kEnable, - nullptr, + "", "maplelinker", kBuildTypeProduct, kArgCheckPolicyBool, @@ -161,7 +161,7 @@ const Descriptor kUsage[] = { {} }, { kCGQuiet, kEnable, - nullptr, + "", "quiet", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -171,7 +171,7 @@ const Descriptor kUsage[] = { {} }, { kCgen, kEnable, - nullptr, + "", "cg", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -181,7 +181,7 @@ const Descriptor kUsage[] = { {} }, { kCGLazyBinding, kEnable, - nullptr, + "", "lazy-binding", kBuildTypeProduct, kArgCheckPolicyBool, @@ -190,7 +190,7 @@ const Descriptor kUsage[] = { {} }, { kCGHotFix, kEnable, - nullptr, + "", "hot-fix", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -200,7 +200,7 @@ const Descriptor kUsage[] = { {} }, { kCGNativeOpt, kEnable, - nullptr, + "", "nativeopt", kBuildTypeProduct, kArgCheckPolicyBool, @@ -210,7 +210,7 @@ const Descriptor kUsage[] = { {} }, { kObjMap, kEnable, - nullptr, + "", "objmap", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -220,7 +220,7 @@ const Descriptor kUsage[] = { {} }, { kYieldPoing, kEnable, - nullptr, + "", "yieldpoint", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -230,7 +230,7 @@ const Descriptor kUsage[] = { {} }, { kProepilogue, kEnable, - nullptr, + "", "proepilogue", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -240,7 +240,7 @@ const Descriptor kUsage[] = { {} }, { kLocalRc, kEnable, - nullptr, + "", "local-rc", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -250,7 +250,7 @@ const Descriptor kUsage[] = { {} }, { kInsertCall, 0, - nullptr, + "", "insert-call", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -259,7 +259,7 @@ const Descriptor kUsage[] = { {} }, { kTrace, 0, - nullptr, + "", "add-debug-trace", kBuildTypeProduct, kArgCheckPolicyNone, @@ -268,7 +268,7 @@ const Descriptor kUsage[] = { {} }, { kCGClassList, 0, - nullptr, + "", "class-list-file", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -279,7 +279,7 @@ const Descriptor kUsage[] = { {} }, { kGenDef, kEnable, - nullptr, + "", "gen-c-macro-def", kBuildTypeProduct, kArgCheckPolicyBool, @@ -290,7 +290,7 @@ const Descriptor kUsage[] = { {} }, { kGenGctib, kEnable, - nullptr, + "", "gen-gctib-file", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -301,7 +301,7 @@ const Descriptor kUsage[] = { {} }, { kStackGuard, kEnable, - nullptr, + "", "stackguard", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -312,7 +312,7 @@ const Descriptor kUsage[] = { { kDebuggingInfo, 0, "g", - nullptr, + "", kBuildTypeExperimental, kArgCheckPolicyNone, " -g \tGenerate debug information\n", @@ -320,7 +320,7 @@ const Descriptor kUsage[] = { {} }, { kDebugGenDwarf, 0, - nullptr, + "", "gdwarf", kBuildTypeProduct, kArgCheckPolicyNone, @@ -329,7 +329,7 @@ const Descriptor kUsage[] = { {} }, { kDebugUseSrc, 0, - nullptr, + "", "gsrc", kBuildTypeProduct, kArgCheckPolicyNone, @@ -338,7 +338,7 @@ const Descriptor kUsage[] = { {} }, { kDebugUseMix, 0, - nullptr, + "", "gmixedsrc", kBuildTypeProduct, kArgCheckPolicyNone, @@ -347,7 +347,7 @@ const Descriptor kUsage[] = { {} }, { kDebugAsmMix, 0, - nullptr, + "", "gmixedasm", kBuildTypeExperimental, kArgCheckPolicyNone, @@ -356,7 +356,7 @@ const Descriptor kUsage[] = { {} }, { kRaColor, 0, - nullptr, + "", "with-ra-graph-color", kBuildTypeExperimental, kArgCheckPolicyNone, @@ -365,7 +365,7 @@ const Descriptor kUsage[] = { {} }, { kConstFoldOpt, 0, - nullptr, + "", "const-fold", kBuildTypeExperimental, kArgCheckPolicyNone, @@ -374,7 +374,7 @@ const Descriptor kUsage[] = { {} }, { kEhList, 0, - nullptr, + "", "eh-exclusive-list", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -384,7 +384,7 @@ const Descriptor kUsage[] = { {} }, { kCGO0, 0, - nullptr, + "", "O0", kBuildTypeExperimental, kArgCheckPolicyNone, @@ -393,7 +393,7 @@ const Descriptor kUsage[] = { {} }, { kCGO1, 0, - nullptr, + "", "O1", kBuildTypeExperimental, kArgCheckPolicyOptional, @@ -402,7 +402,7 @@ const Descriptor kUsage[] = { {} }, { kCGO2, 0, - nullptr, + "", "O2", kBuildTypeProduct, kArgCheckPolicyOptional, @@ -411,7 +411,7 @@ const Descriptor kUsage[] = { {} }, { kSuppressFinfo, 0, - nullptr, + "", "suppress-fileinfo", kBuildTypeExperimental, kArgCheckPolicyNone, @@ -420,7 +420,7 @@ const Descriptor kUsage[] = { {} }, { kCGDumpcfg, 0, - nullptr, + "", "dump-cfg", kBuildTypeExperimental, kArgCheckPolicyNone, @@ -429,7 +429,7 @@ const Descriptor kUsage[] = { {} }, { kCGDumpPhases, 0, - nullptr, + "", "dump-phases", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -438,7 +438,7 @@ const Descriptor kUsage[] = { {} }, { kCGSkipPhases, 0, - nullptr, + "", "skip-phases", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -447,7 +447,7 @@ const Descriptor kUsage[] = { {} }, { kCGSkipFrom, 0, - nullptr, + "", "skip-from", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -456,7 +456,7 @@ const Descriptor kUsage[] = { {} }, { kCGSkipAfter, 0, - nullptr, + "", "skip-after", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -465,7 +465,7 @@ const Descriptor kUsage[] = { {} }, { kCGDumpFunc, 0, - nullptr, + "", "dump-func", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -475,7 +475,7 @@ const Descriptor kUsage[] = { {} }, { kCGDumpBefore, kEnable, - nullptr, + "", "dump-before", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -485,7 +485,7 @@ const Descriptor kUsage[] = { {} }, { kCGDumpAfter, kEnable, - nullptr, + "", "dump-after", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -495,7 +495,7 @@ const Descriptor kUsage[] = { {} }, { kCGTimePhases, kEnable, - nullptr, + "", "time-phases", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -505,7 +505,7 @@ const Descriptor kUsage[] = { {} }, { kCGBarrier, kEnable, - nullptr, + "", "use-barriers-for-volatile", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -515,7 +515,7 @@ const Descriptor kUsage[] = { {} }, { kCalleeCFI, kEnable, - nullptr, + "", "callee-cfi", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -525,7 +525,7 @@ const Descriptor kUsage[] = { {} }, { kPrintFunction, kEnable, - nullptr, + "", "print-func", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -535,7 +535,7 @@ const Descriptor kUsage[] = { {} }, { kCyclePatternList, 0, - nullptr, + "", "cycle-pattern-list", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -545,7 +545,7 @@ const Descriptor kUsage[] = { {} }, { kDuplicateToDelPlt, 0, - nullptr, + "", "duplicate_asm_list", kBuildTypeProduct, kArgCheckPolicyRequired, @@ -555,7 +555,7 @@ const Descriptor kUsage[] = { {} }, { kInsertSoe, 0, - nullptr, + "", "soe-check", kBuildTypeExperimental, kArgCheckPolicyNone, @@ -564,7 +564,7 @@ const Descriptor kUsage[] = { {} }, { kCheckArrayStore, kEnable, - nullptr, + "", "check-arraystore", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -574,7 +574,7 @@ const Descriptor kUsage[] = { {} }, { kLongCalls, kEnable, - nullptr, + "", "long-calls", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -585,11 +585,11 @@ const Descriptor kUsage[] = { // End { kUnknown, 0, - nullptr, - nullptr, + "", + "", kBuildTypeAll, kArgCheckPolicyNone, - nullptr, + "", "mplcg", {} } }; diff --git a/src/maple_be/src/cg/emit.cpp b/src/maple_be/src/cg/emit.cpp index ac56b66176d84fc4ac65540f5ed22c7a130d933b..51aec39d7f12728bfbe854535e3fea504f1eaf63 100644 --- a/src/maple_be/src/cg/emit.cpp +++ b/src/maple_be/src/cg/emit.cpp @@ -1108,7 +1108,11 @@ void Emitter::EmitIntConst(const MIRSymbol &mirSymbol, MIRAggConst &aggConst, ui } else if (mirSymbol.IsRegJNIFuncTab()) { std::string strTabName = kRegJNITabPrefixStr + cg->GetMIRModule()->GetFileNameAsPostfix(); EmitScalarConstant(*elemConst, false); +#ifdef TARGARM32 + Emit("+" + strTabName).Emit("+").Emit(MByteRef::PositiveOffsetBias).Emit("-.\n"); +#else Emit("+" + strTabName + "\n"); +#endif } else if (mirSymbol.IsReflectionMethodAddrData()) { int64 defTabIndex = intConst->GetValue(); #ifdef USE_32BIT_REF @@ -1444,7 +1448,7 @@ void Emitter::EmitFuncLayoutInfo(const MIRSymbol &layout) { MIRAggConst *aggConst = safe_cast(mirConst); ASSERT(aggConst != nullptr, "null ptr check"); if (aggConst->GetConstVec().size() != static_cast(LayoutType::kLayoutTypeCount)) { - maple::logInfo.MapleLogger(kLlErr) << "something wrong happen in funclayoutsym\t" + maple::LogInfo::MapleLogger(kLlErr) << "something wrong happen in funclayoutsym\t" << "constVec size\t" << aggConst->GetConstVec().size() << "\n"; return; } @@ -1557,7 +1561,7 @@ void Emitter::MarkVtabOrItabEndFlag(const std::vector &mirSymbolVec) MIRConst *elemConst = aggConst->GetConstVecItem(size - 1); ASSERT(elemConst != nullptr, "null ptr check"); if (elemConst->GetKind() == kConstAddrofFunc) { - maple::logInfo.MapleLogger(kLlErr) << "ERROR: the last vtab/itab content should not be funcAddr\n"; + maple::LogInfo::MapleLogger(kLlErr) << "ERROR: the last vtab/itab content should not be funcAddr\n"; } else { if (elemConst->GetKind() != kConstInt) { CHECK_FATAL(elemConst->GetKind() == kConstAddrof, "must be"); @@ -1595,7 +1599,7 @@ void Emitter::EmitGlobalVars(std::vector> &globalVar if (!CGOptions::IsGlobalVarProFileEmpty()) { inFile.open(CGOptions::GetGlobalVarProFile()); if (inFile.fail()) { - maple::logInfo.MapleLogger(kLlErr) << "Cannot open globalVar profile file " << CGOptions::GetGlobalVarProFile() + maple::LogInfo::MapleLogger(kLlErr) << "Cannot open globalVar profile file " << CGOptions::GetGlobalVarProFile() << "\n"; } } diff --git a/src/maple_driver/include/driver_option_common.h b/src/maple_driver/include/driver_option_common.h index 03abfb7e932d9d2fe7c8fbe26294554482ac910f..691cf6c2ed20d2505171780921b5a5b01fddc4cf 100644 --- a/src/maple_driver/include/driver_option_common.h +++ b/src/maple_driver/include/driver_option_common.h @@ -44,7 +44,7 @@ enum DriverOptionIndex { class MapleDriverOptionBase { public: void CreateUsages(const mapleOption::Descriptor usage[]) { - for (size_t i = 0; usage[i].help != nullptr; ++i) { + for (size_t i = 0; usage[i].help != ""; ++i) { usageVec.push_back(usage[i]); } } diff --git a/src/maple_driver/include/jbc2mpl_option.h b/src/maple_driver/include/jbc2mpl_option.h index ea2557804ff2a0158f9dbbaed1b19dbdec5550db..e282a1a27abd2ece0554cc173d36bdaef0feea21 100644 --- a/src/maple_driver/include/jbc2mpl_option.h +++ b/src/maple_driver/include/jbc2mpl_option.h @@ -37,8 +37,8 @@ const mapleOption::Descriptor jbcUsage[] = { " -o, -out output.mpl : output mpl name", "jbc2mpl", {} }, - { kUnknown, 0, nullptr, nullptr, mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyNone, - nullptr, + { kUnknown, 0, "", "", mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyNone, + "", "jbc2mpl", {} } }; diff --git a/src/maple_driver/include/option_descriptor.h b/src/maple_driver/include/option_descriptor.h index 869532d4d12c37fddbe5828eeaaedd137509f546..a9893e196dda82a2f4016a25946b3e7ef2de2d72 100644 --- a/src/maple_driver/include/option_descriptor.h +++ b/src/maple_driver/include/option_descriptor.h @@ -46,10 +46,10 @@ struct Descriptor { const int type; // Short form option key - const char * const shortOption; + const std::string shortOption; // Long form option key - const char * const longOption; + const std::string longOption; // The option can be seen in which build type. const BuildType enableBuildType; @@ -58,9 +58,9 @@ struct Descriptor { const ArgCheckPolicy checkPolicy; // Help info - const char * const help; + const std::string help; - const char * const exeName; + const std::string exeName; // option key mapping to target tool const std::vector extras; diff --git a/src/maple_driver/src/driver_option_common.cpp b/src/maple_driver/src/driver_option_common.cpp index 84ddf89129fa0e69095c92bab23c18a6d1c72bcf..16312bc885e7d9460e69439e99797766d00e4fc3 100644 --- a/src/maple_driver/src/driver_option_common.cpp +++ b/src/maple_driver/src/driver_option_common.cpp @@ -21,8 +21,8 @@ const mapleOption::Descriptor usages[] = { // index, type , shortOption , longOption, enableBuildType, checkPolicy, help, exeName, extra bins { kUnknown, 0, - nullptr, - nullptr, + "", + "", kBuildTypeAll, kArgCheckPolicyNone, "USAGE: maple [options]\n\n" @@ -47,7 +47,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kVersion, 0, - nullptr, + "", "version", kBuildTypeProduct, kArgCheckPolicyOptional, @@ -56,7 +56,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kInFile, 0, - nullptr, + "", "infile", kBuildTypeProduct, kArgCheckPolicyRequired, @@ -65,7 +65,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kInMplt, 0, - nullptr, + "", "mplt", kBuildTypeProduct, kArgCheckPolicyRequired, @@ -76,7 +76,7 @@ const mapleOption::Descriptor usages[] = { { kOptimization0, 0, "O0", - nullptr, + "", kBuildTypeProduct, kArgCheckPolicyNone, " -O0 \tNo optimization.\n", @@ -85,7 +85,7 @@ const mapleOption::Descriptor usages[] = { { kOptimization2, 0, "O2", - nullptr, + "", kBuildTypeProduct, kArgCheckPolicyNone, " -O2 \tDo more optimization. (Default)\n", @@ -93,7 +93,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kGCOnly, kEnable, - nullptr, + "", "gconly", kBuildTypeProduct, kArgCheckPolicyBool, @@ -105,7 +105,7 @@ const mapleOption::Descriptor usages[] = { } }, { kMeOpt, 0, - nullptr, + "", "me-opt", kBuildTypeProduct, kArgCheckPolicyNone, @@ -114,7 +114,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kMpl2MplOpt, 0, - nullptr, + "", "mpl2mpl-opt", kBuildTypeProduct, kArgCheckPolicyNone, @@ -123,7 +123,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kSaveTemps, 0, - nullptr, + "", "save-temps", kBuildTypeProduct, kArgCheckPolicyNone, @@ -135,7 +135,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kRun, 0, - nullptr, + "", "run", kBuildTypeProduct, kArgCheckPolicyRequired, @@ -149,7 +149,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kOption, 0, - nullptr, + "", "option", kBuildTypeProduct, kArgCheckPolicyRequired, @@ -162,7 +162,7 @@ const mapleOption::Descriptor usages[] = { { kTimePhases, 0, "time-phases", - nullptr, + "", kBuildTypeExperimental, kArgCheckPolicyNone, " -time-phases \tTiming phases and print percentages\n", @@ -170,7 +170,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kGenMeMpl, 0, - nullptr, + "", "genmempl", kBuildTypeProduct, kArgCheckPolicyNone, @@ -179,7 +179,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kGenVtableImpl, 0, - nullptr, + "", "genVtableImpl", kBuildTypeProduct, kArgCheckPolicyNone, @@ -188,7 +188,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kVerbose, kEnable, - nullptr, + "", "verbose", kBuildTypeDebug, kArgCheckPolicyBool, @@ -197,7 +197,7 @@ const mapleOption::Descriptor usages[] = { { "jbc2mpl", "me", "mpl2mpl", "mplcg" } }, { kAllDebug, 0, - nullptr, + "", "debug", kBuildTypeDebug, kArgCheckPolicyNone, @@ -206,7 +206,7 @@ const mapleOption::Descriptor usages[] = { {} }, { kHelpLevel, 0, - nullptr, + "", "level", kBuildTypeProduct, kArgCheckPolicyNumeric, @@ -219,11 +219,11 @@ const mapleOption::Descriptor usages[] = { {} }, { kUnknown, 0, - nullptr, - nullptr, + "", + "", kBuildTypeAll, kArgCheckPolicyNone, - nullptr, + "", "all", {} } }; diff --git a/src/maple_driver/src/option_parser.cpp b/src/maple_driver/src/option_parser.cpp index 56361754438b9fbe5f5388e726fb9e0d42144e9e..070dfe2b7662480214c55824e80edd6e9bac0b49 100644 --- a/src/maple_driver/src/option_parser.cpp +++ b/src/maple_driver/src/option_parser.cpp @@ -32,13 +32,13 @@ void OptionParser::InsertExtraUsage(const Descriptor &usage) { usage.enableBuildType, usage.checkPolicy, usage.help, - usage.extras[index].c_str(), + usage.extras[index], {} }; - if (usage.shortOption != nullptr) { - InsertOption(std::string(usage.shortOption), tempUsage); + if (usage.shortOption != "") { + InsertOption(usage.shortOption, tempUsage); } - if (usage.longOption != nullptr) { - InsertOption(std::string(usage.longOption), tempUsage); + if (usage.longOption != "") { + InsertOption(usage.longOption, tempUsage); } rawUsages.push_back(tempUsage); index++; @@ -49,29 +49,29 @@ void OptionParser::CreateNoOption(const Descriptor &usage) { std::string longOpt = ""; std::string shortOpt = ""; std::string newHelpInfo = ""; - if (usage.shortOption != nullptr) { + if (usage.shortOption != "") { std::ostringstream optionString; optionString << "no-" << usage.shortOption; // Generate short option: no-opt shortOpt = optionString.str(); } - if (usage.longOption != nullptr) { + if (usage.longOption != "") { std::ostringstream optionString; optionString << "no-" << usage.longOption; // Generate long option: no-opt longOpt = optionString.str(); } Descriptor tempUsage = { usage.index, kDisable, // Change to disable - (usage.shortOption != nullptr) ? shortOpt.c_str() : nullptr, - (usage.longOption != nullptr) ? longOpt.c_str() : nullptr, + (usage.shortOption != "") ? shortOpt : "", + (usage.longOption != "") ? longOpt : "", usage.enableBuildType, usage.checkPolicy, - nullptr, + "", usage.exeName, usage.extras }; - if (usage.shortOption != nullptr) { + if (usage.shortOption != "") { InsertOption(shortOpt, tempUsage); } - if (usage.longOption != nullptr) { + if (usage.longOption != "") { InsertOption(longOpt, tempUsage); } // Insert usage for extra options @@ -80,15 +80,15 @@ void OptionParser::CreateNoOption(const Descriptor &usage) { void OptionParser::RegisteUsages(const MapleDriverOptionBase &base) { for (auto &usage : base.GetUsageVec()) { - if (usage.help == nullptr) { + if (usage.help == "") { continue; } rawUsages.push_back(usage); - if (usage.shortOption != nullptr) { - InsertOption(std::string(usage.shortOption), usage); + if (usage.shortOption != "") { + InsertOption(usage.shortOption, usage); } - if (usage.longOption != nullptr) { - InsertOption(std::string(usage.longOption), usage); + if (usage.longOption != "") { + InsertOption(usage.longOption, usage); } // Insert usage for extra options InsertExtraUsage(usage); @@ -100,13 +100,13 @@ void OptionParser::RegisteUsages(const MapleDriverOptionBase &base) { } void OptionParser::RegisteUsages(const Descriptor usage[]) { - for (size_t i = 0; usage[i].help != nullptr; ++i) { + for (size_t i = 0; usage[i].help != ""; ++i) { rawUsages.push_back(usage[i]); - if (usage[i].shortOption != nullptr) { - InsertOption(std::string(usage[i].shortOption), usage[i]); + if (usage[i].shortOption != "") { + InsertOption(usage[i].shortOption, usage[i]); } - if (usage[i].longOption != nullptr) { - InsertOption(std::string(usage[i].longOption), usage[i]); + if (usage[i].longOption != "") { + InsertOption(usage[i].longOption, usage[i]); } // Insert usage for extra options InsertExtraUsage(usage[i]); @@ -119,7 +119,7 @@ void OptionParser::RegisteUsages(const Descriptor usage[]) { void OptionParser::PrintUsage(const std::string &helpType, const unsigned int helpLevel) const { for (size_t i = 0; i < rawUsages.size(); ++i) { - if (rawUsages[i].help != nullptr && rawUsages[i].IsEnabledForCurrentBuild() && rawUsages[i].exeName == helpType) { + if (rawUsages[i].help != "" && rawUsages[i].IsEnabledForCurrentBuild() && rawUsages[i].exeName == helpType) { if (helpLevel != kBuildTypeDefault && (rawUsages[i].enableBuildType != helpLevel && rawUsages[i].enableBuildType != kBuildTypeAll)) { continue; diff --git a/src/maple_ir/include/metadata_layout.h b/src/maple_ir/include/metadata_layout.h index f0d1eb2195cf7419457d88aa64f6d2a9cb941a17..b4b89ce3509ddde588b9640be3f51ea8eafc2abe 100644 --- a/src/maple_ir/include/metadata_layout.h +++ b/src/maple_ir/include/metadata_layout.h @@ -159,21 +159,26 @@ struct MByteRef { #if defined(__arm__) || defined(USE_ARM32_MACRO) // assume address range 0 ~ 256MB is unused in arm runtime - // OffsetMin ~ OffsetMax is the value range of encoded offset - static constexpr intptr_t FarthestOffset = 128 * 1024 * 1024; + // EncodedOffsetMin ~ EncodedOffsetMax is the value range of encoded offset + static constexpr intptr_t OffsetBound = 128 * 1024 * 1024; + static constexpr intptr_t OffsetMin = -OffsetBound; + static constexpr intptr_t OffsetMax = OffsetBound; + static constexpr intptr_t PositiveOffsetBias = 128 * 1024 * 1024; - static constexpr intptr_t OffsetMin = PositiveOffsetBias + 0; - static constexpr intptr_t OffsetMax = PositiveOffsetBias + FarthestOffset; + static constexpr intptr_t EncodedOffsetMin = PositiveOffsetBias + OffsetMin; + static constexpr intptr_t EncodedOffsetMax = PositiveOffsetBias + OffsetMax; #else enum { kBiasBitPosition = sizeof(refVal) * 8 - 4, // the most significant 4 bits }; - static constexpr uintptr_t FarthestOffset = 256 * 1024 * 1024; // according to kDsoLoadedAddessEnd = 0xF0000000 + static constexpr uintptr_t OffsetBound = 256 * 1024 * 1024; // according to kDsoLoadedAddessEnd = 0xF0000000 + static constexpr uintptr_t PositiveOffsetMin = 0; + static constexpr uintptr_t PositiveOffsetMax = OffsetBound; static constexpr uintptr_t PositiveOffsetBias = static_cast(6) << kBiasBitPosition; - static constexpr uintptr_t PositiveOffsetMin = 0 + PositiveOffsetBias; - static constexpr uintptr_t PositiveOffsetMax = FarthestOffset + PositiveOffsetBias; + static constexpr uintptr_t EncodedPosOffsetMin = PositiveOffsetMin + PositiveOffsetBias; + static constexpr uintptr_t EncodedPosOffsetMax = PositiveOffsetMax + PositiveOffsetBias; #endif template @@ -185,16 +190,18 @@ struct MByteRef { struct MByteRef32 { uint32_t refVal; - static constexpr uint32_t FarthestOffset = 256 * 1024 * 1024; // according to kDsoLoadedAddessEnd = 0xF0000000 + static constexpr uint32_t OffsetBound = 256 * 1024 * 1024; // according to kDsoLoadedAddessEnd = 0xF0000000 + static constexpr uint32_t PositiveOffsetMin = 0; + static constexpr uint32_t PositiveOffsetMax = OffsetBound; static constexpr uint32_t PositiveOffsetBias = 0x60000000; // the most significant 4 bits 0110 - static constexpr uint32_t PositiveOffsetMin = 0 + PositiveOffsetBias; - static constexpr uint32_t PositiveOffsetMax = FarthestOffset + PositiveOffsetBias; + static constexpr uint32_t EncodedPosOffsetMin = PositiveOffsetMin + PositiveOffsetBias; + static constexpr uint32_t EncodedPosOffsetMax = PositiveOffsetMax + PositiveOffsetBias; static constexpr uint32_t DirectRefMin = 0xC0000000; // according to kDsoLoadedAddessStart = 0xC0000000 static constexpr uint32_t DirectRefMax = 0xF0000000; // according to kDsoLoadedAddessEnd = 0xF0000000 - static constexpr int32_t NegativeOffsetMin = -FarthestOffset; + static constexpr int32_t NegativeOffsetMin = -OffsetBound; static constexpr int32_t NegativeOffsetMax = 0; template @@ -246,10 +253,18 @@ struct ClassMetadataRO { }; static constexpr size_t PageSize = 4096; +static constexpr size_t kCacheLine = 64; // according to kSpaceAnchor and kFireBreak defined in bpallocator.cpp -// the address of this readable page is set as kClassInitialized for java class -static constexpr uintptr_t kClassInitializedState = 0xC0000000 - (1u << 20) * 2; +// the address of this readable page is set as kProtectedMemoryStart for java class +static constexpr uintptr_t kClInitStateAddrBase = 0xc0000000 - (1u << 20) * 2; + +// In Kirin 980, 2 mmap memory address with odd number of page distances may have unreasonable L1&L2 cache conflict. +// kClassInitializedState is used as the init state for class that has no method, it's will be loaded in many +// place for Decouple build App. if we set the value to kClInitStateAddrBase(0xbfe00000), it may conflict with the +// yieldpoind test address globalPollingPage which is defined in yieldpoint.cpp. +// Hence we add 1 cache line (64 byte) offset here to avoid such conflict +static constexpr uintptr_t kClassInitializedState = kClInitStateAddrBase + kCacheLine; extern "C" uint8_t classInitProtectRegion[]; diff --git a/src/maple_ir/include/mir_nodes.h b/src/maple_ir/include/mir_nodes.h index 9cd17985be95fc0646cbe4f328c0980e114272ba..0a58dda4075c496c559b6a7fd141be79c10e9beb 100644 --- a/src/maple_ir/include/mir_nodes.h +++ b/src/maple_ir/include/mir_nodes.h @@ -460,6 +460,16 @@ class IreadNode : public UnaryNode { return *base; } + bool IsVolatile() const { + MIRType *type = GlobalTables::GetTypeTable().GetTypeFromTyIdx(tyIdx); + ASSERT(type != nullptr, "null ptr check"); + if (fieldID == 0) { + return (type->HasVolatileField()); + } + ASSERT(type->IsStructType(), "Agg type check"); + auto *structType = static_cast(type); + return structType->IsFieldVolatile(fieldID); + } protected: TyIdx tyIdx = TyIdx(0); FieldID fieldID = 0; @@ -1219,6 +1229,7 @@ class AddrofNode : public BaseNode { fieldID = fieldIDVal; } + bool IsVolatile(const MIRModule &mod) const; private: StIdx stIdx; FieldID fieldID = 0; diff --git a/src/maple_ir/src/mir_nodes.cpp b/src/maple_ir/src/mir_nodes.cpp index aed20069d2eeabcdf01919cf47e7b3aa3295df5d..2bb1d39ca3aef7bbaf74f97ba50e7a7c4aba0023 100644 --- a/src/maple_ir/src/mir_nodes.cpp +++ b/src/maple_ir/src/mir_nodes.cpp @@ -133,6 +133,12 @@ bool AddrofNode::CheckNode(const MIRModule &mod) const { } } +bool AddrofNode::IsVolatile(const MIRModule &mod) const { + auto *symbol = mod.CurFunction()->GetLocalOrGlobalSymbol(stIdx); + ASSERT(symbol != nullptr, "null ptr check on symbol"); + return symbol->IsVolatile(); +} + void BlockNode::AddStatement(StmtNode *stmt) { ASSERT(stmt != nullptr, "null ptr check"); stmtNodeList.push_back(stmt); diff --git a/src/maple_ir/src/option.cpp b/src/maple_ir/src/option.cpp index cc649367c9f5c0099868a40a48f2c44038173bfe..197faf9b558a1dbdfc08d4c849ba9d38618716a0 100644 --- a/src/maple_ir/src/option.cpp +++ b/src/maple_ir/src/option.cpp @@ -108,7 +108,7 @@ enum OptionIndex { const Descriptor kUsage[] = { { kMpl2MplDumpPhase, 0, - nullptr, + "", "dump-phase", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -118,7 +118,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplSkipPhase, 0, - nullptr, + "", "skip-phase", kBuildTypeProduct, kArgCheckPolicyRequired, @@ -128,7 +128,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplSkipFrom, 0, - nullptr, + "", "skip-from", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -138,7 +138,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplSkipAfter, 0, - nullptr, + "", "skip-after", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -148,7 +148,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplDumpFunc, 0, - nullptr, + "", "dump-func", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -159,7 +159,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplQuiet, kEnable, - nullptr, + "", "quiet", kBuildTypeProduct, kArgCheckPolicyBool, @@ -169,7 +169,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplMapleLinker, kEnable, - nullptr, + "", "maplelinker", kBuildTypeProduct, kArgCheckPolicyBool, @@ -179,7 +179,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplStubJniFunc, kEnable, - nullptr, + "", "regnativefunc", kBuildTypeProduct, kArgCheckPolicyBool, @@ -189,7 +189,7 @@ const Descriptor kUsage[] = { {} }, { kInlineWithProfile, kEnable, - nullptr, + "", "inline-with-profile", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -199,7 +199,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplUseInline, kEnable, - nullptr, + "", "inline", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -209,7 +209,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplNoInlineFuncList, 0, - nullptr, + "", "no-inlinefunclist", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -218,7 +218,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplUseCrossModuleInline, kEnable, - nullptr, + "", "cross-module-inline", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -228,7 +228,7 @@ const Descriptor kUsage[] = { {} }, { kInlineSmallFunctionThreshold, 0, - nullptr, + "", "inline-small-function-threshold", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -237,7 +237,7 @@ const Descriptor kUsage[] = { {} }, { kInlineHotFunctionThreshold, 0, - nullptr, + "", "inline-hot-function-threshold", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -246,7 +246,7 @@ const Descriptor kUsage[] = { {} }, { kInlineRecursiveFunctionThreshold, 0, - nullptr, + "", "inline-recursive-function-threshold", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -255,7 +255,7 @@ const Descriptor kUsage[] = { {} }, { kInlineModuleGrowth, 0, - nullptr, + "", "inline-module-growth", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -264,7 +264,7 @@ const Descriptor kUsage[] = { {} }, { kInlineColdFunctionThreshold, 0, - nullptr, + "", "inline-cold-function-threshold", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -273,7 +273,7 @@ const Descriptor kUsage[] = { {} }, { kProfileHotCount, 0, - nullptr, + "", "profile-hot-count", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -282,7 +282,7 @@ const Descriptor kUsage[] = { {} }, { kProfileColdCount, 0, - nullptr, + "", "profile-cold-count", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -291,7 +291,7 @@ const Descriptor kUsage[] = { {} }, { kProfileHotRate, 0, - nullptr, + "", "profile-hot-rate", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -300,7 +300,7 @@ const Descriptor kUsage[] = { {} }, { kProfileColdRate, 0, - nullptr, + "", "profile-cold-rate", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -309,7 +309,7 @@ const Descriptor kUsage[] = { {} }, { kNativeWrapper, kEnable, - nullptr, + "", "nativewrapper", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -318,7 +318,7 @@ const Descriptor kUsage[] = { {} }, { kRegNativeDynamicOnly, kEnable, - nullptr, + "", "regnative-dynamic-only", kBuildTypeProduct, kArgCheckPolicyBool, @@ -328,7 +328,7 @@ const Descriptor kUsage[] = { {} }, { kRegNativeStaticBindingList, 0, - nullptr, + "", "static-binding-list", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -338,7 +338,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplDumpBefore, kEnable, - nullptr, + "", "dump-before", kBuildTypeDebug, kArgCheckPolicyBool, @@ -348,7 +348,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplDumpAfter, kEnable, - nullptr, + "", "dump-after", kBuildTypeDebug, kArgCheckPolicyBool, @@ -358,7 +358,7 @@ const Descriptor kUsage[] = { {} }, { kMplnkDumpMuid, kEnable, - nullptr, + "", "dump-muid", kBuildTypeDebug, kArgCheckPolicyBool, @@ -368,7 +368,7 @@ const Descriptor kUsage[] = { {} }, { kEmitVtableImpl, kEnable, - nullptr, + "", "emitVtableImpl", kBuildTypeProduct, kArgCheckPolicyBool, @@ -379,7 +379,7 @@ const Descriptor kUsage[] = { #if MIR_JAVA { kMpl2MplSkipVirtual, kEnable, - nullptr, + "", "skipvirtual", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -390,7 +390,7 @@ const Descriptor kUsage[] = { #endif { kMpl2MplNativeOpt, kEnable, - nullptr, + "", "nativeopt", kBuildTypeProduct, kArgCheckPolicyBool, @@ -400,7 +400,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplOptL0, 0, - nullptr, + "", "O0", kBuildTypeProduct, kArgCheckPolicyOptional, @@ -409,7 +409,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplOptL2, 0, - nullptr, + "", "O2", kBuildTypeProduct, kArgCheckPolicyOptional, @@ -418,7 +418,7 @@ const Descriptor kUsage[] = { {} }, { kMpl2MplNoDot, kEnable, - nullptr, + "", "nodot", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -428,7 +428,7 @@ const Descriptor kUsage[] = { {} }, { kGenIRProfile, kEnable, - nullptr, + "", "ir-profile-gen", mapleOption::BuildType::kBuildTypeExperimental, mapleOption::ArgCheckPolicy::kArgCheckPolicyBool, @@ -438,7 +438,7 @@ const Descriptor kUsage[] = { {} }, { kProfileTest, kEnable, - nullptr, + "", "profile-test", mapleOption::BuildType::kBuildTypeExperimental, mapleOption::ArgCheckPolicy::kArgCheckPolicyBool, @@ -448,11 +448,11 @@ const Descriptor kUsage[] = { {} }, { kUnknown, 0, - nullptr, - nullptr, + "", + "", kBuildTypeAll, kArgCheckPolicyNone, - nullptr, + "", "mpl2mpl", {} } }; diff --git a/src/maple_me/include/me_ir.h b/src/maple_me/include/me_ir.h index fc2682d17472fbb69ac233076e8713049e888f42..3a2356a0c0050860a4027211cea501a4ea5debcc 100644 --- a/src/maple_me/include/me_ir.h +++ b/src/maple_me/include/me_ir.h @@ -164,7 +164,7 @@ class MeExpr { MeExpr *ResolveMeExprValue(); bool CouldThrowException() const; bool IsAllOpndsIdentical(const MeExpr &meExpr) const; - bool PointsToSomethingThatNeedsIncRef(); + bool PointsToSomethingThatNeedsIncRef(SSATab &ssaTab); virtual uint32 GetHashIndex() const { return 0; } @@ -225,8 +225,8 @@ class VarMeExpr final : public MeExpr { bool IsZeroVersion(const SSATab&) const; BB *GetDefByBBMeStmt(const Dominance&, MeStmtPtr&) const; bool IsSameVariableValue(const VarMeExpr&) const override; - VarMeExpr &ResolveVarMeValue(); - bool PointsToStringLiteral(); + VarMeExpr &ResolveVarMeValue(SSATab &ssaTab); + bool PointsToStringLiteral(SSATab &ssaTab); const OStIdx &GetOStIdx() const { return ostIdx; diff --git a/src/maple_me/src/me_analyze_rc.cpp b/src/maple_me/src/me_analyze_rc.cpp index 19bdbf8a9e4b63163ef8e02ca06d946d71b5e189..e6ef614d5656a3dfcd1b33455cebbecc9bf6bcd2 100644 --- a/src/maple_me/src/me_analyze_rc.cpp +++ b/src/maple_me/src/me_analyze_rc.cpp @@ -135,7 +135,7 @@ bool AnalyzeRC::NeedIncref(const MeStmt &stmt) const { } MeExpr *rhs = stmt.GetRHS(); CHECK_NULL_FATAL(rhs); - return rhs->PointsToSomethingThatNeedsIncRef(); + return rhs->PointsToSomethingThatNeedsIncRef(ssaTab); } // identify assignments to ref pointers and insert decref before it and incref diff --git a/src/maple_me/src/me_ir.cpp b/src/maple_me/src/me_ir.cpp index f59f28ba30692002150e943ba41a2723c8b02ce5..2dd4a2edd3bded0a209d55311e4190cf3aa0d9f0 100644 --- a/src/maple_me/src/me_ir.cpp +++ b/src/maple_me/src/me_ir.cpp @@ -132,10 +132,10 @@ bool RegMeExpr::IsSameVariableValue(const VarMeExpr &expr) const { // this = v1 // this->ResolveVarMeValue() returns v3; // if no resolved VarMeExpr, return this -VarMeExpr &VarMeExpr::ResolveVarMeValue() { +VarMeExpr &VarMeExpr::ResolveVarMeValue(SSATab &ssaTab) { VarMeExpr *cmpop0 = this; while (true) { - if (cmpop0->defBy != kDefByStmt) { + if (cmpop0->defBy != kDefByStmt || cmpop0->IsVolatile(ssaTab)) { break; } @@ -1367,8 +1367,8 @@ bool VarMeExpr::IsVolatile(const SSATab &ssatab) const { return structType->IsFieldVolatile(fieldID); } -bool VarMeExpr::PointsToStringLiteral() { - VarMeExpr &var = ResolveVarMeValue(); +bool VarMeExpr::PointsToStringLiteral(SSATab &ssaTab) { + VarMeExpr &var = ResolveVarMeValue(ssaTab); if (var.GetDefBy() == kDefByMustDef) { MeStmt *baseStmt = var.GetDefMustDef().GetBase(); if (baseStmt->GetOp() == OP_callassigned) { @@ -1418,7 +1418,7 @@ bool MeExpr::HasIvar() const { // check if MeExpr can be a pointer to something that requires incref for its // assigned target -bool MeExpr::PointsToSomethingThatNeedsIncRef() { +bool MeExpr::PointsToSomethingThatNeedsIncRef(SSATab &ssaTab) { if (op == OP_retype) { return true; } @@ -1427,7 +1427,7 @@ bool MeExpr::PointsToSomethingThatNeedsIncRef() { } if (meOp == kMeOpVar) { auto *var = static_cast(this); - if (var->PointsToStringLiteral()) { + if (var->PointsToStringLiteral(ssaTab)) { return false; } return true; diff --git a/src/maple_me/src/me_option.cpp b/src/maple_me/src/me_option.cpp index c9b010b76e8b2b4b94d6d32773e1df855bb95b6c..f47aa7882ac16a7feed2e293e3e9d4d1908db0f7 100644 --- a/src/maple_me/src/me_option.cpp +++ b/src/maple_me/src/me_option.cpp @@ -129,7 +129,7 @@ const Descriptor kUsage[] = { {} }, { kMeOptL1, 0, - nullptr, + "", "O1", kBuildTypeProduct, kArgCheckPolicyOptional, @@ -138,7 +138,7 @@ const Descriptor kUsage[] = { {} }, { kMeOptL2, 0, - nullptr, + "", "O2", kBuildTypeProduct, kArgCheckPolicyOptional, @@ -147,7 +147,7 @@ const Descriptor kUsage[] = { {} }, { kMeRange, 0, - nullptr, + "", "range", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -157,7 +157,7 @@ const Descriptor kUsage[] = { {} }, { kMeDumpPhases, 0, - nullptr, + "", "dump-phases", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -167,7 +167,7 @@ const Descriptor kUsage[] = { {} }, { kMeSkipPhases, 0, - nullptr, + "", "skip-phases", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -177,7 +177,7 @@ const Descriptor kUsage[] = { {} }, { kMeDumpFunc, 0, - nullptr, + "", "dump-func", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -188,7 +188,7 @@ const Descriptor kUsage[] = { {} }, { kMeQuiet, kEnable, - nullptr, + "", "quiet", kBuildTypeProduct, kArgCheckPolicyBool, @@ -198,7 +198,7 @@ const Descriptor kUsage[] = { {} }, { kMeNoDot, kEnable, - nullptr, + "", "nodot", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -208,7 +208,7 @@ const Descriptor kUsage[] = { {} }, { kSetCalleeHasSideEffect, kEnable, - nullptr, + "", "setCalleeHasSideEffect", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -218,7 +218,7 @@ const Descriptor kUsage[] = { {} }, { kNoSteensgaard, kEnable, - nullptr, + "", "noSteensgaard", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -228,7 +228,7 @@ const Descriptor kUsage[] = { {} }, { kNoTBAA, kEnable, - nullptr, + "", "noTBAA", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -238,7 +238,7 @@ const Descriptor kUsage[] = { {} }, { kAliasAnalysisLevel, 0, - nullptr, + "", "aliasAnalysisLevel", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -251,7 +251,7 @@ const Descriptor kUsage[] = { {} }, { kStmtNum, kEnable, - nullptr, + "", "stmtnum", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -261,7 +261,7 @@ const Descriptor kUsage[] = { {} }, { kRcLower, kEnable, - nullptr, + "", "rclower", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -271,7 +271,7 @@ const Descriptor kUsage[] = { {} }, { kMeDumpBefore, kEnable, - nullptr, + "", "dump-before", kBuildTypeDebug, kArgCheckPolicyBool, @@ -281,7 +281,7 @@ const Descriptor kUsage[] = { {} }, { kMeDumpAfter, kEnable, - nullptr, + "", "dump-after", kBuildTypeDebug, kArgCheckPolicyBool, @@ -291,7 +291,7 @@ const Descriptor kUsage[] = { {} }, { kEpreLimit, 0, - nullptr, + "", "eprelimit", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -301,7 +301,7 @@ const Descriptor kUsage[] = { {} }, { kEprepuLimit, 0, - nullptr, + "", "eprepulimit", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -311,7 +311,7 @@ const Descriptor kUsage[] = { {} }, { kStmtPrepuLimit, 0, - nullptr, + "", "stmtprepulimit", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -321,7 +321,7 @@ const Descriptor kUsage[] = { {} }, { kLpreLimit, 0, - nullptr, + "", "lprelimit", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -331,7 +331,7 @@ const Descriptor kUsage[] = { {} }, { kLprepulLimit, 0, - nullptr, + "", "lprepulimit", kBuildTypeDebug, kArgCheckPolicyRequired, @@ -341,7 +341,7 @@ const Descriptor kUsage[] = { {} }, { kPregreNameLimit, 0, - nullptr, + "", "pregrenamelimit", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -351,7 +351,7 @@ const Descriptor kUsage[] = { {} }, { kDelrcpuLimit, 0, - nullptr, + "", "delrcpulimit", kBuildTypeExperimental, kArgCheckPolicyRequired, @@ -361,7 +361,7 @@ const Descriptor kUsage[] = { {} }, { kProfileBBHotRate, 0, - nullptr, + "", "profile-bb-hot-rate", kBuildTypeAll, kArgCheckPolicyRequired, @@ -370,7 +370,7 @@ const Descriptor kUsage[] = { {} }, { kProfileBBColdRate, 0, - nullptr, + "", "profile-bb-cold-rate", kBuildTypeAll, kArgCheckPolicyRequired, @@ -379,7 +379,7 @@ const Descriptor kUsage[] = { {} }, { kEpreIncludeRef, kEnable, - nullptr, + "", "epreincluderef", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -389,7 +389,7 @@ const Descriptor kUsage[] = { {} }, { kEpreLocalRefVar, kEnable, - nullptr, + "", "eprelocalrefvar", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -399,7 +399,7 @@ const Descriptor kUsage[] = { {} }, { kEprelhSivar, kEnable, - nullptr, + "", "eprelhsivar", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -409,7 +409,7 @@ const Descriptor kUsage[] = { {} }, { kLessThrowAlias, kEnable, - nullptr, + "", "lessthrowalias", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -419,7 +419,7 @@ const Descriptor kUsage[] = { {} }, { kNodeLegateRc, kEnable, - nullptr, + "", "nodelegaterc", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -429,7 +429,7 @@ const Descriptor kUsage[] = { {} }, { kNocondBasedRc, kEnable, - nullptr, + "", "nocondbasedrc", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -440,7 +440,7 @@ const Descriptor kUsage[] = { {} }, { kRegReadAtReturn, kEnable, - nullptr, + "", "regreadatreturn", kBuildTypeExperimental, kArgCheckPolicyBool, @@ -450,11 +450,11 @@ const Descriptor kUsage[] = { {} }, { kUnknown, 0, - nullptr, - nullptr, + "", + "", kBuildTypeAll, kArgCheckPolicyNone, - nullptr, + "", "me", {} } }; diff --git a/src/maple_me/src/me_rc_lowering.cpp b/src/maple_me/src/me_rc_lowering.cpp index 1a30c6f1518775a6915d27df567f7519974f4b5b..ad8c1338e9da9bd25fd3920981214bd7f2f444d0 100644 --- a/src/maple_me/src/me_rc_lowering.cpp +++ b/src/maple_me/src/me_rc_lowering.cpp @@ -85,7 +85,7 @@ void RCLowering::MarkAllRefOpnds() { if (rhs == nullptr) { continue; } - if (rhs->PointsToSomethingThatNeedsIncRef()) { + if (rhs->PointsToSomethingThatNeedsIncRef(ssaTab)) { stmt.EnableNeedIncref(); } else { stmt.DisableNeedIncref(); diff --git a/src/maple_me/src/ssa_devirtual.cpp b/src/maple_me/src/ssa_devirtual.cpp index 8a8a6b84cdf1c6d12420959215cbe982981f3f02..9d672b4fbd246c4256954271d2f90e7ed00cb8d5 100644 --- a/src/maple_me/src/ssa_devirtual.cpp +++ b/src/maple_me/src/ssa_devirtual.cpp @@ -155,9 +155,6 @@ bool SSADevirtual::DevirtualizeCall(CallMeStmt &callStmt) { TyIdx receiverInferredTyIdx = GetInferredTyIdx(*thisParm); MIRFunction &mirFunc = callStmt.GetTargetFunction(); if (thisParm->GetPrimType() == PTY_ref && receiverInferredTyIdx != 0u) { - if (skipReturnTypeOpt) { - break; - } Klass *inferredKlass = kh->GetKlassFromTyIdx(receiverInferredTyIdx); if (inferredKlass == nullptr) { break; @@ -188,9 +185,6 @@ bool SSADevirtual::DevirtualizeCall(CallMeStmt &callStmt) { ReplaceCall(callStmt, *uniqFunc); return true; } else { - if (skipReturnTypeOpt) { - break; - } if (thisParm->GetMeOp() == kMeOpVar) { auto *varMeExpr = static_cast(thisParm); const MapleVector inferredTypeCandidates = varMeExpr->GetInferredTypeCandidates(); @@ -634,7 +628,7 @@ void SSADevirtual::Perform(BB &entryBB) { if (mirFunc == nullptr) { return; // maybe wpo } - if (retTy == kSeen) { + if (!skipReturnTypeOpt && retTy == kSeen) { mirFunc->SetInferredReturnTyIdx(this->inferredRetTyIdx); } // Simple rule: if method's declared returning type is a final class, then diff --git a/src/maple_phase/include/phase_impl.h b/src/maple_phase/include/phase_impl.h index fc684feffdec9c4848564dc9c836b8b19c7e505e..131f81815409ad8b4a9fca1e9e689a59cdedefca 100644 --- a/src/maple_phase/include/phase_impl.h +++ b/src/maple_phase/include/phase_impl.h @@ -22,7 +22,7 @@ namespace maple { class FuncOptimizeImpl : public MplTaskParam { public: - explicit FuncOptimizeImpl(MIRModule &mod, KlassHierarchy *kh = nullptr, bool trace = false); + FuncOptimizeImpl(MIRModule &mod, KlassHierarchy *kh = nullptr, bool trace = false); virtual ~FuncOptimizeImpl(); // Each phase needs to implement its own Clone virtual FuncOptimizeImpl *Clone() = 0; @@ -40,7 +40,7 @@ class FuncOptimizeImpl : public MplTaskParam { protected: void SetCurrentFunction(MIRFunction &func) { currFunc = &func; - ASSERT(builder, "builder is null in FuncOptimizeImpl::SetCurrentFunction"); + ASSERT(builder != nullptr, "builder is null in FuncOptimizeImpl::SetCurrentFunction"); module->SetCurFunction(&func); } diff --git a/src/maple_phase/include/phase_manager.h b/src/maple_phase/include/phase_manager.h index 9d524163bbd6c33350b8418fce4534e84724cd52..ae511f6526ce4007756428e9493f095824094d26 100644 --- a/src/maple_phase/include/phase_manager.h +++ b/src/maple_phase/include/phase_manager.h @@ -45,9 +45,9 @@ class PhaseManager { registeredPhases[id] = &p; } - Phase *GetPhaseFromName(const std::string &pname) { + Phase *GetPhaseFromName(const std::string &phaseName) { for (auto it = RegPhaseBegin(); it != RegPhaseEnd(); ++it) { - if (GetPhaseName(it) == pname) { + if (GetPhaseName(it) == phaseName) { return GetPhase(GetPhaseId(it)); } } @@ -107,16 +107,16 @@ class PhaseManager { } // iterator for phaseSeq - using phaseSeq_iterator = MapleVector::iterator; - phaseSeq_iterator PhaseSequenceBegin() { + using PhaseSeqIterator = MapleVector::iterator; + PhaseSeqIterator PhaseSequenceBegin() { return phaseSequences.begin(); } - phaseSeq_iterator PhaseSequenceEnd() { + PhaseSeqIterator PhaseSequenceEnd() { return phaseSequences.end(); } - PhaseID GetPhaseId(phaseSeq_iterator it) const { + PhaseID GetPhaseId(PhaseSeqIterator it) const { return (*it); } @@ -138,10 +138,9 @@ class PhaseManager { ASSERT(total != 0, "calculation check"); ASSERT(registeredPhases[phaseSequences[i]] != nullptr, "Phase null ptr check"); std::ios::fmtflags f(LogInfo::MapleLogger().flags()); - LogInfo::MapleLogger() << std::left << std::setw(25) << registeredPhases[phaseSequences[i]]->PhaseName() - << std::setw(10) << std::right << std::fixed << std::setprecision(2) - << (100.0 * phaseTimers[i] / total) << "%" << std::setw(10) << std::setprecision(0) - << (phaseTimers[i] / 1000.0) << "ms" << '\n'; + LogInfo::MapleLogger() << std::left << std::setw(25) << registeredPhases[phaseSequences[i]]->PhaseName() << + std::setw(10) << std::right << std::fixed << std::setprecision(2) << (100.0 * phaseTimers[i] / total) << + "%" << std::setw(10) << std::setprecision(0) << (phaseTimers[i] / 1000.0) << "ms" << '\n'; LogInfo::MapleLogger().flags(f); } return total; diff --git a/src/maple_util/include/mpl_number.h b/src/maple_util/include/mpl_number.h index bd47ce3c34f034e3417141c65fd9fc4cfd26c843..f10ddffa4c8b53c3d3ce6422dec8cb13ac64a326 100644 --- a/src/maple_util/include/mpl_number.h +++ b/src/maple_util/include/mpl_number.h @@ -18,18 +18,18 @@ #include #include "utils/meta.h" -namespace maple { namespace utils { - +namespace maple { +namespace utils { template class Number { public: static_assert(std::is_integral::value, "Type for Number should be an integral."); - using element_type = T; + using ElementType = T; Number() = default; - explicit Number(element_type data) : val(data) {} + explicit Number(ElementType data) : val(data) {} template ::value>> explicit Number(U data) : val(static_cast(data)) {} @@ -42,7 +42,7 @@ class Number { // As the implicit T cast is enabled, disable it to avoid implicit cast for `Number num = Number()` // which should be two types and should not be able to neither convert to each other nor compare with each other. - Number &operator=(element_type data) = delete; + Number &operator=(ElementType data) = delete; Number &operator=(const Number &num) noexcept { if (this != &num) { @@ -58,7 +58,7 @@ class Number { return *this; } - void reset(element_type data = 0) noexcept { + void reset(ElementType data = 0) noexcept { val = data; } @@ -66,7 +66,7 @@ class Number { std::swap(val, other.val); } - element_type get() const noexcept { + ElementType get() const noexcept { return val; } @@ -134,7 +134,7 @@ class Number { } private: - element_type val = 0; + ElementType val = 0; }; template diff --git a/src/maple_util/include/mpl_scheduler.h b/src/maple_util/include/mpl_scheduler.h index 27c3141a76e2d6e76da48997118f62972d0d7dcc..55d66a0462ed1035ddd75ad49cfafbaa0c24932e 100644 --- a/src/maple_util/include/mpl_scheduler.h +++ b/src/maple_util/include/mpl_scheduler.h @@ -61,13 +61,11 @@ class MplTask { } protected: - virtual int RunImpl(MplTaskParam *param) { - (void)param; + virtual int RunImpl(MplTaskParam*) { return 0; } - virtual int FinishImpl(MplTaskParam *param) { - (void)param; + virtual int FinishImpl(MplTaskParam*) { return 0; } @@ -86,7 +84,7 @@ class MplScheduler { virtual ~MplScheduler() {} virtual void AddTask(MplTask *task); - virtual int RunTask(uint32 nthreads, bool seq = false); + virtual int RunTask(uint32 threadsNum, bool seq = false); virtual MplSchedulerParam *EncodeThreadMainEnvironment(uint32) { return nullptr; } @@ -126,10 +124,14 @@ class MplScheduler { bool isSchedulerSeq; bool dumpTime; - enum THREAD_STATUS { kThreadStop, kThreadRun, kThreadPause }; + enum ThreadStatus { + kThreadStop, + kThreadRun, + kThreadPause + }; - THREAD_STATUS statusFinish; - virtual int FinishTask(MplTask *task); + ThreadStatus statusFinish; + virtual int FinishTask(const MplTask &task); virtual MplTask *GetTaskToRun(); virtual uint32 GetTaskIdsFinishSize(); virtual MplTask *GetTaskFinishFirst(); @@ -156,7 +158,5 @@ class MplScheduler { return nullptr; } }; - } // namespace maple - #endif // MAPLE_UTIL_INCLUDE_MPLSCHEDULER_H diff --git a/src/maple_util/include/muid.h b/src/maple_util/include/muid.h index 65402dd78c939339cfdd56a2f2f334cb43fc1900..53931226ae4b4f452febc90abf20abc51bae22c4 100644 --- a/src/maple_util/include/muid.h +++ b/src/maple_util/include/muid.h @@ -53,7 +53,10 @@ union DigestHash { // muid-related files are shared between maple compiler and runtime, thus not in // namespace maplert struct MuidContext { - unsigned int a, b, c, d; + unsigned int a; + unsigned int b; + unsigned int c; + unsigned int d; unsigned int count[kNumLowAndHigh]; unsigned int block[kBlockLength]; unsigned char buffer[kGroupSize]; diff --git a/src/maple_util/include/profile.h b/src/maple_util/include/profile.h index 910986fd1d2037e0e610a33b32de45e5b348ec68..ce57b764069f237141200e23ecebeefa3de67a30 100644 --- a/src/maple_util/include/profile.h +++ b/src/maple_util/include/profile.h @@ -48,11 +48,11 @@ class Profile { BBInfo() = default; BBInfo(uint64 hash, uint32 num, std::vector &&counter) : funcHash(hash), totalCounter(num), counter(counter) {} - BBInfo(uint64 hash, uint32 num, std::initializer_list iList) : funcHash(hash), totalCounter(num), - counter(iList) {} + BBInfo(uint64 hash, uint32 num, std::initializer_list iList) + : funcHash(hash), totalCounter(num), counter(iList) {} }; - static const uint8 kStringEnd; + static const uint8 stringEnd; void InitTestData(); bool CheckFuncHot(const std::string &className) const; bool CheckMethodHot(const std::string &className) const; @@ -67,7 +67,7 @@ class Profile { bool GetFunctionBBProf(const std::string &funcName, BBInfo &result); size_t GetLiteralProfileSize() const; bool CheckProfValid() const; - bool CheckDexValid(uint32 idx); + bool CheckDexValid(uint32 idx) const; void SetProfileMode(); void Dump() const; void DumpFuncIRProfUseInfo() const; @@ -101,10 +101,10 @@ class Profile { std::unordered_map funcBBProfUseInfo; std::unordered_map funcDesc; std::vector counterTab; - bool CheckProfileHeader(const Header *header) const; + bool CheckProfileHeader(const Header &header) const; std::string GetProfileNameByType(uint8 type) const; - std::string GetFunctionName(uint32 classIdx, uint32 methodIdx, uint32 sigIdx); - void ParseMeta(const char *data, int fileNum, std::unordered_set &metaData); + std::string GetFunctionName(uint32 classIdx, uint32 methodIdx, uint32 sigIdx) const; + void ParseMeta(const char *data, int fileNum, std::unordered_set &metaData) const; void ParseReflectionStr(const char *data, int fileNum); void ParseFunc(const char *data, int fileNum); void ParseLiteral(const char *data, const char *end); diff --git a/src/maple_util/include/ptr.h b/src/maple_util/include/ptr.h index cbd4ed3678ea8c125b79180266225e4b1fb7e4a7..3291fb9edc0d59f5e850e85704eceeb38d852ae4 100644 --- a/src/maple_util/include/ptr.h +++ b/src/maple_util/include/ptr.h @@ -17,7 +17,6 @@ #include namespace maple { namespace utils { - template using PtrCheckerType = void (*)(const T*); @@ -27,97 +26,97 @@ inline constexpr void CheckNothing(const T*) {} template Check = CheckNothing> class Ptr { public: - using pointer = T*; + using Pointer = T*; using element_type = T; constexpr Ptr() noexcept - : ptr_(nullptr) { + : pointer(nullptr) { Check(nullptr); } constexpr explicit Ptr(std::nullptr_t) noexcept - : ptr_(nullptr) { + : pointer(nullptr) { Check(nullptr); } - explicit Ptr(pointer ptr) - : ptr_(ptr) { + explicit Ptr(Pointer ptr) + : pointer(ptr) { Check(ptr); } - Ptr(pointer ref, PtrCheckerType checker) - : ptr_(ref) { - checker(ptr_); + Ptr(Pointer ref, PtrCheckerType checker) + : pointer(ref) { + checker(pointer); } explicit Ptr(T &ref) - : ptr_(&ref) { - Check(ptr_); + : pointer(&ref) { + Check(pointer); } Ptr(T &ref, PtrCheckerType checker) - : ptr_(&ref) { - checker(ptr_); + : pointer(&ref) { + checker(pointer); } - Ptr(T &&ref) = delete; + explicit Ptr(T &&ref) = delete; template::value>> explicit Ptr(U *ptr) - : ptr_(ptr) { - Check(ptr_); + : pointer(ptr) { + Check(pointer); } template::value>> explicit Ptr(U &ref) - : ptr_(&ref) { - Check(ptr_); + : pointer(&ref) { + Check(pointer); } template::value>> Ptr(U &ref, PtrCheckerType checker) - : ptr_(&ref) { - checker(ptr_); + : pointer(&ref) { + checker(pointer); } template::value>> - Ptr(U &&ref) = delete; + explicit Ptr(U &&ref) = delete; - Ptr(const Ptr &other) - : ptr_(other.get()) {} + explicit Ptr(const Ptr &other) + : pointer(other.get()) {} - Ptr(Ptr &&other) noexcept - : ptr_(other.get()) {} + explicit Ptr(Ptr &&other) noexcept + : pointer(other.get()) {} template CheckU, typename = std::enable_if_t::value>> explicit Ptr(const Ptr &other) - : ptr_(other.get()) { - Check(ptr_); + : pointer(other.get()) { + Check(pointer); } template CheckU, typename = std::enable_if_t::value>> Ptr(const Ptr &other, PtrCheckerType checker) - : ptr_(other.get()) { - checker(ptr_); + : pointer(other.get()) { + checker(pointer); } template CheckU, typename = std::enable_if_t::value>> explicit Ptr(Ptr &&other) - : ptr_(other.get()) { - Check(ptr_); + : pointer(other.get()) { + Check(pointer); } template CheckU, typename = std::enable_if_t::value>> Ptr(Ptr &&other, PtrCheckerType checker) - : ptr_(other.get()) { - checker(ptr_); + : pointer(other.get()) { + checker(pointer); } ~Ptr() = default; - Ptr &operator=(pointer ptr) noexcept { + Ptr &operator=(Pointer ptr) noexcept { Check(ptr); - ptr_ = ptr; + pointer = ptr; return *this; } @@ -129,14 +128,14 @@ class Ptr { Ptr &operator=(const Ptr &ptr) noexcept { if (this != &ptr) { - ptr_ = ptr.ptr_; + pointer = ptr.pointer; } return *this; } Ptr &operator=(Ptr &&ptr) noexcept { if (this != &ptr) { - ptr_ = std::move(ptr.ptr_); + pointer = std::move(ptr.pointer); } return *this; } @@ -145,7 +144,7 @@ class Ptr { Ptr &operator=(const Ptr &ptr) noexcept { if (this->get() != ptr.get()) { Check(ptr.get()); - ptr_ = ptr.get(); + pointer = ptr.get(); } return *this; } @@ -154,24 +153,24 @@ class Ptr { Ptr &operator=(Ptr &&ptr) noexcept { if (this->get() != ptr.get()) { Check(ptr.get()); - ptr_ = std::move(ptr.get()); + pointer = std::move(ptr.get()); } return *this; } - pointer release() noexcept = delete; + Pointer release() noexcept = delete; - void reset(pointer ptr = pointer()) noexcept { + void reset(Pointer ptr = Pointer()) noexcept { Check(ptr); - ptr_ = ptr; + pointer = ptr; } void swap(Ptr &other) noexcept { - std::swap(ptr_, other.ptr_); + std::swap(pointer, other.pointer); } T *get() const noexcept { - return ptr_; + return pointer; } explicit operator bool() const noexcept { @@ -201,7 +200,7 @@ class Ptr { Ptr &operator-=(std::ptrdiff_t) = delete; private: - T *ptr_; + T *pointer; }; template CheckT, typename U, PtrCheckerType CheckU> @@ -256,12 +255,12 @@ inline bool operator!=(std::nullptr_t, const Ptr &rhs) { template CheckT> inline bool operator<(const Ptr &lhs, std::nullptr_t) { - return std::less::pointer>()(lhs.get(), nullptr); + return std::less::Pointer>()(lhs.get(), nullptr); } template CheckT> inline bool operator<(std::nullptr_t, const Ptr &rhs) { - return std::less::pointer>()(nullptr, rhs.get()); + return std::less::Pointer>()(nullptr, rhs.get()); } template CheckT> @@ -293,7 +292,6 @@ template CheckT> inline bool operator>=(std::nullptr_t, const Ptr &rhs) { return !(nullptr < rhs); } - }} #endif //DIY_CPLUSPLUS_SAFE_PTR_H diff --git a/src/maple_util/include/safe_cast.h b/src/maple_util/include/safe_cast.h index 47e1a52f61c4a0d6c508a4daa4e2c2f90eeba98c..abf94f12052267f58f8c0bde0e2538316982fbdc 100644 --- a/src/maple_util/include/safe_cast.h +++ b/src/maple_util/include/safe_cast.h @@ -17,71 +17,69 @@ #include "utils/meta.h" namespace maple { - template -struct safe_cast_condition : std::false_type {}; +struct SafeCastCondition : std::false_type {}; #define REGISTER_SAFE_CAST(type, condition) \ template <> \ -struct safe_cast_condition : std::true_type { \ +struct SafeCastCondition : std::true_type { \ template \ static inline bool DoIt(const FromT &from) { \ return (condition); \ } \ } -namespace __impl { +namespace impl { template ::value>> -struct instance_of_impl { + typename = std::enable_if_t::value>> +struct InstanceOfImpl { static inline bool DoIt(const FromT &from) { - return (safe_cast_condition::DoIt(from)); + return (SafeCastCondition::DoIt(from)); } }; template -struct instance_of_impl::value>> { +struct InstanceOfImpl::value>> { static inline bool DoIt(const FromT&) { return true; } }; template -struct enabled_safe_cast - : utils::meta_or, safe_cast_condition>::type {}; +struct EnabledSafeCast + : utils::meta_or, SafeCastCondition>::type {}; } template ::value>> + typename = std::enable_if_t::value>> inline bool instance_of(FromT &from) { - return __impl::instance_of_impl::DoIt(from); + return impl::InstanceOfImpl::DoIt(from); } template ::value>> + typename = std::enable_if_t::value>> inline bool instance_of(FromT *from) { return (from != nullptr && instance_of(*from)); } template ::value || std::is_const>::value, - std::add_pointer_t>>, - std::add_pointer_t>>, - typename = std::enable_if_t<__impl::enabled_safe_cast::value>> + typename RetT = std::conditional_t< + std::is_const::value || std::is_const>::value, + std::add_pointer_t>>, + std::add_pointer_t>>, + typename = std::enable_if_t::value>> inline RetT safe_cast(FromT &from) { return (instance_of(from) ? static_cast(&from) : nullptr); } template ::value || std::is_const>::value, - std::add_pointer_t>>, - std::add_pointer_t>>, - typename = std::enable_if_t<__impl::enabled_safe_cast::value>> + typename RetT = std::conditional_t< + std::is_const::value || std::is_const>::value, + std::add_pointer_t>>, + std::add_pointer_t>>, + typename = std::enable_if_t::value>> inline RetT safe_cast(FromT *from) { return (instance_of(from) ? static_cast(from) : nullptr); } - } #endif //MAPLE_UTIL_INCLUDE_SAFE_CAST_H diff --git a/src/maple_util/include/safe_ptr.h b/src/maple_util/include/safe_ptr.h index 3ac970ea280e099fc6574d23533b02e07e189aa8..827038d789429d52de3e3e14a4a589c45e64e7c7 100644 --- a/src/maple_util/include/safe_ptr.h +++ b/src/maple_util/include/safe_ptr.h @@ -18,7 +18,6 @@ #include "ptr.h" namespace maple { namespace utils { - template inline void AssertNotNull(const T *ptr) { CHECK_FATAL(ptr != nullptr, "nullptr was assigned to SafePtr."); @@ -28,8 +27,8 @@ template class SafePtr { using Base = Ptr>; public: - using pointer = typename Base::pointer; - using element_type = typename Base::element_type; + using pointer = typename Base::Pointer; + using ElementType = typename Base::element_type; constexpr SafePtr() noexcept = delete; @@ -204,7 +203,6 @@ template inline T &ToRef(SafePtr ptr) { return *ptr; } - }} namespace std @@ -216,5 +214,4 @@ struct hash> { } }; } // namespace std - #endif //DIY_CPLUSPLUS_SAFE_PTR_H diff --git a/src/maple_util/src/profile.cpp b/src/maple_util/src/profile.cpp index 8b1bca0fdd47ff6ef6f6c4ee65e85bd79484b41b..297fe31391833ce98d7d305d571f51c704ccf8c6 100644 --- a/src/maple_util/src/profile.cpp +++ b/src/maple_util/src/profile.cpp @@ -29,10 +29,10 @@ #include "types_def.h" namespace maple { -const uint8 Profile::kStringEnd = 0x00; +constexpr uint8 Profile::stringEnd = 0x00; uint32 Profile::hotFuncCountThreshold = 0; bool Profile::debug = false; -const uint32 kPrecision = 1000000; +constexpr uint32 kPrecision = 1000000; // preHot data static const std::string preClassHot[] = { "Ljava/lang/Class;", @@ -47,8 +47,8 @@ static const std::string preClassHot[] = { Profile::Profile() {} -bool Profile::CheckProfileHeader(const Header *header) const { - return (memcmp(header->magic, kProfileMagic, sizeof(kProfileMagic)) == 0); +bool Profile::CheckProfileHeader(const Header &header) const { + return (memcmp(header.magic, kProfileMagic, sizeof(kProfileMagic)) == 0); } std::string Profile::GetProfileNameByType(uint8 type) const { @@ -74,10 +74,9 @@ std::string Profile::GetProfileNameByType(uint8 type) const { default: CHECK_FATAL(false, "type not found"); } - return ""; } -bool Profile::CheckDexValid(uint32 idx) { +bool Profile::CheckDexValid(uint32 idx) const { if (isAppProfile) { return true; // for app dont't check dexName } @@ -86,9 +85,9 @@ bool Profile::CheckDexValid(uint32 idx) { void Profile::ParseLiteral(const char *data, const char *end) { if(data > end) { - LogInfo::MapleLogger() << "parse Literal error" << '\n';; + LogInfo::MapleLogger() << "parse Literal error" << '\n'; } - std::string str(data,end-data); + const std::string str(data,end-data); std::stringstream ss; ss.str(str); std::string item; @@ -100,11 +99,11 @@ void Profile::ParseLiteral(const char *data, const char *end) { } } -std::string Profile::GetFunctionName(uint32 classIdx, uint32 methodIdx, uint32 sigIdx) { - std::string className = NameMangler::EncodeName(strMap.at(classIdx)); - std::string methodName = NameMangler::EncodeName(strMap.at(methodIdx)); - std::string sigName = NameMangler::EncodeName(strMap.at(sigIdx)); - std::string funcName = className + "_7C" + methodName + "_7C" + sigName; +std::string Profile::GetFunctionName(uint32 classIdx, uint32 methodIdx, uint32 sigIdx) const { + const std::string className = NameMangler::EncodeName(strMap.at(classIdx)); + const std::string methodName = NameMangler::EncodeName(strMap.at(methodIdx)); + const std::string sigName = NameMangler::EncodeName(strMap.at(sigIdx)); + const std::string funcName = className + "_7C" + methodName + "_7C" + sigName; return funcName; } @@ -112,14 +111,14 @@ void Profile::ParseFunc(const char *data, int fileNum) { const MapleFileProf *funcProf = nullptr; const FunctionItem *funcItem = nullptr; uint32 offset = 0; - for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; mapleFileIdx++) { + for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; ++mapleFileIdx) { funcProf = reinterpret_cast(data + offset); - if (CheckDexValid(funcProf->idx)) { + if (CheckDexValid(funcProf->idx)) { if (debug) { LogInfo::MapleLogger() << "FuncProfile" << ":" << strMap.at(funcProf->idx) << ":" << funcProf->num << "\n"; } funcItem = reinterpret_cast(data + offset + sizeof(MapleFileProf)); - for (uint32 item = 0; item < funcProf->num; item++, ++funcItem) { + for (uint32 item = 0; item < funcProf->num; ++item, ++funcItem) { if (funcItem->type >= kLayoutTypeCount) { if (debug) { LogInfo::MapleLogger() << "ParseFunc Error usupport type " << funcItem->type << "\n"; @@ -140,9 +139,9 @@ void Profile::ParseIRFuncDesc(const char *data, int fileNum) { const MapleFileProf *funcProf = nullptr; const FunctionIRProfItem *funcItem = nullptr; uint32 offset = 0; - for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; mapleFileIdx++) { + for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; ++mapleFileIdx) { funcProf = reinterpret_cast(data + offset); - if (CheckDexValid(funcProf->idx)) { + if (CheckDexValid(funcProf->idx)) { if (debug) { LogInfo::MapleLogger() << "IRFuncProfile" << ":" << strMap.at(funcProf->idx) << ":" << funcProf->num << "\n"; } @@ -150,7 +149,7 @@ void Profile::ParseIRFuncDesc(const char *data, int fileNum) { for (uint32 item = 0; item < funcProf->num; ++item, ++funcItem) { if ((funcItem->counterStart <= counterTab.size()) && (funcItem->counterEnd <= counterTab.size())) { auto begin = counterTab.begin() + funcItem->counterStart; - auto end = counterTab.begin() + funcItem->counterEnd + 1; + auto end = counterTab.begin() + funcItem->counterEnd + 1; std::vector tempCounter(begin, end); BBInfo bbInfo(funcItem->hash, tempCounter.size(), std::move(tempCounter)); std::string funcName = GetFunctionName(funcItem->classIdx, funcItem->methodIdx, funcItem->sigIdx); @@ -166,8 +165,8 @@ void Profile::ParseIRFuncDesc(const char *data, int fileNum) { void Profile::ParseCounterTab(const char *data, int fileNum) { const MapleFileProf *counterProf = nullptr; uint32 offset = 0; - for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; mapleFileIdx++) { - counterProf = reinterpret_cast(data + offset); + for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; ++mapleFileIdx) { + counterProf = reinterpret_cast(data + offset); if (CheckDexValid(counterProf->idx)) { if (debug) { LogInfo::MapleLogger() << "module name " << strMap.at(counterProf->idx) << std::endl; @@ -181,11 +180,11 @@ void Profile::ParseCounterTab(const char *data, int fileNum) { } } -void Profile::ParseMeta(const char *data, int fileNum, std::unordered_set &metaData) { +void Profile::ParseMeta(const char *data, int fileNum, std::unordered_set &metaData) const { const MapleFileProf *metaProf = nullptr; uint32 offset = 0; - for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; mapleFileIdx++) { - metaProf = reinterpret_cast(data + offset); + for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; ++mapleFileIdx) { + metaProf = reinterpret_cast(data + offset); if (CheckDexValid(metaProf->idx)) { if (debug) { LogInfo::MapleLogger() << "module name " << strMap.at(metaProf->idx) << '\n'; @@ -202,8 +201,8 @@ void Profile::ParseMeta(const char *data, int fileNum, std::unordered_set(data + offset); + for (int32 mapleFileIdx = 0; mapleFileIdx < fileNum; ++mapleFileIdx) { + metaProf = reinterpret_cast(data + offset); if (CheckDexValid(metaProf->idx)) { if (debug) { LogInfo::MapleLogger() << "module name " << strMap.at(metaProf->idx) << '\n'; @@ -220,8 +219,8 @@ void Profile::ParseReflectionStr(const char *data, int fileNum) { } void Profile::InitPreHot() { - const char *kcoreDexName = "core-all"; - if (dexName.find(kcoreDexName) != std::string::npos) { + const char *coreDexName = "core-all"; + if (dexName.find(coreDexName) != std::string::npos) { for (auto &item : preClassHot) { classMeta.insert(item); } @@ -241,8 +240,7 @@ bool Profile::DeCompress(const std::string &path, const std::string &dexNameInne std::ifstream in(path, std::ios::binary); if (!in) { if (errno != ENOENT && errno != EACCES) { - LogInfo::MapleLogger() << "WARN: DeCompress(" - << "), failed to open " << path << '\n';; + LogInfo::MapleLogger() << "WARN: DeCompress(" << "), failed to open " << path << '\n';; } res = false; return res; @@ -254,21 +252,19 @@ bool Profile::DeCompress(const std::string &path, const std::string &dexNameInne bufVector.resize(byteCount); char *buf = reinterpret_cast(bufVector.data()); if (!in.read(buf, byteCount)) { - LogInfo::MapleLogger() << "WARN: DeCompress(" - << "), failed to read all data for " << path << '\n';; + LogInfo::MapleLogger() << "WARN: DeCompress(" << "), failed to read all data for " << path << '\n'; res = false; in.close(); return res; } if (byteCount < sizeof(Header)) { - LogInfo::MapleLogger() << "WARN: DeCompress(" - << "), failed, read no data for " << path << '\n';; + LogInfo::MapleLogger() << "WARN: DeCompress(" << "), failed, read no data for " << path << '\n'; res = false; in.close(); return res; } Header *header = reinterpret_cast(buf); - if (!CheckProfileHeader(header)) { + if (!CheckProfileHeader(*header)) { if (debug) { LogInfo::MapleLogger() << "invalid maigc number " << header->magic << '\n';; } @@ -279,9 +275,8 @@ bool Profile::DeCompress(const std::string &path, const std::string &dexNameInne this->isAppProfile = (header->profileFileType == kApp) ? true : false; size_t stringTabSize = byteCount - header->stringTabOff; if (debug) { - LogInfo::MapleLogger() << "Header summary " - << "profile num " << static_cast(header->profileNum) << "string table size" << stringTabSize - << '\n';; + LogInfo::MapleLogger() << "Header summary " << "profile num " << static_cast(header->profileNum) << + "string table size" << stringTabSize << '\n'; } const char *strBuf = buf + header->stringTabOff; const char *cursor = strBuf; @@ -294,21 +289,21 @@ bool Profile::DeCompress(const std::string &path, const std::string &dexNameInne } ASSERT(strMap.size() == header->stringCount, "string count doesn't match"); if (debug) { - LogInfo::MapleLogger() << "str size " << strMap.size() << '\n';; + LogInfo::MapleLogger() << "str size " << strMap.size() << '\n'; for (const auto &item : strMap) { - LogInfo::MapleLogger() << item << '\n';; + LogInfo::MapleLogger() << item << '\n'; } - LogInfo::MapleLogger() << "str size print end " << '\n';; + LogInfo::MapleLogger() << "str size print end " << '\n'; } size_t idx = 0; - for (idx = 0; idx < header->profileNum; idx++) { + for (idx = 0; idx < header->profileNum; ++idx) { ProfileDataInfo *profileDataInfo = &(header->data[idx]); if (debug) { - LogInfo::MapleLogger() << "profile file num for type " << GetProfileNameByType(profileDataInfo->profileType) << " " - << static_cast(profileDataInfo->mapleFileNum) << '\n';; + LogInfo::MapleLogger() << "profile file num for type " << GetProfileNameByType(profileDataInfo->profileType) << + " " << static_cast(profileDataInfo->mapleFileNum) << '\n';; } if (debug) { - LogInfo::MapleLogger() << GetProfileNameByType(profileDataInfo->profileType) << " Start" << '\n';; + LogInfo::MapleLogger() << GetProfileNameByType(profileDataInfo->profileType) << " Start" << '\n'; } char *proFileData = buf + profileDataInfo->profileDataOff; if (type != kAll && type != profileDataInfo->profileType) { @@ -343,18 +338,18 @@ bool Profile::DeCompress(const std::string &path, const std::string &dexNameInne uint32_t appPackageNameIdx = *reinterpret_cast(proFileData); this->appPackageName = strMap.at(appPackageNameIdx); if (!appPackageName.empty() && this->appPackageName != appPackageName) { - LogInfo::MapleLogger() << "app profile doesnt match expect " << this->appPackageName - << " but got " << appPackageName << '\n';; + LogInfo::MapleLogger() << "app profile doesnt match expect " << this->appPackageName << + " but got " << appPackageName << '\n'; return false; } break; } default: - LogInfo::MapleLogger() << "unsupported tag " << profileDataInfo->profileType << '\n';; + LogInfo::MapleLogger() << "unsupported tag " << profileDataInfo->profileType << '\n'; break; } } - LogInfo::MapleLogger() << "SUCC parse " << path << '\n';; + LogInfo::MapleLogger() << "SUCC parse " << path << '\n'; valid = true; in.close(); return res; @@ -498,44 +493,42 @@ void Profile::DumpFuncIRProfUseInfo() const { if (funcBBProfData.empty()) { return; } - LogInfo::MapleLogger() << "ir profile succ " << funcBBProfUseInfo.size() << " total func " - << funcBBProfData.size() << '\n'; + LogInfo::MapleLogger() << "ir profile succ " << funcBBProfUseInfo.size() << " total func " << + funcBBProfData.size() << '\n'; } void Profile::Dump() const { std::ofstream outFile; outFile.open("prof.dump"); - outFile << "classMeta profile start " <<'\n';; + outFile << "classMeta profile start " <<'\n'; for (const auto &item : classMeta) { - outFile << item << '\n';; + outFile << item << '\n'; } - outFile << "fieldMeta profile start " <<'\n';; + outFile << "fieldMeta profile start " <<'\n'; for (const auto &item : fieldMeta) { - outFile << item << '\n';; + outFile << item << '\n'; } - outFile << "methodMeta profile start " <<'\n';; + outFile << "methodMeta profile start " <<'\n'; for (const auto &item : methodMeta) { - outFile << item << '\n';; + outFile << item << '\n'; } - outFile << "literal profile start " <<'\n';; + outFile << "literal profile start " <<'\n'; for (const auto &item : literal) { - outFile << item << '\n';; + outFile << item << '\n'; } - outFile << "func profile start " <<'\n';; + outFile << "func profile start " <<'\n'; for (const auto &item : funcProfData) { - outFile << item.first << " " - << static_cast((item.second).type) << " " << (item.second).callTimes << '\n';; + outFile << item.first << " " << static_cast((item.second).type) << " " << (item.second).callTimes << '\n'; } - outFile << "reflectStr profile start " <<'\n';; + outFile << "reflectStr profile start " <<'\n'; for (const auto &item : reflectionStrData) { - outFile << item.first << " " << static_cast(item.second) << '\n';; + outFile << item.first << " " << static_cast(item.second) << '\n'; } outFile.close(); } - } // namespace maple diff --git a/src/mpl2mpl/src/native_stub_func.cpp b/src/mpl2mpl/src/native_stub_func.cpp index 6d0b4285594d988484e45eefab14620858a6ec37..80532f21b74febd494efeafec5a7846bdb0c853b 100644 --- a/src/mpl2mpl/src/native_stub_func.cpp +++ b/src/mpl2mpl/src/native_stub_func.cpp @@ -18,6 +18,7 @@ #include "namemangler.h" #include "vtable_analysis.h" #include "reflection_analysis.h" +#include "metadata_layout.h" // NativeStubFunc // This phase is the processing of the java native function. It @@ -275,7 +276,15 @@ void NativeStubFuncGeneration::GenerateRegFuncTabEntry() { #else constexpr int locIdxShift = 4; #endif + +#ifdef TARGARM32 + // LSB can not be used to mark unresolved entries in java native method table for arm, since this bit + // is used to switch arm mode and thumb mode (when LSB of pc is set to 1) + constexpr uint64 locIdxMask = 0; +#else constexpr uint64 locIdxMask = 0x01; +#endif + uint64 locIdx = regFuncTabConst->GetConstVec().size(); auto *newConst = GlobalTables::GetIntConstTable().GetOrCreateIntConst(static_cast((locIdx << locIdxShift) | locIdxMask), @@ -337,19 +346,28 @@ void NativeStubFuncGeneration::GenerateRegisteredNativeFuncCall(MIRFunction &fun bool needCheckThrowPendingExceptionFunc = (!func.GetAttr(FUNCATTR_critical_native)) && (funcProperty.jniType == kJniTypeNormal); bool needIndirectCall = func.GetAttr(FUNCATTR_critical_native) || func.GetAttr(FUNCATTR_fast_native); + // Get current native method function ptr from reg_jni_func_tab slot - // and define a temp register for shift operation - auto funcPtrAndOpPreg = func.GetPregTab()->CreatePreg(PTY_ptr); BaseNode *regReadExpr = builder->CreateExprRegread(PTY_ptr, funcptrPreg); +#ifdef TARGARM32 + BaseNode *checkRegExpr = + builder->CreateExprCompare(OP_lt, *GlobalTables::GetTypeTable().GetUInt1(), + *GlobalTables::GetTypeTable().GetPtr(), + regReadExpr, builder->CreateIntConst(MByteRef::PositiveOffsetBias, PTY_ptr)); +#elif defined(TARGAARCH64) + // define a temp register for bitwise-and operation constexpr int intConstLength = 1; BaseNode *andExpr = builder->CreateExprBinary(OP_band, *GlobalTables::GetTypeTable().GetPtr(), regReadExpr, builder->CreateIntConst(intConstLength, PTY_u32)); + auto funcPtrAndOpPreg = func.GetPregTab()->CreatePreg(PTY_ptr); RegassignNode *funcPtrAndOpAssign = builder->CreateStmtRegassign(PTY_ptr, funcPtrAndOpPreg, andExpr); auto readFuncPtrAndReg = builder->CreateExprRegread(PTY_ptr, funcPtrAndOpPreg); BaseNode *checkRegExpr = builder->CreateExprCompare(OP_eq, *GlobalTables::GetTypeTable().GetUInt1(), *GlobalTables::GetTypeTable().GetPtr(), readFuncPtrAndReg, builder->CreateIntConst(kInvalidCode, PTY_ptr)); +#endif + auto *ifStmt = static_cast(builder->CreateStmtIf(checkRegExpr)); // get find_native_func function MIRType *voidPointerType = GlobalTables::GetTypeTable().GetVoidPtr(); @@ -372,7 +390,9 @@ void NativeStubFuncGeneration::GenerateRegisteredNativeFuncCall(MIRFunction &fun func.GetBody()->AddStatement(wrapperCall); } else if (!Options::regNativeDynamicOnly) { // Qemu func.GetBody()->AddStatement(funcptrAssign); +#ifdef TARGAARCH64 func.GetBody()->AddStatement(funcPtrAndOpAssign); +#endif // Get find_native_func function MIRFunction *findNativeFunc = builder->GetOrCreateFunction(NameMangler::kFindNativeFuncNoeh, voidPointerType->GetTypeIndex()); @@ -426,7 +446,9 @@ void NativeStubFuncGeneration::GenerateRegisteredNativeFuncCall(MIRFunction &fun } } else { // EMUI func.GetBody()->AddStatement(funcptrAssign); +#ifdef TARGAARCH64 func.GetBody()->AddStatement(funcPtrAndOpAssign); +#endif MIRFunction *findNativeFunc = builder->GetOrCreateFunction(NameMangler::kFindNativeFunc, voidPointerType->GetTypeIndex()); findNativeFunc->SetAttr(FUNCATTR_nosideeffect); diff --git a/src/mpl2mpl/src/vtable_impl.cpp b/src/mpl2mpl/src/vtable_impl.cpp index f98ccf73b98f60282f98349a78eb2913f2818078..82603807026aa0ad4834cac341ee4cdc353928fe 100644 --- a/src/mpl2mpl/src/vtable_impl.cpp +++ b/src/mpl2mpl/src/vtable_impl.cpp @@ -88,25 +88,6 @@ void VtableImpl::ProcessFunc(MIRFunction *func) { while (stmt != nullptr) { next = stmt->GetNext(); Opcode opcode = stmt->GetOpCode(); -#if defined(TARGARM) || defined(TARGAARCH64) - if (kOpcodeInfo.IsCallAssigned(opcode)) { - CallNode *cnode = static_cast(stmt); - MIRFunction *calleefunc = GlobalTables::GetFunctionTable().GetFunctionFromPuidx(cnode->GetPUIdx()); - const std::set intrisicsList { -#define DEF_MIR_INTRINSIC(X, NAME, INTRN_CLASS, RETURN_TYPE, ...) NAME, -#include "simplifyintrinsics.def" -#undef DEF_MIR_INTRINSIC - }; - const std::string funcName = calleefunc->GetName(); - if (!Options::buildApp && Options::O2 && intrisicsList.find(funcName) != intrisicsList.end() && - funcName != "Ljava_2Flang_2FString_3B_7CindexOf_7C_28Ljava_2Flang_2FString_3B_29I") { - if (Intrinsify(*func, *cnode)) { - stmt = next; - continue; - } - } - } -#endif switch (opcode) { case OP_regassign: { auto *regassign = static_cast(stmt); diff --git a/src/mplfe/common/src/mplfe_options.cpp b/src/mplfe/common/src/mplfe_options.cpp index 7506781e66534a4fff65cffbc91b9b1637ffb6df..614402397c03d2ba87c38582c97bf238d315bc4a 100644 --- a/src/mplfe/common/src/mplfe_options.cpp +++ b/src/mplfe/common/src/mplfe_options.cpp @@ -180,7 +180,7 @@ const mapleOption::Descriptor kUsage[] = { { static_cast(kReleaseAfterEmit), 0, "", "release-after-emit", mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyNone, " --release-after-emit : release temp memory after emit", "mplfe", {} }, - { 0, 0, nullptr, nullptr, mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyNone, nullptr, "mplfe", {} } + { 0, 0, "", "", mapleOption::kBuildTypeAll, mapleOption::kArgCheckPolicyNone, "", "mplfe", {} } }; MPLFEOptions MPLFEOptions::options; @@ -303,7 +303,7 @@ bool MPLFEOptions::SolveArgs(int argc, char **argv) { } void MPLFEOptions::DumpUsage() const { - for (unsigned int i = 0; kUsage[i].help != nullptr; i++) { + for (unsigned int i = 0; kUsage[i].help != ""; i++) { std::cout << kUsage[i].help << std::endl; } }