Skip to content

Commit db1758c

Browse files
committed
cmd/internal/obj/riscv: support zawrs assembly (#47)
1 parent 0e1bd8b commit db1758c

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

src/cmd/asm/internal/asm/testdata/riscv64.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ start:
244244
AMOMINUW X5, (X6), X7 // af2353c6
245245
AMOMINUD X5, (X6), X7 // af3353c6
246246

247+
// 15: Wait-on-Reservation-Set Instructions (Zawrs)
248+
WRSNTO // 7300d000
249+
WRSSTO // 7300d001
250+
247251
// 20.5: Single-Precision Load and Store Instructions
248252
FLW (X5), F0 // 07a00200
249253
FLW 4(X5), F0 // 07a04200

src/cmd/internal/obj/riscv/anames.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/internal/obj/riscv/cpu.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,10 @@ const (
456456
AAMOMINW
457457
AAMOMINUW
458458

459+
// 15: Wait-on-Reservation-Set Instructions (Zawrs)
460+
AWRSNTO
461+
AWRSSTO
462+
459463
// 20.5: Single-Precision Load and Store Instructions
460464
AFLW
461465
AFSW

src/cmd/internal/obj/riscv/inst.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/internal/obj/riscv/obj.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,10 @@ var instructions = [ALAST & obj.AMask]instructionData{
20322032
AFLD & obj.AMask: {enc: iFEncoding},
20332033
AFSD & obj.AMask: {enc: sFEncoding},
20342034

2035+
// 15: Wait-on-Reservation-Set Instructions (Zawrs)
2036+
AWRSNTO & obj.AMask: {enc: iIIEncoding},
2037+
AWRSSTO & obj.AMask: {enc: iIIEncoding},
2038+
20352039
// 21.4: Double-Precision Floating-Point Computational Instructions
20362040
AFADDD & obj.AMask: {enc: rFFFEncoding},
20372041
AFSUBD & obj.AMask: {enc: rFFFEncoding},
@@ -3610,6 +3614,14 @@ func instructionsForProg(p *obj.Prog) []*instruction {
36103614
ins.funct7 = 3
36113615
ins.rd, ins.rs1, ins.rs2 = uint32(p.RegTo2), uint32(p.To.Reg), uint32(p.From.Reg)
36123616

3617+
case AWRSNTO, AWRSSTO:
3618+
ins.rd, ins.rs1 = REG_ZERO, REG_ZERO
3619+
if ins.as == AWRSNTO {
3620+
ins.imm = 0x0d
3621+
} else {
3622+
ins.imm = 0x1d
3623+
}
3624+
36133625
case AECALL, AEBREAK:
36143626
insEnc := encode(p.As)
36153627
if p.To.Type == obj.TYPE_NONE {

0 commit comments

Comments
 (0)