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>
This commit is contained in:
Родитель
060bf14d30
Коммит
b6e875325b
|
@ -253,10 +253,13 @@ func plan9Arg(inst *Inst, pc uint64, symname func(uint64) (string, uint64), arg
|
|||
// [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 {
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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 @@ func sameFont(f1, f2 string) bool {
|
|||
}
|
||||
|
||||
var jsFix = strings.NewReplacer(
|
||||
// `\u003c`, `<`,
|
||||
// `\u003e`, `>`,
|
||||
// `\u0026`, `&`,
|
||||
// `\u0009`, `\t`,
|
||||
// `\u003c`, `<`,
|
||||
// `\u003e`, `>`,
|
||||
// `\u0026`, `&`,
|
||||
// `\u0009`, `\t`,
|
||||
)
|
||||
|
||||
func printTable(name string, table []Inst) {
|
||||
|
|
|
@ -934,8 +934,10 @@ func (r RegisterWithArrangement) String() string {
|
|||
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
|
||||
|
|
|
@ -359,7 +359,7 @@ func GNUSyntax(inst Inst, pc uint64) string {
|
|||
|
||||
// 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 {
|
||||
|
|
|
@ -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 @@ func sameFont(f1, f2 string) bool {
|
|||
}
|
||||
|
||||
var jsFix = strings.NewReplacer(
|
||||
// `\u003c`, `<`,
|
||||
// `\u003e`, `>`,
|
||||
// `\u0026`, `&`,
|
||||
// `\u0009`, `\t`,
|
||||
// `\u003c`, `<`,
|
||||
// `\u003e`, `>`,
|
||||
// `\u0026`, `&`,
|
||||
// `\u0009`, `\t`,
|
||||
)
|
||||
|
||||
func printTable(name string, table []Inst) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
// 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
|
||||
|
|
|
@ -144,7 +144,7 @@ type Arg interface {
|
|||
// 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 (
|
||||
|
|
|
@ -230,8 +230,8 @@ func (gen *generator) makeYtab(zoffset int, zform string, args []*argument) ytab
|
|||
//
|
||||
// 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
|
||||
|
|
|
@ -224,16 +224,16 @@ func assignZforms(ctx *context) {
|
|||
// 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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -104,9 +104,11 @@ type xtype struct {
|
|||
// 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.
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -92,6 +92,7 @@ func (r *Reader) ReadAll() ([]*Object, error) {
|
|||
// 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)
|
||||
|
|
Загрузка…
Ссылка в новой задаче