golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.31k stars 17.58k forks source link

x/arch/x86/x86asm: add AVX-256 and AVX-512 registers and instructions #47307

Open TACIXAT opened 3 years ago

TACIXAT commented 3 years ago

What version of Go are you using (go version)?

$ go version
go version go1.15.8 windows/amd64

Does this issue reproduce with the latest release?

Didn't try. Documentation says no.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\me\AppData\Local\go-build
set GOENV=C:\Users\me\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\me\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\me\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=off
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\me\AppData\Local\Temp\go-build560694702=/tmp/go-build -gno-record-gcc-switches

What did you do?

package main

import (
    "golang.org/x/arch/x86/x86asm"
    "log"
)

func main() {
    bs := []byte{ 
        0x62, 0xf1, 0x7c, 0x48, 0x10, 0xc1,
        0x62, 0x71, 0x7c, 0x48, 0x10, 0x46, 0x07 } 

    off := 0
    for off < len(bs) {
        inst, err := x86asm.Decode(bs[off:], 64)
        if err != nil {
            log.Fatal(err)
        }
        log.Println(inst)
        off += inst.Len
    }
}

What did you expect to see?

vmovups zmm0,zmm1 or something

What did you see instead?

unrecognized instruction

seankhliao commented 3 years ago

cc @cherrymui

TACIXAT commented 3 years ago
package main

import (
    "golang.org/x/arch/x86/x86asm"
    "log"
)

func main() {
    bs := []byte{ 
        0xc5, 0xf9, 0xef, 0xc0} 

    off := 0
    for off < len(bs) {
        inst, err := x86asm.Decode(bs[off:], 64)
        if err != nil {
            log.Fatal(err)
        }

        log.Println(inst)
        off += inst.Len
    }
}
2021/07/22 14:40:40 Prefix(0xc5) Prefix(0xf9) OUT DX, EAX
2021/07/22 14:40:40 Prefix(0xc0) Op(0)

Should be a vpxor.

image