]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/internal/obj/riscv: add FENCE instruction
authorJoel Sing <joel@sing.id.au>
Thu, 20 Feb 2020 15:28:37 +0000 (02:28 +1100)
committerJoel Sing <joel@sing.id.au>
Sun, 15 Mar 2020 07:13:18 +0000 (07:13 +0000)
Also remove #define's that were previously in use.

Updates #36765

Change-Id: I90b6a8629c78f549012f3f6c5f3b325336182712
Reviewed-on: https://go-review.googlesource.com/c/go/+/220539
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/asm/internal/asm/testdata/riscvenc.s
src/cmd/internal/obj/riscv/obj.go
src/runtime/atomic_riscv64.s
src/runtime/internal/atomic/atomic_riscv64.s
src/runtime/sys_linux_riscv64.s

index 23974b3b9976a55e75e82c51f2e335481d69b06b..18f94adb6917dab183e23a17c80c252b310fc62e 100644 (file)
@@ -122,6 +122,9 @@ start:
        SB      X5, (X6)                                // 23005300
        SB      X5, 4(X6)                               // 23025300
 
+       // 2.7: Memory Ordering Instructions
+       FENCE                                           // 0f00f00f
+
        // 5.2: Integer Computational Instructions (RV64I)
        ADDIW   $1, X5, X6                              // 1b831200
        SLLIW   $1, X5, X6                              // 1b931200
@@ -273,7 +276,7 @@ start:
        // These jumps can get printed as jumps to 2 because they go to the
        // second instruction in the function (the first instruction is an
        // invisible stack pointer adjustment).
-       JMP     start           // JMP  2               // 6ff0dfcc
+       JMP     start           // JMP  2               // 6ff09fcc
        JMP     (X5)                                    // 67800200
        JMP     4(X5)                                   // 67804200
 
index 0fb1c767716b45d78c3ace001f9446bf3c4c05d5..5497a1dbc5284585122f64fc7fe47fe0ecce2aa3 100644 (file)
@@ -1552,6 +1552,9 @@ var encodings = [ALAST & obj.AMask]encoding{
        ASH & obj.AMask:  sIEncoding,
        ASB & obj.AMask:  sIEncoding,
 
+       // 2.7: Memory Ordering
+       AFENCE & obj.AMask: iIEncoding,
+
        // 5.2: Integer Computational Instructions (RV64I)
        AADDIW & obj.AMask: iIEncoding,
        ASLLIW & obj.AMask: iIEncoding,
@@ -1769,6 +1772,10 @@ func instructionsForProg(p *obj.Prog) []*instruction {
                ins.rs1 = REG_ZERO
                ins.imm = insEnc.csr
 
+       case AFENCE:
+               ins.rd, ins.rs1, ins.rs2 = REG_ZERO, REG_ZERO, obj.REG_NONE
+               ins.imm = 0x0ff
+
        case AFCVTWS, AFCVTLS, AFCVTWUS, AFCVTLUS, AFCVTWD, AFCVTLD, AFCVTWUD, AFCVTLUD:
                // Set the rounding mode in funct3 to round to zero.
                ins.funct3 = 1
index 9cf54490f153e85113ac71640f2f85dcaee7fede..544a7c59727239f92a4637546f269f9738f9589c 100644 (file)
@@ -4,8 +4,6 @@
 
 #include "textflag.h"
 
-#define FENCE WORD $0x0ff0000f
-
 // func publicationBarrier()
 TEXT ·publicationBarrier(SB),NOSPLIT|NOFRAME,$0-0
        FENCE
index d79f28acdee6d302bef8a6513b25a92ca7a629ab..80c84cf7d3bfab61f7415586228759c6adfb032f 100644 (file)
@@ -38,7 +38,6 @@
 #define SC_ 3
 #define OR_ 8
 #define AND_ 12
-#define FENCE WORD $0x0ff0000f
 
 // Atomically:
 //      if(*val == *old){
index 9db8e3d0683a0398448141a36528e6b25d2a5899..626ab3912cbf749dcad8b095478ce39e86049c20 100644 (file)
@@ -50,8 +50,6 @@
 #define SYS_tkill              130
 #define SYS_write              64
 
-#define FENCE WORD $0x0ff0000f
-
 // func exit(code int32)
 TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4
        MOVW    code+0(FP), A0