Commit a189467c authored by Ben Shi's avatar Ben Shi

cmd/internal/obj/mips: add MADD/MSUB

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: default avatarCherry Zhang <cherryyz@google.com>
parent 1257d050
...@@ -38,7 +38,8 @@ func IsMIPSMUL(op obj.As) bool { ...@@ -38,7 +38,8 @@ func IsMIPSMUL(op obj.As) bool {
switch op { switch op {
case mips.AMUL, mips.AMULU, mips.AMULV, mips.AMULVU, case mips.AMUL, mips.AMULU, mips.AMULV, mips.AMULVU,
mips.ADIV, mips.ADIVU, mips.ADIVV, mips.ADIVVU, 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 true
} }
return false return false
......
...@@ -424,7 +424,15 @@ label4: ...@@ -424,7 +424,15 @@ label4:
CALL foo(SB) CALL foo(SB)
RET foo(SB) RET foo(SB)
// unary operation
NEGW R1, R2 // 00011023 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 // END
// //
......
...@@ -319,6 +319,7 @@ const ( ...@@ -319,6 +319,7 @@ const (
ALL ALL
ALLV ALLV
ALUI ALUI
AMADD
AMOVB AMOVB
AMOVBU AMOVBU
AMOVD AMOVD
...@@ -334,6 +335,7 @@ const ( ...@@ -334,6 +335,7 @@ const (
AMOVWF AMOVWF
AMOVWL AMOVWL
AMOVWR AMOVWR
AMSUB
AMUL AMUL
AMULD AMULD
AMULF AMULF
......
...@@ -46,6 +46,7 @@ var Anames = []string{ ...@@ -46,6 +46,7 @@ var Anames = []string{
"LL", "LL",
"LLV", "LLV",
"LUI", "LUI",
"MADD",
"MOVB", "MOVB",
"MOVBU", "MOVBU",
"MOVD", "MOVD",
...@@ -61,6 +62,7 @@ var Anames = []string{ ...@@ -61,6 +62,7 @@ var Anames = []string{
"MOVWF", "MOVWF",
"MOVWL", "MOVWL",
"MOVWR", "MOVWR",
"MSUB",
"MUL", "MUL",
"MULD", "MULD",
"MULF", "MULF",
......
...@@ -959,6 +959,8 @@ func buildop(ctxt *obj.Link) { ...@@ -959,6 +959,8 @@ func buildop(ctxt *obj.Link) {
opset(ADIVU, r0) opset(ADIVU, r0)
opset(AMULU, r0) opset(AMULU, r0)
opset(ADIV, r0) opset(ADIV, r0)
opset(AMADD, r0)
opset(AMSUB, r0)
case AMULV: case AMULV:
opset(ADIVV, r0) opset(ADIVV, r0)
...@@ -1785,6 +1787,10 @@ func (c *ctxt0) oprrr(a obj.As) uint32 { ...@@ -1785,6 +1787,10 @@ func (c *ctxt0) oprrr(a obj.As) uint32 {
return SP(3, 4) | OP(4, 1) return SP(3, 4) | OP(4, 1)
case ACLZ: case ACLZ:
return SP(3, 4) | OP(4, 0) 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 { if a < 0 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment