]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj/mips: add MADD/MSUB
authorBen Shi <powerman1st@163.com>
Fri, 15 Mar 2019 08:26:53 +0000 (08:26 +0000)
committerBen Shi <powerman1st@163.com>
Sat, 23 Mar 2019 01:39:16 +0000 (01:39 +0000)
This CL implements MADD&MSUB, which are mips32r2 instructions.

Change-Id: I06fe51573569baf3b71536336b34b95ccd24750b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167680
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/asm/internal/arch/mips.go
src/cmd/asm/internal/asm/testdata/mips.s
src/cmd/internal/obj/mips/a.out.go
src/cmd/internal/obj/mips/anames.go
src/cmd/internal/obj/mips/asm0.go

index 14b29331e5d4ee492e9bcabdf7f051d4da5c4ff6..22c9ebd2dad92566457b0fd1c0aefa6eb63393dc 100644 (file)
@@ -38,7 +38,8 @@ func IsMIPSMUL(op obj.As) bool {
        switch op {
        case mips.AMUL, mips.AMULU, mips.AMULV, mips.AMULVU,
                mips.ADIV, mips.ADIVU, mips.ADIVV, mips.ADIVVU,
-               mips.AREM, mips.AREMU, mips.AREMV, mips.AREMVU:
+               mips.AREM, mips.AREMU, mips.AREMV, mips.AREMVU,
+               mips.AMADD, mips.AMSUB:
                return true
        }
        return false
index 0c6f7fd5526d731837169018b775ab595d463234..7136d686d758a5bc849099f78a1d08c78440b6ea 100644 (file)
@@ -424,7 +424,15 @@ label4:
        CALL    foo(SB)
        RET     foo(SB)
 
+       // unary operation
        NEGW    R1, R2 // 00011023
+       CLZ     R1, R2 // 70221020
+       CLO     R1, R2 // 70221021
+
+       // to (Hi, Lo)
+       MADD    R2, R1 // 70220000
+       MSUB    R2, R1 // 70220004
+       MUL     R2, R1 // 00220018
 
        // END
        //
index d2ae2f8c0b7fd7e8149bd5ad3724be25dc2f1c95..026e8db76a122bb07fa4c1cf1ce93c833039ee19 100644 (file)
@@ -319,6 +319,7 @@ const (
        ALL
        ALLV
        ALUI
+       AMADD
        AMOVB
        AMOVBU
        AMOVD
@@ -334,6 +335,7 @@ const (
        AMOVWF
        AMOVWL
        AMOVWR
+       AMSUB
        AMUL
        AMULD
        AMULF
index d588d131bc4e183c15ae6034d35ac39619077e09..9a2e4f57031002982da125aae3d61e9ea8ad8e07 100644 (file)
@@ -46,6 +46,7 @@ var Anames = []string{
        "LL",
        "LLV",
        "LUI",
+       "MADD",
        "MOVB",
        "MOVBU",
        "MOVD",
@@ -61,6 +62,7 @@ var Anames = []string{
        "MOVWF",
        "MOVWL",
        "MOVWR",
+       "MSUB",
        "MUL",
        "MULD",
        "MULF",
index c117269c35ad0b323f30b8bc54aa286626050a47..c08d97a9aa374ef7732b315c82e0f50cf855f0a9 100644 (file)
@@ -959,6 +959,8 @@ func buildop(ctxt *obj.Link) {
                        opset(ADIVU, r0)
                        opset(AMULU, r0)
                        opset(ADIV, r0)
+                       opset(AMADD, r0)
+                       opset(AMSUB, r0)
 
                case AMULV:
                        opset(ADIVV, r0)
@@ -1785,6 +1787,10 @@ func (c *ctxt0) oprrr(a obj.As) uint32 {
                return SP(3, 4) | OP(4, 1)
        case ACLZ:
                return SP(3, 4) | OP(4, 0)
+       case AMADD:
+               return SP(3, 4) | OP(0, 0)
+       case AMSUB:
+               return SP(3, 4) | OP(0, 4)
        }
 
        if a < 0 {