Commit 1fc330d8 authored by Russ Cox's avatar Russ Cox

[dev.cc] cmd/internal/obj: reconvert from liblink

cmd/internal/obj reconverted using rsc.io/c2go rev 2a95256.

- Brings in new, more regular Prog, Addr definitions

- Add Prog* argument to oclass in liblink/asm[68].c, for c2go conversion.
- Update objwriter for change in TEXT size encoding.
- Merge 5a, 6a, 8a, 9a changes into new5a, new6a, new8a, new9a (by hand).

- Add +build ignore to cmd/asm/internal/{addr,arch,asm}, cmd/asm.
  They need to be updated for the changes.

- Reenable verifyAsm in cmd/go.
- Reenable GOOBJ=2 mode by default in liblink.

All architectures build successfully again.

Change-Id: I2c845c5d365aa484b570476898171bee657b626d
Reviewed-on: https://go-review.googlesource.com/3963Reviewed-by: default avatarRob Pike <r@golang.org>
parent 8db173b8
// +build ignore
// Copyright 2015 The Go Authors. All rights reserved. // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
......
// +build ignore
// Copyright 2015 The Go Authors. All rights reserved. // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
......
// +build ignore
// Copyright 2014 The Go Authors. All rights reserved. // Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
......
// +build ignore
// Copyright 2015 The Go Authors. All rights reserved. // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
......
// +build ignore
// Copyright 2015 The Go Authors. All rights reserved. // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
......
// +build ignore
// Copyright 2014 The Go Authors. All rights reserved. // Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
......
...@@ -1678,7 +1678,7 @@ func (gcToolchain) gc(b *builder, p *Package, archive, obj string, asmhdr bool, ...@@ -1678,7 +1678,7 @@ func (gcToolchain) gc(b *builder, p *Package, archive, obj string, asmhdr bool,
// verifyAsm specifies whether to check the assemblers written in Go // verifyAsm specifies whether to check the assemblers written in Go
// against the assemblers written in C. If set, asm will run both (say) 6a and new6a // against the assemblers written in C. If set, asm will run both (say) 6a and new6a
// and fail if the two produce different output files. // and fail if the two produce different output files.
const verifyAsm = false const verifyAsm = true
func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error { func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error {
// Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files. // Add -I pkg/GOOS_GOARCH so #include "textflag.h" works in .s files.
...@@ -1691,8 +1691,8 @@ func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error { ...@@ -1691,8 +1691,8 @@ func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error {
if verifyAsm { if verifyAsm {
newArgs := make([]interface{}, len(args)) newArgs := make([]interface{}, len(args))
copy(newArgs, args) copy(newArgs, args)
newArgs[0] = tool("new" + archChar + "a") newArgs[1] = tool("new" + archChar + "a")
newArgs[2] = ofile + ".new" // x.6 becomes x.6.new newArgs[3] = ofile + ".new" // x.6 becomes x.6.new
if err := b.run(p.Dir, p.ImportPath, nil, newArgs...); err != nil { if err := b.run(p.Dir, p.ImportPath, nil, newArgs...); err != nil {
return err return err
} }
...@@ -1705,7 +1705,7 @@ func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error { ...@@ -1705,7 +1705,7 @@ func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error {
return err return err
} }
if !bytes.Equal(data1, data2) { if !bytes.Equal(data1, data2) {
return fmt.Errorf("%sa and n%sa produced different output files:\n%s\n%s", archChar, archChar, strings.Join(stringList(args...), " "), strings.Join(stringList(newArgs...), " ")) return fmt.Errorf("%sa and new%sa produced different output files:\n%s\n%s", archChar, archChar, strings.Join(stringList(args...), " "), strings.Join(stringList(newArgs...), " "))
} }
} }
return nil return nil
......
...@@ -30,17 +30,7 @@ ...@@ -30,17 +30,7 @@
package arm package arm
// list[5689].c import "cmd/internal/obj"
// obj.c
// objfile.c
// pass.c
// pcln.c
// sym.c
// TODO(ality): remove this workaround. // TODO(ality): remove this workaround.
// It's here because Pconv in liblink/list?.c references %L. // It's here because Pconv in liblink/list?.c references %L.
...@@ -57,18 +47,54 @@ const ( ...@@ -57,18 +47,54 @@ const (
) )
const ( const (
REGRET = 0 REG_R0 = 32 + iota
REGEXT = 10 REG_R1
REG_R2
REG_R3
REG_R4
REG_R5
REG_R6
REG_R7
REG_R8
REG_R9
REG_R10
REG_R11
REG_R12
REG_R13
REG_R14
REG_R15
REG_F0
REG_F1
REG_F2
REG_F3
REG_F4
REG_F5
REG_F6
REG_F7
REG_F8
REG_F9
REG_F10
REG_F11
REG_F12
REG_F13
REG_F14
REG_F15
REG_FPSR
REG_FPCR
REG_CPSR
REG_SPSR
REGRET = REG_R0
REGEXT = REG_R10
REGG = REGEXT - 0 REGG = REGEXT - 0
REGM = REGEXT - 1 REGM = REGEXT - 1
REGTMP = 11 REGTMP = REG_R11
REGSP = 13 REGSP = REG_R13
REGLINK = 14 REGLINK = REG_R14
REGPC = 15 REGPC = REG_R15
NFREG = 16 NFREG = 16
FREGRET = 0 FREGRET = REG_F0
FREGEXT = 7 FREGEXT = REG_F7
FREGTMP = 15 FREGTMP = REG_F15
) )
/* compiler allocates register variables F0 up */ /* compiler allocates register variables F0 up */
...@@ -110,13 +136,13 @@ const ( ...@@ -110,13 +136,13 @@ const (
C_SP C_SP
C_HREG C_HREG
C_ADDR C_ADDR
C_TEXTSIZE
C_GOK C_GOK
C_NCLASS C_NCLASS
) )
const ( const (
AXXX = iota AAND = obj.A_ARCHSPECIFIC + iota
AAND
AEOR AEOR
ASUB ASUB
ARSB ARSB
...@@ -131,8 +157,6 @@ const ( ...@@ -131,8 +157,6 @@ const (
AORR AORR
ABIC ABIC
AMVN AMVN
AB
ABL
ABEQ ABEQ
ABNE ABNE
ABCS ABCS
...@@ -190,23 +214,12 @@ const ( ...@@ -190,23 +214,12 @@ const (
AMOVM AMOVM
ASWPBU ASWPBU
ASWPW ASWPW
ANOP
ARFE ARFE
ASWI ASWI
AMULA AMULA
ADATA
AGLOBL
AGOK
AHISTORY
ANAME
ARET
ATEXT
AWORD AWORD
ADYNT_
AINIT_
ABCASE ABCASE
ACASE ACASE
AEND
AMULL AMULL
AMULAL AMULAL
AMULLU AMULLU
...@@ -214,31 +227,22 @@ const ( ...@@ -214,31 +227,22 @@ const (
ABX ABX
ABXRET ABXRET
ADWORD ADWORD
ASIGNAME
ALDREX ALDREX
ASTREX ASTREX
ALDREXD ALDREXD
ASTREXD ASTREXD
APLD APLD
AUNDEF
ACLZ ACLZ
AMULWT AMULWT
AMULWB AMULWB
AMULAWT AMULAWT
AMULAWB AMULAWB
AUSEFIELD
ATYPE
AFUNCDATA
APCDATA
ACHECKNIL
AVARDEF
AVARKILL
ADUFFCOPY
ADUFFZERO
ADATABUNDLE ADATABUNDLE
ADATABUNDLEEND ADATABUNDLEEND
AMRC AMRC
ALAST ALAST
AB = obj.AJMP
ABL = obj.ACALL
) )
/* scond byte */ /* scond byte */
...@@ -249,56 +253,29 @@ const ( ...@@ -249,56 +253,29 @@ const (
C_WBIT = 1 << 6 C_WBIT = 1 << 6
C_FBIT = 1 << 7 C_FBIT = 1 << 7
C_UBIT = 1 << 7 C_UBIT = 1 << 7
C_SCOND_EQ = 0 C_SCOND_XOR = 14
C_SCOND_NE = 1 C_SCOND_EQ = 0 ^ C_SCOND_XOR
C_SCOND_HS = 2 C_SCOND_NE = 1 ^ C_SCOND_XOR
C_SCOND_LO = 3 C_SCOND_HS = 2 ^ C_SCOND_XOR
C_SCOND_MI = 4 C_SCOND_LO = 3 ^ C_SCOND_XOR
C_SCOND_PL = 5 C_SCOND_MI = 4 ^ C_SCOND_XOR
C_SCOND_VS = 6 C_SCOND_PL = 5 ^ C_SCOND_XOR
C_SCOND_VC = 7 C_SCOND_VS = 6 ^ C_SCOND_XOR
C_SCOND_HI = 8 C_SCOND_VC = 7 ^ C_SCOND_XOR
C_SCOND_LS = 9 C_SCOND_HI = 8 ^ C_SCOND_XOR
C_SCOND_GE = 10 C_SCOND_LS = 9 ^ C_SCOND_XOR
C_SCOND_LT = 11 C_SCOND_GE = 10 ^ C_SCOND_XOR
C_SCOND_GT = 12 C_SCOND_LT = 11 ^ C_SCOND_XOR
C_SCOND_LE = 13 C_SCOND_GT = 12 ^ C_SCOND_XOR
C_SCOND_NONE = 14 C_SCOND_LE = 13 ^ C_SCOND_XOR
C_SCOND_NV = 15 C_SCOND_NONE = 14 ^ C_SCOND_XOR
C_SCOND_NV = 15 ^ C_SCOND_XOR
SHIFT_LL = 0 << 5 SHIFT_LL = 0 << 5
SHIFT_LR = 1 << 5 SHIFT_LR = 1 << 5
SHIFT_AR = 2 << 5 SHIFT_AR = 2 << 5
SHIFT_RR = 3 << 5 SHIFT_RR = 3 << 5
) )
const (
D_GOK = 0
D_NONE = 1
D_BRANCH = D_NONE + 1
D_OREG = D_NONE + 2
D_CONST = D_NONE + 7
D_FCONST = D_NONE + 8
D_SCONST = D_NONE + 9
D_PSR = D_NONE + 10
D_REG = D_NONE + 12
D_FREG = D_NONE + 13
D_FILE = D_NONE + 16
D_OCONST = D_NONE + 17
D_FILE1 = D_NONE + 18
D_SHIFT = D_NONE + 19
D_FPCR = D_NONE + 20
D_REGREG = D_NONE + 21
D_ADDR = D_NONE + 22
D_SBIG = D_NONE + 23
D_CONST2 = D_NONE + 24
D_REGREG2 = D_NONE + 25
D_EXTERN = D_NONE + 3
D_STATIC = D_NONE + 4
D_AUTO = D_NONE + 5
D_PARAM = D_NONE + 6
D_LAST = D_NONE + 26
)
/* /*
* this is the ranlib header * this is the ranlib header
*/ */
......
package arm package arm
var Anames = []string{ var Anames = []string{
"XXX", "XXX ",
"AND", "CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AND ",
"EOR", "EOR",
"SUB", "SUB",
"RSB", "RSB",
...@@ -17,8 +35,6 @@ var Anames = []string{ ...@@ -17,8 +35,6 @@ var Anames = []string{
"ORR", "ORR",
"BIC", "BIC",
"MVN", "MVN",
"B",
"BL",
"BEQ", "BEQ",
"BNE", "BNE",
"BCS", "BCS",
...@@ -76,23 +92,12 @@ var Anames = []string{ ...@@ -76,23 +92,12 @@ var Anames = []string{
"MOVM", "MOVM",
"SWPBU", "SWPBU",
"SWPW", "SWPW",
"NOP",
"RFE", "RFE",
"SWI", "SWI",
"MULA", "MULA",
"DATA",
"GLOBL",
"GOK",
"HISTORY",
"NAME",
"RET",
"TEXT",
"WORD", "WORD",
"DYNT_",
"INIT_",
"BCASE", "BCASE",
"CASE", "CASE",
"END",
"MULL", "MULL",
"MULAL", "MULAL",
"MULLU", "MULLU",
...@@ -100,27 +105,16 @@ var Anames = []string{ ...@@ -100,27 +105,16 @@ var Anames = []string{
"BX", "BX",
"BXRET", "BXRET",
"DWORD", "DWORD",
"SIGNAME",
"LDREX", "LDREX",
"STREX", "STREX",
"LDREXD", "LDREXD",
"STREXD", "STREXD",
"PLD", "PLD",
"UNDEF",
"CLZ", "CLZ",
"MULWT", "MULWT",
"MULWB", "MULWB",
"MULAWT", "MULAWT",
"MULAWB", "MULAWB",
"USEFIELD",
"TYPE",
"FUNCDATA",
"PCDATA",
"CHECKNIL",
"VARDEF",
"VARKILL",
"DUFFCOPY",
"DUFFZERO",
"DATABUNDLE", "DATABUNDLE",
"DATABUNDLEEND", "DATABUNDLEEND",
"MRC", "MRC",
...@@ -164,6 +158,7 @@ var cnames5 = []string{ ...@@ -164,6 +158,7 @@ var cnames5 = []string{
"SP", "SP",
"HREG", "HREG",
"ADDR", "ADDR",
"TEXTSIZE",
"GOK", "GOK",
"NCLASS", "NCLASS",
"SCOND = (1<<4)-1", "SCOND = (1<<4)-1",
...@@ -172,25 +167,21 @@ var cnames5 = []string{ ...@@ -172,25 +167,21 @@ var cnames5 = []string{
"WBIT = 1<<6", "WBIT = 1<<6",
"FBIT = 1<<7", "FBIT = 1<<7",
"UBIT = 1<<7", "UBIT = 1<<7",
"SCOND_EQ = 0", "SCOND_XOR = 14",
"SCOND_NE = 1", "SCOND_EQ = 0 ^ C_SCOND_XOR",
"SCOND_HS = 2", "SCOND_NE = 1 ^ C_SCOND_XOR",
"SCOND_LO = 3", "SCOND_HS = 2 ^ C_SCOND_XOR",
"SCOND_MI = 4", "SCOND_LO = 3 ^ C_SCOND_XOR",
"SCOND_PL = 5", "SCOND_MI = 4 ^ C_SCOND_XOR",
"SCOND_VS = 6", "SCOND_PL = 5 ^ C_SCOND_XOR",
"SCOND_VC = 7", "SCOND_VS = 6 ^ C_SCOND_XOR",
"SCOND_HI = 8", "SCOND_VC = 7 ^ C_SCOND_XOR",
"SCOND_LS = 9", "SCOND_HI = 8 ^ C_SCOND_XOR",
"SCOND_GE = 10", "SCOND_LS = 9 ^ C_SCOND_XOR",
"SCOND_LT = 11", "SCOND_GE = 10 ^ C_SCOND_XOR",
"SCOND_GT = 12", "SCOND_LT = 11 ^ C_SCOND_XOR",
"SCOND_LE = 13", "SCOND_GT = 12 ^ C_SCOND_XOR",
"SCOND_NONE = 14", "SCOND_LE = 13 ^ C_SCOND_XOR",
"SCOND_NV = 15", "SCOND_NONE = 14 ^ C_SCOND_XOR",
} "SCOND_NV = 15 ^ C_SCOND_XOR",
var dnames5 = []string{
D_GOK: "GOK",
D_NONE: "NONE",
} }
This diff is collapsed.
...@@ -70,7 +70,7 @@ func Pconv(p *obj.Prog) string { ...@@ -70,7 +70,7 @@ func Pconv(p *obj.Prog) string {
a = int(p.As) a = int(p.As)
s = int(p.Scond) s = int(p.Scond)
sc = extra[s&C_SCOND] sc = extra[(s&C_SCOND)^C_SCOND_XOR]
if s&C_SBIT != 0 { if s&C_SBIT != 0 {
sc += ".S" sc += ".S"
} }
...@@ -84,25 +84,21 @@ func Pconv(p *obj.Prog) string { ...@@ -84,25 +84,21 @@ func Pconv(p *obj.Prog) string {
sc += ".U" sc += ".U"
} }
if a == AMOVM { if a == AMOVM {
if p.From.Type == D_CONST { if p.From.Type == obj.TYPE_CONST {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, RAconv(&p.From), Dconv(p, 0, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, RAconv(&p.From), Dconv(p, 0, &p.To))
} else if p.To.Type == D_CONST { } else if p.To.Type == obj.TYPE_CONST {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), RAconv(&p.To)) str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), RAconv(&p.To))
} else { } else {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), Dconv(p, 0, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), Dconv(p, 0, &p.To))
} }
} else if a == ADATA { } else if a == obj.ADATA {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", p.Pc, p.Line(), Aconv(a), Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", p.Pc, p.Line(), Aconv(a), Dconv(p, 0, &p.From), p.From3.Offset, Dconv(p, 0, &p.To))
} else if p.As == ATEXT { } else if p.As == obj.ATEXT {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", p.Pc, p.Line(), Aconv(a), Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", p.Pc, p.Line(), Aconv(a), Dconv(p, 0, &p.From), p.From3.Offset, Dconv(p, 0, &p.To))
} else if p.Reg == NREG { } else if p.Reg == 0 {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), Dconv(p, 0, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), Dconv(p, 0, &p.To))
} else if p.From.Type != D_FREG {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,R%d,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To))
} else { } else {
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,%v,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), Rconv(int(p.Reg)), Dconv(p, 0, &p.To))
str = fmt.Sprintf("%.5d (%v)\t%v%s\t%v,F%d,%v", p.Pc, p.Line(), Aconv(a), sc, Dconv(p, 0, &p.From), p.Reg, Dconv(p, 0, &p.To))
} }
fp += str fp += str
...@@ -114,7 +110,7 @@ func Aconv(a int) string { ...@@ -114,7 +110,7 @@ func Aconv(a int) string {
var fp string var fp string
s = "???" s = "???"
if a >= AXXX && a < ALAST { if a >= obj.AXXX && a < ALAST {
s = Anames[a] s = Anames[a]
} }
fp += s fp += s
...@@ -132,63 +128,53 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string { ...@@ -132,63 +128,53 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string {
default: default:
str = fmt.Sprintf("GOK-type(%d)", a.Type) str = fmt.Sprintf("GOK-type(%d)", a.Type)
case D_NONE: case obj.TYPE_NONE:
str = "" str = ""
if a.Name != D_NONE || a.Reg != NREG || a.Sym != nil { if a.Name != obj.TYPE_NONE || a.Reg != 0 || a.Sym != nil {
str = fmt.Sprintf("%v(R%d)(NONE)", Mconv(a), a.Reg) str = fmt.Sprintf("%v(%v)(NONE)", Mconv(a), Rconv(int(a.Reg)))
} }
case D_CONST: case obj.TYPE_CONST,
if a.Reg != NREG { obj.TYPE_ADDR:
str = fmt.Sprintf("$%v(R%d)", Mconv(a), a.Reg) if a.Reg != 0 {
str = fmt.Sprintf("$%v(%v)", Mconv(a), Rconv(int(a.Reg)))
} else { } else {
str = fmt.Sprintf("$%v", Mconv(a)) str = fmt.Sprintf("$%v", Mconv(a))
} }
case D_CONST2: case obj.TYPE_TEXTSIZE:
str = fmt.Sprintf("$%d-%d", a.Offset, a.Offset2) if a.U.Argsize == obj.ArgsSizeUnknown {
str = fmt.Sprintf("$%d", a.Offset)
} else {
str = fmt.Sprintf("$%d-%d", a.Offset, a.U.Argsize)
}
case D_SHIFT: case obj.TYPE_SHIFT:
v = int(a.Offset) v = int(a.Offset)
op = string("<<>>->@>"[((v>>5)&3)<<1:]) op = string("<<>>->@>"[((v>>5)&3)<<1:])
if v&(1<<4) != 0 { if v&(1<<4) != 0 {
str = fmt.Sprintf("R%d%c%cR%d", v&15, op[0], op[1], (v>>8)&15) str = fmt.Sprintf("R%d%c%cR%d", v&15, op[0], op[1], (v>>8)&15)
} else { } else {
str = fmt.Sprintf("R%d%c%c%d", v&15, op[0], op[1], (v>>7)&31) str = fmt.Sprintf("R%d%c%c%d", v&15, op[0], op[1], (v>>7)&31)
} }
if a.Reg != NREG { if a.Reg != 0 {
str += fmt.Sprintf("(R%d)", a.Reg) str += fmt.Sprintf("(%v)", Rconv(int(a.Reg)))
} }
case D_OREG: case obj.TYPE_MEM:
if a.Reg != NREG { if a.Reg != 0 {
str = fmt.Sprintf("%v(R%d)", Mconv(a), a.Reg) str = fmt.Sprintf("%v(%v)", Mconv(a), Rconv(int(a.Reg)))
} else { } else {
str = fmt.Sprintf("%v", Mconv(a)) str = fmt.Sprintf("%v", Mconv(a))
} }
case D_REG: case obj.TYPE_REG:
str = fmt.Sprintf("R%d", a.Reg) str = fmt.Sprintf("%v", Rconv(int(a.Reg)))
if a.Name != D_NONE || a.Sym != nil { if a.Name != obj.TYPE_NONE || a.Sym != nil {
str = fmt.Sprintf("%v(R%d)(REG)", Mconv(a), a.Reg) str = fmt.Sprintf("%v(%v)(REG)", Mconv(a), Rconv(int(a.Reg)))
}
case D_FREG:
str = fmt.Sprintf("F%d", a.Reg)
if a.Name != D_NONE || a.Sym != nil {
str = fmt.Sprintf("%v(R%d)(REG)", Mconv(a), a.Reg)
} }
case D_PSR: case obj.TYPE_BRANCH:
str = fmt.Sprintf("PSR")
if a.Name != D_NONE || a.Sym != nil {
str = fmt.Sprintf("%v(PSR)(REG)", Mconv(a))
}
case D_BRANCH:
if a.Sym != nil { if a.Sym != nil {
str = fmt.Sprintf("%s(SB)", a.Sym.Name) str = fmt.Sprintf("%s(SB)", a.Sym.Name)
} else if p != nil && p.Pcond != nil { } else if p != nil && p.Pcond != nil {
...@@ -196,14 +182,13 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string { ...@@ -196,14 +182,13 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string {
} else if a.U.Branch != nil { } else if a.U.Branch != nil {
str = fmt.Sprintf("%d", a.U.Branch.Pc) str = fmt.Sprintf("%d", a.U.Branch.Pc)
} else { } else {
str = fmt.Sprintf("%d(PC)", a.Offset) /*-pc*/ str = fmt.Sprintf("%d(PC)", a.Offset) /*-pc*/
} }
case D_FCONST: case obj.TYPE_FCONST:
str = fmt.Sprintf("$%.17g", a.U.Dval) str = fmt.Sprintf("$%.17g", a.U.Dval)
case D_SCONST: case obj.TYPE_SCONST:
str = fmt.Sprintf("$\"%q\"", a.U.Sval) str = fmt.Sprintf("$\"%q\"", a.U.Sval)
break break
} }
...@@ -221,9 +206,8 @@ func RAconv(a *obj.Addr) string { ...@@ -221,9 +206,8 @@ func RAconv(a *obj.Addr) string {
str = fmt.Sprintf("GOK-reglist") str = fmt.Sprintf("GOK-reglist")
switch a.Type { switch a.Type {
case D_CONST, case obj.TYPE_CONST:
D_CONST2: if a.Reg != 0 {
if a.Reg != NREG {
break break
} }
if a.Sym != nil { if a.Sym != nil {
...@@ -233,10 +217,9 @@ func RAconv(a *obj.Addr) string { ...@@ -233,10 +217,9 @@ func RAconv(a *obj.Addr) string {
str = "" str = ""
for i = 0; i < NREG; i++ { for i = 0; i < NREG; i++ {
if v&(1<<uint(i)) != 0 { if v&(1<<uint(i)) != 0 {
if str[0] == 0 { if str == "" {
str += "[R" str += "[R"
} else { } else {
str += ",R" str += ",R"
} }
str += fmt.Sprintf("%d", i) str += fmt.Sprintf("%d", i)
...@@ -253,10 +236,38 @@ func RAconv(a *obj.Addr) string { ...@@ -253,10 +236,38 @@ func RAconv(a *obj.Addr) string {
func Rconv(r int) string { func Rconv(r int) string {
var fp string var fp string
var str string if r == 0 {
fp += "NONE"
return fp
}
if REG_R0 <= r && r <= REG_R15 {
fp += fmt.Sprintf("R%d", r-REG_R0)
return fp
}
if REG_F0 <= r && r <= REG_F15 {
fp += fmt.Sprintf("F%d", r-REG_F0)
return fp
}
str = fmt.Sprintf("R%d", r) switch r {
fp += str case REG_FPSR:
fp += "FPSR"
return fp
case REG_FPCR:
fp += "FPCR"
return fp
case REG_CPSR:
fp += "CPSR"
return fp
case REG_SPSR:
fp += "SPSR"
return fp
}
fp += fmt.Sprintf("badreg(%d)", r)
return fp return fp
} }
...@@ -288,19 +299,19 @@ func Mconv(a *obj.Addr) string { ...@@ -288,19 +299,19 @@ func Mconv(a *obj.Addr) string {
default: default:
str = fmt.Sprintf("GOK-name(%d)", a.Name) str = fmt.Sprintf("GOK-name(%d)", a.Name)
case D_NONE: case obj.NAME_NONE:
str = fmt.Sprintf("%d", a.Offset) str = fmt.Sprintf("%d", a.Offset)
case D_EXTERN: case obj.NAME_EXTERN:
str = fmt.Sprintf("%s+%d(SB)", s.Name, int(a.Offset)) str = fmt.Sprintf("%s+%d(SB)", s.Name, int(a.Offset))
case D_STATIC: case obj.NAME_STATIC:
str = fmt.Sprintf("%s<>+%d(SB)", s.Name, int(a.Offset)) str = fmt.Sprintf("%s<>+%d(SB)", s.Name, int(a.Offset))
case D_AUTO: case obj.NAME_AUTO:
str = fmt.Sprintf("%s-%d(SP)", s.Name, int(-a.Offset)) str = fmt.Sprintf("%s-%d(SP)", s.Name, int(-a.Offset))
case D_PARAM: case obj.NAME_PARAM:
str = fmt.Sprintf("%s+%d(FP)", s.Name, int(a.Offset)) str = fmt.Sprintf("%s+%d(FP)", s.Name, int(a.Offset))
break break
} }
......
This diff is collapsed.
...@@ -37,7 +37,6 @@ import ( ...@@ -37,7 +37,6 @@ import (
) )
func mangle(file string) { func mangle(file string) {
log.Fatalf("%s: mangled input file", file) log.Fatalf("%s: mangled input file", file)
} }
...@@ -58,7 +57,7 @@ func Symgrow(ctxt *Link, s *LSym, lsiz int64) { ...@@ -58,7 +57,7 @@ func Symgrow(ctxt *Link, s *LSym, lsiz int64) {
func savedata(ctxt *Link, s *LSym, p *Prog, pn string) { func savedata(ctxt *Link, s *LSym, p *Prog, pn string) {
off := int32(p.From.Offset) off := int32(p.From.Offset)
siz := int32(ctxt.Arch.Datasize(p)) siz := int32(p.From3.Offset)
if off < 0 || siz < 0 || off >= 1<<30 || siz >= 100 { if off < 0 || siz < 0 || off >= 1<<30 || siz >= 100 {
mangle(pn) mangle(pn)
} }
...@@ -71,7 +70,7 @@ func savedata(ctxt *Link, s *LSym, p *Prog, pn string) { ...@@ -71,7 +70,7 @@ func savedata(ctxt *Link, s *LSym, p *Prog, pn string) {
default: default:
ctxt.Diag("bad data: %P", p) ctxt.Diag("bad data: %P", p)
case ctxt.Arch.D_FCONST: case TYPE_FCONST:
switch siz { switch siz {
default: default:
ctxt.Diag("unexpected %d-byte floating point constant", siz) ctxt.Diag("unexpected %d-byte floating point constant", siz)
...@@ -85,11 +84,11 @@ func savedata(ctxt *Link, s *LSym, p *Prog, pn string) { ...@@ -85,11 +84,11 @@ func savedata(ctxt *Link, s *LSym, p *Prog, pn string) {
ctxt.Arch.ByteOrder.PutUint64(s.P[off:], flt) ctxt.Arch.ByteOrder.PutUint64(s.P[off:], flt)
} }
case ctxt.Arch.D_SCONST: case TYPE_SCONST:
copy(s.P[off:off+siz], p.To.U.Sval) copy(s.P[off:off+siz], p.To.U.Sval)
case ctxt.Arch.D_CONST, ctxt.Arch.D_ADDR: case TYPE_CONST, TYPE_ADDR:
if p.To.Sym != nil || int(p.To.Type) == ctxt.Arch.D_ADDR { if p.To.Sym != nil || int(p.To.Type) == TYPE_ADDR {
r := Addrel(s) r := Addrel(s)
r.Off = off r.Off = off
r.Siz = uint8(siz) r.Siz = uint8(siz)
...@@ -119,7 +118,7 @@ func Addrel(s *LSym) *Reloc { ...@@ -119,7 +118,7 @@ func Addrel(s *LSym) *Reloc {
return &s.R[len(s.R)-1] return &s.R[len(s.R)-1]
} }
func setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 { func Setuintxx(ctxt *Link, s *LSym, off int64, v uint64, wid int64) int64 {
if s.Type == 0 { if s.Type == 0 {
s.Type = SDATA s.Type = SDATA
} }
...@@ -147,7 +146,7 @@ func adduintxx(ctxt *Link, s *LSym, v uint64, wid int) int64 { ...@@ -147,7 +146,7 @@ func adduintxx(ctxt *Link, s *LSym, v uint64, wid int) int64 {
var off int64 var off int64
off = s.Size off = s.Size
setuintxx(ctxt, s, off, v, int64(wid)) Setuintxx(ctxt, s, off, v, int64(wid))
return off return off
} }
...@@ -168,19 +167,19 @@ func Adduint64(ctxt *Link, s *LSym, v uint64) int64 { ...@@ -168,19 +167,19 @@ func Adduint64(ctxt *Link, s *LSym, v uint64) int64 {
} }
func setuint8(ctxt *Link, s *LSym, r int64, v uint8) int64 { func setuint8(ctxt *Link, s *LSym, r int64, v uint8) int64 {
return setuintxx(ctxt, s, r, uint64(v), 1) return Setuintxx(ctxt, s, r, uint64(v), 1)
} }
func setuint16(ctxt *Link, s *LSym, r int64, v uint16) int64 { func setuint16(ctxt *Link, s *LSym, r int64, v uint16) int64 {
return setuintxx(ctxt, s, r, uint64(v), 2) return Setuintxx(ctxt, s, r, uint64(v), 2)
} }
func setuint32(ctxt *Link, s *LSym, r int64, v uint32) int64 { func setuint32(ctxt *Link, s *LSym, r int64, v uint32) int64 {
return setuintxx(ctxt, s, r, uint64(v), 4) return Setuintxx(ctxt, s, r, uint64(v), 4)
} }
func setuint64(ctxt *Link, s *LSym, r int64, v uint64) int64 { func setuint64(ctxt *Link, s *LSym, r int64, v uint64) int64 {
return setuintxx(ctxt, s, r, v, 8) return Setuintxx(ctxt, s, r, v, 8)
} }
func addaddrplus(ctxt *Link, s *LSym, t *LSym, add int64) int64 { func addaddrplus(ctxt *Link, s *LSym, t *LSym, add int64) int64 {
......
// cmd/9l/noop.c, cmd/9l/pass.c, cmd/9l/span.c from Vita Nuova. // Inferno utils/5c/list.c
// http://code.google.com/p/inferno-os/source/browse/utils/5c/list.c
// //
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net) // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
// Portions Copyright © 1997-1999 Vita Nuova Limited // Portions Copyright © 1997-1999 Vita Nuova Limited
// Portions Copyright © 2000-2008 Vita Nuova Holdings Limited (www.vitanuova.com) // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
// Portions Copyright © 2004,2006 Bruce Ellis // Portions Copyright © 2004,2006 Bruce Ellis
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net) // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
// Revisions Copyright © 2000-2008 Lucent Technologies Inc. and others // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
// Portions Copyright © 2009 The Go Authors. All rights reserved. // Portions Copyright © 2009 The Go Authors. All rights reserved.
// //
// Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
...@@ -74,5 +75,5 @@ const ( ...@@ -74,5 +75,5 @@ const (
FUNCDATA_ArgsPointerMaps = 0 FUNCDATA_ArgsPointerMaps = 0
FUNCDATA_LocalsPointerMaps = 1 FUNCDATA_LocalsPointerMaps = 1
FUNCDATA_DeadValueMaps = 2 FUNCDATA_DeadValueMaps = 2
ArgsSizeUnknown = 0x80000000 ArgsSizeUnknown = -0x80000000
) )
...@@ -5,12 +5,75 @@ ...@@ -5,12 +5,75 @@
package obj package obj
import ( import (
"fmt"
"math" "math"
"os"
"strings" "strings"
) )
// go-specific code shared across loaders (5l, 6l, 8l). // go-specific code shared across loaders (5l, 6l, 8l).
var Framepointer_enabled int
var fieldtrack_enabled int
var Zprog Prog
// Toolchain experiments.
// These are controlled by the GOEXPERIMENT environment
// variable recorded when the toolchain is built.
// This list is also known to cmd/gc.
var exper = []struct {
name string
val *int
}{
struct {
name string
val *int
}{"fieldtrack", &fieldtrack_enabled},
struct {
name string
val *int
}{"framepointer", &Framepointer_enabled},
}
func addexp(s string) {
var i int
for i = 0; i < len(exper); i++ {
if exper[i].name == s {
if exper[i].val != nil {
*exper[i].val = 1
}
return
}
}
fmt.Printf("unknown experiment %s\n", s)
os.Exit(2)
}
func linksetexp() {
for _, f := range strings.Split(goexperiment, ",") {
if f != "" {
addexp(f)
}
}
}
func expstring() string {
buf := "X"
for i := range exper {
if *exper[i].val != 0 {
buf += "," + exper[i].name
}
}
if buf == "X" {
buf += ",none"
}
return "X:" + buf[2:]
}
// replace all "". with pkg. // replace all "". with pkg.
func expandpkg(t0 string, pkg string) string { func expandpkg(t0 string, pkg string) string {
return strings.Replace(t0, `"".`, pkg+".", -1) return strings.Replace(t0, `"".`, pkg+".", -1)
......
...@@ -30,9 +30,10 @@ ...@@ -30,9 +30,10 @@
package i386 package i386
import "cmd/internal/obj"
const ( const (
AXXX = iota AAAA = obj.A_ARCHSPECIFIC + iota
AAAA
AAAD AAAD
AAAM AAAM
AAAS AAAS
...@@ -62,7 +63,6 @@ const ( ...@@ -62,7 +63,6 @@ const (
ABTSL ABTSL
ABTSW ABTSW
ABYTE ABYTE
ACALL
ACLC ACLC
ACLD ACLD
ACLI ACLI
...@@ -76,7 +76,6 @@ const ( ...@@ -76,7 +76,6 @@ const (
ACMPSW ACMPSW
ADAA ADAA
ADAS ADAS
ADATA
ADECB ADECB
ADECL ADECL
ADECW ADECW
...@@ -84,9 +83,6 @@ const ( ...@@ -84,9 +83,6 @@ const (
ADIVL ADIVL
ADIVW ADIVW
AENTER AENTER
AGLOBL
AGOK
AHISTORY
AHLT AHLT
AIDIVB AIDIVB
AIDIVL AIDIVL
...@@ -119,7 +115,6 @@ const ( ...@@ -119,7 +115,6 @@ const (
AJLS AJLS
AJLT AJLT
AJMI AJMI
AJMP
AJNE AJNE
AJOC AJOC
AJOS AJOS
...@@ -159,11 +154,9 @@ const ( ...@@ -159,11 +154,9 @@ const (
AMULB AMULB
AMULL AMULL
AMULW AMULW
ANAME
ANEGB ANEGB
ANEGL ANEGL
ANEGW ANEGW
ANOP
ANOTB ANOTB
ANOTL ANOTL
ANOTW ANOTW
...@@ -197,7 +190,6 @@ const ( ...@@ -197,7 +190,6 @@ const (
ARCRW ARCRW
AREP AREP
AREPN AREPN
ARET
AROLB AROLB
AROLL AROLL
AROLW AROLW
...@@ -254,7 +246,6 @@ const ( ...@@ -254,7 +246,6 @@ const (
ATESTB ATESTB
ATESTL ATESTL
ATESTW ATESTW
ATEXT
AVERR AVERR
AVERW AVERW
AWAIT AWAIT
...@@ -367,10 +358,6 @@ const ( ...@@ -367,10 +358,6 @@ const (
AFXTRACT AFXTRACT
AFYL2X AFYL2X
AFYL2XP1 AFYL2XP1
AEND
ADYNT_
AINIT_
ASIGNAME
ACMPXCHGB ACMPXCHGB
ACMPXCHGL ACMPXCHGL
ACMPXCHGW ACMPXCHGW
...@@ -429,7 +416,6 @@ const ( ...@@ -429,7 +416,6 @@ const (
APREFETCHT2 APREFETCHT2
APREFETCHNTA APREFETCHNTA
ABSWAPL ABSWAPL
AUNDEF
AADDPD AADDPD
AADDPS AADDPS
AADDSD AADDSD
...@@ -544,73 +530,53 @@ const ( ...@@ -544,73 +530,53 @@ const (
AAESENC AAESENC
APINSRD APINSRD
APSHUFB APSHUFB
AUSEFIELD
ATYPE
AFUNCDATA
APCDATA
ACHECKNIL
AVARDEF
AVARKILL
ADUFFCOPY
ADUFFZERO
ALAST ALAST
) )
const ( const (
D_AL = 0 + iota REG_NONE = 0
D_CL REG_AL = 0 + 16 + iota - 1
D_DL REG_CL
D_BL REG_DL
D_AH = 4 + iota - 4 REG_BL
D_CH REG_AH = 4 + 16 + iota - 5
D_DH REG_CH
D_BH REG_DH
D_AX = 8 + iota - 8 REG_BH
D_CX REG_AX = 8 + 16 + iota - 9
D_DX REG_CX
D_BX REG_DX
D_SP REG_BX
D_BP REG_SP
D_SI REG_BP
D_DI REG_SI
D_F0 = 16 REG_DI
D_F7 = D_F0 + 7 REG_F0 = 16 + 16
D_CS = 24 + iota - 18 REG_F7 = REG_F0 + 7 + 16
D_SS REG_CS = 24 + 16 + iota - 19
D_DS REG_SS
D_ES REG_DS
D_FS REG_ES
D_GS REG_FS
D_GDTR REG_GS
D_IDTR REG_GDTR
D_LDTR REG_IDTR
D_MSW REG_LDTR
D_TASK REG_MSW
D_CR = 35 REG_TASK
D_DR = 43 REG_CR = 35 + 16
D_TR = 51 REG_DR = 43 + 16
D_X0 = 59 + iota - 32 REG_TR = 51 + 16
D_X1 REG_X0 = 59 + 16 + iota - 33
D_X2 REG_X1
D_X3 REG_X2
D_X4 REG_X3
D_X5 REG_X4
D_X6 REG_X5
D_X7 REG_X6
D_TLS = 67 REG_X7
D_NONE = 68 REG_TLS = 67 + 16
D_BRANCH = 69 MAXREG = 68 + 16
D_EXTERN = 70
D_STATIC = 71
D_AUTO = 72
D_PARAM = 73
D_CONST = 74
D_FCONST = 75
D_SCONST = 76
D_ADDR = 77 + iota - 50
D_INDIR
D_CONST2 = D_INDIR + D_INDIR + iota - 52
D_LAST
T_TYPE = 1 << 0 T_TYPE = 1 << 0
T_INDEX = 1 << 1 T_INDEX = 1 << 1
T_OFFSET = 1 << 2 T_OFFSET = 1 << 2
...@@ -620,8 +586,8 @@ const ( ...@@ -620,8 +586,8 @@ const (
T_OFFSET2 = 1 << 6 T_OFFSET2 = 1 << 6
T_GOTYPE = 1 << 7 T_GOTYPE = 1 << 7
REGARG = -1 REGARG = -1
REGRET = D_AX REGRET = REG_AX
FREGRET = D_F0 FREGRET = REG_F0
REGSP = D_SP REGSP = REG_SP
REGTMP = D_DI REGTMP = REG_DI
) )
...@@ -4,8 +4,26 @@ package i386 ...@@ -4,8 +4,26 @@ package i386
* this is the ranlib header * this is the ranlib header
*/ */
var Anames = []string{ var Anames = []string{
"XXX", "XXX ",
"AAA", "CALL",
"CHECKNIL",
"DATA",
"DUFFCOPY",
"DUFFZERO",
"END",
"FUNCDATA",
"GLOBL",
"JMP",
"NOP",
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
"VARKILL",
"AAA ",
"AAD", "AAD",
"AAM", "AAM",
"AAS", "AAS",
...@@ -35,7 +53,6 @@ var Anames = []string{ ...@@ -35,7 +53,6 @@ var Anames = []string{
"BTSL", "BTSL",
"BTSW", "BTSW",
"BYTE", "BYTE",
"CALL",
"CLC", "CLC",
"CLD", "CLD",
"CLI", "CLI",
...@@ -49,7 +66,6 @@ var Anames = []string{ ...@@ -49,7 +66,6 @@ var Anames = []string{
"CMPSW", "CMPSW",
"DAA", "DAA",
"DAS", "DAS",
"DATA",
"DECB", "DECB",
"DECL", "DECL",
"DECW", "DECW",
...@@ -57,9 +73,6 @@ var Anames = []string{ ...@@ -57,9 +73,6 @@ var Anames = []string{
"DIVL", "DIVL",
"DIVW", "DIVW",
"ENTER", "ENTER",
"GLOBL",
"GOK",
"HISTORY",
"HLT", "HLT",
"IDIVB", "IDIVB",
"IDIVL", "IDIVL",
...@@ -92,7 +105,6 @@ var Anames = []string{ ...@@ -92,7 +105,6 @@ var Anames = []string{
"JLS", "JLS",
"JLT", "JLT",
"JMI", "JMI",
"JMP",
"JNE", "JNE",
"JOC", "JOC",
"JOS", "JOS",
...@@ -132,11 +144,9 @@ var Anames = []string{ ...@@ -132,11 +144,9 @@ var Anames = []string{
"MULB", "MULB",
"MULL", "MULL",
"MULW", "MULW",
"NAME",
"NEGB", "NEGB",
"NEGL", "NEGL",
"NEGW", "NEGW",
"NOP",
"NOTB", "NOTB",
"NOTL", "NOTL",
"NOTW", "NOTW",
...@@ -170,7 +180,6 @@ var Anames = []string{ ...@@ -170,7 +180,6 @@ var Anames = []string{
"RCRW", "RCRW",
"REP", "REP",
"REPN", "REPN",
"RET",
"ROLB", "ROLB",
"ROLL", "ROLL",
"ROLW", "ROLW",
...@@ -227,7 +236,6 @@ var Anames = []string{ ...@@ -227,7 +236,6 @@ var Anames = []string{
"TESTB", "TESTB",
"TESTL", "TESTL",
"TESTW", "TESTW",
"TEXT",
"VERR", "VERR",
"VERW", "VERW",
"WAIT", "WAIT",
...@@ -340,10 +348,6 @@ var Anames = []string{ ...@@ -340,10 +348,6 @@ var Anames = []string{
"FXTRACT", "FXTRACT",
"FYL2X", "FYL2X",
"FYL2XP1", "FYL2XP1",
"END",
"DYNT_",
"INIT_",
"SIGNAME",
"CMPXCHGB", "CMPXCHGB",
"CMPXCHGL", "CMPXCHGL",
"CMPXCHGW", "CMPXCHGW",
...@@ -402,7 +406,6 @@ var Anames = []string{ ...@@ -402,7 +406,6 @@ var Anames = []string{
"PREFETCHT2", "PREFETCHT2",
"PREFETCHNTA", "PREFETCHNTA",
"BSWAPL", "BSWAPL",
"UNDEF",
"ADDPD", "ADDPD",
"ADDPS", "ADDPS",
"ADDSD", "ADDSD",
...@@ -517,68 +520,5 @@ var Anames = []string{ ...@@ -517,68 +520,5 @@ var Anames = []string{
"AESENC", "AESENC",
"PINSRD", "PINSRD",
"PSHUFB", "PSHUFB",
"USEFIELD",
"TYPE",
"FUNCDATA",
"PCDATA",
"CHECKNIL",
"VARDEF",
"VARKILL",
"DUFFCOPY",
"DUFFZERO",
"LAST", "LAST",
} }
var dnames8 = []string{
D_AL: "AL",
D_CL: "CL",
D_DL: "DL",
D_BL: "BL",
D_AH: "AH",
D_CH: "CH",
D_DH: "DH",
D_BH: "BH",
D_AX: "AX",
D_CX: "CX",
D_DX: "DX",
D_BX: "BX",
D_SP: "SP",
D_BP: "BP",
D_SI: "SI",
D_DI: "DI",
D_F0: "F0",
D_CS: "CS",
D_SS: "SS",
D_DS: "DS",
D_ES: "ES",
D_FS: "FS",
D_GS: "GS",
D_GDTR: "GDTR",
D_IDTR: "IDTR",
D_LDTR: "LDTR",
D_MSW: "MSW",
D_TASK: "TASK",
D_CR: "CR",
D_DR: "DR",
D_TR: "TR",
D_X0: "X0",
D_X1: "X1",
D_X2: "X2",
D_X3: "X3",
D_X4: "X4",
D_X5: "X5",
D_X6: "X6",
D_X7: "X7",
D_TLS: "TLS",
D_NONE: "NONE",
D_BRANCH: "BRANCH",
D_EXTERN: "EXTERN",
D_STATIC: "STATIC",
D_AUTO: "AUTO",
D_PARAM: "PARAM",
D_CONST: "CONST",
D_FCONST: "FCONST",
D_SCONST: "SCONST",
D_ADDR: "ADDR",
D_INDIR: "INDIR",
}
This diff is collapsed.
...@@ -46,16 +46,16 @@ func Pconv(p *obj.Prog) string { ...@@ -46,16 +46,16 @@ func Pconv(p *obj.Prog) string {
var fp string var fp string
switch p.As { switch p.As {
case ADATA: case obj.ADATA:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), p.From.Scale, Dconv(p, 0, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v\t%v/%d,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), p.From3.Offset, Dconv(p, 0, &p.To))
case ATEXT: case obj.ATEXT:
if p.From.Scale != 0 { if p.From3.Offset != 0 {
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), p.From.Scale, Dconv(p, fmtLong, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%d,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), p.From3.Offset, Dconv(p, 0, &p.To))
break break
} }
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), Dconv(p, fmtLong, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), Dconv(p, 0, &p.To))
default: default:
str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), Dconv(p, 0, &p.To)) str = fmt.Sprintf("%.5d (%v)\t%v\t%v,%v", p.Pc, p.Line(), Aconv(int(p.As)), Dconv(p, 0, &p.From), Dconv(p, 0, &p.To))
...@@ -78,45 +78,34 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string { ...@@ -78,45 +78,34 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string {
var s string var s string
var fp string var fp string
var i int switch a.Type {
default:
i = int(a.Type) str = fmt.Sprintf("type=%d", a.Type)
if flag&fmtLong != 0 /*untyped*/ {
if i == D_CONST2 {
str = fmt.Sprintf("$%d-%d", a.Offset, a.Offset2)
} else {
// ATEXT dst is not constant
str = fmt.Sprintf("!!%v", Dconv(p, 0, a))
}
goto brk case obj.TYPE_NONE:
} str = ""
if i >= D_INDIR { // TODO(rsc): This special case is for instructions like
// PINSRQ CX,$1,X6
// where the $1 is included in the p->to Addr.
// Move into a new field.
case obj.TYPE_REG:
if a.Offset != 0 { if a.Offset != 0 {
str = fmt.Sprintf("%d(%v)", a.Offset, Rconv(i-D_INDIR)) str = fmt.Sprintf("$%d,%v", a.Offset, Rconv(int(a.Reg)))
} else { break
str = fmt.Sprintf("(%v)", Rconv(i-D_INDIR))
} }
goto brk
}
switch i { str = fmt.Sprintf("%v", Rconv(int(a.Reg)))
default:
if a.Offset != 0 {
str = fmt.Sprintf("$%d,%v", a.Offset, Rconv(i))
} else {
str = fmt.Sprintf("%v", Rconv(i)) // TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as
// SHRQ $32(DX*0), AX
// Remove.
if a.Index != REG_NONE {
s = fmt.Sprintf("(%v*%d)", Rconv(int(a.Index)), int(a.Scale))
str += s
} }
case D_NONE: case obj.TYPE_BRANCH:
str = ""
case D_BRANCH:
if a.Sym != nil { if a.Sym != nil {
str = fmt.Sprintf("%s(SB)", a.Sym.Name) str = fmt.Sprintf("%s(SB)", a.Sym.Name)
} else if p != nil && p.Pcond != nil { } else if p != nil && p.Pcond != nil {
...@@ -124,69 +113,85 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string { ...@@ -124,69 +113,85 @@ func Dconv(p *obj.Prog, flag int, a *obj.Addr) string {
} else if a.U.Branch != nil { } else if a.U.Branch != nil {
str = fmt.Sprintf("%d", a.U.Branch.Pc) str = fmt.Sprintf("%d", a.U.Branch.Pc)
} else { } else {
str = fmt.Sprintf("%d(PC)", a.Offset) str = fmt.Sprintf("%d(PC)", a.Offset)
} }
case D_EXTERN: case obj.TYPE_MEM:
str = fmt.Sprintf("%s+%d(SB)", a.Sym.Name, a.Offset) switch a.Name {
default:
case D_STATIC: str = fmt.Sprintf("name=%d", a.Name)
str = fmt.Sprintf("%s<>+%d(SB)", a.Sym.Name, a.Offset)
case obj.NAME_NONE:
case D_AUTO: if a.Offset != 0 {
if a.Sym != nil { str = fmt.Sprintf("%d(%v)", a.Offset, Rconv(int(a.Reg)))
str = fmt.Sprintf("%s+%d(SP)", a.Sym.Name, a.Offset) } else {
} else { str = fmt.Sprintf("(%v)", Rconv(int(a.Reg)))
}
str = fmt.Sprintf("%d(SP)", a.Offset)
case obj.NAME_EXTERN:
str = fmt.Sprintf("%s+%d(SB)", a.Sym.Name, a.Offset)
case obj.NAME_STATIC:
str = fmt.Sprintf("%s<>+%d(SB)", a.Sym.Name, a.Offset)
case obj.NAME_AUTO:
if a.Sym != nil {
str = fmt.Sprintf("%s+%d(SP)", a.Sym.Name, a.Offset)
} else {
str = fmt.Sprintf("%d(SP)", a.Offset)
}
case obj.NAME_PARAM:
if a.Sym != nil {
str = fmt.Sprintf("%s+%d(FP)", a.Sym.Name, a.Offset)
} else {
str = fmt.Sprintf("%d(FP)", a.Offset)
}
break
} }
case D_PARAM: if a.Index != REG_NONE {
if a.Sym != nil { s = fmt.Sprintf("(%v*%d)", Rconv(int(a.Index)), int(a.Scale))
str = fmt.Sprintf("%s+%d(FP)", a.Sym.Name, a.Offset) str += s
} else {
str = fmt.Sprintf("%d(FP)", a.Offset)
} }
case D_CONST: case obj.TYPE_CONST:
str = fmt.Sprintf("$%d", a.Offset) str = fmt.Sprintf("$%d", a.Offset)
case D_CONST2: // TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as
if !(flag&fmtLong != 0 /*untyped*/) { // SHRQ $32(DX*0), AX
// D_CONST2 outside of ATEXT should not happen // Remove.
str = fmt.Sprintf("!!$%d-%d", a.Offset, a.Offset2) if a.Index != REG_NONE {
s = fmt.Sprintf("(%v*%d)", Rconv(int(a.Index)), int(a.Scale))
str += s
} }
case D_FCONST: case obj.TYPE_TEXTSIZE:
if a.U.Argsize == obj.ArgsSizeUnknown {
str = fmt.Sprintf("$%d", a.Offset)
} else {
str = fmt.Sprintf("$%d-%d", a.Offset, a.U.Argsize)
}
case obj.TYPE_FCONST:
str = fmt.Sprintf("$(%.17g)", a.U.Dval) str = fmt.Sprintf("$(%.17g)", a.U.Dval)
case D_SCONST: case obj.TYPE_SCONST:
str = fmt.Sprintf("$\"%q\"", a.U.Sval) str = fmt.Sprintf("$\"%q\"", a.U.Sval)
case D_ADDR: case obj.TYPE_ADDR:
a.Type = int16(a.Index) a.Type = obj.TYPE_MEM
a.Index = D_NONE
str = fmt.Sprintf("$%v", Dconv(p, 0, a)) str = fmt.Sprintf("$%v", Dconv(p, 0, a))
a.Index = uint8(a.Type) a.Type = obj.TYPE_ADDR
a.Type = D_ADDR break
goto conv
}
brk:
if a.Index != D_NONE {
s = fmt.Sprintf("(%v*%d)", Rconv(int(a.Index)), int(a.Scale))
str += s
} }
conv:
fp += str fp += str
return fp return fp
} }
var Register = []string{ var Register = []string{
"AL", /* [D_AL] */ "AL", /* [REG_AL] */
"CL", "CL",
"DL", "DL",
"BL", "BL",
...@@ -194,7 +199,7 @@ var Register = []string{ ...@@ -194,7 +199,7 @@ var Register = []string{
"CH", "CH",
"DH", "DH",
"BH", "BH",
"AX", /* [D_AX] */ "AX", /* [REG_AX] */
"CX", "CX",
"DX", "DX",
"BX", "BX",
...@@ -202,7 +207,7 @@ var Register = []string{ ...@@ -202,7 +207,7 @@ var Register = []string{
"BP", "BP",
"SI", "SI",
"DI", "DI",
"F0", /* [D_F0] */ "F0", /* [REG_F0] */
"F1", "F1",
"F2", "F2",
"F3", "F3",
...@@ -210,18 +215,18 @@ var Register = []string{ ...@@ -210,18 +215,18 @@ var Register = []string{
"F5", "F5",
"F6", "F6",
"F7", "F7",
"CS", /* [D_CS] */ "CS", /* [REG_CS] */
"SS", "SS",
"DS", "DS",
"ES", "ES",
"FS", "FS",
"GS", "GS",
"GDTR", /* [D_GDTR] */ "GDTR", /* [REG_GDTR] */
"IDTR", /* [D_IDTR] */ "IDTR", /* [REG_IDTR] */
"LDTR", /* [D_LDTR] */ "LDTR", /* [REG_LDTR] */
"MSW", /* [D_MSW] */ "MSW", /* [REG_MSW] */
"TASK", /* [D_TASK] */ "TASK", /* [REG_TASK] */
"CR0", /* [D_CR] */ "CR0", /* [REG_CR] */
"CR1", "CR1",
"CR2", "CR2",
"CR3", "CR3",
...@@ -229,7 +234,7 @@ var Register = []string{ ...@@ -229,7 +234,7 @@ var Register = []string{
"CR5", "CR5",
"CR6", "CR6",
"CR7", "CR7",
"DR0", /* [D_DR] */ "DR0", /* [REG_DR] */
"DR1", "DR1",
"DR2", "DR2",
"DR3", "DR3",
...@@ -237,7 +242,7 @@ var Register = []string{ ...@@ -237,7 +242,7 @@ var Register = []string{
"DR5", "DR5",
"DR6", "DR6",
"DR7", "DR7",
"TR0", /* [D_TR] */ "TR0", /* [REG_TR] */
"TR1", "TR1",
"TR2", "TR2",
"TR3", "TR3",
...@@ -245,7 +250,7 @@ var Register = []string{ ...@@ -245,7 +250,7 @@ var Register = []string{
"TR5", "TR5",
"TR6", "TR6",
"TR7", "TR7",
"X0", /* [D_X0] */ "X0", /* [REG_X0] */
"X1", "X1",
"X2", "X2",
"X3", "X3",
...@@ -253,18 +258,21 @@ var Register = []string{ ...@@ -253,18 +258,21 @@ var Register = []string{
"X5", "X5",
"X6", "X6",
"X7", "X7",
"TLS", /* [D_TLS] */ "TLS", /* [REG_TLS] */
"NONE", /* [D_NONE] */ "MAXREG", /* [MAXREG] */
} }
func Rconv(r int) string { func Rconv(r int) string {
var str string var str string
var fp string var fp string
if r >= D_AL && r <= D_NONE { if r == REG_NONE {
str = fmt.Sprintf("%s", Register[r-D_AL]) fp += "NONE"
return fp
}
if r >= REG_AL && r-REG_AL < len(Register) {
str = fmt.Sprintf("%s", Register[r-REG_AL])
} else { } else {
str = fmt.Sprintf("gok(%d)", r) str = fmt.Sprintf("gok(%d)", r)
} }
......
This diff is collapsed.
...@@ -116,7 +116,6 @@ func mkfwd(sym *LSym) { ...@@ -116,7 +116,6 @@ func mkfwd(sym *LSym) {
if i == 0 { if i == 0 {
cnt[i] = 1 cnt[i] = 1
} else { } else {
cnt[i] = LOG * cnt[i-1] cnt[i] = LOG * cnt[i-1]
} }
dwn[i] = 1 dwn[i] = 1
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ const ( ...@@ -15,7 +15,7 @@ const (
NSYM = 50 NSYM = 50
) )
func linklinefmt(ctxt *Link, lno0 int, showAll, showFullPath bool) string { func Linklinefmt(ctxt *Link, lno0 int, showAll, showFullPath bool) string {
var a [HISTSZ]struct { var a [HISTSZ]struct {
incl *Hist incl *Hist
idel int32 idel int32
...@@ -222,11 +222,9 @@ func Linklinehist(ctxt *Link, lineno int, f string, offset int) { ...@@ -222,11 +222,9 @@ func Linklinehist(ctxt *Link, lineno int, f string, offset int) {
if offset != 0 { if offset != 0 {
fmt.Printf("%4d: %s (#line %d)\n", lineno, f, offset) fmt.Printf("%4d: %s (#line %d)\n", lineno, f, offset)
} else { } else {
fmt.Printf("%4d: %s\n", lineno, f) fmt.Printf("%4d: %s\n", lineno, f)
} }
} else { } else {
fmt.Printf("%4d: <pop>\n", lineno) fmt.Printf("%4d: <pop>\n", lineno)
} }
} }
...@@ -297,7 +295,6 @@ func Linkprfile(ctxt *Link, line int) { ...@@ -297,7 +295,6 @@ func Linkprfile(ctxt *Link, line int) {
* start a new Prog list. * start a new Prog list.
*/ */
func Linknewplist(ctxt *Link) *Plist { func Linknewplist(ctxt *Link) *Plist {
var pl *Plist var pl *Plist
pl = new(Plist) pl = new(Plist)
...@@ -305,7 +302,6 @@ func Linknewplist(ctxt *Link) *Plist { ...@@ -305,7 +302,6 @@ func Linknewplist(ctxt *Link) *Plist {
if ctxt.Plist == nil { if ctxt.Plist == nil {
ctxt.Plist = pl ctxt.Plist = pl
} else { } else {
ctxt.Plast.Link = pl ctxt.Plast.Link = pl
} }
ctxt.Plast = pl ctxt.Plast = pl
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment