Skip to content

Commit

Permalink
assembler: Handle wait-on-reservation extension (Zawrs)
Browse files Browse the repository at this point in the history
  • Loading branch information
lioncash committed Jan 8, 2024
1 parent 703ce98 commit 017631d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Includes both 32-bit and 64-bit instructions in the following:
| S | 1.12 |
| V | 1.0 |
| Sstc | 0.5.4 |
| Zawrs | 1.01 |
| Zfh | 1.0 |
| Zfhmin | 1.0 |
| Zicbom | 1.0 |
Expand Down
4 changes: 4 additions & 0 deletions include/biscuit/assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ class Assembler {
void SRLW(GPR rd, GPR lhs, GPR rhs) noexcept;
void SUBW(GPR rd, GPR lhs, GPR rhs) noexcept;

// Zawrs Extension Instructions
void WRS_NTO() noexcept;
void WRS_STO() noexcept;

// Zicond Extension Instructions
void CZERO_EQZ(GPR rd, GPR value, GPR condition) noexcept;
void CZERO_NEZ(GPR rd, GPR value, GPR condition) noexcept;
Expand Down
9 changes: 9 additions & 0 deletions src/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,15 @@ void Assembler::SUBW(GPR rd, GPR lhs, GPR rhs) noexcept {
EmitRType(m_buffer, 0b0100000, rhs, lhs, 0b000, rd, 0b0111011);
}

// Zawrs Extension Instructions

void Assembler::WRS_NTO() noexcept {
EmitIType(m_buffer, 0b01101, x0, 0, x0, 0b1110011);
}
void Assembler::WRS_STO() noexcept {
EmitIType(m_buffer, 0b11101, x0, 0, x0, 0b1110011);
}

// Zicond Extension Instructions

void Assembler::CZERO_EQZ(GPR rd, GPR value, GPR condition) noexcept {
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ add_executable(${PROJECT_NAME}
src/assembler_rvm_tests.cpp
src/assembler_rvq_tests.cpp
src/assembler_rvv_tests.cpp
src/assembler_zawrs_tests.cpp
src/assembler_zicond_tests.cpp
src/assembler_zicsr_tests.cpp
src/assembler_zihintntl_tests.cpp
Expand Down
21 changes: 21 additions & 0 deletions tests/src/assembler_zawrs_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <catch/catch.hpp>

#include <biscuit/assembler.hpp>

using namespace biscuit;

TEST_CASE("WRS.NTO", "[Zawrs]") {
uint32_t value = 0;
Assembler as(reinterpret_cast<uint8_t*>(&value), sizeof(value));

as.WRS_NTO();
REQUIRE(value == 0x00D00073);
}

TEST_CASE("WRS.STO", "[Zawrs]") {
uint32_t value = 0;
Assembler as(reinterpret_cast<uint8_t*>(&value), sizeof(value));

as.WRS_STO();
REQUIRE(value == 0x01D00073);
}

0 comments on commit 017631d

Please sign in to comment.