Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cmd/asm/internal/asm/testdata/riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ start:
RDTIME X5 // f32210c0
RDINSTRET X5 // f32220c0

// 10.1: Zihintpause Extension for Pause Hint
PAUSE // 0f000001

// 12.3: Integer Conditional Operations (Zicond)
CZEROEQZ X5, X6, X7 // b353530e
CZEROEQZ X5, X7 // b3d3530e
Expand Down
1 change: 1 addition & 0 deletions src/cmd/internal/obj/riscv/anames.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/cmd/internal/obj/riscv/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,7 @@ const (
ANEG
ANEGW
ANOT
APAUSE
ARDCYCLE
ARDINSTRET
ARDTIME
Expand Down
4 changes: 4 additions & 0 deletions src/cmd/internal/obj/riscv/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -3674,6 +3674,10 @@ func instructionsForProg(p *obj.Prog) []*instruction {
ins.rd, ins.rs1, ins.rs2 = REG_ZERO, REG_ZERO, obj.REG_NONE
ins.imm = 0x0ff

case APAUSE:
ins.as, ins.rd, ins.rs1, ins.rs2 = AFENCE, REG_ZERO, REG_ZERO, obj.REG_NONE
ins.imm = 0x010

case AFCVTWS, AFCVTLS, AFCVTWUS, AFCVTLUS, AFCVTWD, AFCVTLD, AFCVTWUD, AFCVTLUD:
// Set the default rounding mode in funct3 to round to zero.
if p.Scond&rmSuffixBit == 0 {
Expand Down
1 change: 1 addition & 0 deletions src/runtime/asm_riscv64.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
#define hasZbs
#define hasZfa
#define hasZicond
#define hasZihintpause
#endif
12 changes: 10 additions & 2 deletions src/runtime/asm_riscv64.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "go_asm.h"
#include "funcdata.h"
#include "textflag.h"

#include "asm_riscv64.h"

// When building with -buildmode=c-shared, this symbol is called when the shared
// library is loaded.
Expand Down Expand Up @@ -367,8 +367,16 @@ TEXT gogo<>(SB), NOSPLIT|NOFRAME, $0
MOV gobuf_pc(T0), T0
JALR ZERO, T0


// func procyieldAsm(cycles uint32)
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
TEXT runtime·procyieldAsm<ABIInternal>(SB),NOSPLIT,$0-0
#ifdef hasZihintpause
MOVWU X10, T0
yieldloop:
PAUSE
SUBW $1, T0
BNEZ T0, yieldloop
#endif
RET

// Switch to m->g0's stack, call fn(g).
Expand Down