Commit 4b981ed3 authored by Rob Pike's avatar Rob Pike

cmd/internal/obj/*: go generate the slice of Anames strings

Add cmd/internal/obj/stringer.go to do the generation and update
the architecture packages to use it to maintain the Anames tables.

Change-Id: I9c6d4def1bf21624668396d70c17973d0db11fbc
Reviewed-on: https://go-review.googlesource.com/7430Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 5d987f15
...@@ -32,6 +32,8 @@ package arm ...@@ -32,6 +32,8 @@ package arm
import "cmd/internal/obj" import "cmd/internal/obj"
//go:generate go run ../stringer.go -i $GOFILE -o anames.go -p arm
const ( const (
NSNAME = 8 NSNAME = 8
NSYM = 50 NSYM = 50
......
// Generated by stringer -i 5.out.go -o anames.go -p arm
// Do not edit.
package arm
import "cmd/internal/obj"
var Anames = []string{
obj.A_ARCHSPECIFIC: "AND",
"EOR",
"SUB",
"RSB",
"ADD",
"ADC",
"SBC",
"RSC",
"TST",
"TEQ",
"CMP",
"CMN",
"ORR",
"BIC",
"MVN",
"BEQ",
"BNE",
"BCS",
"BHS",
"BCC",
"BLO",
"BMI",
"BPL",
"BVS",
"BVC",
"BHI",
"BLS",
"BGE",
"BLT",
"BGT",
"BLE",
"MOVWD",
"MOVWF",
"MOVDW",
"MOVFW",
"MOVFD",
"MOVDF",
"MOVF",
"MOVD",
"CMPF",
"CMPD",
"ADDF",
"ADDD",
"SUBF",
"SUBD",
"MULF",
"MULD",
"DIVF",
"DIVD",
"SQRTF",
"SQRTD",
"ABSF",
"ABSD",
"SRL",
"SRA",
"SLL",
"MULU",
"DIVU",
"MUL",
"DIV",
"MOD",
"MODU",
"MOVB",
"MOVBS",
"MOVBU",
"MOVH",
"MOVHS",
"MOVHU",
"MOVW",
"MOVM",
"SWPBU",
"SWPW",
"RFE",
"SWI",
"MULA",
"WORD",
"BCASE",
"CASE",
"MULL",
"MULAL",
"MULLU",
"MULALU",
"BX",
"BXRET",
"DWORD",
"LDREX",
"STREX",
"LDREXD",
"STREXD",
"PLD",
"CLZ",
"MULWT",
"MULWB",
"MULAWT",
"MULAWB",
"DATABUNDLE",
"DATABUNDLEEND",
"MRC",
"LAST",
}
package arm // Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
import "cmd/internal/obj" // license that can be found in the LICENSE file.
var Anames = []string{ package arm
obj.A_ARCHSPECIFIC: "AND",
"EOR",
"SUB",
"RSB",
"ADD",
"ADC",
"SBC",
"RSC",
"TST",
"TEQ",
"CMP",
"CMN",
"ORR",
"BIC",
"MVN",
"BEQ",
"BNE",
"BCS",
"BHS",
"BCC",
"BLO",
"BMI",
"BPL",
"BVS",
"BVC",
"BHI",
"BLS",
"BGE",
"BLT",
"BGT",
"BLE",
"MOVWD",
"MOVWF",
"MOVDW",
"MOVFW",
"MOVFD",
"MOVDF",
"MOVF",
"MOVD",
"CMPF",
"CMPD",
"ADDF",
"ADDD",
"SUBF",
"SUBD",
"MULF",
"MULD",
"DIVF",
"DIVD",
"SQRTF",
"SQRTD",
"ABSF",
"ABSD",
"SRL",
"SRA",
"SLL",
"MULU",
"DIVU",
"MUL",
"DIV",
"MOD",
"MODU",
"MOVB",
"MOVBS",
"MOVBU",
"MOVH",
"MOVHS",
"MOVHU",
"MOVW",
"MOVM",
"SWPBU",
"SWPW",
"RFE",
"SWI",
"MULA",
"WORD",
"BCASE",
"CASE",
"MULL",
"MULAL",
"MULLU",
"MULALU",
"BX",
"BXRET",
"DWORD",
"LDREX",
"STREX",
"LDREXD",
"STREXD",
"PLD",
"CLZ",
"MULWT",
"MULWB",
"MULAWT",
"MULAWB",
"DATABUNDLE",
"DATABUNDLEEND",
"MRC",
"LAST",
}
var cnames5 = []string{ var cnames5 = []string{
"NONE", "NONE",
......
...@@ -31,7 +31,7 @@ package ppc64 ...@@ -31,7 +31,7 @@ package ppc64
import "cmd/internal/obj" import "cmd/internal/obj"
// auto generated by go tool dist //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p ppc64
/* /*
* powerpc 64 * powerpc 64
......
// Generated by stringer -i 9.out.go -o anames.go -p ppc64
// Do not edit.
package ppc64
import "cmd/internal/obj"
var Anames = []string{
obj.A_ARCHSPECIFIC: "ADD",
"ADDCC",
"ADDV",
"ADDVCC",
"ADDC",
"ADDCCC",
"ADDCV",
"ADDCVCC",
"ADDME",
"ADDMECC",
"ADDMEVCC",
"ADDMEV",
"ADDE",
"ADDECC",
"ADDEVCC",
"ADDEV",
"ADDZE",
"ADDZECC",
"ADDZEVCC",
"ADDZEV",
"AND",
"ANDCC",
"ANDN",
"ANDNCC",
"BC",
"BCL",
"BEQ",
"BGE",
"BGT",
"BLE",
"BLT",
"BNE",
"BVC",
"BVS",
"CMP",
"CMPU",
"CNTLZW",
"CNTLZWCC",
"CRAND",
"CRANDN",
"CREQV",
"CRNAND",
"CRNOR",
"CROR",
"CRORN",
"CRXOR",
"DIVW",
"DIVWCC",
"DIVWVCC",
"DIVWV",
"DIVWU",
"DIVWUCC",
"DIVWUVCC",
"DIVWUV",
"EQV",
"EQVCC",
"EXTSB",
"EXTSBCC",
"EXTSH",
"EXTSHCC",
"FABS",
"FABSCC",
"FADD",
"FADDCC",
"FADDS",
"FADDSCC",
"FCMPO",
"FCMPU",
"FCTIW",
"FCTIWCC",
"FCTIWZ",
"FCTIWZCC",
"FDIV",
"FDIVCC",
"FDIVS",
"FDIVSCC",
"FMADD",
"FMADDCC",
"FMADDS",
"FMADDSCC",
"FMOVD",
"FMOVDCC",
"FMOVDU",
"FMOVS",
"FMOVSU",
"FMSUB",
"FMSUBCC",
"FMSUBS",
"FMSUBSCC",
"FMUL",
"FMULCC",
"FMULS",
"FMULSCC",
"FNABS",
"FNABSCC",
"FNEG",
"FNEGCC",
"FNMADD",
"FNMADDCC",
"FNMADDS",
"FNMADDSCC",
"FNMSUB",
"FNMSUBCC",
"FNMSUBS",
"FNMSUBSCC",
"FRSP",
"FRSPCC",
"FSUB",
"FSUBCC",
"FSUBS",
"FSUBSCC",
"MOVMW",
"LSW",
"LWAR",
"MOVWBR",
"MOVB",
"MOVBU",
"MOVBZ",
"MOVBZU",
"MOVH",
"MOVHBR",
"MOVHU",
"MOVHZ",
"MOVHZU",
"MOVW",
"MOVWU",
"MOVFL",
"MOVCRFS",
"MTFSB0",
"MTFSB0CC",
"MTFSB1",
"MTFSB1CC",
"MULHW",
"MULHWCC",
"MULHWU",
"MULHWUCC",
"MULLW",
"MULLWCC",
"MULLWVCC",
"MULLWV",
"NAND",
"NANDCC",
"NEG",
"NEGCC",
"NEGVCC",
"NEGV",
"NOR",
"NORCC",
"OR",
"ORCC",
"ORN",
"ORNCC",
"REM",
"REMCC",
"REMV",
"REMVCC",
"REMU",
"REMUCC",
"REMUV",
"REMUVCC",
"RFI",
"RLWMI",
"RLWMICC",
"RLWNM",
"RLWNMCC",
"SLW",
"SLWCC",
"SRW",
"SRAW",
"SRAWCC",
"SRWCC",
"STSW",
"STWCCC",
"SUB",
"SUBCC",
"SUBVCC",
"SUBC",
"SUBCCC",
"SUBCV",
"SUBCVCC",
"SUBME",
"SUBMECC",
"SUBMEVCC",
"SUBMEV",
"SUBV",
"SUBE",
"SUBECC",
"SUBEV",
"SUBEVCC",
"SUBZE",
"SUBZECC",
"SUBZEVCC",
"SUBZEV",
"SYNC",
"XOR",
"XORCC",
"DCBF",
"DCBI",
"DCBST",
"DCBT",
"DCBTST",
"DCBZ",
"ECIWX",
"ECOWX",
"EIEIO",
"ICBI",
"ISYNC",
"PTESYNC",
"TLBIE",
"TLBIEL",
"TLBSYNC",
"TW",
"SYSCALL",
"WORD",
"RFCI",
"FRES",
"FRESCC",
"FRSQRTE",
"FRSQRTECC",
"FSEL",
"FSELCC",
"FSQRT",
"FSQRTCC",
"FSQRTS",
"FSQRTSCC",
"CNTLZD",
"CNTLZDCC",
"CMPW",
"CMPWU",
"DIVD",
"DIVDCC",
"DIVDVCC",
"DIVDV",
"DIVDU",
"DIVDUCC",
"DIVDUVCC",
"DIVDUV",
"EXTSW",
"EXTSWCC",
"FCFID",
"FCFIDCC",
"FCTID",
"FCTIDCC",
"FCTIDZ",
"FCTIDZCC",
"LDAR",
"MOVD",
"MOVDU",
"MOVWZ",
"MOVWZU",
"MULHD",
"MULHDCC",
"MULHDU",
"MULHDUCC",
"MULLD",
"MULLDCC",
"MULLDVCC",
"MULLDV",
"RFID",
"RLDMI",
"RLDMICC",
"RLDC",
"RLDCCC",
"RLDCR",
"RLDCRCC",
"RLDCL",
"RLDCLCC",
"SLBIA",
"SLBIE",
"SLBMFEE",
"SLBMFEV",
"SLBMTE",
"SLD",
"SLDCC",
"SRD",
"SRAD",
"SRADCC",
"SRDCC",
"STDCCC",
"TD",
"DWORD",
"REMD",
"REMDCC",
"REMDV",
"REMDVCC",
"REMDU",
"REMDUCC",
"REMDUV",
"REMDUVCC",
"HRFID",
"LAST",
}
package ppc64 package ppc64
import "cmd/internal/obj"
var Anames = []string{
obj.A_ARCHSPECIFIC: "ADD",
"ADDCC",
"ADDV",
"ADDVCC",
"ADDC",
"ADDCCC",
"ADDCV",
"ADDCVCC",
"ADDME",
"ADDMECC",
"ADDMEVCC",
"ADDMEV",
"ADDE",
"ADDECC",
"ADDEVCC",
"ADDEV",
"ADDZE",
"ADDZECC",
"ADDZEVCC",
"ADDZEV",
"AND",
"ANDCC",
"ANDN",
"ANDNCC",
"BC",
"BCL",
"BEQ",
"BGE",
"BGT",
"BLE",
"BLT",
"BNE",
"BVC",
"BVS",
"CMP",
"CMPU",
"CNTLZW",
"CNTLZWCC",
"CRAND",
"CRANDN",
"CREQV",
"CRNAND",
"CRNOR",
"CROR",
"CRORN",
"CRXOR",
"DIVW",
"DIVWCC",
"DIVWVCC",
"DIVWV",
"DIVWU",
"DIVWUCC",
"DIVWUVCC",
"DIVWUV",
"EQV",
"EQVCC",
"EXTSB",
"EXTSBCC",
"EXTSH",
"EXTSHCC",
"FABS",
"FABSCC",
"FADD",
"FADDCC",
"FADDS",
"FADDSCC",
"FCMPO",
"FCMPU",
"FCTIW",
"FCTIWCC",
"FCTIWZ",
"FCTIWZCC",
"FDIV",
"FDIVCC",
"FDIVS",
"FDIVSCC",
"FMADD",
"FMADDCC",
"FMADDS",
"FMADDSCC",
"FMOVD",
"FMOVDCC",
"FMOVDU",
"FMOVS",
"FMOVSU",
"FMSUB",
"FMSUBCC",
"FMSUBS",
"FMSUBSCC",
"FMUL",
"FMULCC",
"FMULS",
"FMULSCC",
"FNABS",
"FNABSCC",
"FNEG",
"FNEGCC",
"FNMADD",
"FNMADDCC",
"FNMADDS",
"FNMADDSCC",
"FNMSUB",
"FNMSUBCC",
"FNMSUBS",
"FNMSUBSCC",
"FRSP",
"FRSPCC",
"FSUB",
"FSUBCC",
"FSUBS",
"FSUBSCC",
"MOVMW",
"LSW",
"LWAR",
"MOVWBR",
"MOVB",
"MOVBU",
"MOVBZ",
"MOVBZU",
"MOVH",
"MOVHBR",
"MOVHU",
"MOVHZ",
"MOVHZU",
"MOVW",
"MOVWU",
"MOVFL",
"MOVCRFS",
"MTFSB0",
"MTFSB0CC",
"MTFSB1",
"MTFSB1CC",
"MULHW",
"MULHWCC",
"MULHWU",
"MULHWUCC",
"MULLW",
"MULLWCC",
"MULLWVCC",
"MULLWV",
"NAND",
"NANDCC",
"NEG",
"NEGCC",
"NEGVCC",
"NEGV",
"NOR",
"NORCC",
"OR",
"ORCC",
"ORN",
"ORNCC",
"REM",
"REMCC",
"REMV",
"REMVCC",
"REMU",
"REMUCC",
"REMUV",
"REMUVCC",
"RFI",
"RLWMI",
"RLWMICC",
"RLWNM",
"RLWNMCC",
"SLW",
"SLWCC",
"SRW",
"SRAW",
"SRAWCC",
"SRWCC",
"STSW",
"STWCCC",
"SUB",
"SUBCC",
"SUBVCC",
"SUBC",
"SUBCCC",
"SUBCV",
"SUBCVCC",
"SUBME",
"SUBMECC",
"SUBMEVCC",
"SUBMEV",
"SUBV",
"SUBE",
"SUBECC",
"SUBEV",
"SUBEVCC",
"SUBZE",
"SUBZECC",
"SUBZEVCC",
"SUBZEV",
"SYNC",
"XOR",
"XORCC",
"DCBF",
"DCBI",
"DCBST",
"DCBT",
"DCBTST",
"DCBZ",
"ECIWX",
"ECOWX",
"EIEIO",
"ICBI",
"ISYNC",
"PTESYNC",
"TLBIE",
"TLBIEL",
"TLBSYNC",
"TW",
"SYSCALL",
"WORD",
"RFCI",
"FRES",
"FRESCC",
"FRSQRTE",
"FRSQRTECC",
"FSEL",
"FSELCC",
"FSQRT",
"FSQRTCC",
"FSQRTS",
"FSQRTSCC",
"CNTLZD",
"CNTLZDCC",
"CMPW",
"CMPWU",
"DIVD",
"DIVDCC",
"DIVDVCC",
"DIVDV",
"DIVDU",
"DIVDUCC",
"DIVDUVCC",
"DIVDUV",
"EXTSW",
"EXTSWCC",
"FCFID",
"FCFIDCC",
"FCTID",
"FCTIDCC",
"FCTIDZ",
"FCTIDZCC",
"LDAR",
"MOVD",
"MOVDU",
"MOVWZ",
"MOVWZU",
"MULHD",
"MULHDCC",
"MULHDU",
"MULHDUCC",
"MULLD",
"MULLDCC",
"MULLDVCC",
"MULLDV",
"RFID",
"RLDMI",
"RLDMICC",
"RLDC",
"RLDCCC",
"RLDCR",
"RLDCRCC",
"RLDCL",
"RLDCLCC",
"SLBIA",
"SLBIE",
"SLBMFEE",
"SLBMFEV",
"SLBMTE",
"SLD",
"SLDCC",
"SRD",
"SRAD",
"SRADCC",
"SRDCC",
"STDCCC",
"TD",
"DWORD",
"REMD",
"REMDCC",
"REMDV",
"REMDVCC",
"REMDU",
"REMDUCC",
"REMDUV",
"REMDUVCC",
"HRFID",
"LAST",
}
var cnames9 = []string{ var cnames9 = []string{
"NONE", "NONE",
"REG", "REG",
......
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
// This is a mini version of the stringer tool customized for the Anames table
// in the architecture support for obj.
// This version just generates the slice of strings, not the String method.
package main
import (
"bufio"
"flag"
"fmt"
"log"
"os"
"regexp"
"strings"
)
var (
input = flag.String("i", "", "input file name")
output = flag.String("o", "", "output file name")
pkg = flag.String("p", "", "package name")
)
var Are = regexp.MustCompile(`^\tA([A-Z0-9]+)`)
func main() {
flag.Parse()
if *input == "" || *output == "" || *pkg == "" {
flag.Usage()
os.Exit(2)
}
in, err := os.Open(*input)
if err != nil {
log.Fatal(err)
}
fd, err := os.Create(*output)
if err != nil {
log.Fatal(err)
}
out := bufio.NewWriter(fd)
defer out.Flush()
var on = false
s := bufio.NewScanner(in)
first := true
for s.Scan() {
line := s.Text()
if !on {
// First relevant line contains "= obj.ABase".
// If we find it, delete the = so we don't stop immediately.
const prefix = "= obj.ABase"
index := strings.Index(line, prefix)
if index < 0 {
continue
}
// It's on. Start with the header.
fmt.Fprintf(out, header, *input, *output, *pkg, *pkg)
on = true
line = line[:index]
}
// Strip comments so their text won't defeat our heuristic.
index := strings.Index(line, "//")
if index > 0 {
line = line[:index]
}
index = strings.Index(line, "/*")
if index > 0 {
line = line[:index]
}
// Termination condition: Any line with an = changes the sequence,
// so stop there, and stop at a closing brace.
if strings.HasPrefix(line, "}") || strings.ContainsRune(line, '=') {
break
}
sub := Are.FindStringSubmatch(line)
if len(sub) < 2 {
continue
}
if first {
fmt.Fprintf(out, "\tobj.A_ARCHSPECIFIC: %q,\n", sub[1])
first = false
} else {
fmt.Fprintf(out, "\t%q,\n", sub[1])
}
}
fmt.Fprintln(out, "}")
if s.Err() != nil {
log.Fatal(err)
}
}
const header = `// Generated by stringer -i %s -o %s -p %s
// Do not edit.
package %s
import "cmd/internal/obj"
var Anames = []string{
`
...@@ -32,6 +32,8 @@ package x86 ...@@ -32,6 +32,8 @@ package x86
import "cmd/internal/obj" import "cmd/internal/obj"
//go:generate go run ../stringer.go -i $GOFILE -o anames.go -p x86
/* /*
* amd64 * amd64
*/ */
......
// Generated by stringer -i 6.out.go -o anames.go -p x86
// Do not edit.
package x86 package x86
import "cmd/internal/obj" import "cmd/internal/obj"
/*
* this is the ranlib header
*/
var Anames = []string{ var Anames = []string{
obj.A_ARCHSPECIFIC: "AAA", obj.A_ARCHSPECIFIC: "AAA",
"AAD", "AAD",
......
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