Skip to content

Commit

Permalink
Merge pull request #20 from OFFTKP/addsl
Browse files Browse the repository at this point in the history
assembler: Add XTheadBa support
  • Loading branch information
lioncash authored Nov 9, 2024
2 parents c86bf13 + e72b279 commit 1f5546d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Includes both 32-bit and 64-bit instructions in the following:
| V | 1.0 |
| Ssctr | 1.0 rc6 |
| Sstc | 0.5.4 |
| XTheadBa | 1.0 |
| XTheadCondMov | 1.0 |
| Zabha | 1.0 |
| Zacas | 1.0 |
Expand Down
3 changes: 3 additions & 0 deletions include/biscuit/assembler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ class Assembler {
void TH_MVEQZ(GPR rd, GPR value, GPR condition) noexcept;
void TH_MVNEZ(GPR rd, GPR value, GPR condition) noexcept;

// XTheadBa Extension Instructions
void TH_ADDSL(GPR rd, GPR rs1, GPR rs2, uint32_t shift) noexcept;

// Zicsr Extension Instructions

void CSRRC(GPR rd, CSR csr, GPR rs) noexcept;
Expand Down
7 changes: 7 additions & 0 deletions src/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,13 @@ void Assembler::TH_MVNEZ(GPR rd, GPR value, GPR condition) noexcept {
EmitRType(m_buffer, 0b0100001, condition, value, 0b001, rd, 0b0001011);
}

// XTheadBa Extension Instructions

void Assembler::TH_ADDSL(GPR rd, GPR rs1, GPR rs2, uint32_t shift) noexcept {
BISCUIT_ASSERT(shift <= 3);
EmitRType(m_buffer, 0b0000000 | shift, rs2, rs1, 0b001, rd, 0b0001011);
}

// Zicsr Extension Instructions

void Assembler::CSRRC(GPR rd, CSR csr, GPR rs) noexcept {
Expand Down
23 changes: 23 additions & 0 deletions tests/src/assembler_xthead_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,26 @@ TEST_CASE("TH.MVNEZ", "[XThead]") {
as.TH_MVNEZ(x1, x2, x3);
REQUIRE(value == 0x4231108B);
}

TEST_CASE("TH.ADDSL", "[XThead]") {
uint32_t value = 0;
auto as = MakeAssembler64(value);

as.TH_ADDSL(x31, x30, x29, 0);
REQUIRE(value == 0x01DF1F8B);

as.RewindBuffer();

as.TH_ADDSL(x31, x30, x29, 1);
REQUIRE(value == 0x03DF1F8B);

as.RewindBuffer();

as.TH_ADDSL(x31, x30, x29, 2);
REQUIRE(value == 0x05DF1F8B);

as.RewindBuffer();

as.TH_ADDSL(x31, x30, x29, 3);
REQUIRE(value == 0x07DF1F8B);
}

0 comments on commit 1f5546d

Please sign in to comment.