Skip to content

Commit

Permalink
liblink, cmd/7a: add C_VCONADDR class
Browse files Browse the repository at this point in the history
This change adds the C_VCONADDR representing $r(SB), the address of a
relocatable symbol. The old C_ADDR, r(SB) without $, means data at a
relocatable symbol.

C_VCONADDR matches C_VCON in optab. We could have overloaded the meaning
of C_VCON, but adding a new class simplifies the logic in addpool.

Fixes golang#65
  • Loading branch information
4ad committed Jan 29, 2015
1 parent 547c1b1 commit 076d34d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/cmd/7l/7.out.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ enum cs
C_LCON, /* 32-bit constant */
C_FCON, /* floating-point constant */
C_VCON, /* 64-bit constant */
C_VCONADDR, /* $foo(SB) reference to relocatable address */

C_AACON, /* ADDCON offset in auto constant $a(FP) */
C_LACON, /* 32-bit offset in auto constant $a(FP) */
Expand Down Expand Up @@ -156,7 +157,7 @@ enum cs
C_UOREG64K,
C_LOREG,

C_ADDR, /* relocatable address for dynamic loading */
C_ADDR, /* foo(SB) reference to relocatable address */
C_ROFF, /* register offset (inc register extended) */
C_XPOST,
C_XPRE,
Expand Down
1 change: 1 addition & 0 deletions src/cmd/internal/obj/arm64/7.out.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const (
C_LCON
C_FCON
C_VCON
C_VCONADDR
C_AACON
C_LACON
C_AECON
Expand Down
1 change: 1 addition & 0 deletions src/cmd/internal/obj/arm64/anames7.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ var cnames7 = []string{
"LCON",
"FCON",
"VCON",
"VCONADDR",
"AACON",
"LACON",
"AECON",
Expand Down
18 changes: 8 additions & 10 deletions src/cmd/internal/obj/arm64/asm7.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ var optab = []Optab{
Optab{AADD, C_VCON, C_REG, C_REG, 13, 8, 0, LFROM},
Optab{AADD, C_VCON, C_NONE, C_REG, 13, 8, 0, LFROM},
Optab{ACMP, C_VCON, C_REG, C_NONE, 13, 8, 0, LFROM},
Optab{AADD, C_ADDR, C_REG, C_REG, 13, 8, 0, LFROM},
Optab{AADD, C_ADDR, C_NONE, C_REG, 13, 8, 0, LFROM},
Optab{ACMP, C_ADDR, C_REG, C_NONE, 13, 8, 0, LFROM},
Optab{AADD, C_SHIFT, C_REG, C_REG, 3, 4, 0, 0},
Optab{AADD, C_SHIFT, C_NONE, C_REG, 3, 4, 0, 0},
Optab{AMVN, C_SHIFT, C_NONE, C_REG, 3, 4, 0, 0},
Expand Down Expand Up @@ -213,10 +210,6 @@ var optab = []Optab{
Optab{AAND, C_VCON, C_NONE, C_REG, 28, 8, 0, LFROM},
Optab{ABIC, C_VCON, C_REG, C_REG, 28, 8, 0, LFROM},
Optab{ABIC, C_VCON, C_NONE, C_REG, 28, 8, 0, LFROM},
Optab{AAND, C_ADDR, C_REG, C_REG, 28, 8, 0, LFROM},
Optab{AAND, C_ADDR, C_NONE, C_REG, 28, 8, 0, LFROM},
Optab{ABIC, C_ADDR, C_REG, C_REG, 28, 8, 0, LFROM},
Optab{ABIC, C_ADDR, C_NONE, C_REG, 28, 8, 0, LFROM},
Optab{AAND, C_SHIFT, C_REG, C_REG, 3, 4, 0, 0},
Optab{AAND, C_SHIFT, C_NONE, C_REG, 3, 4, 0, 0},
Optab{ABIC, C_SHIFT, C_REG, C_REG, 3, 4, 0, 0},
Expand Down Expand Up @@ -272,7 +265,6 @@ var optab = []Optab{
Optab{AWORD, C_NONE, C_NONE, C_ADDR, 14, 4, 0, 0},
Optab{AMOVW, C_VCON, C_NONE, C_REG, 12, 4, 0, LFROM},
Optab{AMOV, C_VCON, C_NONE, C_REG, 12, 4, 0, LFROM},
Optab{AMOV, C_ADDR, C_NONE, C_REG, 12, 4, 0, LFROM},
Optab{AMOVB, C_REG, C_NONE, C_ADDR, 64, 8, 0, LTO},
Optab{AMOVBU, C_REG, C_NONE, C_ADDR, 64, 8, 0, LTO},
Optab{AMOVH, C_REG, C_NONE, C_ADDR, 64, 8, 0, LTO},
Expand Down Expand Up @@ -1138,7 +1130,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
break
}
ctxt.Instoffset = a.Offset
return C_ADDR
return C_VCONADDR

case D_AUTO:
ctxt.Instoffset = int64(ctxt.Autosize) + a.Offset
Expand Down Expand Up @@ -1277,7 +1269,13 @@ func cmp(a int, b int) bool {
}

case C_VCON:
return cmp(C_LCON, b)
if b == C_VCONADDR {
return true
} else {

return cmp(C_LCON, b)
}
fallthrough

case C_LACON:
if b == C_AACON {
Expand Down
15 changes: 5 additions & 10 deletions src/liblink/asm7.c
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,6 @@ static Optab optab[] = {
{ AADD, C_VCON, C_REG, C_REG, 13, 8, 0, LFROM },
{ AADD, C_VCON, C_NONE, C_REG, 13, 8, 0, LFROM },
{ ACMP, C_VCON, C_REG, C_NONE, 13, 8, 0, LFROM },
{ AADD, C_ADDR, C_REG, C_REG, 13, 8, 0, LFROM },
{ AADD, C_ADDR, C_NONE, C_REG, 13, 8, 0, LFROM },
{ ACMP, C_ADDR, C_REG, C_NONE, 13, 8, 0, LFROM },

{ AADD, C_SHIFT,C_REG, C_REG, 3, 4, 0 },
{ AADD, C_SHIFT,C_NONE, C_REG, 3, 4, 0 },
Expand Down Expand Up @@ -297,10 +294,6 @@ static Optab optab[] = {
{ AAND, C_VCON, C_NONE, C_REG, 28, 8, 0, LFROM },
{ ABIC, C_VCON, C_REG, C_REG, 28, 8, 0, LFROM },
{ ABIC, C_VCON, C_NONE, C_REG, 28, 8, 0, LFROM },
{ AAND, C_ADDR, C_REG, C_REG, 28, 8, 0, LFROM },
{ AAND, C_ADDR, C_NONE, C_REG, 28, 8, 0, LFROM },
{ ABIC, C_ADDR, C_REG, C_REG, 28, 8, 0, LFROM },
{ ABIC, C_ADDR, C_NONE, C_REG, 28, 8, 0, LFROM },

{ AAND, C_SHIFT,C_REG, C_REG, 3, 4, 0 },
{ AAND, C_SHIFT,C_NONE, C_REG, 3, 4, 0 },
Expand Down Expand Up @@ -372,7 +365,6 @@ static Optab optab[] = {

{ AMOVW, C_VCON, C_NONE, C_REG, 12, 4, 0, LFROM },
{ AMOV, C_VCON, C_NONE, C_REG, 12, 4, 0, LFROM },
{ AMOV, C_ADDR, C_NONE, C_REG, 12, 4, 0, LFROM },

{ AMOVB, C_REG, C_NONE, C_ADDR, 64, 8, 0, LTO },
{ AMOVBU, C_REG, C_NONE, C_ADDR, 64, 8, 0, LTO },
Expand Down Expand Up @@ -1186,7 +1178,7 @@ aclass(Link *ctxt, Addr *a)
if(s == nil)
break;
ctxt->instoffset = a->offset;
return C_ADDR;
return C_VCONADDR;
case D_AUTO:
ctxt->instoffset = ctxt->autosize + a->offset;
goto aconsize;
Expand Down Expand Up @@ -1305,7 +1297,10 @@ cmp(int a, int b)
return 1;
break;
case C_VCON:
return cmp(C_LCON, b);
if(b == C_VCONADDR)
return 1;
else
return cmp(C_LCON, b);
case C_LACON:
if(b == C_AACON)
return 1;
Expand Down

0 comments on commit 076d34d

Please sign in to comment.