Граф коммитов

39 Коммитов

Автор SHA1 Сообщение Дата
Dmitri Shuralyov 05c9512268 all: update go directive to 1.18
Done with:

go get go@1.18
go mod tidy
go fix ./...

Using go1.21.3.

Also delete the build constraints that are always satisfied
when using supported Go versions.

For golang/go#60268.

Change-Id: Iab4a7237a368b1ac05bb72a646501defb51503f1
Reviewed-on: https://go-review.googlesource.com/c/arch/+/534197
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2023-10-10 23:22:25 +00:00
cui fliter b6e875325b 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>
2023-08-21 18:18:40 +00:00
cui fliter 40c19ba4a7 all: fix some comments
Change-Id: Ic196f7a97e423708d0a86ff8da99871e966dc2fc
Reviewed-on: https://go-review.googlesource.com/c/arch/+/466000
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-08 14:50:55 +00:00
Paul E. Murphy 1bb480fc25 ppc64/ppc64asm: add ISA 3.1B support
The new ISA fixes a couple typos, and adds special hashing
instructions to support ROP exploitation.

The hash instructions encode a negative offset in a novel
way which requires a bit of special handling.

Change-Id: I9491e10ac87efe37d93b6efaf7f108ae3a4402fd
Reviewed-on: https://go-review.googlesource.com/c/arch/+/418859
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-11-16 20:18:07 +00:00
cui fliter e1262b008e all: remove redundant type conversion
Change-Id: I1bff578bdcacac6ea471ed9effb9d9ade573d813
GitHub-Last-Rev: 43904f8dd8
GitHub-Pull-Request: golang/arch#6
Reviewed-on: https://go-review.googlesource.com/c/arch/+/428983
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-11-09 15:34:24 +00:00
Paul E. Murphy 6a65923eb7 ppc64/ppc64asm: improve PCrel argument decoding
If an object is built for PIE, CALL opcodes will target the symbol's
local entry point. When disassembling, we should print the symbol
name if the target is the symbol+8.

The local entry offset on PPC64 is almost always 0 or 8. For pure go,
it is always 0 or 8 today.

If a call looks like it targets a local entry, print it as
"CALL symbol+8(SB)".

Change-Id: I72a2f1eaafd226ed5466384c63040d2f375a541f
Reviewed-on: https://go-review.googlesource.com/c/arch/+/432166
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-27 17:28:34 +00:00
Paul E. Murphy 2926576b28 ppc64/ppc64asm: fix decoding of several CC opcodes
A few of them decoded to invalid plan9 opcodes, and
some did not swap there input arguments similar to
their non-CC variants.

Change-Id: I26b2b4e318891a75d9c4973bb88efaff8b188bbf
Reviewed-on: https://go-review.googlesource.com/c/arch/+/431475
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-19 18:30:40 +00:00
Paul E. Murphy 44deed0493 ppc64/ppc64map: add encoder functionality
Use the ISA information to generate bits for supporting ISA 3.1
(POWER10) instructions. This creates a new file asm9_gtables.go
to allow assembly of instructions defined in pp64.csv.

This uses the input pp64.csv file to generate an encoding function
for each "type" of instruction. Some encoder functions can be
shared (e.x fpr/gpr/vsr opcodes which share similar encoding). These
are named based on the oldest instruction which uses the function,
like "type_xxspltiw".

All functions share two tables which store the fixed bits of an
instruction. Non-prefixed instructions use GenOpcodes exclusively,
prefixed opcodes use the GenPfxOpcodes table to hold the suffix
instruction word bits. These are used to populate the instruction
specific encoding bits for a particular type.

Likewise, the function opsetGen is created to map opcodes which share
identical argument types. This plugs into the buildop function in
asm9.go.

Change-Id: I50cddfcec86b667774af858fb8efe8910dfe80b8
Reviewed-on: https://go-review.googlesource.com/c/arch/+/350609
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-15 21:17:55 +00:00
Paul E. Murphy ada1728ceb ppc64/ppc64asm,ppc64map: fix BHRBE argument translation
BHRBE stands for "branch history rolling buffer entry". This is not
an SPR. Treat it as an unsigned immediate type argument.

Similarly, DCRN, SR, TMR, PMRN fields are no longer present in ISA 3.1,
they can be removed and nearby code simplified.

