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/internal/obj/arm: Wrong SWI/SWPW/SWPBU in ARM assembler #20375

Closed
benshi001 opened this issue May 16, 2017 · 4 comments
Closed

cmd/internal/obj/arm: Wrong SWI/SWPW/SWPBU in ARM assembler #20375

benshi001 opened this issue May 16, 2017 · 4 comments
Milestone

Comments

@benshi001
Copy link
Member

  1. SWPBU/SWPW

The assembler front end expects SWPW/SWPBU in
SWPBU R4, (R2), R8
Otherwise it will complaint
SWPBU: expected register; found (R2)

But it I add a new line in cmd/asm/internal/asm/testdata/arm.s
endtoend_test.go:155: mismatched output:
have 00725 (testdata/arm.s:1001) SWPBU (R2), R4, R8
want 00725 (testdata/arm.s:1001) SWPBU R4, (R2), R8

  1. SWI
    According to the newest ARM maunal,
    SWI only has one form
    SWI $imm
    But
    SWI (R0) is also accepted, which should be rejected.
@benshi001
Copy link
Member Author

benshi001 commented May 16, 2017

  1. SWPW/SWPBU can be fixed by changing either the front end, line 555 - 566 of cmd/asm/internal/asm/asm.go
    case sys.ARM:
    // Special cases.
    if arch.IsARMSTREX(op) {
    /*
    STREX x, (y), z
    from=(y) reg=x to=z
    */
    prog.From = a[1]
    prog.Reg = p.getRegister(prog, op, &a[0])
    prog.To = a[2]
    break
    }

or the backend line 219 of cmd/internal/obj/arm/asm5.go
{ASWPW, C_SOREG, C_REG, C_REG, 40, 4, 0, 0, 0},
which one is better?

  1. no "SWI (Reg)" is used in the entire go source tree, so we can safely remove line 130 of cmd/internal/obj/arm/asm5.go

    {ASWI, C_NONE, C_NONE, C_LOREG, 10, 4, 0, 0, 0},
    

@benshi001
Copy link
Member Author

"SWI.S $3" is also accepted, but SWI does not has a S bit.

@benshi001
Copy link
Member Author

There is a "STREX R3, (R1), R0" in runtime/internal/atomic/asm_arm.s, and
"{ASTREXD, C_SOREG, C_REG, C_REG, 92, 4, 0, 0, 0}," in cmd/internal/obj/arm/asm5.go,
so the least change way might be changing cmd/asm/internal/asm/testdata/arm.s,
SWPW R3, (R7), R9 // SWPW (R7), R3, R9 // 939007e1
SWPBU R4, (R2), R8 // SWPBU (R2), R4, R8 // 948042e1

@benshi001 benshi001 changed the title Wrong SWI/SWPW/SWPBU in ARM assembler cmd/internal/obj/arm: Wrong SWI/SWPW/SWPBU in ARM assembler May 16, 2017
@gopherbot
Copy link

CL https://golang.org/cl/43552 mentions this issue.

@cherrymui cherrymui added this to the Go1.10 milestone May 16, 2017
@golang golang locked and limited conversation to collaborators May 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants