]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/riscv: add NOT pseudo-instruction
authorJoel Sing <joel@sing.id.au>
Mon, 2 Mar 2020 16:40:37 +0000 (03:40 +1100)
committerJoel Sing <joel@sing.id.au>
Sun, 15 Mar 2020 08:14:24 +0000 (08:14 +0000)
Add a NOT pseudo-instruction that translates to XORI $-1.

Change-Id: I2be4cfe2939e988cd7f8d30260b704701d78475f
Reviewed-on: https://go-review.googlesource.com/c/go/+/221688
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/asm/internal/asm/testdata/riscvenc.s
src/cmd/internal/obj/riscv/anames.go
src/cmd/internal/obj/riscv/cpu.go
src/cmd/internal/obj/riscv/obj.go

index 06158153d8cbd2ade1d9a8005725ae25ed3bcef4..6ccac42d68a39a61a85b7dc14a2c8620a16513e6 100644 (file)
@@ -305,10 +305,14 @@ start:
        MOVD    F0, 4(X5)                               // 27b20200
        MOVD    F0, F1                                  // d3000022
 
+       // NOT pseudo-instruction
+       NOT     X5                                      // 93c2f2ff
+       NOT     X5, X6                                  // 13c3f2ff
+
        // 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               // 6ff09fc6
+       JMP     start           // JMP  2               // 6ff01fc6
        JMP     (X5)                                    // 67800200
        JMP     4(X5)                                   // 67804200
 
index 7d0e52f91bf8c5417b1823df72d99dce209e3025..9edf8f0e656f39a3f73d5beb35b2bf589efe9621 100644 (file)
@@ -239,6 +239,7 @@ var Anames = []string{
        "MOVHU",
        "MOVW",
        "MOVWU",
+       "NOT",
        "SEQZ",
        "SNEZ",
        "LAST",
index 61a68b91c284d060e18bd1f53519cfcb58db5a10..c1fc67f4ab22187ac69389478a2566e1f47e4d26 100644 (file)
@@ -589,6 +589,7 @@ const (
        AMOVHU
        AMOVW
        AMOVWU
+       ANOT
        ASEQZ
        ASNEZ
 
index 63b5ed6119d09c5c9fd2232ff84ac00912d0883d..e003584dad8e899c9a808fde787b935156a2ca58 100644 (file)
@@ -1849,6 +1849,15 @@ func instructionsForProg(p *obj.Prog) []*instruction {
                ins.rs1 = uint32(p.From.Reg)
                ins.rs2 = REG_F0
 
+       case ANOT:
+               // NOT rs, rd -> XORI $-1, rs, rd
+               ins.as = AXORI
+               ins.rs1, ins.rs2 = uint32(p.From.Reg), obj.REG_NONE
+               if ins.rd == obj.REG_NONE {
+                       ins.rd = ins.rs1
+               }
+               ins.imm = -1
+
        case ASEQZ:
                // SEQZ rs, rd -> SLTIU $1, rs, rd
                ins.as = ASLTIU