mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/asm: refine Go assembly for ARM64
Some ARM64-specific instructions (such as SIMD instructions) are not supported.
This patch adds support for the following:
1. Extended register, e.g.:
ADD Rm.<ext>[<<amount], Rn, Rd
<ext> can have the following values:
UXTB, UXTH, UXTW, UXTX, SXTB, SXTH, SXTW and SXTX
2. Arrangement for SIMD instructions, e.g.:
VADDP Vm.<T>, Vn.<T>, Vd.<T>
<T> can have the following values:
B8, B16, H4, H8, S2, S4 and D2
3. Width specifier and element index for SIMD instructions, e.g.:
VMOV Vn.<T>[index], Rd // MOV(to general register)
<T> can have the following values:
S and D
4. Register List, e.g.:
VLD1 (Rn), [Vt1.<T>, Vt2.<T>, Vt3.<T>]
5. Register offset variant, e.g.:
VLD1.P (Rn)(Rm), [Vt1.<T>, Vt2.<T>] // Rm is the post-index register
6. Go assembly for ARM64 reference manual
new added instructions are required to have according explanation items in
the manual and items for existed instructions will be added incrementally
For more information about the refinement background, please refer to the
discussion (https://groups.google.com/forum/#!topic/golang-dev/rWgDxCrL4GU)
This patch only adds syntax and doesn't break any assembly that already exists.
Change-Id: I34e90b7faae032820593a0e417022c354a882008
Reviewed-on: https://go-review.googlesource.com/41654
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
31cd20a70e
commit
531e6c06c4
12 changed files with 1204 additions and 53 deletions
|
|
@ -186,7 +186,7 @@ func Dconv(p *Prog, a *Addr) string {
|
|||
// PINSRQ CX,$1,X6
|
||||
// where the $1 is included in the p->to Addr.
|
||||
// Move into a new field.
|
||||
if a.Offset != 0 {
|
||||
if a.Offset != 0 && (a.Reg < RBaseARM64 || a.Reg >= RBaseMIPS) {
|
||||
str = fmt.Sprintf("$%d,%v", a.Offset, Rconv(int(a.Reg)))
|
||||
break
|
||||
}
|
||||
|
|
@ -195,6 +195,10 @@ func Dconv(p *Prog, a *Addr) string {
|
|||
if a.Name != NAME_NONE || a.Sym != nil {
|
||||
str = fmt.Sprintf("%v(%v)(REG)", Mconv(a), Rconv(int(a.Reg)))
|
||||
}
|
||||
if (RBaseARM64+1<<10+1<<9) /* arm64.REG_ELEM */ <= a.Reg &&
|
||||
a.Reg < (RBaseARM64+1<<11) /* arm64.REG_ELEM_END */ {
|
||||
str += fmt.Sprintf("[%d]", a.Index)
|
||||
}
|
||||
|
||||
case TYPE_BRANCH:
|
||||
if a.Sym != nil {
|
||||
|
|
@ -272,7 +276,7 @@ func Dconv(p *Prog, a *Addr) string {
|
|||
str = fmt.Sprintf("%v, %v", Rconv(int(a.Offset)), Rconv(int(a.Reg)))
|
||||
|
||||
case TYPE_REGLIST:
|
||||
str = regListConv(int(a.Offset))
|
||||
str = RLconv(a.Offset)
|
||||
}
|
||||
|
||||
return str
|
||||
|
|
@ -409,27 +413,40 @@ func Rconv(reg int) string {
|
|||
return fmt.Sprintf("R???%d", reg)
|
||||
}
|
||||
|
||||
func regListConv(list int) string {
|
||||
str := ""
|
||||
type regListSet struct {
|
||||
lo int64
|
||||
hi int64
|
||||
RLconv func(int64) string
|
||||
}
|
||||
|
||||
for i := 0; i < 16; i++ { // TODO: 16 is ARM-specific.
|
||||
if list&(1<<uint(i)) != 0 {
|
||||
if str == "" {
|
||||
str += "["
|
||||
} else {
|
||||
str += ","
|
||||
}
|
||||
// This is ARM-specific; R10 is g.
|
||||
if i == 10 {
|
||||
str += "g"
|
||||
} else {
|
||||
str += fmt.Sprintf("R%d", i)
|
||||
}
|
||||
var regListSpace []regListSet
|
||||
|
||||
// Each architecture is allotted a distinct subspace: [Lo, Hi) for declaring its
|
||||
// arch-specific register list numbers.
|
||||
const (
|
||||
RegListARMLo = 0
|
||||
RegListARMHi = 1 << 16
|
||||
|
||||
// arm64 uses the 60th bit to differentiate from other archs
|
||||
RegListARM64Lo = 1 << 60
|
||||
RegListARM64Hi = 1<<61 - 1
|
||||
)
|
||||
|
||||
// RegisterRegisterList binds a pretty-printer (RLconv) for register list
|
||||
// numbers to a given register list number range. Lo is inclusive,
|
||||
// hi exclusive (valid register list are lo through hi-1).
|
||||
func RegisterRegisterList(lo, hi int64, rlconv func(int64) string) {
|
||||
regListSpace = append(regListSpace, regListSet{lo, hi, rlconv})
|
||||
}
|
||||
|
||||
func RLconv(list int64) string {
|
||||
for i := range regListSpace {
|
||||
rls := ®ListSpace[i]
|
||||
if rls.lo <= list && list < rls.hi {
|
||||
return rls.RLconv(list)
|
||||
}
|
||||
}
|
||||
|
||||
str += "]"
|
||||
return str
|
||||
return fmt.Sprintf("RL???%d", list)
|
||||
}
|
||||
|
||||
type opSet struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue