Skip to content

Commit

Permalink
<cache>
Browse files Browse the repository at this point in the history
  • Loading branch information
NanQin555 committed Aug 19, 2024
1 parent 79a43d7 commit c3c4928
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
5 changes: 3 additions & 2 deletions RISCVLib/CacheLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ struct CacheEntity
CacheEntity list[1023];
constexpr unsigned int m1 = 1023, m2 = 1021;
CacheEntity* CacheLookUp(int param1, int param2) {
unsigned long int key = (static_cast<unsigned long int>(param1) & static_cast<unsigned long int>(param2)) << 32;
key |= (static_cast<unsigned long int>(param1) | static_cast<unsigned long int>(param2));
// unsigned long int key = (static_cast<unsigned long int>(param1) & static_cast<unsigned long int>(param2)) << 32;
// key |= (static_cast<unsigned long int>(param1) | static_cast<unsigned long int>(param2));
unsigned long int key = (static_cast<unsigned long int>(param1) << 32 | static_cast<unsigned long int>(param2));
const auto hash = key % m1, step = 1 + key % m2;
unsigned int cur = hash;
constexpr unsigned int max = 5;
Expand Down
17 changes: 3 additions & 14 deletions RISCVLib/CacheLib.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ _ZL2m2:
.globl CacheLookUp
.type CacheLookUp, @function
CacheLookUp:
.LFB0:
.LFB0_cache:
.cfi_startproc
addi sp,sp,-96
.cfi_def_cfa_offset 96
Expand All @@ -36,20 +36,9 @@ CacheLookUp:
mv a5,a4
sw a5,-88(s0)
lw a5,-84(s0)
mv a4,a5
lw a5,-88(s0)
and a5,a4,a5
sext.w a5,a5
slli a5,a5,32
sd a5,-32(s0)
lw a5,-84(s0)
mv a4,a5
slli a4,a5,32
lw a5,-88(s0)
or a5,a4,a5
sext.w a5,a5
mv a4,a5
ld a5,-32(s0)
or a5,a5,a4
sd a5,-32(s0)
ld a4,-32(s0)
li a5,1023
Expand Down Expand Up @@ -133,5 +122,5 @@ CacheLookUp:
.cfi_def_cfa_offset 0
jr ra
.cfi_endproc
.LFE0:
.LFE0_cache:
.size CacheLookUp, .-CacheLookUp
20 changes: 4 additions & 16 deletions include/RISCVSupport/cachelib.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ R"( .text
.globl CacheLookUp
.type CacheLookUp, @function
CacheLookUp:
.LFB0:
.LFB0_cache:
.cfi_startproc
addi sp,sp,-96
.cfi_def_cfa_offset 96
Expand All @@ -36,20 +36,9 @@ R"( .text
mv a5,a4
sw a5,-88(s0)
lw a5,-84(s0)
mv a4,a5
lw a5,-88(s0)
and a5,a4,a5
sext.w a5,a5
slli a5,a5,32
sd a5,-32(s0)
lw a5,-84(s0)
mv a4,a5
slli a4,a5,32
lw a5,-88(s0)
or a5,a4,a5
sext.w a5,a5
mv a4,a5
ld a5,-32(s0)
or a5,a5,a4
sd a5,-32(s0)
ld a4,-32(s0)
li a5,1023
Expand Down Expand Up @@ -133,6 +122,5 @@ R"( .text
.cfi_def_cfa_offset 0
jr ra
.cfi_endproc
.LFE0:
.size CacheLookUp, .-CacheLookUp
)"
.LFE0_cache:
.size CacheLookUp, .-CacheLookUp)"
2 changes: 1 addition & 1 deletion upload.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# 本地上传文件夹的绝对路径
LOCAL_DIR="/home/nanqin/compiler/miniC-compiler/uploadfolder"
LOCAL_DIR="./uploadfolder"

# 远程服务器的目标路径
REMOTE_USER="user"
Expand Down

0 comments on commit c3c4928

Please sign in to comment.