diff --git a/Scripts/UpdateInstructionCountJson.py b/Scripts/UpdateInstructionCountJson.py index 41a303a05..2a2197662 100755 --- a/Scripts/UpdateInstructionCountJson.py +++ b/Scripts/UpdateInstructionCountJson.py @@ -13,7 +13,11 @@ def update_performance_numbers(performance_json_path, performance_json, new_json if not key in performance_json["Instructions"]: logging.error("{} didn't exist in performance json file?".format(key)) return 1 - performance_json["Instructions"][key]["ExpectedInstructionCount"] = items + + if "ExpectedInstructionCount" in items: + performance_json["Instructions"][key]["ExpectedInstructionCount"] = items["ExpectedInstructionCount"] + if "ExpectedArm64ASM" in items: + performance_json["Instructions"][key]["ExpectedArm64ASM"] = items["ExpectedArm64ASM"] # Output to the original file. with open(performance_json_path, "w") as json_file: diff --git a/Source/Tools/CodeSizeValidation/Main.cpp b/Source/Tools/CodeSizeValidation/Main.cpp index b8cce1a84..f77ee96b5 100644 --- a/Source/Tools/CodeSizeValidation/Main.cpp +++ b/Source/Tools/CodeSizeValidation/Main.cpp @@ -270,7 +270,6 @@ static bool TestInstructions(FEXCore::Context::Context *CTX, FEXCore::Core::Inte } bool TestsPassed {true}; - bool InstructionCountChanged {}; // Get all the data for the instructions compiled. CurrentTest = &TestHeaderData->Tests[0]; @@ -294,7 +293,6 @@ static bool TestInstructions(FEXCore::Context::Context *CTX, FEXCore::Core::Inte if (INSTStats->first.HostCodeInstructions != CurrentTest->ExpectedInstructionCount) { LogMan::Msg::EFmt("Fail: '{}': {} host instructions", CurrentTest->TestInst, INSTStats->first.HostCodeInstructions); LogMan::Msg::EFmt("Fail: Test took {} instructions but we expected {} instructions!", INSTStats->first.HostCodeInstructions, CurrentTest->ExpectedInstructionCount); - InstructionCountChanged = true; if (CurrentTest->Optimal) { // Don't count the test as a failure if it's known non-optimal. @@ -310,11 +308,6 @@ static bool TestInstructions(FEXCore::Context::Context *CTX, FEXCore::Core::Inte // Unlink the file. unlink(UpdatedInstructionCountsPath); - if (!InstructionCountChanged) { - // If no instruction count changed then just return the results. - return TestsPassed; - } - FEXCore::File::File FD(UpdatedInstructionCountsPath, FEXCore::File::FileModes::WRITE | FEXCore::File::FileModes::CREATE | FEXCore::File::FileModes::TRUNCATE); if (!FD.IsValid()) { @@ -331,10 +324,22 @@ static bool TestInstructions(FEXCore::Context::Context *CTX, FEXCore::Core::Inte // Get the instruction stats. auto INSTStats = CodeSize::Validation.GetDataForRIP(CodeRIP); + FD.Write(fextl::fmt::format("\t\"{}\": {{\n", CurrentTest->TestInst)); + if (INSTStats->first.HostCodeInstructions != CurrentTest->ExpectedInstructionCount) { - FD.Write(fextl::fmt::format("\t\"{}\": {},\n", CurrentTest->TestInst, INSTStats->first.HostCodeInstructions)); + FD.Write(fextl::fmt::format("\t\t\"ExpectedInstructionCount\": {},\n", INSTStats->first.HostCodeInstructions)); } + FD.Write(fextl::fmt::format("\t\t\"ExpectedArm64ASM\": [\n", INSTStats->first.HostCodeInstructions)); + for (auto it = INSTStats->second.begin(); it != INSTStats->second.end(); ++it) { + const auto &Line = *it; + const auto NextIt = it + 1; + FD.Write(fextl::fmt::format("\t\t\t\"{}\"{}\n", Line, NextIt != INSTStats->second.end() ? "," : "")); + } + FD.Write(fextl::fmt::format("\t\t]\n", INSTStats->first.HostCodeInstructions)); + + FD.Write(fextl::fmt::format("\t}},\n", CurrentTest->TestInst)); + // Go to the next test. CurrentTest = reinterpret_cast(&CurrentTest->Code[CurrentTest->CodeSize]); }