Fix ppc64map and update tables.go.

Change-Id: Ie779d24ae9d24541db6565ea169be0d80b893ff8
Reviewed-on: https://go-review.googlesource.com/c/arch/+/418858
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
2022-08-23 14:41:27 +00:00
Paul E. Murphy 13eedde411 ppc64/ppc64asm: fix objdump tests
In short, these tests create an object file from a list of opcodes,
and expect objdump to generate exactly as many decoded opcodes.

Unfortunately, objdump generates two opcode entries for each invalid
prefixed instruction, which causes the the testing code to deadlock
itself.

For example, objdump decodes an invalid form of paddi like:

    .long ...
    addi ...

instead of something like:

    .quadword ...

Work around this by examing the primary opcode of any entry which
objdump reports as ".long", and skip over the next word if the
primary opcode is "1" (the prefix opcode). The test skips over
".long" entries, so it will continue to work as expected.

Change-Id: I9dd0fda10683f666aace4140b63e81fc0fea2ad0
Reviewed-on: https://go-review.googlesource.com/c/arch/+/418857
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-18 19:34:41 +00:00
Dan Kortschak fc48f9fe4c ppc64,x86: fix code generation notice
Change-Id: I6de117af0ae5f9ccb0dbecad53bebf6241a13e38
Reviewed-on: https://go-review.googlesource.com/c/arch/+/399274
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-04-12 00:13:46 +00:00
Paul E. Murphy 6544aa4a77 ppc64asm: don't print invalid encodings of pst*/pl*/paddi insn
Change-Id: I5a01b89c96eba94f0eac3d4db65f98d0c2fc1166
Reviewed-on: https://go-review.googlesource.com/c/arch/+/347570
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-09-17 15:17:45 +00:00
Paul E. Murphy 5e4c51d3ff ppc64asm: fix plan9 style decoding issues
This reworks the decoding of CR bit fields to correctly decode the
fcmp/cmp/setbc families of instructions.

Comparison instructions always produce a result in a CR field, thus
it should be listed last if not implied to be CR0.

Furthermore, remove the context sensitive decoding of CR field and
CR bit type arguments from plan9Arg. These edge cases are better
handled during the per-instruction combining of decoded arguments.
This allows setbc like instructions to decode correctly without
special handling.

Change-Id: I264a600034b5abb8901b0c2e6bffe2887200ac27
Reviewed-on: https://go-review.googlesource.com/c/arch/+/347569
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Cherry Mui <cherryyz@google.com>
2021-09-17 15:14:18 +00:00
Paul E. Murphy ebb09ed340 ppc64: add ISA level information to pp64.csv
Re-purpose the metadata field to hold the ISA level. This
field is currently unused.

Note, lq/stq/scv/rfscv appear out-of-order in appendix
F of ISA 3.1.

Change-Id: I96211bf75305a29c0805d95489eee132444d919c
Reviewed-on: https://go-review.googlesource.com/c/arch/+/342969
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-09-01 14:30:47 +00:00
Paul E. Murphy 4d4a2a2eb4 ppc64asm,ppc64map: enable prefixed insn decoding support
ISA 3.1 introduces prefixed instructions. These are 64b
instructions which look like 2 consecutive instructions.
These allow 34 bit constant displancements and PC-relative
addressing. When decoded into an Inst structure, we place
the prefix inside the Enc field. The prefix opcode is unique,
and thus cannot be confused with any existing ISA 3.1
instruction. The second instruction word (the "suffix") is
placed into a new field named SuffixEnc.

Rework the decoder table to use 64 bit instruction sizes, and
shift the regular instructions into the upper 32 bits.

Likewise, extend bitfield parsing to support 2 words and
aggregate values beyond 32 bits (prefixed add and load
generate 34 bit constants/displacements).

Likewise, support nop extended mnemonic. These show
up when fixing prefixed instructions to avoid crossing
a 64B boundary. This happens in the generated decoding
test cases.

Likewise, handle pcrel and prefixed load address extended
mnemonics to match objdump.

Finally, fix some broken documentation propagated from
the parser generation. YMSK should only be the upper two
bits of the field described as 4 bits. These fixups have
been backported to the ISA parser tool.

Change-Id: I21e311f93014cf176f3f6b155849a7359af54763
Reviewed-on: https://go-review.googlesource.com/c/arch/+/307353
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-27 11:49:10 +00:00
Paul E. Murphy 8ee3ab241e ppc64asm,ppc64map: enable parsing of prefixed ISA 3.1 insn entries
ppc64map is modified to store a second set of Mask/Value/DontCare
fields in its internal Inst structure.  The existing fields are
used to store the prefix, and the newly added fields store similar
information about the second instruction word. It is worth noting
that prefixed instructions are 64 bits long, but are encoded like
a pair of regular (32 bit) instructions.

This requires some refactoring of ppc64map to support decoding fields
from the second instruction word.  To do this, we add a Word field
as needed to indicate the instruction word (0 == prefix, 1 == suffix),
and field names are updated to reflect bit positions as if such insn
extended to 64 bits.

All prefixed instructions share the same primary opcode, so the
decode logic will need to be updated in a subsequent patch to choose
the correct prefixed instruction when decoding.

Note, that while enabling prefix support, a few ISA bugs were found
and reported. YMSK should be 2 bits, not 4. Likewise, the nop
extended mnemonic is added as it shows up more frequently when
prefixed instructions need to be moved to avoid crossing a 64B
boundary.

Change-Id: I8fd43bbd05738e8d70267efed447022c36c4616f
Reviewed-on: https://go-review.googlesource.com/c/arch/+/307352
Run-TryBot: Carlos Eduardo Seo <carlos.seo@linaro.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-04-22 03:13:29 +00:00
Paul E. Murphy 08b684f594 ppc64asm: cleanup pp64.csv and regenerate tables.go
This is now in ISA 3.1 appendix F, ISA version ordering, and
disabled instruction forms are removed (that is, SPR/VLE/TX
instructions).

pp64.csv is now in the form directly exported by the ISA
3.1 scraping tool.

Change-Id: I51f52544800db3098947a4de15bdf5a9251414e0
Reviewed-on: https://go-review.googlesource.com/c/arch/+/306593
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-05 15:43:55 +00:00
Paul E. Murphy cd4b3ce7f7 ppc64asm: remove duplicate entries in ppc64.csv
The sort+append of isa31 did not remove duplicate entries.

There are 17 such duplications, notably, mtspr showed up 3 times.

Change-Id: Ie95c6e87412edceace368879cf124f9cd9800e70
Reviewed-on: https://go-review.googlesource.com/c/arch/+/304409
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-04-01 20:39:52 +00:00
Paul E. Murphy d48d9c4a19 ppc64asm,ppc64map: update for ISA 3.1
Likewise, add all missing ISA 3.0 instructions.

This table is generated in a two-step process.

1. Parse ISA 3.1 Appendix F.
2. Scan ISA for descriptions
3. Sort to match old ISA (and check for bugs)
   and append new insn to bottom

A second patch will reformat these instructions into
a sorting order of the ISA 3.1 appendix F, that is
by version then alphabetically. This intermediate
patch ensures we don't regress, and helped catch
quite a few ISA 3.1 typos.

The tooling is left in another repo, and is loosely
based on the spec.go tooling for ppc64.

Notably, transaction memory instructions are effectively
removed in ISA 3.1, and some shuffling of descriptions
has result in cmp*/li/lis becoming extended mnemonics
instead, thus they go away. VLE/SPE/embedded instructions
are also removed. They were never used, and have been
removed since ISA 3.0.

Similarly, the new ISA introduces prefixed instructions
using opcode 1. They are encoded like two instruction
words. However, it should be noted prefixes cannot be
applied to any instruction, only those specifically
enumerated in the documentation. Likewise, what would
be the primary opcode of the suffixed instruction is
not always identical to it's non-prefixed counterpart.

A number of small changes have been made to the parser
to accomodate new instructions and minor changes to
existing ones.

Note, DCBI was a book iii-e instruction in ISA 2.07, and
only emulated on P8, and the opcode is reserved in newer
ISAs.

Note, isel BI decoding is slightly different than gnu.
It is much more readable to decode like other condition
register BI fields. Similarly, paste. and mtfsf* like
instruction decoding is improved to match the newer ISA.

Note, book ii extended mnemonics are mostly ignored.
These are inconsistently described in the documentation,
and most should never appear in golang compiled code.
We do handle the exceptional cases for some, such as the
hwsync/lwsync and the l*arx instructions.

