From 4fead4d444aebba2c9ca5da282c51ed9b7f9b4c9 Mon Sep 17 00:00:00 2001 From: binaryfz Date: Mon, 1 Feb 2021 16:47:46 +0800 Subject: [PATCH] fix conflict --- .../maple_be/include/cg/aarch64/aarch64_abi.h | 2 +- .../include/cg/aarch64/aarch64_cgfunc.h | 8 +- src/mapleall/maple_be/include/cg/cgfunc.h | 8 +- src/mapleall/maple_be/src/be/lower.cpp | 2 +- .../maple_be/src/cg/aarch64/aarch64_abi.cpp | 2 +- .../src/cg/aarch64/aarch64_cgfunc.cpp | 26 +- .../src/cg/aarch64/aarch64_memlayout.cpp | 5 +- src/mplfe/common/src/fe_input.cpp | 118 -------- src/mplfe/jbc_input/src/jbc_class_header.cpp | 35 --- .../fe_function_process_schedular_test.cpp | 256 ----------------- src/mplfe/test/feir_stmt_loc_test.cpp | 87 ------ src/mplfe/test/feir_test_base.h | 35 --- src/mplfe/test/feir_type_infer_test.cpp | 271 ------------------ src/mplfe/test/mplfe_ut.h | 21 -- src/mplfe/test/mplfe_ut_environment.h | 38 --- src/mplfe/test/mplfe_ut_options.h | 80 ------ src/mplfe/test/mplfe_ut_regx.h | 35 --- src/mplfe/test/ops_ut_check.sh | 28 -- src/mplfe/test/redirect_buffer.h | 70 ----- 19 files changed, 25 insertions(+), 1102 deletions(-) delete mode 100644 src/mplfe/common/src/fe_input.cpp delete mode 100644 src/mplfe/jbc_input/src/jbc_class_header.cpp delete mode 100644 src/mplfe/test/fe_function_process_schedular_test.cpp delete mode 100644 src/mplfe/test/feir_stmt_loc_test.cpp delete mode 100644 src/mplfe/test/feir_test_base.h delete mode 100644 src/mplfe/test/feir_type_infer_test.cpp delete mode 100644 src/mplfe/test/mplfe_ut.h delete mode 100644 src/mplfe/test/mplfe_ut_environment.h delete mode 100644 src/mplfe/test/mplfe_ut_options.h delete mode 100644 src/mplfe/test/mplfe_ut_regx.h delete mode 100644 src/mplfe/test/ops_ut_check.sh delete mode 100644 src/mplfe/test/redirect_buffer.h diff --git a/src/mapleall/maple_be/include/cg/aarch64/aarch64_abi.h b/src/mapleall/maple_be/include/cg/aarch64/aarch64_abi.h index 7291d9878e..0ad43dfb86 100644 --- a/src/mapleall/maple_be/include/cg/aarch64/aarch64_abi.h +++ b/src/mapleall/maple_be/include/cg/aarch64/aarch64_abi.h @@ -83,7 +83,7 @@ class ParmLocator { ~ParmLocator() = default; // Return size of aggregate structure copy on stack. - int32 LocateNextParm(MIRType &mirType, PLocInfo &ploc); + int32 LocateNextParm(MIRType &mirType, PLocInfo &pLoc); private: BECommon &beCommon; diff --git a/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h b/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h index 5d42f5200e..889fcdc6d0 100644 --- a/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h +++ b/src/mapleall/maple_be/include/cg/aarch64/aarch64_cgfunc.h @@ -438,7 +438,7 @@ class AArch64CGFunc : public CGFunc { bool HasStackLoadStore(); - MemOperand &LoadStructCopyBase(MIRSymbol &symbol, int32 offset, int datasize) override; + MemOperand &LoadStructCopyBase(const MIRSymbol &symbol, int32 offset, int datasize); int32 GetSplitBaseOffset() const { return splitStpldpBaseOffset; @@ -554,12 +554,12 @@ class AArch64CGFunc : public CGFunc { return (o.IsRegister() ? static_cast(o) : SelectCopy(o, oty, oty)); } - void SelectParmListDreadSmallAggregate(MIRSymbol &sym, AArch64ListOperand &srcOpnds, ParmLocator &parmLocator, - int32 &structCopyOffset); - void SelectParmListDreadLargeAggregate(MIRSymbol &sym, AArch64ListOperand &srcOpnds, ParmLocator &parmLocator, + void SelectParmListDreadSmallAggregate(const MIRSymbol &sym, AArch64ListOperand &srcOpnds, ParmLocator &parmLocator); + void SelectParmListDreadLargeAggregate(const MIRSymbol &sym, AArch64ListOperand &srcOpnds, ParmLocator &parmLocator, int32 &structCopyOffset); void SelectParmListForAggregate(BaseNode &argExpr, AArch64ListOperand &srcOpnds, ParmLocator &parmLocator, int32 &structCopyOffset); + void SelectParmList(StmtNode &naryNode, AArch64ListOperand &srcOpnds, bool isCallNative = false); Operand *SelectClearStackCallParam(const AddrofNode &expr, int64 &offsetValue); void SelectClearStackCallParmList(const StmtNode &naryNode, AArch64ListOperand &srcOpnds, diff --git a/src/mapleall/maple_be/include/cg/cgfunc.h b/src/mapleall/maple_be/include/cg/cgfunc.h index 8845408f5c..7457d3f9d5 100644 --- a/src/mapleall/maple_be/include/cg/cgfunc.h +++ b/src/mapleall/maple_be/include/cg/cgfunc.h @@ -867,18 +867,14 @@ class CGFunc { } // See if the symbol is a structure parameter that requires a copy. - bool IsParamStructCopy(MIRSymbol &symbol) { + bool IsParamStructCopy(const MIRSymbol &symbol) { if (symbol.GetStorageClass() == kScFormal && - GetBecommon().GetTypeSize(symbol.GetTyIdx().GetIdx()) > 16) { + GetBecommon().GetTypeSize(symbol.GetTyIdx().GetIdx()) > k16ByteSize) { return true; } return false; } - // For struct parameter that is copied to stack, load the base address. - // Return the mem opnd with the base address. - virtual MemOperand &LoadStructCopyBase(MIRSymbol &symbol, int32 offset, int datasize) = 0; - private: CGFunc &operator=(const CGFunc &cgFunc); CGFunc(const CGFunc&); diff --git a/src/mapleall/maple_be/src/be/lower.cpp b/src/mapleall/maple_be/src/be/lower.cpp index 098ad0b76d..c5927960f6 100644 --- a/src/mapleall/maple_be/src/be/lower.cpp +++ b/src/mapleall/maple_be/src/be/lower.cpp @@ -160,7 +160,7 @@ BaseNode *CGLowerer::LowerIaddrof(const IreadNode &iaddrof) { return iaddrof.Opnd(0); } MIRType *type = GlobalTables::GetTypeTable().GetTypeFromTyIdx(iaddrof.GetTyIdx()); - MIRPtrType *pointerTy = dynamic_cast(type); + MIRPtrType *pointerTy = static_cast(type); CHECK_FATAL(pointerTy != nullptr, "LowerIaddrof: expect a pointer type at iaddrof node"); MIRStructType *structTy = static_cast( GlobalTables::GetTypeTable().GetTypeFromTyIdx(pointerTy->GetPointedTyIdx())); diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp index a70bb6febc..15a272e27d 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp @@ -461,7 +461,7 @@ int32 ParmLocator::LocateNextParm(MIRType &mirType, PLocInfo &pLoc) { } int32 ParmLocator::ProcessPtyAggWhenLocateNextParm(MIRType &mirType, PLocInfo &pLoc, uint64 &typeSize, - int32 typeAlign) { + int32 typeAlign) { /* * In AArch64, integer-float or float-integer * argument passing is not allowed. All should go through diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp index 5840ef8487..168df6177a 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_cgfunc.cpp @@ -844,7 +844,7 @@ void AArch64CGFunc::SelectDassign(StIdx stIdx, FieldID fieldId, PrimType rhsPTyp } uint32 dataSize = GetPrimTypeBitSize(type->GetPrimType()); - MemOperand *memOpnd; + MemOperand *memOpnd = nullptr; if (parmCopy) { memOpnd = &LoadStructCopyBase(*symbol, offset, dataSize); } else { @@ -1313,7 +1313,7 @@ Operand *AArch64CGFunc::SelectDread(DreadNode &expr) { } CHECK_FATAL(symType != PTY_agg, "dread type error"); uint32 dataSize = GetPrimTypeSize(symType) * kBitsPerByte; - MemOperand *memOpnd; + MemOperand *memOpnd = nullptr; if (parmCopy) { memOpnd = &LoadStructCopyBase(*symbol, offset, dataSize); } else { @@ -4587,8 +4587,8 @@ void AArch64CGFunc::HandleRCCall(bool begin, const MIRSymbol *retRef) { } } -void AArch64CGFunc::SelectParmListDreadSmallAggregate(MIRSymbol &sym, AArch64ListOperand &srcOpnds, - ParmLocator &parmLocator, int32 &structCopyOffset) { +void AArch64CGFunc::SelectParmListDreadSmallAggregate(const MIRSymbol &sym, AArch64ListOperand &srcOpnds, + ParmLocator &parmLocator) { // in two param regs if possible // If struct is <= 8 bytes, then it fits into one param reg. // If struct is <= 16 bytes, then it fits into two param regs. @@ -4626,20 +4626,20 @@ void AArch64CGFunc::SelectParmListDreadSmallAggregate(MIRSymbol &sym, AArch64Lis } } else { // pass by param regs. - MemOperand &mopnd = GetOrCreateMemOpnd(sym, 0, k64BitSize); + MemOperand &mopnd0 = GetOrCreateMemOpnd(sym, 0, k64BitSize); AArch64RegOperand &parmOpnd = GetOrCreatePhysicalRegisterOperand(ploc.reg0, k64BitSize, kRegTyInt); - GetCurBB()->AppendInsn(cg->BuildInstruction(PickLdInsn(k64BitSize, PTY_i64), parmOpnd, mopnd)); + GetCurBB()->AppendInsn(cg->BuildInstruction(PickLdInsn(k64BitSize, PTY_i64), parmOpnd, mopnd0)); srcOpnds.PushOpnd(parmOpnd); if (ploc.reg1) { - MemOperand &mopnd = GetOrCreateMemOpnd(sym, kSizeOfPtr, k64BitSize); + MemOperand &mopnd1 = GetOrCreateMemOpnd(sym, kSizeOfPtr, k64BitSize); parmOpnd = GetOrCreatePhysicalRegisterOperand(ploc.reg1, k64BitSize, kRegTyInt); - GetCurBB()->AppendInsn(cg->BuildInstruction(PickLdInsn(k64BitSize, PTY_i64), parmOpnd, mopnd)); + GetCurBB()->AppendInsn(cg->BuildInstruction(PickLdInsn(k64BitSize, PTY_i64), parmOpnd, mopnd1)); srcOpnds.PushOpnd(parmOpnd); } } } -void AArch64CGFunc::SelectParmListDreadLargeAggregate(MIRSymbol &sym, AArch64ListOperand &srcOpnds, +void AArch64CGFunc::SelectParmListDreadLargeAggregate(const MIRSymbol &sym, AArch64ListOperand &srcOpnds, ParmLocator &parmLocator, int32 &structCopyOffset) { // Pass larger sized struct on stack. // Need to copy the entire structure onto the stack. @@ -4683,15 +4683,15 @@ void AArch64CGFunc::SelectParmListDreadLargeAggregate(MIRSymbol &sym, AArch64Lis } void AArch64CGFunc::SelectParmListForAggregate(BaseNode &argExpr, AArch64ListOperand &srcOpnds, - ParmLocator &parmLocator, int32 &structCopyOffset) { + ParmLocator &parmLocator, int32 &structCopyOffset) { CHECK_FATAL((argExpr.GetOpCode() == OP_dread), "call param is agg but not dread"); DreadNode &dread = static_cast(argExpr); MIRSymbol *sym = GetBecommon().GetMIRModule().CurFunction()->GetLocalOrGlobalSymbol(dread.GetStIdx()); MIRType *ty = sym->GetType(); int32 symSize = GetBecommon().GetTypeSize(ty->GetTypeIndex().GetIdx()); if (argExpr.GetOpCode() == OP_dread) { - if (symSize <= 16) { - SelectParmListDreadSmallAggregate(*sym, srcOpnds, parmLocator, structCopyOffset); + if (symSize <= k16ByteSize) { + SelectParmListDreadSmallAggregate(*sym, srcOpnds, parmLocator); } else { SelectParmListDreadLargeAggregate(*sym, srcOpnds, parmLocator, structCopyOffset); } @@ -6409,7 +6409,7 @@ RegType AArch64CGFunc::GetRegisterType(regno_t reg) const { } } -MemOperand &AArch64CGFunc::LoadStructCopyBase(MIRSymbol &symbol, int32 offset, int dataSize) { +MemOperand &AArch64CGFunc::LoadStructCopyBase(const MIRSymbol &symbol, int32 offset, int dataSize) { // For struct formals > 16 bytes, this is the pointer to the struct copy. // Load the base pointer first. RegOperand *vreg = &CreateVirtualRegisterOperand(NewVReg(kRegTyInt, k8ByteSize)); diff --git a/src/mapleall/maple_be/src/cg/aarch64/aarch64_memlayout.cpp b/src/mapleall/maple_be/src/cg/aarch64/aarch64_memlayout.cpp index 2b915a1aa0..da1036253f 100644 --- a/src/mapleall/maple_be/src/cg/aarch64/aarch64_memlayout.cpp +++ b/src/mapleall/maple_be/src/cg/aarch64/aarch64_memlayout.cpp @@ -26,7 +26,7 @@ using namespace maple; * which is used to pass arguments that cannot be * passed through registers */ -uint32 AArch64MemLayout::ComputeStackSpaceRequirementForCall(StmtNode &stmt, int32 &aggCopySize, bool isIcall) { +uint32 AArch64MemLayout::ComputeStackSpaceRequirementForCall(StmtNode &stmt, int32 &aggCopySize, bool isIcall) { /* instantiate a parm locator */ ParmLocator parmLocator(be); uint32 sizeOfArgsToStkPass = 0; @@ -198,7 +198,8 @@ void AArch64MemLayout::LayoutEAVariales(std::vector &tempVar) { } } -void AArch64MemLayout::LayoutReturnRef(std::vector &returnDelays, int32 &structCopySize, int32 &maxParmStackSize) { +void AArch64MemLayout::LayoutReturnRef(std::vector &returnDelays, + int32 &structCopySize, int32 &maxParmStackSize) { for (auto sym : returnDelays) { uint32 stIndex = sym->GetStIndex(); TyIdx tyIdx = sym->GetTyIdx(); diff --git a/src/mplfe/common/src/fe_input.cpp b/src/mplfe/common/src/fe_input.cpp deleted file mode 100644 index 0943b7bad6..0000000000 --- a/src/mplfe/common/src/fe_input.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include "fe_input.h" -#include "mempool_allocator.h" - -namespace maple { -// ---------- FEInputContent ---------- -template -FEInputContent::FEInputContent(MapleAllocator &alloc) - : allocator(alloc), - items(allocator.Adapter()), - nameItemMap(allocator.Adapter()), - sameNames(allocator.Adapter()), - policySameName(FEInputSameNamePolicy::kFatalOnce) {} - -template -void FEInputContent::RegisterItem(T *item) { - FEInputUnit *itemUnit = dynamic_cast(item); - ASSERT(itemUnit != nullptr, "Invalid item type"); - ASSERT(itemUnit->GetNameIdxMpl().GetIdx() != 0, "Invalid name idx (not set)"); - GStrIdx nameIdxMpl = itemUnit->GetNameIdxMpl(); - if (nameItemMap.find(nameIdxMpl) != nameItemMap.end()) { - // name is defined - std::string catagoryName = itemUnit->GetCatagoryName(); - std::string name = GlobalTables::GetStrTable().GetStringFromStrIdx(nameIdxMpl); - switch (policySameName) { - case FEInputSameNamePolicy::kFatalOnce: - FATAL(kLncFatal, "%s with the same name %s existed. exit.", catagoryName.c_str(), name.c_str()); - break; - case FEInputSameNamePolicy::kFatalAll: - WARN(kLncWarn, "%s with the same name %s existed.", catagoryName.c_str(), name.c_str()); - sameNames.push_back(nameIdxMpl); - break; - case FEInputSameNamePolicy::kUseFirst: - WARN(kLncWarn, "%s with the same name %s existed. Use first.", catagoryName.c_str(), name.c_str()); - break; - case FEInputSameNamePolicy::kUseNewest: - WARN(kLncWarn, "%s with the same name %s existed. Use newest.", catagoryName.c_str(), name.c_str()); - EraseItem(nameIdxMpl); - items.push_back(item); - nameItemMap[nameIdxMpl] = item; - break; - } - } else { - // name is undefined - items.push_back(item); - nameItemMap[nameIdxMpl] = item; - } -} - -template -void FEInputContent::CheckSameName() { - if (policySameName != FEInputSameNamePolicy::kFatalAll) { - return; - } - if (sameNames.size() > 0) { - T *item = items.front(); - FEInputUnit *itemUnit = dynamic_cast(item); - ASSERT(itemUnit != nullptr, "Invalid item type"); - FATAL(kLncFatal, "%s with the same name existed. Exit", itemUnit->GetCatagoryName().c_str()); - } -} - -template -void FEInputContent::EraseItem(GStrIdx nameIdxMpl) { - typename MapleList::iterator it; - for (it = items.begin(); it != items.end();) { - FEInputUnit *itemUnit = dynamic_cast(*it); - ASSERT(itemUnit != nullptr, "Invalid item type"); - if (itemUnit->GetNameIdxMpl() == nameIdxMpl) { - it = items.erase(it); - } else { - ++it; - } - } -} - -// ---------- FEInputUnitMethod ---------- -FEInputUnitMethod::FEInputUnitMethod(MapleAllocator &alloc) - : allocator(alloc) {} - -std::string FEInputUnitMethod::GetCatagoryNameImpl() { - return "Method"; -} - -// ---------- FEInputUnitVariable ---------- -FEInputUnitVariable::FEInputUnitVariable(MapleAllocator &alloc) - : allocator(alloc) {} - -std::string FEInputUnitVariable::GetCatagoryNameImpl() { - return "Variable/Field"; -} - -// ---------- FEInputUnitStruct ---------- -FEInputUnitStruct::FEInputUnitStruct(MapleAllocator &alloc) - : allocator(alloc), - methods(allocator), - methodsStatic(allocator), - fields(allocator), - fieldsStatic(allocator), - typeKind(kTypeInvalid) {} - -std::string FEInputUnitStruct::GetCatagoryNameImpl() { - return "Variable/Field"; -} -} // namespace maple \ No newline at end of file diff --git a/src/mplfe/jbc_input/src/jbc_class_header.cpp b/src/mplfe/jbc_input/src/jbc_class_header.cpp deleted file mode 100644 index 5bff1e53b5..0000000000 --- a/src/mplfe/jbc_input/src/jbc_class_header.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include "jbc_class_header.h" -namespace maple { -namespace jbc { -JBCClassHeader::JBCClassHeader() - : magic(0), - minorVersion(0), - majorVersion(0), - constPoolCount(0), - accessFlag(0), - thisClass(0), - superClass(0), - interfacesCount(0), - fieldsCount(0), - methodsCount(0), - attrsCount(0) {} - -bool JBCClassHeader::ParseClassFile(BasicIORead &io) const { - return false; -} -} // namespace jbc -} // namespace maple \ No newline at end of file diff --git a/src/mplfe/test/fe_function_process_schedular_test.cpp b/src/mplfe/test/fe_function_process_schedular_test.cpp deleted file mode 100644 index 8f1fa5b092..0000000000 --- a/src/mplfe/test/fe_function_process_schedular_test.cpp +++ /dev/null @@ -1,256 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include -#include -#include "mplfe_compiler_component.h" -#include -#include -#include - -namespace maple { -class FEFunctionChild : public FEFunction { - public: - FEFunctionChild(std::list &argResult, uint32 argIdx) - : FEFunction(nullptr), - result(argResult), - idx(argIdx) {} - virtual ~FEFunctionChild() = default; - void Process() override { - usleep(rand() % 1000); - } - void EmitToMIR() override { - result.push_back(idx); - } - bool PreProcessTypeNameIdx() override { - return true; - } - void GenerateGeneralStmt(bool &success) override {} - void GenerateGeneralStmtFailCallBack() override {} - void GenerateGeneralDebugInfo() override {} - bool VerifyGeneral() override { - return true; - } - void VerifyGeneralFailCallBack() override {} - void EmitToFEIRStmt() override {} - void GenerateArgVarList() override {} - bool HasThis() override { - return false; - } - - private: - std::list &result; - uint32 idx; -}; // class FEFunctionChild - -TEST(FEFunctionProcessSchedular, RunSingle) { - std::list results; - std::unique_ptr function = std::make_unique(results, 0); - std::unique_ptr task = std::make_unique(function.get()); - task->Run(); - task->Finish(); - EXPECT_EQ(results.size(), 1); -} - -TEST(FEFunctionProcessSchedular, RunDirect) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - task->Run(); - task->Finish(); - } - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunSerial) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(1, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel2) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(2, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel4) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(4, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel8) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(8, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel16) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(16, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel32) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(32, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel48) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(48, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel64) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(64, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} - -TEST(FEFunctionProcessSchedular, RunParallel128) { - std::list> functions; - std::list> tasks; - std::list results; - FEFunctionProcessSchedular schedular("test schedular"); - schedular.Init(); - for (uint32 i = 0; i < 1000; i++) { - functions.push_back(std::make_unique(results, i)); - tasks.push_back(std::make_unique(functions.back().get())); - } - for (const std::unique_ptr &task : tasks) { - schedular.AddTask(task.get()); - } - schedular.RunTask(128, true); - for (uint32 i = 0; i < 1000; i++) { - EXPECT_EQ(results.front(), i); - results.pop_front(); - } -} -} // namespace maple \ No newline at end of file diff --git a/src/mplfe/test/feir_stmt_loc_test.cpp b/src/mplfe/test/feir_stmt_loc_test.cpp deleted file mode 100644 index 43f7ec9884..0000000000 --- a/src/mplfe/test/feir_stmt_loc_test.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include -#include -#include "jbc_function.h" -#include "fe_manager.h" -#include "redirect_buffer.h" -#include "feir_type_helper.h" -#include "mplfe_ut_regx.h" -#include "mplfe_ut_environment.h" -#include "feir_stmt.h" -#include "feir_var.h" -#include "feir_var_reg.h" -#include "feir_var_name.h" -#include "feir_test_base.h" -namespace maple { -class FEIRStmtLOCTest : public FEIRTestBase { - public: - static MemPool *mp; - MapleAllocator allocator; - jbc::JBCClass jbcClass; - jbc::JBCClassMethod jbcMethod; - JBCClassMethod2FEHelper jbcMethodHelper; - MIRFunction mirFunction; - JBCFunction jbcFunction; - FEIRStmtLOCTest() - : allocator(mp), - jbcClass(allocator), - jbcMethod(allocator, jbcClass), - jbcMethodHelper(allocator, jbcMethod), - mirFunction(&MPLFEUTEnvironment::GetMIRModule(), StIdx(0, 0)), - jbcFunction(jbcMethodHelper, mirFunction, std::make_unique(true)) {} - ~FEIRStmtLOCTest() = default; - - static void SetUpTestCase() { - mp = memPoolCtrler.NewMemPool("MemPool for FEIRStmtLOCTest"); - } - - static void TearDownTestCase() { - memPoolCtrler.DeleteMemPool(mp); - mp = nullptr; - } -}; -MemPool *FEIRStmtLOCTest::mp = nullptr; - -// ---------- FEIRStmtDAssign ---------- -TEST_F(FEIRStmtLOCTest, GetLOCForStmt) { - std::unique_ptr type = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/String;", false, true); - std::unique_ptr dstVar = std::make_unique(0, type->Clone()); - std::unique_ptr srcVar = std::make_unique(1, type->Clone()); - std::unique_ptr exprDRead = std::make_unique(std::move(srcVar)); - std::unique_ptr stmtDAssign = - std::make_unique(std::move(dstVar), std::move(exprDRead)); - - uint32 srcFileIdx = 2; - uint32 lineNumber = 10; - std::unique_ptr stmtPesudoLOC = std::make_unique(srcFileIdx, lineNumber); - jbcFunction.InitImpl(); - jbcFunction.feirStmtTail->InsertBefore(static_cast(stmtPesudoLOC.get())); - jbcFunction.feirStmtTail->InsertBefore(static_cast(stmtDAssign.get())); - FEIRStmtPesudoLOC *expectedLOC = jbcFunction.GetLOCForStmt(*static_cast(stmtDAssign.get())); - std::list mirStmts = stmtDAssign->GenMIRStmts(mirBuilder); - mirStmts.front()->GetSrcPos().SetFileNum(static_cast(expectedLOC->GetSrcFileIdx())); - mirStmts.front()->GetSrcPos().SetLineNum(expectedLOC->GetLineNumber()); - RedirectCout(); - mirStmts.front()->Dump(); - std::string dumpStr = GetBufferString(); - std::string pattern = std::string("LOC 2 10\n") + std::string("dassign %Reg0_") + - MPLFEUTRegx::RefIndex(MPLFEUTRegx::kAnyNumber) + - " 0 \\(dread ref %Reg1_" + MPLFEUTRegx::RefIndex(MPLFEUTRegx::kAnyNumber) + "\\)" + - MPLFEUTRegx::Any(); - EXPECT_EQ(MPLFEUTRegx::Match(dumpStr, pattern), true); - RestoreCout(); -} -} // namespace maple diff --git a/src/mplfe/test/feir_test_base.h b/src/mplfe/test/feir_test_base.h deleted file mode 100644 index 3b7374e9f9..0000000000 --- a/src/mplfe/test/feir_test_base.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include -#include -#include "redirect_buffer.h" -#include "global_tables.h" -#include "mir_module.h" -#include "mir_builder.h" - -namespace maple { -class FEIRTestBase : public testing::Test, public RedirectBuffer { - public: - static MemPool *mp; - MapleAllocator allocator; - MIRBuilder mirBuilder; - MIRFunction func; - FEIRTestBase(); - virtual ~FEIRTestBase() = default; - - static void SetUpTestCase(); - static void TearDownTestCase(); -}; -} // namespace maple \ No newline at end of file diff --git a/src/mplfe/test/feir_type_infer_test.cpp b/src/mplfe/test/feir_type_infer_test.cpp deleted file mode 100644 index 72aee38ff6..0000000000 --- a/src/mplfe/test/feir_type_infer_test.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#include -#include -#include -#include "redirect_buffer.h" -#include "global_tables.h" -#include "mir_module.h" -#include "feir_type_helper.h" -#include "feir_type_infer.h" -#include "feir_builder.h" -#include "feir_var_type_scatter.h" -#include "feir_dfg.h" -#include "namemangler.h" - -#define protected public -#define private public -#include "fe_type_hierarchy.h" -#undef protected -#undef private - -namespace maple { -class FEIRTypeHelperTest : public testing::Test, public RedirectBuffer { - public: - FEIRTypeHelperTest() = default; - ~FEIRTypeHelperTest() = default; -}; - -class FEIRTypeInferTest : public testing::Test, public RedirectBuffer { - public: - FEIRTypeInferTest() {}; - ~FEIRTypeInferTest() = default; -}; - -TEST_F(FEIRTypeHelperTest, MergeType_Parent) { - GStrIdx type0StrIdx = - GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(namemangler::EncodeName("Ljava/lang/Integer;")); - GStrIdx type1StrIdx = - GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(namemangler::EncodeName("Ljava/lang/Number;")); - FETypeHierarchy::GetInstance().AddParentChildRelation(type1StrIdx, type0StrIdx); - UniqueFEIRType type0 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Integer;", false, false); - UniqueFEIRType type1 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Number;", false, false); - UniqueFEIRType type2 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/String;", false, false); - UniqueFEIRType type3 = FEIRTypeHelper::CreateTypeByJavaName("[Ljava/lang/String;", false, false); - UniqueFEIRType type4 = FEIRTypeHelper::CreateTypeByJavaName("I", false, false); - UniqueFEIRType type5 = FEIRTypeHelper::CreateTypeByJavaName("J", false, false); - UniqueFEIRType type6 = FEIRTypeHelper::CreateTypeByJavaName("LFEIRTypeHelperTest", false, false); - UniqueFEIRType typeDefault = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Object;", false, false); - UniqueFEIRType typeResult; - FEIRTypeMergeHelper typeMergeHelper(typeDefault); - // merge type0 and type1, expect Ljava/lang/Number; - typeResult.reset(type0->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type1), true); - EXPECT_EQ(typeResult->IsEqualTo(type1), true); - - // merge type1 and type0, expect Ljava/lang/Number; - typeResult.reset(type1->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type0), true); - EXPECT_EQ(typeResult->IsEqualTo(type1), true); - - // merge type0 and type2, expect Ljava/lang/Object; - typeResult.reset(type0->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type2), true); - EXPECT_EQ(typeResult->IsEqualTo(typeDefault), true); - - // merge type1 and type2, expect Ljava/lang/Object; - typeResult.reset(type1->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type2), true); - EXPECT_EQ(typeResult->IsEqualTo(typeDefault), true); - - // merge diff dim - typeResult.reset(type2->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type3), false); - - // merge diff PrimType - typeResult.reset(type4->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type5), false); - - // merge type0 and type6, expect Ljava/lang/Object; - typeResult.reset(type0->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type6), true); - EXPECT_EQ(typeResult->IsEqualTo(typeDefault), true); - - // merge type6 and type0, expect Ljava/lang/Object; - typeResult.reset(type6->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type0), true); - EXPECT_EQ(typeResult->IsEqualTo(typeDefault), true); -} - -TEST_F(FEIRTypeHelperTest, MergeType_Child) { - UniqueFEIRType type0 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Integer;", false, false); - UniqueFEIRType type1 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Number;", false, false); - UniqueFEIRType type2 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/String;", false, false); - UniqueFEIRType typeDefault = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Object;", false, false); - UniqueFEIRType typeResult; - FEIRTypeMergeHelper typeMergeHelper(typeDefault); - // merge type0 and type1, expect Ljava/lang/Integer; - typeResult.reset(type0->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type1, false), true); - EXPECT_EQ(typeResult->IsEqualTo(type0), true); - - // merge type1 and type0, expect Ljava/lang/Integer; - typeResult.reset(type1->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type0, false), true); - EXPECT_EQ(typeResult->IsEqualTo(type0), true); - - // merge type0 and type2, expect error - typeResult.reset(type0->Clone().release()); - EXPECT_EQ(typeMergeHelper.MergeType(typeResult, type2, false), false); -} - -// -// TypeInferTest: Test1 -// DFG: mplfe/doc/images/ut_cases/TypeInfer/Test1.dot -// Image: mplfe/doc/images/ut_cases/TypeInfer/Test1.png -// UseDef: -// var1 -> var0 -// DefUse: -// var0 -> var1 -// -TEST_F(FEIRTypeInferTest, Test1) { - std::map> mapDefUse; - UniqueFEIRVar var0 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRVar var1 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRType type0 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/String;", false, true); - UniqueFEIRType type1 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Object;", false, true); - var0->SetType(type0->Clone()); - var1->SetType(type1->Clone()); - mapDefUse[&var0].insert(&var1); - - std::unique_ptr typeInfer = std::make_unique(kSrcLangJava, mapDefUse); - EXPECT_EQ(typeInfer->GetTypeForVarUse(var1)->IsEqualTo(type1), true); - EXPECT_EQ(typeInfer->GetTypeForVarDef(var0)->IsEqualTo(type0), true); - typeInfer->ProcessVarDef(var0); - EXPECT_EQ(var0->GetKind(), FEIRVarKind::kFEIRVarTypeScatter); - FEIRVarTypeScatter *ptrVar0 = static_cast(var0.get()); - EXPECT_EQ(ptrVar0->GetVar()->GetType()->IsEqualTo(type0), true); - EXPECT_EQ(ptrVar0->GetScatterTypes().size(), 1); - EXPECT_NE(ptrVar0->GetScatterTypes().find(FEIRTypeKey(type1)), ptrVar0->GetScatterTypes().end()); -} - -// -// TypeInferTest: Test2 -// DFG: mplfe/doc/images/ut_cases/TypeInfer/Test2.dot -// Image: mplfe/doc/images/ut_cases/TypeInfer/Test2.png -// UseDef: -// var1 -> var0 -// var3 -> var2 -// DefUse: -// var0 -> var1 -// var2 -> var3 -// -TEST_F(FEIRTypeInferTest, Test2) { - std::map> mapDefUse; - UniqueFEIRVar var0 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRVar var1 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRVar var2 = FEIRBuilder::CreateVarReg(1, PTY_ref, false); - UniqueFEIRVar var3 = FEIRBuilder::CreateVarReg(1, PTY_ref, false); - UniqueFEIRType type0 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/String;", false, true); - UniqueFEIRType type3 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Object;", false, true); - UniqueFEIRVarTrans trans0 = std::make_unique(FEIRVarTransKind::kFEIRVarTransDirect, var1); - UniqueFEIRVarTrans trans1 = std::make_unique(FEIRVarTransKind::kFEIRVarTransDirect, var2); - var1->SetTrans(std::move(trans1)); - var2->SetTrans(std::move(trans0)); - var0->SetType(type0->Clone()); - var3->SetType(type3->Clone()); - mapDefUse[&var0].insert(&var1); - mapDefUse[&var2].insert(&var3); - std::unique_ptr typeInfer = std::make_unique(kSrcLangJava, mapDefUse); - EXPECT_EQ(typeInfer->GetTypeForVarUse(var1)->IsEqualTo(type3), true); - typeInfer->Reset(); - EXPECT_EQ(typeInfer->GetTypeForVarUse(var3)->IsEqualTo(type3), true); - - typeInfer->ProcessVarDef(var0); - typeInfer->ProcessVarDef(var2); - EXPECT_EQ(var0->GetKind(), FEIRVarKind::kFEIRVarTypeScatter); - EXPECT_EQ(var2->GetKind(), FEIRVarKind::kFEIRVarReg); -} - -// -// TypeInferTest: Test3 -// DFG: mplfe/doc/images/ut_cases/TypeInfer/Test3.dot -// Image: mplfe/doc/images/ut_cases/TypeInfer/Test3.png -// UseDef: -// var1 -> {var0, var5} -// var3 -> var2 -// var4 -> var2 -TEST_F(FEIRTypeInferTest, Test3) { - std::map> mapDefUse; - UniqueFEIRVar var0 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRVar var1 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRVar var2 = FEIRBuilder::CreateVarReg(1, PTY_ref, false); - UniqueFEIRVar var3 = FEIRBuilder::CreateVarReg(1, PTY_ref, false); - UniqueFEIRVar var4 = FEIRBuilder::CreateVarReg(1, PTY_ref, false); - UniqueFEIRVar var5 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRType type0 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/String;", false, true); - UniqueFEIRVarTrans transFrom1To2 = std::make_unique(FEIRVarTransKind::kFEIRVarTransDirect, var1); - UniqueFEIRVarTrans transFrom2To1 = std::make_unique(FEIRVarTransKind::kFEIRVarTransDirect, var2); - UniqueFEIRVarTrans transFrom4To5 = std::make_unique(FEIRVarTransKind::kFEIRVarTransDirect, var4); - UniqueFEIRVarTrans transFrom5To4 = std::make_unique(FEIRVarTransKind::kFEIRVarTransDirect, var5); - var1->SetTrans(std::move(transFrom2To1)); - var2->SetTrans(std::move(transFrom1To2)); - var4->SetTrans(std::move(transFrom5To4)); - var5->SetTrans(std::move(transFrom4To5)); - var3->SetType(type0->Clone()); - mapDefUse[&var0].insert(&var1); - mapDefUse[&var5].insert(&var1); - mapDefUse[&var2].insert(&var3); - mapDefUse[&var2].insert(&var4); - std::unique_ptr typeInfer = std::make_unique(kSrcLangJava, mapDefUse); - typeInfer->Reset(); - EXPECT_EQ(typeInfer->GetTypeForVarUse(var1)->IsEqualTo(type0), true); - typeInfer->Reset(); - EXPECT_EQ(typeInfer->GetTypeForVarUse(var3)->IsEqualTo(type0), true); - typeInfer->Reset(); - EXPECT_EQ(typeInfer->GetTypeForVarUse(var4)->IsEqualTo(type0), true); - typeInfer->ProcessVarDef(var0); - typeInfer->ProcessVarDef(var2); - typeInfer->ProcessVarDef(var5); - EXPECT_EQ(var0->GetKind(), FEIRVarKind::kFEIRVarReg); - EXPECT_EQ(var2->GetKind(), FEIRVarKind::kFEIRVarReg); - EXPECT_EQ(var5->GetKind(), FEIRVarKind::kFEIRVarReg); - EXPECT_EQ(var0->GetType()->IsEqualTo(type0), true); - EXPECT_EQ(var2->GetType()->IsEqualTo(type0), true); - EXPECT_EQ(var5->GetType()->IsEqualTo(type0), true); -} - -// -// TypeInferTest: Test4 -// DFG: mplfe/doc/images/ut_cases/TypeInfer/Test4.dot -// Image: mplfe/doc/images/ut_cases/TypeInfer/Test4.png -// UseDef: -// var1 -> var0 -// var3 -> var2 -// -TEST_F(FEIRTypeInferTest, Test4) { - std::map> mapDefUse; - UniqueFEIRVar var0 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRVar var1 = FEIRBuilder::CreateVarReg(0, PTY_ref, false); - UniqueFEIRVar var2 = FEIRBuilder::CreateVarReg(1, PTY_ref, false); - UniqueFEIRVar var3 = FEIRBuilder::CreateVarReg(1, PTY_ref, false); - UniqueFEIRType type0 = FEIRTypeHelper::CreateTypeByJavaName("Ljava/lang/Object;", false, true); - UniqueFEIRType type1 = FEIRTypeHelper::CreateTypeByJavaName("[Ljava/lang/Object;", false, true); - UniqueFEIRVarTrans transFrom1To2 = std::make_unique(FEIRVarTransKind::kFEIRVarTransArrayDimDecr, var1); - UniqueFEIRVarTrans transFrom2To1 = std::make_unique(FEIRVarTransKind::kFEIRVarTransArrayDimIncr, var2); - var3->SetType(type0->Clone()); - var1->SetTrans(std::move(transFrom2To1)); - var2->SetTrans(std::move(transFrom1To2)); - mapDefUse[&var0].insert(&var1); - mapDefUse[&var2].insert(&var3); - std::unique_ptr typeInfer = std::make_unique(kSrcLangJava, mapDefUse); - typeInfer->Reset(); - EXPECT_EQ(typeInfer->GetTypeForVarUse(var1)->IsEqualTo(type1), true); - typeInfer->ProcessVarDef(var0); - typeInfer->ProcessVarDef(var2); - EXPECT_EQ(var0->GetType()->IsEqualTo(type1), true); - EXPECT_EQ(var2->GetType()->IsEqualTo(type0), true); -} -} // namespace maple diff --git a/src/mplfe/test/mplfe_ut.h b/src/mplfe/test/mplfe_ut.h deleted file mode 100644 index 095633fb7a..0000000000 --- a/src/mplfe/test/mplfe_ut.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef MPLFEUT_INCLUDE_MPLFE_UT_H -#define MPLFEUT_INCLUDE_MPLFE_UT_H -#include "mir_module.h" - -extern maple::MIRModule &module; -extern MPLFEUTOptions &options; -#endif // MPLFEUT_INCLUDE_MPLFE_UT_H \ No newline at end of file diff --git a/src/mplfe/test/mplfe_ut_environment.h b/src/mplfe/test/mplfe_ut_environment.h deleted file mode 100644 index 371b40fd15..0000000000 --- a/src/mplfe/test/mplfe_ut_environment.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef MPLFE_TEST_MPLFE_UT_ENVIRONMENT_H -#define MPLFE_TEST_MPLFE_UT_ENVIRONMENT_H -#include -#include -#include "global_tables.h" -#include "mir_module.h" - -namespace maple { -class MPLFEUTEnvironment : public ::testing::Environment { - public: - MPLFEUTEnvironment() = default; - ~MPLFEUTEnvironment() = default; - - static MIRModule &GetMIRModule() { - static MIRModule module("mplfeUT"); - return module; - } - - void SetUp() override { - theMIRModule = &GetMIRModule(); - } -}; -} // namespace maple -#endif // MPLFE_TEST_MPLFE_UT_ENVIRONMENT_H \ No newline at end of file diff --git a/src/mplfe/test/mplfe_ut_options.h b/src/mplfe/test/mplfe_ut_options.h deleted file mode 100644 index c19348ac5e..0000000000 --- a/src/mplfe/test/mplfe_ut_options.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef MPLFE_INCLUDE_MPLFE_UT_OPTIONS_H -#define MPLFE_INCLUDE_MPLFE_UT_OPTIONS_H -#include -#include -#include "driver_option_common.h" - -namespace maple { -class MPLFEUTOptions : public maple::MapleDriverOptionBase { - public: - MPLFEUTOptions(); - ~MPLFEUTOptions() = default; - void DumpUsage() const; - bool SolveArgs(int argc, char **argv); - template - static void Split(const std::string &s, char delim, Out result); - - static MPLFEUTOptions &GetInstance() { - static MPLFEUTOptions options; - return options; - } - - bool GetRunAll() const { - return runAll; - } - - bool GetRunAllWithCore() const { - return runAllWithCore; - } - - bool GetGenBase64() const { - return genBase64; - } - - std::string GetBase64SrcFileName() const { - return base64SrcFileName; - } - - std::string GetCoreMpltName() const { - return coreMpltName; - } - - const std::list &GetClassFileList() const { - return classFileList; - } - - const std::list &GetJarFileList() const { - return jarFileList; - } - - const std::list &GetMpltFileList() const { - return mpltFileList; - } - - private: - bool runAll; - bool runAllWithCore; - bool genBase64; - std::string base64SrcFileName; - std::string coreMpltName; - std::list classFileList; - std::list jarFileList; - std::list mpltFileList; -}; -} // namespace maple - -#endif // MPLFE_INCLUDE_MPLFE_UT_OPTIONS_H \ No newline at end of file diff --git a/src/mplfe/test/mplfe_ut_regx.h b/src/mplfe/test/mplfe_ut_regx.h deleted file mode 100644 index a139207eb7..0000000000 --- a/src/mplfe/test/mplfe_ut_regx.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef MPLFE_UT_INCLUDE_MPLFE_UT_REGX_H -#define MPLFE_UT_INCLUDE_MPLFE_UT_REGX_H -#include -#include -#include "types_def.h" - -namespace maple { -class MPLFEUTRegx { - public: - static const uint32 kAnyNumber = 0xFFFFFFFF; - MPLFEUTRegx() = default; - ~MPLFEUTRegx() = default; - static bool Match(const std::string &str, const std::string &pattern); - static std::string RegName(uint32 regNum); - static std::string RefIndex(uint32 typeIdx); - static std::string Any() { - return "(.|\r|\n)*"; - } -}; -} // namespace maple -#endif // MPLFE_UT_INCLUDE_MPLFE_UT_REGX_H \ No newline at end of file diff --git a/src/mplfe/test/ops_ut_check.sh b/src/mplfe/test/ops_ut_check.sh deleted file mode 100644 index ba0f18b1db..0000000000 --- a/src/mplfe/test/ops_ut_check.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash -# -# Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. -# -# OpenArkCompiler is licensed under the Mulan PSL v1. -# You can use this software according to the terms and conditions of the Mulan PSL v1. -# You may obtain a copy of Mulan PSL v1 at: -# -# http://license.coscl.org.cn/MulanPSL -# -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR -# FIT FOR A PARTICULAR PURPOSE. -# See the Mulan PSL v1 for more details. -# -set -e - -JAVA_CORE=${MAPLE_ROOT}/libjava-core/java-core.jar -cd ${MAPLE_ROOT}/libjava-core -${MAPLE_ROOT}/output/bin/mplfe ${JAVA_CORE} -t -o java-core -cd - -rm -rf ${MAPLE_ROOT}/report -${MAPLE_ROOT}/output/bin/mplfeUT ext -gen-base64 ${MAPLE_ROOT}/src/mplfe/test/jbc_input/JBC0001/Test.class -${MAPLE_ROOT}/output/bin/mplfeUT ext -in-class ${MAPLE_ROOT}/src/mplfe/test/jbc_input/JBC0001/Test.class -${MAPLE_ROOT}/output/bin/mplfeUT ext -in-jar ${JAVA_CORE} -${MAPLE_ROOT}/output/bin/mplfeUT ext -mplt ${MAPLE_ROOT}/libjava-core/java-core.mplt -${MAPLE_ROOT}/output/bin/mplfeUT testWithMplt ${MAPLE_ROOT}/libjava-core/java-core.mplt - diff --git a/src/mplfe/test/redirect_buffer.h b/src/mplfe/test/redirect_buffer.h deleted file mode 100644 index 0c46424300..0000000000 --- a/src/mplfe/test/redirect_buffer.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) [2020] Huawei Technologies Co.,Ltd.All rights reserved. - * - * OpenArkCompiler is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * - * http://license.coscl.org.cn/MulanPSL2 - * - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR - * FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -#ifndef MPLFE_INCLUDE_REDIRECT_BUFFER_H -#define MPLFE_INCLUDE_REDIRECT_BUFFER_H -#include -#include - -namespace maple { -class RedirectBuffer { - public: - RedirectBuffer() : sbuf(std::cout.rdbuf()), outByErr(false) {} - ~RedirectBuffer() = default; - - void RedirectCout(bool outByErrIn = false) { - sbuf = RedirectCoutBuf(ss.rdbuf()); - ss.str(""); - outByErr = outByErrIn; - } - - void RestoreCout() { - ss.str(""); - RedirectCoutBuf(sbuf); - } - - std::string GetBufferString() { - std::string str = ss.str(); - ss.str(""); - if (outByErr) { - std::cerr << str; - } - return str; - } - - void ClearBufferString() { - ss.str(""); - } - - std::string RemoveLastReturnChar(const std::string &input) { - size_t length = input.length(); - while (input[length - 1] == '\n') { - length--; - } - return input.substr(0, length); - } - - private: - std::stringstream ss; - std::streambuf *sbuf; - bool outByErr; - - std::streambuf *RedirectCoutBuf(std::streambuf *newBuf) { - std::streambuf *streamBuf = std::cout.rdbuf(); - std::cout.rdbuf(newBuf); - return streamBuf; - } -}; -} // namespace maple -#endif // MPLFE_INCLUDE_REDIRECT_BUFFER_H \ No newline at end of file -- Gitee