Skip to content

Commit

Permalink
AMO: added besic AMO.D asm
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD committed May 31, 2020
1 parent c83c3ff commit 487563c
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Tests/asm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ ELF=$(addprefix build/,$(TESTS))
ELF32=$(addsuffix 32,$(ELF))
ELF64=$(addsuffix 64,$(ELF))

RISCVCC64=riscv64-unknown-elf-gcc -march=rv64ima -mabi=lp64 -static -nostdlib -nostartfiles -mcmodel=medany
# RISCVCC64=riscv64-unknown-elf-gcc -march=rv64ima -mabi=lp64 -static -nostdlib -nostartfiles -mcmodel=medany
RISCVCC64=riscv64-unknown-linux-gnu-gcc -march=rv64ima -mabi=lp64 -static -nostdlib -nostartfiles -mcmodel=medany
RISCVCC32=riscv32-unknown-elf-gcc -march=rv32ima -mabi=ilp32 -static -nostdlib -nostartfiles -mcmodel=medany

build32: $(ELF32)
Expand Down
19 changes: 15 additions & 4 deletions Tests/asm/src/amo.lrsc.w.S
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,39 @@
#define LOG_ITERATIONS 10

main:
la a0, coreid
li a1, 1
amoadd.w a2, a1, (a0)

1:li a3, 1
bgeu a2, a3, 1b

1: lw a1, (a0)
bltu a1, a3, 1b

# ======================================
la a0, foo
li a5, 0xdeadbeef
sc.w a4, a5, (a0); a4 = 1

lw a4, foo; a4 = 0
lw a5, foo; a5 = 0

la a0, foo
la a1, fooTest3
lr.w a1, (a1)
sc.w a4, a1, (a0); a4 = 1
sc.w a6, a1, (a0); a6 = 1

lw a0, foo
slli a1, a3, LOG_ITERATIONS-1
1: sub a0, a0, a1
addi a3, a3, -1
bgez a3, 1b; a0 = 0
bgez a3, 1b

la a0, foo
1: lr.w a1, (a0)
sc.w a1, x0, (a0)
bnez a1, 1b
sc.w a1, x0, (a0); a1 = 1
sc.w a7, x0, (a0); a7 = 1

ret

Expand Down
70 changes: 70 additions & 0 deletions Tests/asm/src/amo_d.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.section ".text"
.globl main
main:
li a0, 0xffffffff80000000
li a1, 0xfffffffffffff800
la a3, amo_operand
sw a0, 0(a3)

#===================================
# AMOADD.D
amoadd.d a4, a1, 0(a3); a4 = 0xffffffff80000000
ld a5, 0(a3); a5 = 0xffffffff7ffff800

# try again after a cache miss
amoadd.d a6, a1, 0(a3); a6 = 0xffffffff7ffff800
ld a7, 0(a3); a7 = 0xffffffff7ffff000

#===================================
# AMOAND.D
amoand.d a4, a1, 0(a3); a4 = 0xffffffff80000000
ld a5, 0(a3); a5 = 0xffffffff80000000

# try again after a cache miss
li a1, 0x0000000080000000;
amoand.d a6, a1, 0(a3); a6 = 0xffffffff80000000
ld a7, 0(a3); a7 = 0x0000000080000000

#===================================
# AMOOR.D
amoor.d a4, a1, 0(a3); a4 = 0xffffffff80000000
ld a5, 0(a3); a5 = 0xfffffffffffff800

# try again after a cache miss
li a1, 1;
amoor.d a6, a1, 0(a3); a6 = 0xfffffffffffff800
ld a7, 0(a3); a7 = 0xfffffffffffff801

#===================================
# AMOXOR.D
amoxor.d a4, a1, 0(a3); a4 = 0xffffffff80000000
ld a5, 0(a3); a5 = 0x000000007ffff800

# try again after a cache miss
li a1, 1;
amoxor.d a6, a1, 0(a3); a6 = 0x000000007ffff800
ld a7, 0(a3); a7 = 0x000000007ffff801

#===================================
# AMOSWAP.D
# try again after a cache miss

#===================================
# AMOMAX.D

#===================================
# AMOMAXU.D

#===================================
# AMOMIN.D

#===================================
# AMOMINU.D

ret

.data
.bss
.align 3
amo_operand:
.dword 0

0 comments on commit 487563c

Please sign in to comment.