Change-Id: I41711807a5fbdbdd22a2bde4159a09dad5382691
Reviewed-on: https://go-review.googlesource.com/c/arch/+/298793
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
2021-03-24 14:21:54 +00:00
Paul E. Murphy 05f8f0431f ppc64asm: cleanup objdump comparison tests
The objdump comparison test compares the instructions encoded
in decode.txt with a ppc64 objdump.  We can reduce the number
of exceptions (cases where objdump and golang disagree) to those
which are contained in decode.txt.

With ISA 3.1 many of the more exotic instructions which never
appeared in go have been removed.  Likewise, we may consider
removing this test as the additional generated tests for ISA 3.1
cover all instructions and do not require a ppc64 gnu objdump.

Change-Id: Ica84c3e8f977da2e9df2c138456ea5b791aaec9f
Reviewed-on: https://go-review.googlesource.com/c/arch/+/295194
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-03-08 15:50:06 +00:00
Paul E. Murphy a3652b17be ppc64asm,ppc64map: improve gnu branch decoding, and other misc
Rewrite the branch decoding to be more consistent with objdump.
Comments are taken from ISA 3.1 sections on the BO field (book i, 2.4),
and Appendix C.2 for extended branch mnemonics.  Also, generate all
interesting cases to verify.  Interesting cases are those which
don't choke objdump (e.g not setting z bits in BO, or setting at to
0b01).

Likewise, fixup handling of mtfs* instructions.  The field names are
similar to condition registers, but these operate on FPSCR bits and
fields.  Decode them as immediates, similar to objdump.

Likewise, when printing CR bits, use gnu/ISA syntax of 4*crN+B when
N > 0, and B is a named CR bit.

Likewise, when running testcode, track the "PC".  This keeps the
generated tests working without hacks.  This requires fixing up
some offsets in the handwritten tests.  Similarly, allow testing
of multiple files in the test directory which are prefixed with
"decode".

Likewise, allow appropriately prefixed to run these tests too.  This
allows running tests on non-native systems (e.g with IBM's advance
toolchain on an x86 host).

