Skip to content

Commit

Permalink
cmd/internal/obj/arm64: add support of NOOP instruction
Browse files Browse the repository at this point in the history
This patch uses symbol NOOP to support arm64 instruction NOP. In
arm64, NOP stands for that No Operation does nothing, other than
advance the value of the program counter by 4. This instruction
can be used for instruction alignment purposes. This patch uses
NOOP to support arm64 instruction NOP, because we have a generic
"NOP" instruction, which is a zero-width pseudo-instruction.

In arm64, instruction NOP is an alias of HINT #0. This patch adds
test cases for instruction HINT #0.

Change-Id: I54e6854c46516eb652b412ef9e0f73ab7f171f8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/200578
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
  • Loading branch information
dianhong01 authored and cherrymui committed Oct 18, 2019
1 parent 57c63e0 commit 3876bd6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/cmd/asm/internal/asm/testdata/arm64.s
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,8 @@ again:
FSTPS (F3, F4), 1024(RSP) // fb0310916313002d
FSTPS (F3, F4), x(SB)
FSTPS (F3, F4), x+8(SB)
NOOP // 1f2003d5
HINT $0 // 1f2003d5

// System Register
MSR $1, SPSel // bf4100d5
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/asm/internal/asm/testdata/arm64enc.s
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$-8
EXTR $35, R22, R12, R8 // 888dd693
SEVL // bf2003d5
HINT $6 // df2003d5
HINT $0 // 1f2003d5
HLT $65509 // a0fc5fd4
HVC $61428 // 82fe1dd4
ISB $1 // df3103d5
Expand Down Expand Up @@ -281,7 +282,7 @@ TEXT asmtest(SB),DUPOK|NOSPLIT,$-8
NGC R2, R7 // e70302da
NGCSW R10, R5 // e5030a7a
NGCS R24, R16 // f00318fa
//TODO NOP // 1f2003d5
NOOP // 1f2003d5
ORNW R4@>11, R16, R3 // 032ee42a
ORN R22@>19, R3, R3 // 634cf6aa
ORRW $4294443071, R15, R24 // f8490d32
Expand Down
1 change: 1 addition & 0 deletions src/cmd/internal/obj/arm64/a.out.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ const (
ANGCS
ANGCSW
ANGCW
ANOOP
AORN
AORNW
AORR
Expand Down
1 change: 1 addition & 0 deletions src/cmd/internal/obj/arm64/anames.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/cmd/internal/obj/arm64/asm7.go
Original file line number Diff line number Diff line change
Expand Up @@ -2486,6 +2486,7 @@ func buildop(ctxt *obj.Link) {
oprangeset(AYIELD, t)
oprangeset(ASEV, t)
oprangeset(ASEVL, t)
oprangeset(ANOOP, t)
oprangeset(ADRPS, t)

case ACBZ:
Expand Down Expand Up @@ -6036,8 +6037,8 @@ func (c *ctxt7) op0(p *obj.Prog, a obj.As) uint32 {
case AERET:
return 0x6B<<25 | 4<<21 | 0x1F<<16 | 0<<10 | 0x1F<<5

// case ANOP:
// return SYSHINT(0)
case ANOOP:
return SYSHINT(0)

case AYIELD:
return SYSHINT(1)
Expand Down

0 comments on commit 3876bd6

Please sign in to comment.