x86/x86csv: s/Inst.Size/Inst.DataSize/, add Inst.HasTag method

Fix bad field name and add new method that is going to be used
in XED-based x86spec generator.

Change-Id: I7932e095f74a3354402b566a3f750b25b7bb7def
Reviewed-on: https://go-review.googlesource.com/104475
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/x86/x86csv/reader.go b/x86/x86csv/reader.go
index 9d4d9df..ed59e31 100644
--- a/x86/x86csv/reader.go
+++ b/x86/x86csv/reader.go
@@ -63,7 +63,7 @@
 		Tags:      cols[7],
 		Action:    cols[8],
 		Multisize: cols[9],
-		Size:      cols[10],
+		DataSize:  cols[10],
 	}
 	return inst, nil
 }
diff --git a/x86/x86csv/x86csv.go b/x86/x86csv/x86csv.go
index 14d5e5c..e205c1b 100644
--- a/x86/x86csv/x86csv.go
+++ b/x86/x86csv/x86csv.go
@@ -53,8 +53,8 @@
 	// operand size, like most arithmetic instructions ("" or "Y").
 	Multisize string
 
-	// Size of the data operation in bits ("8" for MOVB, "16" for MOVW, and so on)
-	Size string
+	// DataSize is the size of the data operation in bits ("8" for MOVB, "16" for MOVW, and so on).
+	DataSize string
 }
 
 // IntelOpcode returns the opcode in the Intel syntax.
@@ -75,6 +75,19 @@
 // GNUArgs returns the arguments in GNU binutils (mostly AT&T) syntax.
 func (inst *Inst) GNUArgs() []string { return instArgs(inst.GNU) }
 
+// HasTag reports whether inst tag list contains the specified tag.
+func (inst *Inst) HasTag(tag string) bool {
+	i := strings.Index(inst.Tags, tag)
+	if i == -1 {
+		return false
+	}
+	leftOK := i == 0 ||
+		(inst.Tags[i-1] == ',')
+	rigthOK := i+len(tag) == len(inst.Tags) ||
+		(inst.Tags[i+len(tag)] == ',')
+	return leftOK && rigthOK
+}
+
 // instOpcode returns the opcode from an instruction syntax.
 func instOpcode(syntax string) string {
 	i := strings.Index(syntax, " ")
diff --git a/x86/x86csv/x86csv_test.go b/x86/x86csv/x86csv_test.go
index 2793f13..55487c1 100644
--- a/x86/x86csv/x86csv_test.go
+++ b/x86/x86csv/x86csv_test.go
@@ -51,7 +51,7 @@
 			Tags:      "pseudo64",
 			Action:    "rw,r",
 			Multisize: "Y",
-			Size:      "8",
+			DataSize:  "8",
 		},
 	}