Change-Id: I1d6b2fc78a22a182524fdec596f05a10d25363c5
Reviewed-on: https://go-review.googlesource.com/c/arch/+/293270
Trust: Carlos Eduardo Seo <carlos.seo@linaro.org>
Run-TryBot: Carlos Eduardo Seo <carlos.seo@linaro.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2021-02-22 21:50:09 +00:00
Russ Cox d79151a12d all: go fmt ./...
Make all our package sources use Go 1.17 gofmt format
(adding //go:build lines).

Not strictly necessary but will avoid spurious changes
as files are edited.

Part of //go:build change (#41184).
See https://golang.org/design/draft-gobuild

Change-Id: I4580f638ce5c885f9e90af4ae9284b62419912a5
Reviewed-on: https://go-review.googlesource.com/c/arch/+/294416
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-20 00:26:09 +00:00
Paul E. Murphy cfa462d596 ppc64asm: ignore m[tf]vsr* objdump decoding mismatches
A recent binutils change prioritized extended mnemonics of these
instructions.  These mismatches can be safely ignored.

Fixes golang/go#43222

Change-Id: Ie3df612aad7aaba4798e13bab56b04291c703d48
Reviewed-on: https://go-review.googlesource.com/c/arch/+/278784
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-01-05 14:43:30 +00:00
Lynn Boger 52c3e6f60c ppc64: add instructions to decoder
These instructions were recently added to asm9 so should
be included in golang.org/x/arch/ppc64.

lxvh8x
lxvb16x
stxv8x
stxvb16x
xxbrd
xxbrw
xxbrh

Change-Id: I51a08366f9bc81081bc95f9c28726ebd3f749373
Reviewed-on: https://go-review.googlesource.com/c/arch/+/260617
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
2020-10-08 16:18:08 +00:00
Paul E. Murphy b19915210f ppc64/ppc64asm: learn lxvx and stxvx instructions
These are the indexed vsx load/store instructions added
in ISA 3.0.

Change-Id: I31c5d77f0f993347a1079e5504e8bdf9260eeb9b
Reviewed-on: https://go-review.googlesource.com/c/arch/+/249158
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2020-08-26 20:03:59 +00:00
Lynn Boger f7c7858683 ppc64/ppc64asm: update power9 for ppc64 and improve tests
This adds some new instructions, mostly power9, to
the ppc64 instruction tables. This also fixes some
issues with the ppc64 disassembler's ordering of
operands and improves the test examples.

Change-Id: Ib9a2e9722897bc25556d0c9ae5189cb6cbdfc6a1
Reviewed-on: https://go-review.googlesource.com/c/arch/+/230957
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-05-11 17:53:25 +00:00
Lynn Boger 7fe50f7625 ppc64/ppc64asm: improve disassembly for ppc64
The following improvements are included in this change:
- Display common special purpose registers for mtlr,mflr,mtctr,mfctr,
mtxer,mfxer,mftb; for others use mtspr and mfspr.
- Provide branch condition information (lt, gt, eq, ne, ge, le).
- Add cr number if cr1-cr7 is used.
- Pass pc to gnuArg to generate branch targets that are not relative.

Change-Id: Ia3ef6cb248c484a3ad72545e68d1ca59e32ae645
Reviewed-on: https://go-review.googlesource.com/c/arch/+/194597
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-09-19 21:35:54 +00:00
Ainar Garipov 46d78d1859 ppc64/ppc64asm: fix a typo
Change-Id: Iaa0a18315c22124dcc0ee273c129218f6386901d
Reviewed-on: https://go-review.googlesource.com/c/arch/+/194098
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-09-09 03:06:13 +00:00
Lynn Boger 5a4828bb70 ppc64: fixes for ppc64 objdump
The current output for the Go objdump on ppc64 is not correct
in many cases, generating opcodes that are not acceptable by the
Go assembler, and generating operands in the wrong order.

This adds some changes to generate an objdump for ppc64 code so that
the instructions generated are acceptable by the Go assembler,
and where some of the non-obvious operands have more meaningful names.

This includes the following changes:
- Correct some errors in ppc64map to make it work.
- Make a minor update to ppc64.csv to add the Go opcodes that have been
added to the Go assembler that were not in the table.
- Fix ppc64map to generate correct Go opcodes for ppc64 opcodes that end with '.'
indicating condition codes are set. The previous ppc64map was adding '_' at the end
for this case, but then had to be translated in plan9.go to 'CC' and many were not
being translated. This generates the correct suffix in the first step when
generating tables.go.
- Handle compare instructions correctly, since the names don't quite match
and the CR was not always handled correctly.
- Handle index loads and stores correctly, including VMX and VSX.
- Add mappings for all the names where the Go opcode does not match the ppc64 opcode.
- Handle all CR values, not just CR0 for those instructions that use them.
- Provide more information on BC instructions and generate the correct
branch mnemonic (BEQ, BNE, etc.) where possible.
- Make the output more consistent in spacing.
- Add some more testcases to testdata/decode.txt.
- If the instruction word is all 0s, the Go assembler will output WORD $0,
otherwise unrecognized instructions will be identified with '?'. For GNU,
all 0s will decode to .long 0x0 like the binutils objdump. This can happen
following a call to a panic or throw as a trap, or at the end of a function
for alignment purposes.

Note: the decoder does not handle extended opcodes correctly yet. I will add
that support in the next release and add the corresponding testcases.

We are working on an updated ppc64.csv, but I believe what is
there now covers the opcodes that are supported by the Go assembler.

Change-Id: If7fe1a2205512b476f4fb6b29a21f5459430e50c
Reviewed-on: https://go-review.googlesource.com/c/148574
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-12-03 22:54:21 +00:00
Tobias Klauser 1b162167b1 ppc64/ppc64spec: fix tool name in log prefix and usage
Change-Id: Ic2a89ffb46b3e3d92d9470bbdc64ad9da4578e67
Reviewed-on: https://go-review.googlesource.com/112295
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-09 14:52:07 +00:00
Tobias Klauser 5099b4b992 all: use io.SeekStart constant instead of 0
Change-Id: Ie91f539c896ddd92d4a039a237468fabdc3cf408
Reviewed-on: https://go-review.googlesource.com/105076
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-06 14:08:48 +00:00
Cherry Zhang dda8112e05 all: fix/silence vet errors
Change-Id: I04d12297538c6308bc7d7b14c9d50ff7f87eba0a
Reviewed-on: https://go-review.googlesource.com/79579
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-23 03:17:08 +00:00
namusyaka 2598a9c6f8 docs: fix article typos
a -> an

Change-Id: I6917aff4eb36ad1cd46b159391f39c1a70b54452
Reviewed-on: https://go-review.googlesource.com/63990
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-15 03:23:41 +00:00
Brad Fitzpatrick c49399feb8 ppc64/ppc64spec: skip build unless Go 1.8+ or amd64
Fix build failure:

../../gopath/src/golang.org/x/arch/ppc64/ppc64spec/spec.go:146: undefined: pdf.Outline
../../gopath/src/golang.org/x/arch/ppc64/ppc64spec/spec.go:153: undefined: pdf.Outline
../../gopath/src/golang.org/x/arch/ppc64/ppc64spec/spec.go:174: undefined: pdf.Page
../../gopath/src/golang.org/x/arch/ppc64/ppc64spec/spec.go:271: undefined: pdf.Content
../../gopath/src/golang.org/x/arch/ppc64/ppc64spec/spec.go:271: undefined: pdf.Text
../../gopath/src/golang.org/x/arch/ppc64/ppc64spec/spec.go:396: undefined: pdf.Rect

ppc64spec depends on other packages that don't build on 32-bit
systems prior to Go 1.8.

Fixes golang/go#17635
Updates golang/go#12840

Change-Id: I594adef1d0bc498940183215c7c5a958628a254a
Reviewed-on: https://go-review.googlesource.com/33247
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-15 21:48:24 +00:00
Lynn Boger 8e2d489854 x/arch/ppc64/ppc64asm: skip ObjdumpPowerManual on some hosts
The TestObjdumpPowerManualTest compares the go disassembler
output against the host objdump, but if the test is not being
run on a ppc64 or ppc64le, the host objdump won't be correct
for the test, so skip it in that case.

Change-Id: I34ba6f3efa5bde1248a1e2eaeb110a8c8dc95ea9
Reviewed-on: https://go-review.googlesource.com/32510
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-01 15:37:24 +00:00
Lynn Boger fcea5eadff ppc64/ppc64asm,ppc64/ppc64map: fixes for ppc64 disassembly
This adds some fixes to the ppc64 disassembly:
- Add support for VSX registers, by updating the map
function to recognize them, regenerating tables.go
to include them with VSX instructions, and adding the
defines needed to display them correctly.
- Change the path to the system objdump in the testcase
for use in comparing the decoded machine instructions.
- Add mappings for missing opcodes in plan9.go.
- Disable the testcase that generates words with random
bit settings for use in decoding. This will be replaced
later by an assembler testcase that decodes and compares
the result with the system objdump.

Fixes golang/go#17447

Change-Id: I23bf276ea7fcf0b54abb3dccca8b41c221c81c94
Reviewed-on: https://go-review.googlesource.com/31146
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2016-10-24 16:09:17 +00:00
Josh Bleecher Snyder 37086322b0 ppc64/ppc64asm: fix nits found by vet
Part of the Sisyphean goal of keeping vet happy
with the main Go repo.

Change-Id: I706b4d79066396a1ab5207f5b86dbb3d1a30d8b4
Reviewed-on: https://go-review.googlesource.com/31756
Reviewed-by: Minux Ma <minux@golang.org>
2016-10-23 20:13:57 +00:00
Russ Cox 4831b0a617 ppc64/ppc64asm: first round of fixes
- make test pass on 32-bit systems
- make test skip objdump when objdump not available,
  like in the other architecture tests
- expose plan9Syntax as GoSyntax

Change-Id: I8b1bb7cc4a07c6bd8a4eb0569553cb47773fb2a4
Reviewed-on: https://go-review.googlesource.com/30934
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 18:28:04 +00:00
Russ Cox 21375ab36a ppc64: add, from github.com/minux/power64
This is a direct copy of github.com/minux/power64,
which in turn was forked from rsc.io/power64,
which was using Mercurial and is gone.
The code in those places was reviewed via code review
and is by Minux and me under the usual Go CLA.

I've done a global search and replace of power64 to ppc64
and checked that everything still builds. Any further fixes
will be in followup CLs.

(The arch subrepo did not exist when this code was written.)

Change-Id: I80ea16ca689c9fc51a7501c3492099f19aa30873
Reviewed-on: https://go-review.googlesource.com/30932
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-12 18:28:02 +00:00