diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index 326af1944a193a76ee46b7587ac3a0e3d2cb4a0d..8fbfc773a14bea5a598f656143b3e37900bd9def 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index 6053feffc4e206eeed1e030ee6cbfa5a70c54d4d..8bd382bbc3263aa0333034107ddd4f481a5cd43f 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/deplibs/libmplutil.a b/src/deplibs/libmplutil.a index 6cc43036f8e924c6781f9c33bcd11f37d0ebc732..7a57b6d9fd92f490ff3ec63d3f4ae26a9891cfa2 100644 Binary files a/src/deplibs/libmplutil.a and b/src/deplibs/libmplutil.a differ 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 ed8bfa8c721e057b33ea78cc7231705c84870a3b..3c8e9157e508c997b58007252e87efcb87d46a9d 100644 --- a/src/maple_be/include/ad/target/mplad_unit_define.def +++ b/src/maple_be/include/ad/target/mplad_unit_define.def @@ -1,6 +1,6 @@ /* cortex_a55 function units definition : */ -const int kunitNum = 2; +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; diff --git a/src/maple_be/mdgen/include/mdparser.h b/src/maple_be/mdgen/include/mdparser.h index 5833e6385951fd59c3352fb64053bf61b27ade85..c5a8a5d3e0348271c1632cefe7aa63dc3b997722 100644 --- a/src/maple_be/mdgen/include/mdparser.h +++ b/src/maple_be/mdgen/include/mdparser.h @@ -37,8 +37,8 @@ class MDParser { bool ParseMDObjBody(MDObject &curObj); bool ParseIntElement(MDObject &curObj, bool isVec); bool ParseStrElement(MDObject &curObj, bool isVec); - bool ParseDefTyElement(MDObject &curObj, bool isVec, std::set &childSet); - bool ParseDefObjElement(MDObject &curObj, bool isVec, MDClass &pClass); + bool ParseDefTyElement(MDObject &curObj, bool isVec, const std::set &childSet); + bool ParseDefObjElement(MDObject &curObj, bool isVec, const MDClass &pClass); /* error process */ bool EmitError(const std::string &errMsg); diff --git a/src/maple_be/mdgen/include/mdrecord.h b/src/maple_be/mdgen/include/mdrecord.h index e8b923d9f376bdbf8fdb6e87dede6026b48aeb14..7185712fdc6a093b4197b8693beec12f31dc5472 100644 --- a/src/maple_be/mdgen/include/mdrecord.h +++ b/src/maple_be/mdgen/include/mdrecord.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "mempool_allocator.h" #include "mempool.h" #include "mpl_logging.h" @@ -41,9 +42,9 @@ enum RecordType : maple::uint32 { }; struct StrInfo { - int idx; + unsigned int idx; RecordType sType; - StrInfo(int curIdx, RecordType curTy) : idx(curIdx), sType(curTy) {} + StrInfo(unsigned int curIdx, RecordType curTy) : idx(curIdx), sType(curTy) {} }; class MDElement { @@ -60,13 +61,19 @@ class MDElement { kEleInValidTy }; - virtual int GetContent() const = 0; + unsigned int GetContent() const { + return DoGetContent(); + } + ElementTy GetRecDataTy() const { return eleType; } protected: ElementTy eleType = kEleInValidTy; + + private: + virtual unsigned int DoGetContent() const = 0; }; class DefaultElement : public MDElement { @@ -74,39 +81,44 @@ class DefaultElement : public MDElement { DefaultElement() { eleType = kEleDefaultTy; } + ~DefaultElement() override = default; - int GetContent() const override { + private: + unsigned int DoGetContent() const override { CHECK_FATAL(false, "Cannnot load default element's content"); - return -1; + return UINT_MAX; } }; class IntElement : public MDElement { public: - explicit IntElement(int curVal) : intEleVal(curVal) { + explicit IntElement(unsigned int curVal) : intEleVal(curVal) { eleType = kEleIntTy; } + ~IntElement() override = default; - int GetContent() const override { - return intEleVal; - } private: - int intEleVal; + unsigned int intEleVal; + unsigned int DoGetContent() const override { + return intEleVal; + } }; class StringElement : public MDElement { public: - explicit StringElement(int curIdx) : strElemntIdx(curIdx) { + explicit StringElement(unsigned int curIdx) : strElemntIdx(curIdx) { eleType = kEleStrTy; } + ~StringElement() override = default; - int GetContent() const override { + + private: + unsigned int strElemntIdx; + unsigned int DoGetContent() const override { return strElemntIdx; } - private: - int strElemntIdx; }; class DefTyElement : public MDElement { @@ -114,14 +126,16 @@ class DefTyElement : public MDElement { DefTyElement() { eleType = kEleDefTyTy; } + ~DefTyElement() override = default; - int GetContent() const override { - return elementIdx; - } - bool SetContent(StrInfo curInfo, std::set &childTySet); + + bool SetContent(const StrInfo curInfo, const std::set &childTySet); private: - int elementIdx = -1; + unsigned int elementIdx = UINT_MAX; + unsigned int DoGetContent() const override { + return elementIdx; + } }; class DefObjElement : public MDElement { @@ -129,14 +143,16 @@ class DefObjElement : public MDElement { DefObjElement() { eleType = kEleDefObjTy; } + ~DefObjElement() override = default; - int GetContent() const override { - return elementIdx; - } - bool SetContent(StrInfo curInfo, MDClass &parentClass); + + bool SetContent(const StrInfo curInfo, const MDClass &parentClass); private: - int elementIdx = -1; + unsigned int elementIdx = UINT_MAX; + unsigned int DoGetContent() const override { + return elementIdx; + } }; class VecElement : public MDElement { @@ -144,44 +160,54 @@ class VecElement : public MDElement { explicit VecElement(maple::MemPool &mem) : alloc(&mem), vecData(alloc.Adapter()) { eleType = kEleVecTy; } + ~VecElement() override = default; + void appendElement(MDElement *curElement) { vecData.push_back(curElement); } - int GetContent() const override { - CHECK_FATAL(false, "Vector element does not have a single content"); - return -1; - } + const maple::MapleVector GetVecData() const { return vecData; } + size_t GetVecDataSize() const { return vecData.size(); } + private: maple::MapleAllocator alloc; maple::MapleVector vecData; + + unsigned int DoGetContent() const override { + CHECK_FATAL(false, "Vector element does not have a single content"); + return UINT_MAX; + } }; class MDObject { public: - MDObject(int curIdx, MDClass &pClass, maple::MemPool &memPool) + MDObject(unsigned int curIdx, MDClass &pClass, maple::MemPool &memPool) : objectIdx(curIdx), parentClass(&pClass), alloc(&memPool), mdElements(alloc.Adapter()) {} + ~MDObject() = default; - const MDElement *GetOneMDElement(int index) const; + const MDElement *GetOneMDElement(size_t index) const; + void AddMDElements(MDElement* curElement) { mdElements.push_back(curElement); } - int GetIdx() const { + + unsigned int GetIdx() const { return objectIdx; } + const MDClass *GetParentClass() const { return parentClass; } private: - int objectIdx; + unsigned int objectIdx; MDClass *parentClass; maple::MapleAllocator alloc; maple::MapleVector mdElements; @@ -189,26 +215,26 @@ class MDObject { class MDClass { public: - MDClass(int classIdx, bool isAnonymous) { + MDClass(unsigned int classIdx, bool isAnonymous) { this->classIdx = classIdx; this->isAnonymous = isAnonymous; } ~MDClass() = default; - const MDObject &GetOneMDObject(int index) const; + const MDObject &GetOneMDObject(size_t index) const; void AddClassMember(MDObject inputObj); - bool IsClassMember(int curIdx); + bool IsClassMember(unsigned int curIdx) const; bool IsValidStructEle(RecordType curTy) const; - int GetClassIdx() const { + unsigned int GetClassIdx() const { return classIdx; } bool IsAnonymousClass() const { return isAnonymous; } - const std::vector> GetFormalTypes() const { + const std::vector> GetFormalTypes() const { return formalTypes; } - const std::set GetchildObjNames() const { + const std::set GetchildObjNames() const { return childObjNames; } size_t GetFormalTypeSize() const { @@ -217,14 +243,14 @@ class MDClass { size_t GetMDObjectSize() const { return mdObjects.size(); } - void BuildFormalTypes(int memberIdx, bool isVec); + void BuildFormalTypes(unsigned int memberIdx, bool isVec); private: - int classIdx; + unsigned int classIdx; bool isAnonymous; std::vector mdObjects; - std::vector> formalTypes; - std::set childObjNames; + std::vector> formalTypes; + std::set childObjNames; }; class MDClassRange { @@ -232,34 +258,34 @@ class MDClassRange { explicit MDClassRange(std::string module) : moduleName(module) { stringTable.clear(); stringHashTable.clear(); - /* init common types such as int ,string , float */ - std::set initTypes; + /* init common types such as unsigned int ,string , float */ + std::set initTypes; AddDefinedType(CreateStrInTable("int", kIntType), initTypes); AddDefinedType(CreateStrInTable("string", kStringType), initTypes); } ~MDClassRange() = default; StrInfo GetStrInTable(const std::string &inStr); - RecordType GetStrTyByIdx(int curIdx); - const std::string &GetStrByIdx(int curIdx); + RecordType GetStrTyByIdx(size_t curIdx); + const std::string &GetStrByIdx(size_t curIdx); void AddMDClass(MDClass curClass); - MDClass GetOneMDClass(int givenIdx); - std::set GetOneSpcType(int givenTyIdx); + MDClass GetOneMDClass(unsigned int givenIdx); + std::set GetOneSpcType(unsigned int givenTyIdx); size_t GetStringTableSize() const { return stringTable.size(); } - int CreateStrInTable(const std::string &inStr, RecordType curTy); + unsigned int CreateStrInTable(const std::string &inStr, RecordType curTy); void ModifyStrTyInTable(const std::string &inStr, RecordType newTy); - void AddDefinedType(int typesName, std::set typesSet); - void FillMDClass(int givenIdx, const MDObject &insertObj); + void AddDefinedType(unsigned int typesName, std::set typesSet); + void FillMDClass(unsigned int givenIdx, const MDObject &insertObj); private: std::string moduleName; std::unordered_map stringHashTable; std::vector stringTable; - int totalStr = 0; - std::unordered_map> definedTypes; - std::unordered_map allClasses; + unsigned int totalStr = 0; + std::unordered_map> definedTypes; + std::unordered_map allClasses; }; } /* namespace MDGen */ diff --git a/src/maple_be/mdgen/src/mdgenerator.cpp b/src/maple_be/mdgen/src/mdgenerator.cpp index 41328a133dd1dac434e86d86f05341a8d834fc21..0191e4519b7cdeebdcdcda624c7dd35d83249ed7 100644 --- a/src/maple_be/mdgen/src/mdgenerator.cpp +++ b/src/maple_be/mdgen/src/mdgenerator.cpp @@ -35,9 +35,9 @@ void MDCodeGen::EmitFileHead(std::ofstream &outputFile, const std::string &headI outputFile << "/* " << targetArchName << " " << headInfo << " definition : */\n"; } -MDClass MDCodeGen::GetSpecificClass (const std::string &className) { - int classIdx = curKeeper.GetStrInTable(className).idx; - CHECK_FATAL(classIdx >= 0, "Load Class Failed!"); +MDClass MDCodeGen::GetSpecificClass(const std::string &className) { + unsigned int classIdx = curKeeper.GetStrInTable(className).idx; + CHECK_FATAL(classIdx != UINT_MAX, "Load Class Failed!"); return curKeeper.GetOneMDClass(classIdx); } @@ -100,7 +100,7 @@ void SchedInfoGen::EmitUnitDef() { std::string unitPrefix = "Unit *" + emitUnitName + " = new Unit("; if (!isUnitNumDef) { outFile << "\n"; - outFile << "const int kunitNum = 2;\n"; + outFile << "const unsigned int kunitNum = 2;\n"; isUnitNumDef = true; } outFile << unitPrefix; @@ -116,7 +116,7 @@ void SchedInfoGen::EmitUnitDef() { CHECK_FATAL(unitTypeStr.size() != 0, "Haven't support this kind of Unit yet"); outFile << unitTypeStr << ", " << curUnitName << ", kunitNum,\n"; outFile << std::setiosflags(std::ios::right) << std::setw(unitPrefix.length()) << std::setfill(' ') << " "; - int dependUnitsIndex = 1; + unsigned int dependUnitsIndex = 1; auto *dependUnitEle = static_cast(singleUnit.GetOneMDElement(dependUnitsIndex)); for (size_t k = 0; k < dependUnitEle->GetVecDataSize(); ++k) { auto *dependUnit = static_cast(dependUnitEle->GetVecData()[k]); @@ -159,7 +159,7 @@ void SchedInfoGen::EmitResvDef() { if (singleResv.GetOneMDElement(1)->GetRecDataTy() == MDElement::kEleDefaultTy) { outFile << "0);\n"; } else { - int dependUnitsIndex = 1; + size_t dependUnitsIndex = 1; auto *dependUnitEle = static_cast(singleResv.GetOneMDElement(dependUnitsIndex)); outFile << dependUnitEle->GetVecDataSize() << ",\n"; for (size_t k = 0; k < dependUnitEle->GetVecDataSize(); ++k) { @@ -190,9 +190,9 @@ void SchedInfoGen::EmitBypassDef() { if (singleBypass.GetOneMDElement(0)->GetRecDataTy() == MDElement::kEleDefaultTy) { continue; } - constexpr int fromVecIndex = 1; - constexpr int toVecIndex = 2; - constexpr int curBpTyIndex = 3; + constexpr size_t fromVecIndex = 1; + constexpr size_t toVecIndex = 2; + constexpr size_t curBpTyIndex = 3; auto *bpTyEle = singleBypass.GetOneMDElement(curBpTyIndex); std::string curBypassTy = (bpTyEle->GetRecDataTy() == MDElement::kEleDefaultTy) ? "" : curKeeper.GetStrByIdx(bpTyEle->GetContent()); @@ -204,7 +204,7 @@ void SchedInfoGen::EmitBypassDef() { CHECK_FATAL(singleBypass.GetOneMDElement(toVecIndex)->GetRecDataTy() == MDElement::ElementTy::kEleVecTy, "Bypass illegal"); - int bypassNum = static_cast(singleBypass.GetOneMDElement(0))->GetContent(); + unsigned int bypassNum = static_cast(singleBypass.GetOneMDElement(0))->GetContent(); auto *fromVec = static_cast(singleBypass.GetOneMDElement(fromVecIndex)); auto *toVec = static_cast(singleBypass.GetOneMDElement(toVecIndex)); for (auto itTo : toVec->GetVecData()) { diff --git a/src/maple_be/mdgen/src/mdparser.cpp b/src/maple_be/mdgen/src/mdparser.cpp index 7e6095a872a5779a7cbda11059b5cc6124786ce6..6af377972338d414dd77e86cccc14d55ca5ef46a 100644 --- a/src/maple_be/mdgen/src/mdparser.cpp +++ b/src/maple_be/mdgen/src/mdparser.cpp @@ -56,19 +56,19 @@ bool MDParser::ParseDefType() { if (lexer.NextToken() != kMDIdentifier) { return EmitError("Expect a name after a specific type defined"); } - int defTypeIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kTypeName); - if (defTypeIdx < 0) { + unsigned int defTypeIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kTypeName); + if (defTypeIdx == UINT_MAX) { return EmitError("InValid defType is defined"); } if (lexer.NextToken() != kMDEqual) { return EmitError("Expect a equal when a specific type is going to be instantiated"); } - std::set defTypeMembers; + std::set defTypeMembers; while (lexer.NextToken() != kMDSemi) { switch (lexer.GetCurKind()) { case kMDIdentifier: { - int defTypeMemberIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kTypeMemberName); - if (defTypeMemberIdx < 0 || !defTypeMembers.insert(defTypeMemberIdx).second) { + unsigned int defTypeMemberIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kTypeMemberName); + if (defTypeMemberIdx == UINT_MAX || !defTypeMembers.insert(defTypeMemberIdx).second) { return EmitError("InValid defType member is defined"); } break; @@ -87,8 +87,8 @@ bool MDParser::ParseMDClass() { if (lexer.NextToken() != kMDIdentifier) { return EmitError("Expect a name after a specific class defined"); } - int classIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kClassName); - if (classIdx < 0) { + unsigned int classIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kClassName); + if (classIdx == UINT_MAX) { return EmitError("InValid class name. Please change a class name"); } bool isAnon = true; @@ -123,7 +123,7 @@ bool MDParser::ParseMDClassBody(MDClass &oneClass) { switch (lexer.GetCurKind()) { case kMDIdentifier: { StrInfo defTypeInfo = dataKeeper.GetStrInTable(lexer.GetStrToken()); - if (defTypeInfo.idx < 0 || !oneClass.IsValidStructEle(defTypeInfo.sType)) { + if (defTypeInfo.idx == UINT_MAX || !oneClass.IsValidStructEle(defTypeInfo.sType)) { return EmitError("Expect a defined Type to be a memeber of a class"); } bool isVec = false; @@ -149,11 +149,11 @@ bool MDParser::ParseMDObject() { return EmitError("Expect a name after a specific object defined"); } StrInfo parentInfo = dataKeeper.GetStrInTable(lexer.GetStrToken()); - if (parentInfo.idx < 0 || (parentInfo.sType != kClassName && parentInfo.sType != kAnonClassName)) { + if (parentInfo.idx == UINT_MAX || (parentInfo.sType != kClassName && parentInfo.sType != kAnonClassName)) { return EmitError("A new object should be belong to a defined class"); } MDClass parentClass = dataKeeper.GetOneMDClass(parentInfo.idx); - int objectIdx = -1; + unsigned int objectIdx = UINT_MAX; if (!parentClass.IsAnonymousClass()) { if (lexer.NextToken() != kMDColon) { return EmitError("Expect a colon when a object name is going to be defined"); @@ -162,7 +162,7 @@ bool MDParser::ParseMDObject() { return EmitError("Expect a name for a specific object"); } objectIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kObjectName); - if (objectIdx < 0) { + if (objectIdx == UINT_MAX) { return EmitError("InValid ObjectName!"); } } @@ -198,7 +198,7 @@ bool MDParser::ParseMDObjBody(MDObject &curObj) { curObj.AddMDElements(defaultEle); continue; } - int typeIdx = curObj.GetParentClass()->GetFormalTypes().at(i).first; + unsigned int typeIdx = curObj.GetParentClass()->GetFormalTypes().at(i).first; bool isVec = curObj.GetParentClass()->GetFormalTypes().at(i).second; if (dataKeeper.GetStrTyByIdx(typeIdx) == kIntType) { if (!ParseIntElement(curObj, isVec)) { @@ -209,7 +209,7 @@ bool MDParser::ParseMDObjBody(MDObject &curObj) { return false; } } else if (dataKeeper.GetStrTyByIdx(typeIdx) == kTypeName) { - std::set childSet = dataKeeper.GetOneSpcType(typeIdx); + std::set childSet = dataKeeper.GetOneSpcType(typeIdx); if (!ParseDefTyElement(curObj, isVec, childSet)) { return false; } @@ -266,8 +266,8 @@ bool MDParser::ParseStrElement(MDObject &curObj, bool isVec) { while (lexer.NextToken() != kMDCloseSquare) { switch (lexer.GetCurKind()) { case kMDIdentifier: { - int elementIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kElementName); - if (elementIdx < 0) { + unsigned int elementIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kElementName); + if (elementIdx == UINT_MAX) { return EmitError("Duplicate string name has already been defined"); } StringElement *singleEle = mdMemPool->New(elementIdx); @@ -285,8 +285,8 @@ bool MDParser::ParseStrElement(MDObject &curObj, bool isVec) { if (lexer.GetCurKind() != kMDIdentifier) { return EmitError("Expect a string elemet as defined"); } - int elementIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kElementName); - if (elementIdx < 0) { + unsigned int elementIdx = dataKeeper.CreateStrInTable(lexer.GetStrToken(), kElementName); + if (elementIdx == UINT_MAX) { return EmitError("Duplicate string name has already been defined"); } StringElement *curEle = mdMemPool->New(elementIdx); @@ -295,7 +295,7 @@ bool MDParser::ParseStrElement(MDObject &curObj, bool isVec) { return true; } -bool MDParser::ParseDefTyElement(MDObject &curObj, bool isVec, std::set &childSet) { +bool MDParser::ParseDefTyElement(MDObject &curObj, bool isVec, const std::set &childSet) { if (isVec) { if (lexer.GetCurKind() != kMDOpenSquare) { return EmitError("Expect a OpenSquare before a list element defined"); @@ -333,7 +333,7 @@ bool MDParser::ParseDefTyElement(MDObject &curObj, bool isVec, std::set &ch return true; } -bool MDParser::ParseDefObjElement(MDObject &curObj, bool isVec, MDClass &pClass) { +bool MDParser::ParseDefObjElement(MDObject &curObj, bool isVec, const MDClass &pClass) { if (isVec) { if (lexer.GetCurKind() != kMDOpenSquare) { return EmitError("Expect a OpenSquare before a list element defined"); diff --git a/src/maple_be/mdgen/src/mdrecord.cpp b/src/maple_be/mdgen/src/mdrecord.cpp index 2139d0156ff4d0ab13ed59e0d262257476b8a556..d98966e5de0e10037d84becbe375e819aaa9a524 100644 --- a/src/maple_be/mdgen/src/mdrecord.cpp +++ b/src/maple_be/mdgen/src/mdrecord.cpp @@ -15,9 +15,9 @@ #include "mdrecord.h" namespace MDGen { -static int inValidStrIdx = -1; +constexpr unsigned int kInValidStrIdx = UINT_MAX; -bool DefTyElement::SetContent(StrInfo curInfo, std::set &childTySet) { +bool DefTyElement::SetContent(const StrInfo curInfo, const std::set &childTySet) { if (!childTySet.count(curInfo.idx)) { return false; } @@ -25,7 +25,7 @@ bool DefTyElement::SetContent(StrInfo curInfo, std::set &childTySet) { return true; } -bool DefObjElement::SetContent(StrInfo curInfo, MDClass &parentClass) { +bool DefObjElement::SetContent(const StrInfo curInfo, const MDClass &parentClass) { if (!parentClass.IsClassMember(curInfo.idx)) { return false; } @@ -33,12 +33,12 @@ bool DefObjElement::SetContent(StrInfo curInfo, MDClass &parentClass) { return true; } -const MDElement *MDObject::GetOneMDElement (int index) const { +const MDElement *MDObject::GetOneMDElement(size_t index) const { CHECK_FATAL(index < mdElements.size(), "Array boundary check failed"); return mdElements[index]; } -const MDObject &MDClass::GetOneMDObject(int index) const{ +const MDObject &MDClass::GetOneMDObject(size_t index) const { CHECK_FATAL(index < mdObjects.size(), "Array boundary check failed"); return mdObjects[index]; } @@ -48,11 +48,11 @@ void MDClass::AddClassMember(MDObject inputObj) { childObjNames.insert(inputObj.GetIdx()); } -bool MDClass::IsClassMember(int curIdx) { +bool MDClass::IsClassMember(unsigned int curIdx) const { return childObjNames.count(curIdx); } -void MDClass::BuildFormalTypes(int memberIdx, bool isVec) { +void MDClass::BuildFormalTypes(unsigned int memberIdx, bool isVec) { formalTypes.push_back(std::make_pair(memberIdx, isVec)); } @@ -60,30 +60,31 @@ bool MDClass::IsValidStructEle(RecordType curTy) const { return (curTy == kTypeName || curTy == kClassName || curTy == kIntType || curTy == kStringType); } -int MDClassRange::CreateStrInTable(const std::string &inStr, RecordType curTy) { +unsigned int MDClassRange::CreateStrInTable(const std::string &inStr, RecordType curTy) { + unsigned int result = kInValidStrIdx; StrInfo curInfo (totalStr, curTy); auto ret = stringHashTable.insert(std::make_pair(inStr, curInfo)); if (ret.second) { - int temp = totalStr; + unsigned int temp = totalStr; stringTable.push_back(inStr); ++totalStr; return temp; } - return inValidStrIdx; + return result; } StrInfo MDClassRange::GetStrInTable(const std::string &inStr) { auto ret = stringHashTable.find(inStr); - StrInfo inValidInfo (-1, kUndefinedStr); + StrInfo inValidInfo (UINT_MAX, kUndefinedStr); return (ret != stringHashTable.end()) ? ret->second : inValidInfo; } -RecordType MDClassRange::GetStrTyByIdx(int curIdx) { +RecordType MDClassRange::GetStrTyByIdx(size_t curIdx) { CHECK_FATAL(curIdx < stringTable.size(), "Array boundary check failed"); return GetStrInTable(stringTable[curIdx]).sType; } -const std::string &MDClassRange::GetStrByIdx(int curIdx) { +const std::string &MDClassRange::GetStrByIdx(size_t curIdx) { CHECK_FATAL(curIdx < stringTable.size(), "Array boundary check failed"); return stringTable[curIdx]; } @@ -94,7 +95,7 @@ void MDClassRange::ModifyStrTyInTable(const std::string &inStr, RecordType newTy ret->second.sType = newTy; } -void MDClassRange::AddDefinedType(int typesName, std::set typesSet) { +void MDClassRange::AddDefinedType(unsigned int typesName, std::set typesSet) { definedTypes.insert(std::make_pair(typesName, typesSet)); } @@ -102,19 +103,19 @@ void MDClassRange::AddMDClass(MDClass curClass) { allClasses.insert(std::make_pair(curClass.GetClassIdx(), curClass)); } -void MDClassRange::FillMDClass(int givenIdx, const MDObject &insertObj) { +void MDClassRange::FillMDClass(unsigned int givenIdx, const MDObject &insertObj) { auto ret = allClasses.find(givenIdx); CHECK_FATAL(ret != allClasses.end(), "Cannot achieve target MD Class"); ret->second.AddClassMember(insertObj); } -MDClass MDClassRange::GetOneMDClass(int givenIdx) { +MDClass MDClassRange::GetOneMDClass(unsigned int givenIdx) { auto ret = allClasses.find(givenIdx); CHECK_FATAL(ret != allClasses.end(), "Cannot achieve target MD Class"); return ret->second; } -std::set MDClassRange::GetOneSpcType(int givenTyIdx) { +std::set MDClassRange::GetOneSpcType(unsigned int givenTyIdx) { auto ret = definedTypes.find(givenTyIdx); CHECK_FATAL(ret != definedTypes.end(), "Cannot achieve a defined type"); return ret->second; diff --git a/src/maple_driver/include/usages.h b/src/maple_driver/include/usages.h index a9354e1b404dcab3cb96168a680bfb09eecc4c35..79580b4e3b18c1f9bf6e569589fc871e8e59a51e 100644 --- a/src/maple_driver/include/usages.h +++ b/src/maple_driver/include/usages.h @@ -117,7 +117,7 @@ enum OptionIndex : uint64 { kMpl2MplOptL2, kMpl2MplNoDot, kGenIRProfile, - kTestCase, + kProfileTest, // ----------mplcg begin--------- kCGQuiet, kPie, diff --git a/src/maple_ir/include/metadata_layout.h b/src/maple_ir/include/metadata_layout.h index 3049b737d7115832848050bcea15ba0095da297d..80415011d73cdc5572847f2fcefb5d191aa00397 100644 --- a/src/maple_ir/include/metadata_layout.h +++ b/src/maple_ir/include/metadata_layout.h @@ -75,7 +75,7 @@ struct DataRefOffset { 3. "indirect.label_name - . + 3" for indirect reference this format aims to support lld which does not support expression "global_symbol - ." DataRef is self-decoded by also encoding the format and is defined for binary compatibility. - If no compatibility problem is involved, DataRefOffset is preferred. + If no compatibility problem is involved, DataRefOffset64 is preferred. */ enum DataRefFormat { kDataRefIsDirect = 0, // must be 0 @@ -105,7 +105,6 @@ struct DataRef { template inline T GetRawValue() const; }; - /* GctibRef aims to represent a reference to gctib in maple file, which is an offset by default. GctibRef is meant to have pointer size and aligned to at least 4 bytes. GctibRef allows 2 formats of value: @@ -281,8 +280,8 @@ struct ClassMetadata { uint16_t numOfSuperclasses; #endif // USE_32BIT_REF - DataRef iTable; // iTable of current class, used for virtual call, will insert the content into classinfo - DataRef vTable; // vTable of current class, used for interface call, will insert the content into classinfo + DataRef iTable; // iTable of current class, used for interface call, will insert the content into classinfo + DataRef vTable; // vTable of current class, used for virtual call, will insert the content into classinfo GctibRef gctib; // for rc #ifdef USE_32BIT_REF diff --git a/src/maple_ir/include/option.h b/src/maple_ir/include/option.h index ae6383c92ae85a3935ab5d58e528136fdb6d7da2..1b8741e5ed099c0c9c6e2f6ba92d20e8b1ce3ef9 100644 --- a/src/maple_ir/include/option.h +++ b/src/maple_ir/include/option.h @@ -97,7 +97,7 @@ class Options : public MapleDriverOptionBase { static std::string proFileClassData; static bool profileStaticFields; static bool genIRProfile; - static bool testCase; + static bool profileTest; static bool checkArrayStore; private: void DecideMpl2MplRealLevel(const std::vector &inputOptions) const; diff --git a/src/maple_ir/src/option.cpp b/src/maple_ir/src/option.cpp index db746d7a5702938f10e326a00b75493b8685aaf9..c03ce6d837789f8f69676055973d2b00e77de5d9 100644 --- a/src/maple_ir/src/option.cpp +++ b/src/maple_ir/src/option.cpp @@ -59,7 +59,7 @@ bool Options::nativeOpt = true; bool Options::O2 = false; bool Options::noDot = false; bool Options::genIRProfile = false; -bool Options::testCase = false; +bool Options::profileTest = false; bool Options::profileStaticFields = false; std::string Options::proFileData = ""; std::string Options::proFileFuncData = ""; @@ -101,7 +101,7 @@ enum OptionIndex { kMpl2MplOptL2, kMpl2MplNoDot, kGenIRProfile, - kTestCase, + kProfileTest, }; const Descriptor kUsage[] = { @@ -436,14 +436,14 @@ const Descriptor kUsage[] = { " --no-ir-profile-gen \tDisable Gen IR level Profile\n", "mpl2mpl", {} }, - { kTestCase, + { kProfileTest, kEnable, nullptr, - "testcase", + "profile-test", mapleOption::BuildType::kBuildTypeAll, mapleOption::ArgCheckPolicy::kArgCheckPolicyBool, - " --testcase \tTest Case\n" - " --no-testcase \tDisable Test Case\n", + " --profile-test \tprofile test\n" + " --no-profile-test \tDisable profile test\n", "mpl2mpl", {} }, { kUnknown, @@ -638,8 +638,8 @@ bool Options::SolveOptions(const std::vector