-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from dramforever/add-vector-zb
- Loading branch information
Showing
6 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.globl sha256_sigma0 | ||
|
||
sha256_sigma0: | ||
sha256sig0 a0, a0 | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <stdlib.h> | ||
#include <time.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <cgreen/cgreen.h> | ||
|
||
uint32_t sha256_sigma0(uint32_t input); | ||
|
||
uint32_t sha256_sigma0_ref(uint32_t input) { | ||
uint32_t a = (input >> 7) | (input << 25); | ||
uint32_t b = (input >> 18) | (input << 14); | ||
uint32_t c = input >> 3; | ||
return a ^ b ^ c; | ||
} | ||
|
||
Describe(sha256_sigma0); | ||
BeforeEach(sha256_sigma0) {} | ||
AfterEach(sha256_sigma0) {} | ||
|
||
Ensure(sha256_sigma0, works_for_some_fixed_tests) { | ||
assert_that(sha256_sigma0(0x12345678u), is_equal_to(sha256_sigma0_ref(0x12345678))); | ||
} | ||
|
||
TestSuite *solution_tests() { | ||
TestSuite *suite = create_test_suite(); | ||
add_test_with_context(suite, sha256_sigma0, works_for_some_fixed_tests); | ||
return suite; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.globl rvv_memcpy | ||
|
||
rvv_memcpy: | ||
mv a4, a0 | ||
|
||
1: | ||
vsetvli a3, a2, e8, m8, ta, ma | ||
vle8.v v8, (a1) | ||
vse8.v v8, (a0) | ||
add a0, a0, a3 | ||
add a1, a1, a3 | ||
sub a2, a2, a3 | ||
bnez a2, 1b | ||
|
||
mv a0, a4 | ||
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include <stdlib.h> | ||
#include <time.h> | ||
#include <stddef.h> | ||
#include <cgreen/cgreen.h> | ||
|
||
void *rvv_memcpy(void *dst, const void *src, size_t len); | ||
|
||
Describe(rvv_memcpy); | ||
BeforeEach(rvv_memcpy) {} | ||
AfterEach(rvv_memcpy) {} | ||
|
||
Ensure(rvv_memcpy, works_for_some_fixed_tests) { | ||
char buf1[] = "Hello, world!"; | ||
char buf2[] = "Alhoa, RISC-V!"; | ||
char *res = rvv_memcpy(buf2, buf1, 5); | ||
assert_that(res, is_equal_to(buf2)); | ||
assert_that(buf2, is_equal_to_string("Hello, RISC-V!")); | ||
} | ||
|
||
TestSuite *solution_tests() { | ||
TestSuite *suite = create_test_suite(); | ||
add_test_with_context(suite, rvv_memcpy, works_for_some_fixed_tests); | ||
return suite; | ||
} |