Commit 3d0397a4 authored by Russ Cox's avatar Russ Cox

cmd/internal/obj/x86: change SHRQ to store second source in From3, not jammed into From

SHRQ CX, DX:AX is changing to SHRQ CX, AX, DX.
This is the first step: using SHRQ From=CX, From3=AX, To=DX
as the preferred encoding.
Once the assemblers and 6g have been updated,
support for the old encoding can be removed.

Change-Id: Ie603fb8ac25a6df78e42f7ddcae078a7684a7c26
Reviewed-on: https://go-review.googlesource.com/6693Reviewed-by: 's avatarRob Pike <r@golang.org>
parent b759e225
...@@ -69,7 +69,7 @@ type Movtab struct { ...@@ -69,7 +69,7 @@ type Movtab struct {
} }
const ( const (
Yxxx = 0 + iota Yxxx = iota
Ynone Ynone
Yi0 Yi0
Yi1 Yi1
...@@ -91,7 +91,6 @@ const ( ...@@ -91,7 +91,6 @@ const (
Yml Yml
Ym Ym
Ybr Ybr
Ycol
Ycs Ycs
Yss Yss
Yds Yds
...@@ -136,8 +135,12 @@ const ( ...@@ -136,8 +135,12 @@ const (
Yxm Yxm
Ytls Ytls
Ytextsize Ytextsize
Yreg2
Ymax Ymax
Zxxx = 0 + iota - 68 )
const (
Zxxx = iota
Zlit Zlit
Zlitm_r Zlitm_r
Z_rp Z_rp
...@@ -183,6 +186,9 @@ const ( ...@@ -183,6 +186,9 @@ const (
Zclr Zclr
Zbyte Zbyte
Zmax Zmax
)
const (
Px = 0 Px = 0
P32 = 0x32 P32 = 0x32
Pe = 0x66 Pe = 0x66
...@@ -1908,9 +1914,27 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int { ...@@ -1908,9 +1914,27 @@ func oclass(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) int {
// TODO(rsc): This special case is for SHRQ $3, AX:DX, // TODO(rsc): This special case is for SHRQ $3, AX:DX,
// which encodes as SHRQ $32(DX*0), AX. // which encodes as SHRQ $32(DX*0), AX.
// Similarly SHRQ CX, AX:DX is really SHRQ CX(DX*0), AX. // Similarly SHRQ CX, AX:DX is really SHRQ CX(DX*0), AX.
// Change encoding and remove. // Change encoding generated by assemblers and remove.
if (a.Type == obj.TYPE_CONST || a.Type == obj.TYPE_REG) && a.Index != REG_NONE && a.Scale == 0 { if a == &p.From && (a.Type == obj.TYPE_CONST || a.Type == obj.TYPE_REG) && a.Index != REG_NONE && a.Scale == 0 {
return Ycol p.From3.Type = obj.TYPE_REG
p.From3.Reg = a.Index
a.Index = 0
}
// To avoid changing tables, the info about p.From and p.From3 are returned together.
if a == &p.From && p.From3.Type != obj.TYPE_NONE {
if (a.Type == obj.TYPE_CONST || a.Type == obj.TYPE_REG) && p.From3.Type == obj.TYPE_REG {
return Yreg2
}
switch p.As {
case obj.ATEXT, obj.ADATA, obj.AGLOBL:
// we know these use From3 - ignore that
default:
// unexpected use of From3. report invalid argument
ctxt.Diag("unexpected argument: %v", obj.Dconv(p, &p.From3))
return Yxxx
}
} }
switch a.Type { switch a.Type {
...@@ -2684,17 +2708,18 @@ var ymovtab = []Movtab{ ...@@ -2684,17 +2708,18 @@ var ymovtab = []Movtab{
Movtab{AMOVW, Yml, Ytask, 4, [4]uint8{0x0f, 0x00, 3, 0}}, Movtab{AMOVW, Yml, Ytask, 4, [4]uint8{0x0f, 0x00, 3, 0}},
Movtab{AMOVW, Ytask, Yml, 3, [4]uint8{0x0f, 0x00, 1, 0}}, Movtab{AMOVW, Ytask, Yml, 3, [4]uint8{0x0f, 0x00, 1, 0}},
/* load full pointer */ /* load full pointer - unsupported
Movtab{AMOVL, Yml, Ycol, 5, [4]uint8{0, 0, 0, 0}}, Movtab{AMOVL, Yml, Ycol, 5, [4]uint8{0, 0, 0, 0}},
Movtab{AMOVW, Yml, Ycol, 5, [4]uint8{Pe, 0, 0, 0}}, Movtab{AMOVW, Yml, Ycol, 5, [4]uint8{Pe, 0, 0, 0}},
*/
/* double shift */ /* double shift */
Movtab{ASHLL, Ycol, Yml, 6, [4]uint8{0xa4, 0xa5, 0, 0}}, Movtab{ASHLL, Yreg2, Yml, 6, [4]uint8{0xa4, 0xa5, 0, 0}},
Movtab{ASHRL, Ycol, Yml, 6, [4]uint8{0xac, 0xad, 0, 0}}, Movtab{ASHRL, Yreg2, Yml, 6, [4]uint8{0xac, 0xad, 0, 0}},
Movtab{ASHLQ, Ycol, Yml, 6, [4]uint8{Pw, 0xa4, 0xa5, 0}}, Movtab{ASHLQ, Yreg2, Yml, 6, [4]uint8{Pw, 0xa4, 0xa5, 0}},
Movtab{ASHRQ, Ycol, Yml, 6, [4]uint8{Pw, 0xac, 0xad, 0}}, Movtab{ASHRQ, Yreg2, Yml, 6, [4]uint8{Pw, 0xac, 0xad, 0}},
Movtab{ASHLW, Ycol, Yml, 6, [4]uint8{Pe, 0xa4, 0xa5, 0}}, Movtab{ASHLW, Yreg2, Yml, 6, [4]uint8{Pe, 0xa4, 0xa5, 0}},
Movtab{ASHRW, Ycol, Yml, 6, [4]uint8{Pe, 0xac, 0xad, 0}}, Movtab{ASHRW, Yreg2, Yml, 6, [4]uint8{Pe, 0xac, 0xad, 0}},
/* load TLS base */ /* load TLS base */
Movtab{AMOVQ, Ytls, Yrl, 7, [4]uint8{0, 0, 0, 0}}, Movtab{AMOVQ, Ytls, Yrl, 7, [4]uint8{0, 0, 0, 0}},
...@@ -3490,7 +3515,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) { ...@@ -3490,7 +3515,7 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
ctxt.Andptr[0] = t[0] ctxt.Andptr[0] = t[0]
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
asmandsz(ctxt, p, &p.To, reg[int(p.From.Index)], regrex[int(p.From.Index)], 0) asmandsz(ctxt, p, &p.To, reg[p.From3.Reg], regrex[p.From3.Reg], 0)
ctxt.Andptr[0] = byte(p.From.Offset) ctxt.Andptr[0] = byte(p.From.Offset)
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
...@@ -3499,13 +3524,12 @@ func doasm(ctxt *obj.Link, p *obj.Prog) { ...@@ -3499,13 +3524,12 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
default: default:
goto bad goto bad
case REG_CL, case REG_CL, REG_CX:
REG_CX:
ctxt.Andptr[0] = 0x0f ctxt.Andptr[0] = 0x0f
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
ctxt.Andptr[0] = t[1] ctxt.Andptr[0] = t[1]
ctxt.Andptr = ctxt.Andptr[1:] ctxt.Andptr = ctxt.Andptr[1:]
asmandsz(ctxt, p, &p.To, reg[int(p.From.Index)], regrex[int(p.From.Index)], 0) asmandsz(ctxt, p, &p.To, reg[p.From3.Reg], regrex[p.From3.Reg], 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