Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: missing logical/move instruction for RSP on arm64 #24332

Closed
mengzhuo opened this issue Mar 10, 2018 · 5 comments

Comments

Projects
None yet
7 participants
@mengzhuo
Copy link
Contributor

commented Mar 10, 2018

What did you do?

        BIC     $1, RSP
        ORR     $1, RSP
        AND     $1, RSP
        EOR     $1, RSP
        SUB     $1, RSP
        ADD     $1, RSP
        MOVD    (56)(R21), RSP

What did you expect to see?

all instruction passed

What did you see instead?

asm: illegal combination: 00000 (/root/go/src/github.com/t/t_arm64.s:4) BIC     $1, RSP ABCON0 NONE RSP, 4 7
asm: illegal combination: 00004 (/root/go/src/github.com/t/t_arm64.s:5) ORR     $1, RSP ABCON0 NONE RSP, 4 7
asm: illegal combination: 00008 (/root/go/src/github.com/t/t_arm64.s:6) AND     $1, RSP ABCON0 NONE RSP, 4 7
asm: illegal combination: 00012 (/root/go/src/github.com/t/t_arm64.s:7) EOR     $1, RSP ABCON0 NONE RSP, 4 7
asm: illegal combination: 00024 (/root/go/src/github.com/t/t_arm64.s:10)        MOVD    56(R21), RSP PSOREG_8 NONE RSP, 3 7

System details

go version go1.10 linux/arm64
GOARCH="arm64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="arm64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/root/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_arm64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build946549955=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version go1.10 linux/arm64
GOROOT/bin/go tool compile -V: compile version go1.10
uname -sr: Linux 4.4.49-s5p6818
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:        16.04
Codename:       xenial
/lib/aarch64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.23-0ubuntu10) stable release version 2.23, by Roland McGrath et al.
gdb --version: GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1

@odeke-em odeke-em changed the title compile: missing logical/move instruction for RSP on arm64 cmd/compile: missing logical/move instruction for RSP on arm64 Mar 11, 2018

@odeke-em

This comment has been minimized.

Copy link
Member

commented Mar 11, 2018

@andybons andybons added this to the Go1.11 milestone Mar 11, 2018

@randall77

This comment has been minimized.

Copy link
Contributor

commented Mar 12, 2018

From the arm64 manual:

You can only use SP as an operand in the following instructions:

As the base register for loads and stores. In this case it must be quadword-aligned before adding any offset, or a stack alignment exception occurs.

As a source or destination for arithmetic instructions, but it cannot be used as the destination in instructions that set the condition flags.

In logical instructions, for example in order to align it.

My reading of that is that the MOVD error is correct, RSP cannot be the target of a load. But the others look like they should be ok.

@randall77

This comment has been minimized.

Copy link
Contributor

commented Mar 12, 2018

The obvious patch of just duplicating the RSP AADD lines and replacing the opcode with AAND and ABIC doesn't work. It gets rid of the errors, but go tool objdump doesn't print the right result on the resulting .o file (of course, that may be a bug in objdump). This is beyond my skillset...
@benshi001 @4ad @williamweixiao

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Mar 12, 2018

The two-operand form of logical instructions, AND $1, RSP, which is equivalent to the three-operand form AND $1, RSP, RSP, is not valid. For logical instructions, while the destination can be RSP, the source register cannot.

That said, AND $1, R0, RSP is valid. We should support it.

@gopherbot

This comment has been minimized.

Copy link

commented Mar 13, 2018

Change https://golang.org/cl/100217 mentions this issue: cmd/internal/obj/arm64: support logical instructions targeting RSP

@gopherbot gopherbot closed this in 518e6f0 Mar 13, 2018

@golang golang locked and limited conversation to collaborators Mar 13, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.