instructions["PSRLDQ"] = x86.APSRLO
instructions["PADDD"] = x86.APADDL
- x86.InstInit()
-
return &Arch{
LinkArch: linkArch,
Instructions: instructions,
func testEndToEnd(t *testing.T, goarch, file string) {
input := filepath.Join("testdata", file+".s")
architecture, ctxt := setArch(goarch)
+ architecture.Init(ctxt)
lexer := lex.NewLexer(input)
parser := NewParser(ctxt, architecture, lexer)
pList := new(obj.Plist)
ctxt.Bso = bufio.NewWriter(os.Stdout)
defer ctxt.Bso.Flush()
+ architecture.Init(ctxt)
+
// Create object file, write header.
out, err := os.Create(*flags.OutputFile)
if err != nil {
arch.SSAMarkMoves = ssaMarkMoves
arch.SSAGenValue = ssaGenValue
arch.SSAGenBlock = ssaGenBlock
-
- x86.InstInit()
}
usage()
}
+ thearch.LinkArch.Init(Ctxt)
+
if outfile == "" {
p := flag.Arg(0)
if i := strings.LastIndex(p, "/"); i >= 0 {
arch.Ginsnop = ginsnop
arch.SSAMarkMoves = ssaMarkMoves
-
- x86.InstInit()
}
}
if oprange[AAND&obj.AMask] == nil {
- buildop(ctxt)
+ ctxt.Diag("arm ops not initialized, call arm.buildop first")
}
ctxt.Cursym = cursym
}
func buildop(ctxt *obj.Link) {
+ if oprange[AAND&obj.AMask] != nil {
+ // Already initialized; stop now.
+ // This happens in the cmd/asm tests,
+ // each of which re-initializes the arch.
+ return
+ }
+
var n int
for i := 0; i < C_GOK; i++ {
var Linkarm = obj.LinkArch{
Arch: sys.ArchARM,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span5,
Progedit: progedit,
ctxt.Autosize = int32(p.To.Offset&0xffffffff) + 8
if oprange[AAND&obj.AMask] == nil {
- buildop(ctxt)
+ ctxt.Diag("arm64 ops not initialized, call arm64.buildop first")
}
bflag := 1
}
func buildop(ctxt *obj.Link) {
+ if oprange[AAND&obj.AMask] != nil {
+ // Already initialized; stop now.
+ // This happens in the cmd/asm tests,
+ // each of which re-initializes the arch.
+ return
+ }
+
var n int
for i := 0; i < C_GOK; i++ {
for n = 0; n < C_GOK; n++ {
var Linkarm64 = obj.LinkArch{
Arch: sys.ArchARM64,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span7,
Progedit: progedit,
// LinkArch is the definition of a single architecture.
type LinkArch struct {
*sys.Arch
+ Init func(*Link)
Preprocess func(*Link, *LSym, ProgAlloc)
Assemble func(*Link, *LSym, ProgAlloc)
Progedit func(*Link, *Prog, ProgAlloc)
ctxt.Autosize = int32(p.To.Offset + ctxt.FixedFrameSize())
if oprange[AOR&obj.AMask] == nil {
- buildop(ctxt)
+ ctxt.Diag("mips ops not initialized, call mips.buildop first")
}
c := int64(0)
func oplook(ctxt *obj.Link, p *obj.Prog) *Optab {
if oprange[AOR&obj.AMask] == nil {
- buildop(ctxt)
+ ctxt.Diag("mips ops not initialized, call mips.buildop first")
}
a1 := int(p.Optab)
}
func buildop(ctxt *obj.Link) {
+ if oprange[AOR&obj.AMask] != nil {
+ // Already initialized; stop now.
+ // This happens in the cmd/asm tests,
+ // each of which re-initializes the arch.
+ return
+ }
+
var n int
for i := 0; i < C_NCLASS; i++ {
var Linkmips64 = obj.LinkArch{
Arch: sys.ArchMIPS64,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span0,
Progedit: progedit,
var Linkmips64le = obj.LinkArch{
Arch: sys.ArchMIPS64LE,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span0,
Progedit: progedit,
var Linkmips = obj.LinkArch{
Arch: sys.ArchMIPS,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span0,
Progedit: progedit,
var Linkmipsle = obj.LinkArch{
Arch: sys.ArchMIPSLE,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span0,
Progedit: progedit,
ctxt.Autosize = int32(p.To.Offset)
if oprange[AANDN&obj.AMask] == nil {
- buildop(ctxt)
+ ctxt.Diag("ppc64 ops not initialized, call ppc64.buildop first")
}
c := int64(0)
}
func buildop(ctxt *obj.Link) {
+ if oprange[AANDN&obj.AMask] != nil {
+ // Already initialized; stop now.
+ // This happens in the cmd/asm tests,
+ // each of which re-initializes the arch.
+ return
+ }
+
var n int
for i := 0; i < C_NCLASS; i++ {
var Linkppc64 = obj.LinkArch{
Arch: sys.ArchPPC64,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span9,
Progedit: progedit,
var Linkppc64le = obj.LinkArch{
Arch: sys.ArchPPC64LE,
+ Init: buildop,
Preprocess: preprocess,
Assemble: span9,
Progedit: progedit,
ctxt.Autosize = int32(p.To.Offset)
if oprange[AORW&obj.AMask] == nil {
- buildop(ctxt)
+ ctxt.Diag("s390x ops not initialized, call s390x.buildop first")
}
buffer := make([]byte, 0)
}
func buildop(ctxt *obj.Link) {
+ if oprange[AORW&obj.AMask] != nil {
+ // Already initialized; stop now.
+ // This happens in the cmd/asm tests,
+ // each of which re-initializes the arch.
+ return
+ }
+
for i := 0; i < C_NCLASS; i++ {
for n := 0; n < C_NCLASS; n++ {
if cmp(n, i) {
var Links390x = obj.LinkArch{
Arch: sys.ArchS390X,
+ Init: buildop,
Preprocess: preprocess,
Assemble: spanz,
Progedit: progedit,
* two values match the Ytypes of the p->from and p->to operands. The function
* oclass in span.c computes the specific Ytype of an operand and then the set
* of more general Ytypes that it satisfies is implied by the ycover table, set
- * up in InstInit. For example, oclass distinguishes the constants 0 and 1
- * from the more general 8-bit constants, but InstInit says
+ * up in instinit. For example, oclass distinguishes the constants 0 and 1
+ * from the more general 8-bit constants, but instinit says
*
* ycover[Yi0*Ymax + Ys32] = 1;
* ycover[Yi1*Ymax + Ys32] = 1;
}
if ycover[0] == 0 {
- ctxt.Diag("x86 tables not initialized, call x86.InstInit first")
+ ctxt.Diag("x86 tables not initialized, call x86.instinit first")
}
var asmbuf AsmBuf
}
}
-func InstInit() {
+func instinit(ctxt *obj.Link) {
if ycover[0] != 0 {
// Already initialized; stop now.
// This happens in the cmd/asm tests,
for i := 1; optab[i].as != 0; i++ {
c := optab[i].as
if opindex[c&obj.AMask] != nil {
- log.Fatalf("phase error in optab: %d (%v)", i, c)
+ ctxt.Diag("phase error in optab: %d (%v)", i, c)
}
opindex[c&obj.AMask] = &optab[i]
}
var Linkamd64 = obj.LinkArch{
Arch: sys.ArchAMD64,
+ Init: instinit,
Preprocess: preprocess,
Assemble: span6,
Progedit: progedit,
var Linkamd64p32 = obj.LinkArch{
Arch: sys.ArchAMD64P32,
+ Init: instinit,
Preprocess: preprocess,
Assemble: span6,
Progedit: progedit,
var Link386 = obj.LinkArch{
Arch: sys.Arch386,
+ Init: instinit,
Preprocess: preprocess,
Assemble: span6,
Progedit: progedit,