]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj, cmd/asm: get rid of obj.ADATA
authorMatthew Dempsky <mdempsky@google.com>
Sun, 13 Mar 2016 22:44:00 +0000 (15:44 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Mon, 14 Mar 2016 05:13:47 +0000 (05:13 +0000)
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>
src/cmd/asm/internal/arch/arch.go
src/cmd/asm/internal/asm/parse.go
src/cmd/asm/internal/asm/pseudo_test.go
src/cmd/internal/obj/link.go
src/cmd/internal/obj/util.go

index bff9177675e84033df8e1bdaea62a7925b0d5d69..6159ede6c56594204fc0eae47549a00658199634 100644 (file)
@@ -44,14 +44,6 @@ func nilRegisterNumber(name string, n int16) (int16, bool) {
        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.
 // It returns nil if GOARCH is not recognized.
 func Set(GOARCH string) *Arch {
index f4f204b2d37ecdd890621c5aa621e1f61e9d2b74..ee374399620625fe441a454001a6d2c36482a4ea 100644 (file)
@@ -183,12 +183,10 @@ func (p *Parser) line() bool {
                        p.errorf("missing operand")
                }
        }
-       i, present := arch.Pseudos[word]
-       if present {
-               p.pseudo(i, word, operands)
+       if p.pseudo(word, operands) {
                return true
        }
-       i, present = p.arch.Instructions[word]
+       i, present := p.arch.Instructions[word]
        if present {
                p.instruction(i, word, cond, operands)
                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)
 }
 
-func (p *Parser) pseudo(op obj.As, word string, operands [][]lex.Token) {
-       switch op {
-       case obj.ATEXT:
-               p.asmText(word, operands)
-       case obj.ADATA:
+func (p *Parser) pseudo(word string, operands [][]lex.Token) bool {
+       switch word {
+       case "DATA":
                p.asmData(word, operands)
-       case obj.AGLOBL:
+       case "FUNCDATA":
+               p.asmFuncData(word, operands)
+       case "GLOBL":
                p.asmGlobl(word, operands)
-       case obj.APCDATA:
+       case "PCDATA":
                p.asmPCData(word, operands)
-       case obj.AFUNCDATA:
-               p.asmFuncData(word, operands)
+       case "TEXT":
+               p.asmText(word, operands)
        default:
-               p.errorf("unimplemented: %s", word)
+               return false
        }
+       return true
 }
 
 func (p *Parser) start(operand []lex.Token) {
index 2e6d6c8154f327225cceb9610945102ac671cfef..16979730e939bc95381cad42ea6513a6055b6cef 100644 (file)
@@ -9,7 +9,6 @@ import (
        "strings"
        "testing"
 
-       "cmd/asm/internal/arch"
        "cmd/asm/internal/lex"
 )
 
@@ -58,11 +57,9 @@ func TestErroneous(t *testing.T) {
                parser.errorCount = 0
                parser.lineNum++
                parser.histLineNum++
-               op, ok := arch.Pseudos[test.pseudo]
-               if !ok {
+               if !parser.pseudo(test.pseudo, tokenize(test.operands)) {
                        t.Fatalf("Wrong pseudo-instruction: %s", test.pseudo)
                }
-               parser.pseudo(op, test.pseudo, tokenize(test.operands))
                errorLine := buf.String()
                if test.expected != errorLine {
                        t.Errorf("Unexpected error %q; expected %q", errorLine, test.expected)
index cfd4c736751829aba6dd02a13cbaa6a54baf1e15..430fab3b3e6a7581ca8823ebfc10ef13c58ccc09 100644 (file)
@@ -266,7 +266,6 @@ const (
        AXXX As = iota
        ACALL
        ACHECKNIL
-       ADATA // used only by the assembler for parsing
        ADUFFCOPY
        ADUFFZERO
        AEND
index 05cfd8c720935ab96b870a3772470a897511c5f7..18450962edacd001f0c79be3ae5ba4d1e5070f2b 100644 (file)
@@ -603,7 +603,6 @@ var Anames = []string{
        "XXX",
        "CALL",
        "CHECKNIL",
-       "DATA",
        "DUFFCOPY",
        "DUFFZERO",
        "END",