all: gofmt format Change-Id: Iaea9ce0d3b237123cdb4315790960aeee1b13a80 Reviewed-on: https://go-review.googlesource.com/c/arch/+/520577 Run-TryBot: shuang cui <imcusg@gmail.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
diff --git a/arm/armasm/plan9x.go b/arm/armasm/plan9x.go index a143d2e..842ab98 100644 --- a/arm/armasm/plan9x.go +++ b/arm/armasm/plan9x.go
@@ -253,10 +253,13 @@ // [r2, r0, ror #1] -> (R2)(R0@>1) // inst [r2, -r0, ror #1] -> INST.U (R2)(R0@>1) // input: -// a memory operand +// +// a memory operand +// // return values: -// corresponding memory operand in Plan 9 syntax -// .W/.P/.U suffix +// +// corresponding memory operand in Plan 9 syntax +// .W/.P/.U suffix func memOpTrans(mem Mem) (string, string) { suffix := "" switch mem.Mode {
diff --git a/arm/armmap/map.go b/arm/armmap/map.go index f505305..3e8f307 100644 --- a/arm/armmap/map.go +++ b/arm/armmap/map.go
@@ -5,12 +5,13 @@ // Armmap constructs the ARM opcode map from the instruction set CSV file. // // Usage: +// // armmap [-fmt=format] arm.csv // // The known output formats are: // -// text (default) - print decoding tree in text form -// decoder - print decoding tables for the armasm package +// text (default) - print decoding tree in text form +// decoder - print decoding tables for the armasm package package main import (
diff --git a/arm/armspec/spec.go b/arm/armspec/spec.go index f5bad80..108f7ed 100644 --- a/arm/armspec/spec.go +++ b/arm/armspec/spec.go
@@ -8,15 +8,14 @@ // ... see golang.org/issue/12840 -// Armspec reads the ``ARM Architecture Reference Manual'' +// Armspec reads the “ARM Architecture Reference Manual” // to collect instruction encoding details and writes those details to standard output // in JSON format. // -// Warning Warning Warning +// # Warning Warning Warning // // This program is unfinished. It is being published in this incomplete form // for interested readers, but do not expect it to be runnable or useful. -// package main import ( @@ -606,10 +605,10 @@ } var jsFix = strings.NewReplacer( -// `\u003c`, `<`, -// `\u003e`, `>`, -// `\u0026`, `&`, -// `\u0009`, `\t`, +// `\u003c`, `<`, +// `\u003e`, `>`, +// `\u0026`, `&`, +// `\u0009`, `\t`, ) func printTable(name string, table []Inst) {
diff --git a/arm64/arm64asm/inst.go b/arm64/arm64asm/inst.go index 8c633fe..866e399 100644 --- a/arm64/arm64asm/inst.go +++ b/arm64/arm64asm/inst.go
@@ -934,8 +934,10 @@ return result } -// Register with arrangement and index: <Vm>.<Ts>[<index>], -// { <Vt>.B, <Vt2>.B }[<index>]. +// Register with arrangement and index: +// +// <Vm>.<Ts>[<index>], +// { <Vt>.B, <Vt2>.B }[<index>]. type RegisterWithArrangementAndIndex struct { r Reg a Arrangement
diff --git a/ppc64/ppc64asm/gnu.go b/ppc64/ppc64asm/gnu.go index b4c9bf8..367acdd 100644 --- a/ppc64/ppc64asm/gnu.go +++ b/ppc64/ppc64asm/gnu.go
@@ -359,7 +359,7 @@ // gnuArg formats arg (which is the argIndex's arg in inst) according to GNU rules. // NOTE: because GNUSyntax is the only caller of this func, and it receives a copy -// of inst, it's ok to modify inst.Args here. +// of inst, it's ok to modify inst.Args here. func gnuArg(inst *Inst, argIndex int, arg Arg, pc uint64) string { // special cases for load/store instructions if _, ok := arg.(Offset); ok {
diff --git a/ppc64/ppc64spec/spec.go b/ppc64/ppc64spec/spec.go index 54e0535..55cb275 100644 --- a/ppc64/ppc64spec/spec.go +++ b/ppc64/ppc64spec/spec.go
@@ -5,11 +5,12 @@ //go:build (go1.6 && amd64) || go1.8 // +build go1.6,amd64 go1.8 -// Power64spec reads the ``Power ISA V2.07'' Manual +// Power64spec reads the “Power ISA V2.07” Manual // to collect instruction encoding details and writes those details to standard output // in CSV format. // // Usage: +// // ppc64spec PowerISA_V2.07_PUBLIC.pdf >ppc64.csv // // Each CSV line contains four fields: @@ -24,7 +25,6 @@ // For now, empty. // // For more on the exact meaning of these fields, see the Power manual. -// package main import ( @@ -495,10 +495,10 @@ } var jsFix = strings.NewReplacer( -// `\u003c`, `<`, -// `\u003e`, `>`, -// `\u0026`, `&`, -// `\u0009`, `\t`, +// `\u003c`, `<`, +// `\u003e`, `>`, +// `\u0026`, `&`, +// `\u0009`, `\t`, ) func printTable(name string, table []Inst) {
diff --git a/x86/x86asm/gnu.go b/x86/x86asm/gnu.go index 75cff72..8eba1fd 100644 --- a/x86/x86asm/gnu.go +++ b/x86/x86asm/gnu.go
@@ -10,7 +10,7 @@ ) // GNUSyntax returns the GNU assembler syntax for the instruction, as defined by GNU binutils. -// This general form is often called ``AT&T syntax'' as a reference to AT&T System V Unix. +// This general form is often called “AT&T syntax” as a reference to AT&T System V Unix. func GNUSyntax(inst Inst, pc uint64, symname SymLookup) string { // Rewrite instruction to mimic GNU peculiarities. // Note that inst has been passed by value and contains
diff --git a/x86/x86asm/inst.go b/x86/x86asm/inst.go index 4632b50..e98f1a8 100644 --- a/x86/x86asm/inst.go +++ b/x86/x86asm/inst.go
@@ -144,7 +144,7 @@ // the interface value instead of requiring an allocation. // A Reg is a single register. -// The zero Reg value has no name but indicates ``no register.'' +// The zero Reg value has no name but indicates “no register.” type Reg uint8 const (
diff --git a/x86/x86avxgen/generate.go b/x86/x86avxgen/generate.go index 14985cb..da7fd31 100644 --- a/x86/x86avxgen/generate.go +++ b/x86/x86avxgen/generate.go
@@ -230,8 +230,8 @@ // // This is required due to how masking is implemented in asm6. // Single MASK1() instruction produces 2 ytabs, for example: -// 1. OP xmm, mem | Yxr, Yxm | Does not permit K arguments (K0 implied) -// 2. OP xmm, K2, mem | Yxr, Yknot0, Yxm | Does not permit K0 argument +// 1. OP xmm, mem | Yxr, Yxm | Does not permit K arguments (K0 implied) +// 2. OP xmm, K2, mem | Yxr, Yknot0, Yxm | Does not permit K0 argument // // This function also exploits that both ytab entries have same opbytes, // hence it is efficient to emit only one opbytes line and 0 Z-offset
diff --git a/x86/x86avxgen/main.go b/x86/x86avxgen/main.go index 9fdf262..b759c50 100644 --- a/x86/x86avxgen/main.go +++ b/x86/x86avxgen/main.go
@@ -224,16 +224,16 @@ // elements order inside ytabList. // // We want these rules to be satisfied: -// - EVEX-encoded entries go after VEX-encoded entries. -// This way, VEX forms are selected over EVEX variants. -// - EVEX forms with SAE/RC must go before forms without them. -// This helps to avoid problems with reg-reg instructions -// that encode either of them in ModRM.R/M which causes -// ambiguity in ytabList (more than 1 ytab can match args). -// If first matching ytab has SAE/RC, problem will not occur. -// - Memory argument position affects order. -// Required to be in sync with XED encoder when there -// are multiple choices of how to encode instruction. +// - EVEX-encoded entries go after VEX-encoded entries. +// This way, VEX forms are selected over EVEX variants. +// - EVEX forms with SAE/RC must go before forms without them. +// This helps to avoid problems with reg-reg instructions +// that encode either of them in ModRM.R/M which causes +// ambiguity in ytabList (more than 1 ytab can match args). +// If first matching ytab has SAE/RC, problem will not occur. +// - Memory argument position affects order. +// Required to be in sync with XED encoder when there +// are multiple choices of how to encode instruction. func sortGroups(ctx *context) { sort.SliceStable(ctx.groups, func(i, j int) bool { return ctx.groups[i].opcode < ctx.groups[j].opcode
diff --git a/x86/x86csv/x86csv.go b/x86/x86csv/x86csv.go index e205c1b..6f6b68c 100644 --- a/x86/x86csv/x86csv.go +++ b/x86/x86csv/x86csv.go
@@ -6,7 +6,7 @@ // Only latest version of "x86.csv" format is supported. // // Terminology: -// given "OPCODE [ARGS...]" line; +// given "OPCODE [ARGS...]" line; // Opcode - instruction name/mnemonic/class. // Args - instruction operands. // Syntax - Opcode with Args.
diff --git a/x86/x86map/map.go b/x86/x86map/map.go index df8c68e..9d45a70 100644 --- a/x86/x86map/map.go +++ b/x86/x86map/map.go
@@ -5,13 +5,14 @@ // X86map constructs the x86 opcode map from the instruction set CSV file. // // Usage: +// // x86map [-fmt=format] x86.csv // // The known output formats are: // -// text (default) - print decoding tree in text form -// decoder - print decoding tables for the x86asm package -// scanner - print scanning tables for x86scan package +// text (default) - print decoding tree in text form +// decoder - print decoding tables for the x86asm package +// scanner - print scanning tables for x86scan package package main import (
diff --git a/x86/x86spec/spec.go b/x86/x86spec/spec.go index 2526794..57f3276 100644 --- a/x86/x86spec/spec.go +++ b/x86/x86spec/spec.go
@@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// X86spec reads the ``Intel® 64 and IA-32 Architectures Software Developer's Manual'' +// X86spec reads the “Intel® 64 and IA-32 Architectures Software Developer's Manual” // to collect instruction encoding details and writes those details to standard output // in CSV format. // @@ -20,7 +20,7 @@ // // There are additional debugging flags, not shown. Run x86spec -help for the list. // -// File Format +// # File Format // // TODO: Mention comments at top of file. // TODO: Mention that this is version 0.2 of the file. @@ -59,7 +59,7 @@ // // "SHR r/m32, imm8","SHRL imm8, r/m32","shrl imm8, r/m32","C1 /5 ib","V","V","","operand32","rw,r","Y","32" // -// Mnemonics +// # Mnemonics // // The instruction mnemonics are as used in the Intel manual, with a few exceptions. // @@ -109,7 +109,7 @@ // moffs8, moffs16, moffs32, moffs64, vm32x, vm32y, vm64x, and vm64y // are all as in the Intel manual. // -// Encodings +// # Encodings // // The encodings are also as used in the Intel manual, with automated corrections. // For example, the Intel manual sometimes omits the modrm /r indicator or other trailing bytes, @@ -118,7 +118,7 @@ // tools for processing x86 machine code. // See https://golang.org/x/arch/x86/x86map for one such generator. // -// Valid32 and Valid64 +// # Valid32 and Valid64 // // These columns hold validity abbreviations as defined in the Intel manual: // V, I, N.E., N.P., N.S., or N.I. @@ -128,7 +128,7 @@ // For example, the manual lists many instruction forms using REX bytes // with an incorrect "V" in the Valid32 column. // -// CPUID Feature Flags +// # CPUID Feature Flags // // This column specifies CPUID feature flags that must be present in order // to use the instruction. If multiple flags are required, @@ -136,7 +136,7 @@ // The column can also list one of the values 486, Pentium, PentiumII, and P6, // indicating that the instruction was introduced on that architecture version. // -// Tags +// # Tags // // The tag column does not correspond to a traditional column in the Intel manual tables. // Instead, it is itself a comma-separated list of tags or hints derived by analysis @@ -169,7 +169,7 @@ // Since most decoders will handle the REX byte separately, the form with the // unnecessary REX is tagged pseudo64. // -// Corrections and Additions +// # Corrections and Additions // // The x86spec program makes various corrections to the Intel manual data // as part of extracting the information. Those corrections are described above. @@ -177,7 +177,7 @@ // The x86spec program also adds a few well-known undocumented instructions, // such as UD1 and FFREEP. // -// Examples +// # Examples // // The latest version of the CSV file is available in this Git repository and also // online at https://golang.org/s/x86.csv. It is meant to be human-readable for @@ -193,7 +193,6 @@ // reads the CSV file and generates an x86 instruction decoder in the form // of a simple byte-code program. This decoder is the core of the disassembler // in the x86asm package (https://golang.org/x/arch/x86/x86asm). -// package main import (
diff --git a/x86/xeddata/database.go b/x86/xeddata/database.go index 35d86d9..94d21de 100644 --- a/x86/xeddata/database.go +++ b/x86/xeddata/database.go
@@ -104,9 +104,11 @@ // parsing of found file is. // // Lookup: +// // "$xedPath/all-state.txt" => db.LoadStates() // "$xedPath/all-widths.txt" => db.LoadWidths() // "$xedPath/all-element-types.txt" => db.LoadXtypes() +// // $xedPath is the interpolated value of function argument. // // The call NewDatabase("") is valid and returns empty database.
diff --git a/x86/xeddata/doc.go b/x86/xeddata/doc.go index bb1a96a..23d51dc 100644 --- a/x86/xeddata/doc.go +++ b/x86/xeddata/doc.go
@@ -5,17 +5,18 @@ // Package xeddata provides utilities to work with XED datafiles. // // Main features: -// * Fundamental XED enumerations (CPU modes, operand sizes, ...) -// * XED objects and their components -// * XED datafiles reader (see below) -// * Utility functions like ExpandStates +// - Fundamental XED enumerations (CPU modes, operand sizes, ...) +// - XED objects and their components +// - XED datafiles reader (see below) +// - Utility functions like ExpandStates // // The amount of file formats that is understood is a minimal // set required to generate x86.csv from XED tables: -// * states - simple macro substitutions used in patterns -// * widths - mappings from width names to their size -// * element-types - XED xtype information -// * objects - XED objects that constitute "the tables" +// - states - simple macro substitutions used in patterns +// - widths - mappings from width names to their size +// - element-types - XED xtype information +// - objects - XED objects that constitute "the tables" +// // Collectively, those files are called "datafiles". // // Terminology is borrowed from XED itself, @@ -26,9 +27,9 @@ // file under local XED source repository folder. // // The default usage scheme: -// 1. Open "XED database" to load required metadata. -// 2. Read XED file with objects definitions. -// 3. Operate on XED objects. +// 1. Open "XED database" to load required metadata. +// 2. Read XED file with objects definitions. +// 3. Operate on XED objects. // // See example_test.go for complete examples. //
diff --git a/x86/xeddata/reader.go b/x86/xeddata/reader.go index 4176b66..fc8aa94 100644 --- a/x86/xeddata/reader.go +++ b/x86/xeddata/reader.go
@@ -92,6 +92,7 @@ // It expects lines that are joined by '\' to be concatenated. // // The format can be described as: +// // unquoted field name "[A-Z_]+" (captured) // field value delimiter ":" // field value string (captured)