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 {
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
......
......@@ -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
//
......
......@@ -319,6 +319,7 @@ const (
ALL
ALLV
ALUI
AMADD
AMOVB
AMOVBU
AMOVD
......@@ -334,6 +335,7 @@ const (
AMOVWF
AMOVWL
AMOVWR
AMSUB
AMUL
AMULD
AMULF
......
......@@ -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",
......
......@@ -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 {
......
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