From ee6a6944293cbbb303173cf4aff924a8c9957d64 Mon Sep 17 00:00:00 2001 From: Alex Cockrean <84676155+ABenC377@users.noreply.github.com> Date: Thu, 19 Dec 2024 15:28:03 +0000 Subject: [PATCH 1/6] Getting rid of checkEarlyMispredict() function --- src/include/simeng/Instruction.hh | 6 --- .../simeng/arch/aarch64/Instruction.hh | 6 --- src/include/simeng/arch/riscv/Instruction.hh | 6 --- src/lib/arch/aarch64/Instruction.cc | 15 ------- src/lib/arch/riscv/Instruction.cc | 15 ------- src/lib/pipeline/DecodeUnit.cc | 38 +----------------- test/unit/aarch64/InstructionTest.cc | 40 ------------------- test/unit/riscv/InstructionTest.cc | 40 ------------------- 8 files changed, 1 insertion(+), 165 deletions(-) diff --git a/src/include/simeng/Instruction.hh b/src/include/simeng/Instruction.hh index b5a4e33e3b..c6c9c78bcb 100644 --- a/src/include/simeng/Instruction.hh +++ b/src/include/simeng/Instruction.hh @@ -73,12 +73,6 @@ class Instruction { /** Retrieve supplied memory data. */ virtual span getData() const = 0; - /** Early misprediction check; see if it's possible to determine whether the - * next instruction address was mispredicted without executing the - * instruction. Returns a {mispredicted, target} tuple representing whether - * the instruction was mispredicted, and the correct target address. */ - virtual std::tuple checkEarlyBranchMisprediction() const = 0; - /** Retrieve branch type. */ virtual BranchType getBranchType() const = 0; diff --git a/src/include/simeng/arch/aarch64/Instruction.hh b/src/include/simeng/arch/aarch64/Instruction.hh index 76e74d7eb7..5c6f38b771 100644 --- a/src/include/simeng/arch/aarch64/Instruction.hh +++ b/src/include/simeng/arch/aarch64/Instruction.hh @@ -317,12 +317,6 @@ class Instruction : public simeng::Instruction { /** Retrieve supplied memory data. */ span getData() const override; - /** Early misprediction check; see if it's possible to determine whether the - * next instruction address was mispredicted without executing the - * instruction. Returns a {mispredicted, target} tuple representing whether - * the instruction was mispredicted, and the correct target address. */ - std::tuple checkEarlyBranchMisprediction() const override; - /** Retrieve branch type. */ BranchType getBranchType() const override; diff --git a/src/include/simeng/arch/riscv/Instruction.hh b/src/include/simeng/arch/riscv/Instruction.hh index 9e707449c6..62b6c0b8b5 100644 --- a/src/include/simeng/arch/riscv/Instruction.hh +++ b/src/include/simeng/arch/riscv/Instruction.hh @@ -132,12 +132,6 @@ class Instruction : public simeng::Instruction { /** Retrieve supplied memory data. */ span getData() const override; - /** Early misprediction check; see if it's possible to determine whether the - * next instruction address was mispredicted without executing the - * instruction. Returns a {mispredicted, target} tuple representing whether - * the instruction was mispredicted, and the correct target address. */ - std::tuple checkEarlyBranchMisprediction() const override; - /** Retrieve branch type. */ BranchType getBranchType() const override; diff --git a/src/lib/arch/aarch64/Instruction.cc b/src/lib/arch/aarch64/Instruction.cc index e3b697433e..755d0235b8 100644 --- a/src/lib/arch/aarch64/Instruction.cc +++ b/src/lib/arch/aarch64/Instruction.cc @@ -100,21 +100,6 @@ span Instruction::getData() const { return {memoryData_.data(), memoryData_.size()}; } -std::tuple Instruction::checkEarlyBranchMisprediction() const { - assert( - !executed_ && - "Early branch misprediction check shouldn't be called after execution"); - - if (!isBranch()) { - // Instruction isn't a branch; if predicted as taken, it will require a - // flush - return {prediction_.isTaken, instructionAddress_ + 4}; - } - - // Not enough information to determine this was a misprediction - return {false, 0}; -} - BranchType Instruction::getBranchType() const { return branchType_; } int64_t Instruction::getKnownOffset() const { return knownOffset_; } diff --git a/src/lib/arch/riscv/Instruction.cc b/src/lib/arch/riscv/Instruction.cc index c71b581a60..a0937aa9e7 100644 --- a/src/lib/arch/riscv/Instruction.cc +++ b/src/lib/arch/riscv/Instruction.cc @@ -95,21 +95,6 @@ span Instruction::getData() const { return {memoryData_.data(), memoryData_.size()}; } -std::tuple Instruction::checkEarlyBranchMisprediction() const { - assert( - !executed_ && - "Early branch misprediction check shouldn't be called after execution"); - - if (!isBranch()) { - // Instruction isn't a branch; if predicted as taken, it will require a - // flush - return {prediction_.isTaken, instructionAddress_ + 4}; - } - - // Not enough information to determine this was a misprediction - return {false, 0}; -} - BranchType Instruction::getBranchType() const { return branchType_; } int64_t Instruction::getKnownOffset() const { return knownOffset_; } diff --git a/src/lib/pipeline/DecodeUnit.cc b/src/lib/pipeline/DecodeUnit.cc index 31df59fa66..997d8fbab0 100644 --- a/src/lib/pipeline/DecodeUnit.cc +++ b/src/lib/pipeline/DecodeUnit.cc @@ -48,44 +48,8 @@ void DecodeUnit::tick() { if (!microOps_.size()) break; // Move uop to output buffer and remove from internal buffer - auto& uop = (output_.getTailSlots()[slot] = std::move(microOps_.front())); + output_.getTailSlots()[slot] = std::move(microOps_.front()); microOps_.pop_front(); - - // Check preliminary branch prediction results now that the instruction is - // decoded. Identifies: - // - Non-branch instructions mistakenly predicted as branches - // - Incorrect targets for immediate branches - auto [misprediction, correctAddress] = uop->checkEarlyBranchMisprediction(); - if (misprediction) { - earlyFlushes_++; - shouldFlush_ = true; - pc_ = correctAddress; - - if (!uop->isBranch()) { - // Non-branch incorrectly predicted as a branch; let the predictor know - predictor_.update(uop->getInstructionAddress(), false, pc_, - uop->getBranchType(), uop->getInstructionId()); - } - // Remove macro-operations in microOps_ buffer after macro-operation - // decoded in this cycle - auto uopIt = microOps_.begin(); - // Find first microOps_ entry not belonging to same address as flushing - // instruction - while (uopIt != microOps_.end()) { - if ((*uopIt)->getInstructionAddress() != uop->getInstructionAddress()) { - break; - } else { - uopIt++; - } - } - // Remove all entries after first macro-operation in buffer - while (uopIt != microOps_.end()) { - uopIt = microOps_.erase(uopIt); - } - - // Skip processing remaining uops, as they need to be flushed - break; - } } } diff --git a/test/unit/aarch64/InstructionTest.cc b/test/unit/aarch64/InstructionTest.cc index 92b8e9393a..27c8f17239 100644 --- a/test/unit/aarch64/InstructionTest.cc +++ b/test/unit/aarch64/InstructionTest.cc @@ -461,38 +461,6 @@ TEST_F(AArch64InstructionTest, supplyData_dataAbort) { EXPECT_EQ(insn.getException(), InstructionException::DataAbort); } -// Test to check logic around early branch misprediction logic -TEST_F(AArch64InstructionTest, earlyBranchMisprediction) { - // Insn is `fdivr z1.s, p0/m, z1.s, z0.s` - Instruction insn = Instruction(arch, *fdivMetadata.get(), MicroOpInfo()); - insn.setInstructionAddress(64); - - // Check initial state of an instruction's branch related options - BranchPrediction pred = {false, 0}; - bool matchingPred = (insn.getBranchPrediction() == pred); - EXPECT_TRUE(matchingPred); - EXPECT_FALSE(insn.wasBranchTaken()); - EXPECT_EQ(insn.getBranchAddress(), 0); - EXPECT_EQ(insn.getBranchType(), BranchType::Unknown); - EXPECT_FALSE(insn.isBranch()); - std::tuple tup = {false, insn.getInstructionAddress() + 4}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); - - // Set prediction and ensure expected state changes / outcomes are seen - pred = {true, 0x4848}; - insn.setBranchPrediction(pred); - matchingPred = (insn.getBranchPrediction() == pred); - EXPECT_TRUE(matchingPred); - EXPECT_FALSE(insn.wasBranchTaken()); - EXPECT_EQ(insn.getBranchAddress(), 0); - EXPECT_EQ(insn.getBranchType(), BranchType::Unknown); - // Check logic of `checkEarlyBranchMisprediction` which is different for - // non-branch instructions - EXPECT_FALSE(insn.isBranch()); - tup = {true, insn.getInstructionAddress() + 4}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); -} - // Test that a correct prediction (branch taken) is handled correctly TEST_F(AArch64InstructionTest, correctPred_taken) { // insn is `cbz x2, #0x28` @@ -507,8 +475,6 @@ TEST_F(AArch64InstructionTest, correctPred_taken) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test a correct prediction where branch is taken is handled correctly pred = {true, 80 + 0x28}; @@ -536,8 +502,6 @@ TEST_F(AArch64InstructionTest, correctPred_notTaken) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test a correct prediction where a branch isn't taken is handled correctly pred = {false, 80 + 4}; @@ -565,8 +529,6 @@ TEST_F(AArch64InstructionTest, incorrectPred_target) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test an incorrect prediction is handled correctly - target is wrong pred = {true, 80 + 0x28}; @@ -594,8 +556,6 @@ TEST_F(AArch64InstructionTest, incorrectPred_taken) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test an incorrect prediction is handled correctly - taken is wrong pred = {true, 100 + 0x28}; diff --git a/test/unit/riscv/InstructionTest.cc b/test/unit/riscv/InstructionTest.cc index 6103cd4f5c..cda72c7fb9 100644 --- a/test/unit/riscv/InstructionTest.cc +++ b/test/unit/riscv/InstructionTest.cc @@ -435,38 +435,6 @@ TEST_F(RiscVInstructionTest, supplyData_dataAbort) { EXPECT_EQ(insn.getException(), InstructionException::DataAbort); } -// Test to check logic around early branch misprediction logic -TEST_F(RiscVInstructionTest, earlyBranchMisprediction) { - // Insn is `div a3, a3, a0` - Instruction insn = Instruction(arch, *divMetadata.get()); - insn.setInstructionAddress(64); - - // Check initial state of an instruction's branch related options - BranchPrediction pred = {false, 0}; - bool matchingPred = (insn.getBranchPrediction() == pred); - EXPECT_TRUE(matchingPred); - EXPECT_FALSE(insn.wasBranchTaken()); - EXPECT_EQ(insn.getBranchAddress(), 0); - EXPECT_EQ(insn.getBranchType(), BranchType::Unknown); - EXPECT_FALSE(insn.isBranch()); - std::tuple tup = {false, insn.getInstructionAddress() + 4}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); - - // Set prediction and ensure expected state changes / outcomes are seen - pred = {true, 0x4848}; - insn.setBranchPrediction(pred); - matchingPred = (insn.getBranchPrediction() == pred); - EXPECT_TRUE(matchingPred); - EXPECT_FALSE(insn.wasBranchTaken()); - EXPECT_EQ(insn.getBranchAddress(), 0); - EXPECT_EQ(insn.getBranchType(), BranchType::Unknown); - // Check logic of `checkEarlyBranchMisprediction` which is different for - // non-branch instructions - EXPECT_FALSE(insn.isBranch()); - tup = {true, insn.getInstructionAddress() + 4}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); -} - // Test that a correct prediction (branch taken) is handled correctly TEST_F(RiscVInstructionTest, correctPred_taken) { // insn is `bgeu a5, a4, -86` @@ -481,8 +449,6 @@ TEST_F(RiscVInstructionTest, correctPred_taken) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test a correct prediction where branch is taken is handled correctly pred = {true, 400 - 86}; @@ -511,8 +477,6 @@ TEST_F(RiscVInstructionTest, correctPred_notTaken) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test a correct prediction where a branch isn't taken is handled correctly // imm operand 0x28 has 4 added implicitly by dissassembler @@ -542,8 +506,6 @@ TEST_F(RiscVInstructionTest, incorrectPred_target) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test an incorrect prediction is handled correctly - target is wrong // imm operand 0x28 has 4 added implicitly by dissassembler @@ -573,8 +535,6 @@ TEST_F(RiscVInstructionTest, incorrectPred_taken) { EXPECT_EQ(insn.getBranchAddress(), 0); EXPECT_EQ(insn.getBranchType(), BranchType::Conditional); EXPECT_TRUE(insn.isBranch()); - std::tuple tup = {false, 0}; - EXPECT_EQ(insn.checkEarlyBranchMisprediction(), tup); // Test an incorrect prediction is handled correctly - taken is wrong // imm operand 0x28 has 4 added implicitly by dissassembler From 99981e1b26c69786ce3d57fc07c026c1bf90ef1a Mon Sep 17 00:00:00 2001 From: Alex Cockrean <84676155+ABenC377@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:00:11 +0000 Subject: [PATCH 2/6] Cleaning up tests --- src/include/simeng/Instruction.hh | 2 +- src/include/simeng/arch/ArchInfo.hh | 2 +- src/include/simeng/arch/Architecture.hh | 4 +-- .../branchpredictors/BranchPredictor.hh | 2 +- src/include/simeng/config/ExpectationNode.hh | 4 +-- src/include/simeng/pipeline/PortAllocator.hh | 2 +- test/integration/ConfigTest.cc | 8 ++--- test/regression/aarch64/instructions/neon.cc | 2 +- test/unit/aarch64/AuxiliaryFunctionsTest.cc | 27 +++++++++-------- test/unit/pipeline/DecodeUnitTest.cc | 29 ------------------- 10 files changed, 26 insertions(+), 56 deletions(-) diff --git a/src/include/simeng/Instruction.hh b/src/include/simeng/Instruction.hh index c6c9c78bcb..d09e88aad6 100644 --- a/src/include/simeng/Instruction.hh +++ b/src/include/simeng/Instruction.hh @@ -29,7 +29,7 @@ struct ExecutionInfo { * Each supported ISA should provide a derived implementation of this class. */ class Instruction { public: - virtual ~Instruction(){}; + virtual ~Instruction() {}; /** Retrieve the source registers this instruction reads. */ virtual const span getSourceRegisters() const = 0; diff --git a/src/include/simeng/arch/ArchInfo.hh b/src/include/simeng/arch/ArchInfo.hh index e029699c07..eed7055cf7 100644 --- a/src/include/simeng/arch/ArchInfo.hh +++ b/src/include/simeng/arch/ArchInfo.hh @@ -12,7 +12,7 @@ namespace arch { /** A class to hold and generate architecture specific configuration options. */ class ArchInfo { public: - virtual ~ArchInfo(){}; + virtual ~ArchInfo() {}; /** Get the set of system register enums currently supported. */ virtual const std::vector& getSysRegEnums() const = 0; diff --git a/src/include/simeng/arch/Architecture.hh b/src/include/simeng/arch/Architecture.hh index aa293d6f5f..b4e6ac6001 100644 --- a/src/include/simeng/arch/Architecture.hh +++ b/src/include/simeng/arch/Architecture.hh @@ -30,7 +30,7 @@ struct ExceptionResult { * cycle until complete. */ class ExceptionHandler { public: - virtual ~ExceptionHandler(){}; + virtual ~ExceptionHandler() {}; /** Tick the exception handler to progress handling of the exception. Should * return `false` if the exception requires further handling, or `true` once * complete. */ @@ -46,7 +46,7 @@ class Architecture { public: Architecture(kernel::Linux& kernel) : linux_(kernel) {} - virtual ~Architecture(){}; + virtual ~Architecture() {}; /** Attempt to pre-decode from `bytesAvailable` bytes of instruction memory. * Writes into the supplied macro-op vector, and returns the number of bytes diff --git a/src/include/simeng/branchpredictors/BranchPredictor.hh b/src/include/simeng/branchpredictors/BranchPredictor.hh index 7779fe0703..d1cf1eeec3 100644 --- a/src/include/simeng/branchpredictors/BranchPredictor.hh +++ b/src/include/simeng/branchpredictors/BranchPredictor.hh @@ -12,7 +12,7 @@ namespace simeng { /** An abstract branch predictor interface. */ class BranchPredictor { public: - virtual ~BranchPredictor(){}; + virtual ~BranchPredictor() {}; /** Generate a branch prediction for the supplied instruction address, a * branch type, and a known branch offset. Returns a branch direction and diff --git a/src/include/simeng/config/ExpectationNode.hh b/src/include/simeng/config/ExpectationNode.hh index 187d3ed37a..cbf59d5750 100644 --- a/src/include/simeng/config/ExpectationNode.hh +++ b/src/include/simeng/config/ExpectationNode.hh @@ -134,9 +134,9 @@ class ExpectationNode { /** Default constructor. Used primarily to provide a root node for populated * ExpectationNode instances to be added to. */ - ExpectationNode(){}; + ExpectationNode() {}; - ~ExpectationNode(){}; + ~ExpectationNode() {}; /** A getter function to retrieve the key of a node. */ std::string getKey() const { return nodeKey_; } diff --git a/src/include/simeng/pipeline/PortAllocator.hh b/src/include/simeng/pipeline/PortAllocator.hh index 78e3a0c5c9..bd566702ae 100644 --- a/src/include/simeng/pipeline/PortAllocator.hh +++ b/src/include/simeng/pipeline/PortAllocator.hh @@ -16,7 +16,7 @@ const uint8_t OPTIONAL = 1; /** An abstract execution port allocator interface. */ class PortAllocator { public: - virtual ~PortAllocator(){}; + virtual ~PortAllocator() {}; /** Allocate a port for the specified instruction group; returns the allocated * port. */ diff --git a/test/integration/ConfigTest.cc b/test/integration/ConfigTest.cc index 4e6ac2ad68..3ab6c9ff63 100644 --- a/test/integration/ConfigTest.cc +++ b/test/integration/ConfigTest.cc @@ -302,9 +302,7 @@ TEST(ConfigTest, invalidTypeOnSetBounds) { simeng::config::ExpectationNode::createExpectation("DEFAULT", "CHILD")); ASSERT_DEATH( - { - expectations["HEAD"]["CHILD"].setValueSet({0, 1, 2}); - }, + { expectations["HEAD"]["CHILD"].setValueSet({0, 1, 2}); }, "The data type of the passed vector used in setValueSet\\() " "does not match that held within the ExpectationNode with key " "HEAD:CHILD. Passed vector elements are of type 32-bit integer and the " @@ -322,9 +320,7 @@ TEST(ConfigTest, alreadyDefinedBounds) { simeng::config::ExpectationNode::createExpectation(0, "CHILD")); expectations["HEAD"]["CHILD"].setValueBounds(0, 10); ASSERT_DEATH( - { - expectations["HEAD"]["CHILD"].setValueSet({1, 2, 3}); - }, + { expectations["HEAD"]["CHILD"].setValueSet({1, 2, 3}); }, "Invalid call of setValueSet\\() for the ExpectationNode with key " "HEAD:CHILD as value bounds have already been defined."); } diff --git a/test/regression/aarch64/instructions/neon.cc b/test/regression/aarch64/instructions/neon.cc index a4731f388f..64efb68110 100644 --- a/test/regression/aarch64/instructions/neon.cc +++ b/test/regression/aarch64/instructions/neon.cc @@ -2546,7 +2546,7 @@ TEST_P(InstNeon, mvni) { ~((32u << 8) | 255)}); } -TEST_P(InstNeon, not ) { +TEST_P(InstNeon, not) { initialHeapData_.resize(128); uint8_t* heap = reinterpret_cast(initialHeapData_.data()); heap[0] = 0b11111111; diff --git a/test/unit/aarch64/AuxiliaryFunctionsTest.cc b/test/unit/aarch64/AuxiliaryFunctionsTest.cc index dd18b16a31..c7b823f5c7 100644 --- a/test/unit/aarch64/AuxiliaryFunctionsTest.cc +++ b/test/unit/aarch64/AuxiliaryFunctionsTest.cc @@ -71,10 +71,11 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { { bitfieldManipulate(0, 0, 16, 0, false); }, "Attempted to use a rotate amount of 16 in bitfieldManipulate which is " "greater than or equal to the data type size of 16b in use"); - ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 16, false); }, - "Attempted to use a source bit position value of 16 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 16b in use"); + ASSERT_DEATH( + { bitfieldManipulate(0, 0, 0, 16, false); }, + "Attempted to use a source bit position value of 16 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 16b in use"); // uint32 EXPECT_EQ(bitfieldManipulate(0x0000FFFF, 0xFFFF0000, 0, 0, false), @@ -104,10 +105,11 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { { bitfieldManipulate(0, 0, 32, 0, false); }, "Attempted to use a rotate amount of 32 in bitfieldManipulate which is " "greater than or equal to the data type size of 32b in use"); - ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 32, false); }, - "Attempted to use a source bit position value of 32 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 32b in use"); + ASSERT_DEATH( + { bitfieldManipulate(0, 0, 0, 32, false); }, + "Attempted to use a source bit position value of 32 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 32b in use"); // uint64 EXPECT_EQ(bitfieldManipulate(0x00000000FFFFFFFF, 0xFFFFFFFF00000000, @@ -147,10 +149,11 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { { bitfieldManipulate(0, 0, 64, 0, false); }, "Attempted to use a rotate amount of 64 in bitfieldManipulate which is " "greater than or equal to the data type size of 64b in use"); - ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 64, false); }, - "Attempted to use a source bit position value of 64 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 64b in use"); + ASSERT_DEATH( + { bitfieldManipulate(0, 0, 0, 64, false); }, + "Attempted to use a source bit position value of 64 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 64b in use"); } /** `conditionHolds` Tests */ diff --git a/test/unit/pipeline/DecodeUnitTest.cc b/test/unit/pipeline/DecodeUnitTest.cc index eed1ab60ae..bd89f3c291 100644 --- a/test/unit/pipeline/DecodeUnitTest.cc +++ b/test/unit/pipeline/DecodeUnitTest.cc @@ -53,9 +53,6 @@ TEST_F(PipelineDecodeUnitTest, TickEmpty) { TEST_F(PipelineDecodeUnitTest, Tick) { input.getHeadSlots()[0] = {uopPtr}; - EXPECT_CALL(*uop, checkEarlyBranchMisprediction()) - .WillOnce(Return(std::tuple(false, 0))); - decodeUnit.tick(); // Check result uop is the same as the one provided @@ -67,32 +64,6 @@ TEST_F(PipelineDecodeUnitTest, Tick) { EXPECT_EQ(decodeUnit.getEarlyFlushes(), 0); } -// Tests that the decode unit requests a flush when a non-branch is mispredicted -TEST_F(PipelineDecodeUnitTest, Flush) { - input.getHeadSlots()[0] = {uopPtr}; - - uop->setInstructionAddress(2); - - // Return branch type as unconditional by default - ON_CALL(*uop, getBranchType()) - .WillByDefault(Return(BranchType::Unconditional)); - - EXPECT_CALL(*uop, checkEarlyBranchMisprediction()) - .WillOnce(Return(std::tuple(true, 1))); - EXPECT_CALL(*uop, isBranch()).WillOnce(Return(false)); - - // Check the predictor is updated with the correct instruction address and PC - EXPECT_CALL(predictor, update(2, false, 1, BranchType::Unconditional, - uop->getInstructionId())); - - decodeUnit.tick(); - - // Check that a flush was correctly requested - EXPECT_EQ(decodeUnit.shouldFlush(), true); - EXPECT_EQ(decodeUnit.getFlushAddress(), 1); - EXPECT_EQ(decodeUnit.getEarlyFlushes(), 1); -} - // Tests that PurgeFlushed empties the microOps queue TEST_F(PipelineDecodeUnitTest, purgeFlushed) { input.getHeadSlots()[0] = {uopPtr, uop2Ptr}; From c24e63c9a874e50aa2de831bb5b30cd7e7986b87 Mon Sep 17 00:00:00 2001 From: Alex Cockrean <84676155+ABenC377@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:28:33 +0000 Subject: [PATCH 3/6] Undoing unnecessary clang format changes --- src/include/simeng/arch/ArchInfo.hh | 2 +- src/include/simeng/arch/Architecture.hh | 4 ++-- src/include/simeng/branchpredictors/BranchPredictor.hh | 2 +- src/include/simeng/config/ExpectationNode.hh | 4 ++-- src/include/simeng/pipeline/PortAllocator.hh | 2 +- test/integration/ConfigTest.cc | 8 ++++++-- test/regression/aarch64/instructions/neon.cc | 2 +- test/unit/aarch64/AuxiliaryFunctionsTest.cc | 9 +++------ 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/include/simeng/arch/ArchInfo.hh b/src/include/simeng/arch/ArchInfo.hh index eed7055cf7..e029699c07 100644 --- a/src/include/simeng/arch/ArchInfo.hh +++ b/src/include/simeng/arch/ArchInfo.hh @@ -12,7 +12,7 @@ namespace arch { /** A class to hold and generate architecture specific configuration options. */ class ArchInfo { public: - virtual ~ArchInfo() {}; + virtual ~ArchInfo(){}; /** Get the set of system register enums currently supported. */ virtual const std::vector& getSysRegEnums() const = 0; diff --git a/src/include/simeng/arch/Architecture.hh b/src/include/simeng/arch/Architecture.hh index b4e6ac6001..aa293d6f5f 100644 --- a/src/include/simeng/arch/Architecture.hh +++ b/src/include/simeng/arch/Architecture.hh @@ -30,7 +30,7 @@ struct ExceptionResult { * cycle until complete. */ class ExceptionHandler { public: - virtual ~ExceptionHandler() {}; + virtual ~ExceptionHandler(){}; /** Tick the exception handler to progress handling of the exception. Should * return `false` if the exception requires further handling, or `true` once * complete. */ @@ -46,7 +46,7 @@ class Architecture { public: Architecture(kernel::Linux& kernel) : linux_(kernel) {} - virtual ~Architecture() {}; + virtual ~Architecture(){}; /** Attempt to pre-decode from `bytesAvailable` bytes of instruction memory. * Writes into the supplied macro-op vector, and returns the number of bytes diff --git a/src/include/simeng/branchpredictors/BranchPredictor.hh b/src/include/simeng/branchpredictors/BranchPredictor.hh index d1cf1eeec3..7779fe0703 100644 --- a/src/include/simeng/branchpredictors/BranchPredictor.hh +++ b/src/include/simeng/branchpredictors/BranchPredictor.hh @@ -12,7 +12,7 @@ namespace simeng { /** An abstract branch predictor interface. */ class BranchPredictor { public: - virtual ~BranchPredictor() {}; + virtual ~BranchPredictor(){}; /** Generate a branch prediction for the supplied instruction address, a * branch type, and a known branch offset. Returns a branch direction and diff --git a/src/include/simeng/config/ExpectationNode.hh b/src/include/simeng/config/ExpectationNode.hh index cbf59d5750..187d3ed37a 100644 --- a/src/include/simeng/config/ExpectationNode.hh +++ b/src/include/simeng/config/ExpectationNode.hh @@ -134,9 +134,9 @@ class ExpectationNode { /** Default constructor. Used primarily to provide a root node for populated * ExpectationNode instances to be added to. */ - ExpectationNode() {}; + ExpectationNode(){}; - ~ExpectationNode() {}; + ~ExpectationNode(){}; /** A getter function to retrieve the key of a node. */ std::string getKey() const { return nodeKey_; } diff --git a/src/include/simeng/pipeline/PortAllocator.hh b/src/include/simeng/pipeline/PortAllocator.hh index bd566702ae..78e3a0c5c9 100644 --- a/src/include/simeng/pipeline/PortAllocator.hh +++ b/src/include/simeng/pipeline/PortAllocator.hh @@ -16,7 +16,7 @@ const uint8_t OPTIONAL = 1; /** An abstract execution port allocator interface. */ class PortAllocator { public: - virtual ~PortAllocator() {}; + virtual ~PortAllocator(){}; /** Allocate a port for the specified instruction group; returns the allocated * port. */ diff --git a/test/integration/ConfigTest.cc b/test/integration/ConfigTest.cc index a713a4cbc0..48975eeacd 100644 --- a/test/integration/ConfigTest.cc +++ b/test/integration/ConfigTest.cc @@ -304,7 +304,9 @@ TEST(ConfigTest, invalidTypeOnSetBounds) { simeng::config::ExpectationNode::createExpectation("DEFAULT", "CHILD")); ASSERT_DEATH( - { expectations["HEAD"]["CHILD"].setValueSet({0, 1, 2}); }, + { + expectations["HEAD"]["CHILD"].setValueSet({0, 1, 2}); + }, "The data type of the passed vector used in setValueSet\\() " "does not match that held within the ExpectationNode with key " "HEAD:CHILD. Passed vector elements are of type 32-bit integer and the " @@ -322,7 +324,9 @@ TEST(ConfigTest, alreadyDefinedBounds) { simeng::config::ExpectationNode::createExpectation(0, "CHILD")); expectations["HEAD"]["CHILD"].setValueBounds(0, 10); ASSERT_DEATH( - { expectations["HEAD"]["CHILD"].setValueSet({1, 2, 3}); }, + { + expectations["HEAD"]["CHILD"].setValueSet({1, 2, 3}); + }, "Invalid call of setValueSet\\() for the ExpectationNode with key " "HEAD:CHILD as value bounds have already been defined."); } diff --git a/test/regression/aarch64/instructions/neon.cc b/test/regression/aarch64/instructions/neon.cc index 64efb68110..a4731f388f 100644 --- a/test/regression/aarch64/instructions/neon.cc +++ b/test/regression/aarch64/instructions/neon.cc @@ -2546,7 +2546,7 @@ TEST_P(InstNeon, mvni) { ~((32u << 8) | 255)}); } -TEST_P(InstNeon, not) { +TEST_P(InstNeon, not ) { initialHeapData_.resize(128); uint8_t* heap = reinterpret_cast(initialHeapData_.data()); heap[0] = 0b11111111; diff --git a/test/unit/aarch64/AuxiliaryFunctionsTest.cc b/test/unit/aarch64/AuxiliaryFunctionsTest.cc index e6918f72d9..df288435da 100644 --- a/test/unit/aarch64/AuxiliaryFunctionsTest.cc +++ b/test/unit/aarch64/AuxiliaryFunctionsTest.cc @@ -71,8 +71,7 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { { bitfieldManipulate(0, 0, 16, 0, false); }, "Attempted to use a rotate amount of 16 in bitfieldManipulate which is " "greater than or equal to the data type size of 16b in use"); - ASSERT_DEATH( - { bitfieldManipulate(0, 0, 0, 16, false); }, + ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 16, false); }, "Attempted to use a source bit position value of 16 in " "bitfieldManipulate which is greater than or equal to the data " "type size of 16b in use"); @@ -105,8 +104,7 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { { bitfieldManipulate(0, 0, 32, 0, false); }, "Attempted to use a rotate amount of 32 in bitfieldManipulate which is " "greater than or equal to the data type size of 32b in use"); - ASSERT_DEATH( - { bitfieldManipulate(0, 0, 0, 32, false); }, + ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 32, false); }, "Attempted to use a source bit position value of 32 in " "bitfieldManipulate which is greater than or equal to the data " "type size of 32b in use"); @@ -149,8 +147,7 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { { bitfieldManipulate(0, 0, 64, 0, false); }, "Attempted to use a rotate amount of 64 in bitfieldManipulate which is " "greater than or equal to the data type size of 64b in use"); - ASSERT_DEATH( - { bitfieldManipulate(0, 0, 0, 64, false); }, + ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 64, false); }, "Attempted to use a source bit position value of 64 in " "bitfieldManipulate which is greater than or equal to the data " "type size of 64b in use"); From e79f08ffda8d3d4bb269e9f3f31c2b6572058fef Mon Sep 17 00:00:00 2001 From: Alex Cockrean <84676155+ABenC377@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:30:21 +0000 Subject: [PATCH 4/6] Undoing unnecessary clang format changes --- src/include/simeng/Instruction.hh | 2 +- test/unit/aarch64/AuxiliaryFunctionsTest.cc | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/include/simeng/Instruction.hh b/src/include/simeng/Instruction.hh index d09e88aad6..c6c9c78bcb 100644 --- a/src/include/simeng/Instruction.hh +++ b/src/include/simeng/Instruction.hh @@ -29,7 +29,7 @@ struct ExecutionInfo { * Each supported ISA should provide a derived implementation of this class. */ class Instruction { public: - virtual ~Instruction() {}; + virtual ~Instruction(){}; /** Retrieve the source registers this instruction reads. */ virtual const span getSourceRegisters() const = 0; diff --git a/test/unit/aarch64/AuxiliaryFunctionsTest.cc b/test/unit/aarch64/AuxiliaryFunctionsTest.cc index df288435da..3b7a4fefb4 100644 --- a/test/unit/aarch64/AuxiliaryFunctionsTest.cc +++ b/test/unit/aarch64/AuxiliaryFunctionsTest.cc @@ -72,9 +72,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 16 in bitfieldManipulate which is " "greater than or equal to the data type size of 16b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 16, false); }, - "Attempted to use a source bit position value of 16 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 16b in use"); + "Attempted to use a source bit position value of 16 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 16b in use"); // uint32 EXPECT_EQ(bitfieldManipulate(0x0000FFFF, 0xFFFF0000, 0, 0, false), @@ -105,9 +105,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 32 in bitfieldManipulate which is " "greater than or equal to the data type size of 32b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 32, false); }, - "Attempted to use a source bit position value of 32 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 32b in use"); + "Attempted to use a source bit position value of 32 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 32b in use"); // uint64 EXPECT_EQ(bitfieldManipulate(0x00000000FFFFFFFF, 0xFFFFFFFF00000000, @@ -148,9 +148,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 64 in bitfieldManipulate which is " "greater than or equal to the data type size of 64b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 64, false); }, - "Attempted to use a source bit position value of 64 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 64b in use"); + "Attempted to use a source bit position value of 64 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 64b in use"); } /** `conditionHolds` Tests */ From 314dd8540e781cacd5766c4301efd64c43a16ec1 Mon Sep 17 00:00:00 2001 From: Alex Cockrean <84676155+ABenC377@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:30:56 +0000 Subject: [PATCH 5/6] Undoing unnecessary clang format changes --- test/unit/aarch64/AuxiliaryFunctionsTest.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/unit/aarch64/AuxiliaryFunctionsTest.cc b/test/unit/aarch64/AuxiliaryFunctionsTest.cc index 3b7a4fefb4..07c7f67478 100644 --- a/test/unit/aarch64/AuxiliaryFunctionsTest.cc +++ b/test/unit/aarch64/AuxiliaryFunctionsTest.cc @@ -72,9 +72,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 16 in bitfieldManipulate which is " "greater than or equal to the data type size of 16b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 16, false); }, - "Attempted to use a source bit position value of 16 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 16b in use"); + "Attempted to use a source bit position value of 16 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 16b in use"); // uint32 EXPECT_EQ(bitfieldManipulate(0x0000FFFF, 0xFFFF0000, 0, 0, false), @@ -105,9 +105,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 32 in bitfieldManipulate which is " "greater than or equal to the data type size of 32b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 32, false); }, - "Attempted to use a source bit position value of 32 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 32b in use"); + "Attempted to use a source bit position value of 32 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 32b in use"); // uint64 EXPECT_EQ(bitfieldManipulate(0x00000000FFFFFFFF, 0xFFFFFFFF00000000, @@ -148,9 +148,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 64 in bitfieldManipulate which is " "greater than or equal to the data type size of 64b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 64, false); }, - "Attempted to use a source bit position value of 64 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 64b in use"); + "Attempted to use a source bit position value of 64 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 64b in use"); } /** `conditionHolds` Tests */ From 4e9cffcf4efbeef9ab929a814c44eb93cb946332 Mon Sep 17 00:00:00 2001 From: Alex Cockrean <84676155+ABenC377@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:32:37 +0000 Subject: [PATCH 6/6] Undoing unnecessary clang format changes --- test/unit/aarch64/AuxiliaryFunctionsTest.cc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/unit/aarch64/AuxiliaryFunctionsTest.cc b/test/unit/aarch64/AuxiliaryFunctionsTest.cc index 07c7f67478..f319b55dbb 100644 --- a/test/unit/aarch64/AuxiliaryFunctionsTest.cc +++ b/test/unit/aarch64/AuxiliaryFunctionsTest.cc @@ -72,9 +72,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 16 in bitfieldManipulate which is " "greater than or equal to the data type size of 16b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 16, false); }, - "Attempted to use a source bit position value of 16 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 16b in use"); + "Attempted to use a source bit position value of 16 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 16b in use"); // uint32 EXPECT_EQ(bitfieldManipulate(0x0000FFFF, 0xFFFF0000, 0, 0, false), @@ -105,9 +105,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 32 in bitfieldManipulate which is " "greater than or equal to the data type size of 32b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 32, false); }, - "Attempted to use a source bit position value of 32 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 32b in use"); + "Attempted to use a source bit position value of 32 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 32b in use"); // uint64 EXPECT_EQ(bitfieldManipulate(0x00000000FFFFFFFF, 0xFFFFFFFF00000000, @@ -148,9 +148,9 @@ TEST(AArch64AuxiliaryFunctionTest, BitfieldManipulate) { "Attempted to use a rotate amount of 64 in bitfieldManipulate which is " "greater than or equal to the data type size of 64b in use"); ASSERT_DEATH({ bitfieldManipulate(0, 0, 0, 64, false); }, - "Attempted to use a source bit position value of 64 in " - "bitfieldManipulate which is greater than or equal to the data " - "type size of 64b in use"); + "Attempted to use a source bit position value of 64 in " + "bitfieldManipulate which is greater than or equal to the data " + "type size of 64b in use"); } /** `conditionHolds` Tests */