1
0
mirror of https://github.com/golang/go synced 2024-10-02 02:08:33 -06:00

cmd/internal/obj, cmd/asm: get rid of obj.ADATA

Just recognize "DATA" as a special pseudo op word in the assembler
directly.

Change-Id: I508e111fd71f561efa600ad69567a7089a57adb2
Reviewed-on: https://go-review.googlesource.com/20648
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Matthew Dempsky 2016-03-13 15:44:00 -07:00
parent edde955d7f
commit 2dcbbbd193
5 changed files with 15 additions and 29 deletions

View File

@ -44,14 +44,6 @@ func nilRegisterNumber(name string, n int16) (int16, bool) {
return 0, false return 0, false
} }
var Pseudos = map[string]obj.As{
"DATA": obj.ADATA,
"FUNCDATA": obj.AFUNCDATA,
"GLOBL": obj.AGLOBL,
"PCDATA": obj.APCDATA,
"TEXT": obj.ATEXT,
}
// Set configures the architecture specified by GOARCH and returns its representation. // Set configures the architecture specified by GOARCH and returns its representation.
// It returns nil if GOARCH is not recognized. // It returns nil if GOARCH is not recognized.
func Set(GOARCH string) *Arch { func Set(GOARCH string) *Arch {

View File

@ -183,12 +183,10 @@ func (p *Parser) line() bool {
p.errorf("missing operand") p.errorf("missing operand")
} }
} }
i, present := arch.Pseudos[word] if p.pseudo(word, operands) {
if present {
p.pseudo(i, word, operands)
return true return true
} }
i, present = p.arch.Instructions[word] i, present := p.arch.Instructions[word]
if present { if present {
p.instruction(i, word, cond, operands) p.instruction(i, word, cond, operands)
return true return true
@ -214,21 +212,22 @@ func (p *Parser) instruction(op obj.As, word, cond string, operands [][]lex.Toke
p.asmInstruction(op, cond, p.addr) p.asmInstruction(op, cond, p.addr)
} }
func (p *Parser) pseudo(op obj.As, word string, operands [][]lex.Token) { func (p *Parser) pseudo(word string, operands [][]lex.Token) bool {
switch op { switch word {
case obj.ATEXT: case "DATA":
p.asmText(word, operands)
case obj.ADATA:
p.asmData(word, operands) p.asmData(word, operands)
case obj.AGLOBL: case "FUNCDATA":
p.asmGlobl(word, operands)
case obj.APCDATA:
p.asmPCData(word, operands)
case obj.AFUNCDATA:
p.asmFuncData(word, operands) p.asmFuncData(word, operands)
case "GLOBL":
p.asmGlobl(word, operands)
case "PCDATA":
p.asmPCData(word, operands)
case "TEXT":
p.asmText(word, operands)
default: default:
p.errorf("unimplemented: %s", word) return false
} }
return true
} }
func (p *Parser) start(operand []lex.Token) { func (p *Parser) start(operand []lex.Token) {

View File

@ -9,7 +9,6 @@ import (
"strings" "strings"
"testing" "testing"
"cmd/asm/internal/arch"
"cmd/asm/internal/lex" "cmd/asm/internal/lex"
) )
@ -58,11 +57,9 @@ func TestErroneous(t *testing.T) {
parser.errorCount = 0 parser.errorCount = 0
parser.lineNum++ parser.lineNum++
parser.histLineNum++ parser.histLineNum++
op, ok := arch.Pseudos[test.pseudo] if !parser.pseudo(test.pseudo, tokenize(test.operands)) {
if !ok {
t.Fatalf("Wrong pseudo-instruction: %s", test.pseudo) t.Fatalf("Wrong pseudo-instruction: %s", test.pseudo)
} }
parser.pseudo(op, test.pseudo, tokenize(test.operands))
errorLine := buf.String() errorLine := buf.String()
if test.expected != errorLine { if test.expected != errorLine {
t.Errorf("Unexpected error %q; expected %q", errorLine, test.expected) t.Errorf("Unexpected error %q; expected %q", errorLine, test.expected)

View File

@ -266,7 +266,6 @@ const (
AXXX As = iota AXXX As = iota
ACALL ACALL
ACHECKNIL ACHECKNIL
ADATA // used only by the assembler for parsing
ADUFFCOPY ADUFFCOPY
ADUFFZERO ADUFFZERO
AEND AEND

View File

@ -603,7 +603,6 @@ var Anames = []string{
"XXX", "XXX",
"CALL", "CALL",
"CHECKNIL", "CHECKNIL",
"DATA",
"DUFFCOPY", "DUFFCOPY",
"DUFFZERO", "DUFFZERO",
"END", "END",