]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.cc] cmd/asm: fix build for x86 architectures
authorRob Pike <r@golang.org>
Tue, 17 Feb 2015 04:42:55 +0000 (20:42 -0800)
committerRob Pike <r@golang.org>
Tue, 17 Feb 2015 04:55:38 +0000 (04:55 +0000)
Mishandled the complex addressing mode in masks<>(SB)(CX*8)
as a casualty of the ARM work. Fix by backing all the flows up to
the state where registerIndirect is always called with the input
sitting on the opening paren.

With this, build passes for me with linux-arm, linux-386, and linux-amd64.

Change-Id: I7cae69a6fa9b635c79efd93850bd1e744b22bc79
Reviewed-on: https://go-review.googlesource.com/4964
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/asm/internal/asm/parse.go

index 9d2f49290e595a79f9047435cff2d021e933f7f8..706b9c06a4b34308243a4751a9c65c364f7378b4 100644 (file)
@@ -313,6 +313,9 @@ func (p *Parser) operand(a *obj.Addr) bool {
                rname := p.next().String()
                p.back()
                haveConstant = !p.isRegister(rname)
+               if !haveConstant {
+                       p.back() // Put back the '('.
+               }
        }
        if haveConstant {
                p.back()
@@ -355,10 +358,9 @@ func (p *Parser) operand(a *obj.Addr) bool {
                        return true
                }
                // fmt.Printf("offset %d \n", a.Offset)
-               p.get('(')
        }
 
-       // Register indirection: (reg) or (index*scale). We have consumed the opening paren.
+       // Register indirection: (reg) or (index*scale). We are on the opening paren.
        p.registerIndirect(a, prefix)
        // fmt.Printf("DONE %s\n", p.arch.Dconv(&emptyProg, 0, a))
 
@@ -505,7 +507,7 @@ func (p *Parser) symbolReference(a *obj.Addr, name string, prefix rune) {
 // setPseudoRegister sets the NAME field of addr for a pseudo-register reference such as (SB).
 func (p *Parser) setPseudoRegister(addr *obj.Addr, name string, reg int16, isStatic bool, prefix rune) {
        if addr.Reg != 0 {
-               p.errorf("internal error: reg already set in psuedo")
+               p.errorf("internal error: reg %s already set in pseudo", name)
        }
        switch reg {
        case arch.RFP:
@@ -535,8 +537,9 @@ func (p *Parser) setPseudoRegister(addr *obj.Addr, name string, reg int16, isSta
 // It is can be (R1), (R2*scale), or (R1)(R2*scale) where R1 may be a simple
 // register or register pair R:R or (R, R).
 // Or it might be a pseudo-indirection like (FP).
-// The opening parenthesis has already been consumed.
+// We are sitting on the opening parenthesis.
 func (p *Parser) registerIndirect(a *obj.Addr, prefix rune) {
+       p.get('(')
        tok := p.next()
        name := tok.String()
        r1, r2, scale, ok := p.register(name, 0)