Information about CPU architectures (e.g., name, family, byte
ordering, pointer and register size) is currently redundantly
scattered around the source tree. Instead consolidate the basic
information into a single new package cmd/internal/sys.
Also, introduce new sys.I386, sys.AMD64, etc. names for the constants
'8', '6', etc. and replace most uses of the latter. The notable
exceptions are a couple of error messages that still refer to the old
char-based toolchain names and function reltype in cmd/link.
Passes toolstash/buildall.
Change-Id: I8a6f0cbd49577ec1672a98addebc45f767e36461
Reviewed-on: https://go-review.googlesource.com/21623
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
s390x doesn't introduce any new assembly syntax. There are a few
instructions which require the operands to be reordered, notably
the storage-storage instructions that put the length into From3 so
that the memory operands can be put into From and To.
The assembly test currently covers a subset of instructions but
tries to hit edge cases as much as possible. Unlike the other ports
it can be linked as an executable to make disassembling it easy.
It would be nice to autogenerate it at some point in the future.
Change-Id: I8dd542c34b9e450b8129d46693a5acb0ded791ce
Reviewed-on: https://go-review.googlesource.com/21253
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This reverts commit 85bbabd9c4.
The reverted CL broke all builds, because it depends on other CLs
that haven't been reviewed or landed yet.
Change-Id: I936f969431e0ac77133e43de2bf63042cef6b777
Reviewed-on: https://go-review.googlesource.com/21238
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
s390x doesn't introduce any new assembly syntax. There are a few
instructions which require the operands to be reordered, notably
the storage-storage instructions that put the length into From3 so
that the memory operands can be put into From and To.
The assembly test currently covers a subset of instructions but
tries to hit edge cases as much as possible. Unlike the other ports
it can be linked as an executable to make disassembling it easy.
It would be nice to autogenerate it at some point in the future.
Change-Id: I7615ac6ecf239e3f347fad9ae1f8eede91742859
Reviewed-on: https://go-review.googlesource.com/20934
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
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>
The only remaining place that generated ADATA
Prog was the assembler. Stop, and delete some
now-dead code.
Passes toolstash -cmp.
Change-Id: I26578ff1b4868e98562b44f69d909c083e96f8d5
Reviewed-on: https://go-review.googlesource.com/20646
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This is a subset of https://golang.org/cl/20022 with only the copyright
header lines, so the next CL will be smaller and more reviewable.
Go policy has been single space after periods in comments for some time.
The copyright header template at:
https://golang.org/doc/contribute.html#copyright
also uses a single space.
Make them all consistent.
Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0
Reviewed-on: https://go-review.googlesource.com/20111
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
If the parsing of an operand completes but the parser thinks there
is more to read, return an "expected end of operand" error message
instead of "expected EOF." This also removes extra "asm: " prefixes
in error strings since "asm: " is already set as the global log
prefix.
Fixes#14071
Change-Id: I7d621c1aea529a0eca3bcba032359bd25b3e1080
Reviewed-on: https://go-review.googlesource.com/19731
Reviewed-by: Rob Pike <r@golang.org>
Only tests do this, provide them a hook to disable freeing
after flush.
Change-Id: I810c6c51414a93f476a18ba07b807e16092bf8cf
Reviewed-on: https://go-review.googlesource.com/19907
Reviewed-by: Keith Randall <khr@golang.org>
3DNotAnymore!
These only ever existed on AMD (not Intel) processors,
and AMD cancelled support for them in August 2010.
Change-Id: Ia362259add9d4f5788fd151fb373f91288677407
Reviewed-on: https://go-review.googlesource.com/19611
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Semi-regular merge from tip to dev.ssa.
Two fixes:
1) Mark selectgo as not returning. This caused problems
because there are no VARKILL ops on the selectgo path,
causing things to be marked live that shouldn't be.
2) Tell the amd64 assembler that addressing modes like
name(SP)(AX*4) are ok.
Change-Id: I9ca81c76391b1a65cc47edc8610c70ff1a621913
Was part of #13822 but not in the first message, so I missed it.
Fixes#13822 again.
Change-Id: I775004fa8d47b6af293124605521ec396573e267
Reviewed-on: https://go-review.googlesource.com/18900
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Add test for assembly errors, to verify fix.
Make sure invalid instruction errors are printed just once
(was printing them once per span iteration, so typically twice).
Fixes#13282.
Change-Id: Id5f66f80a80b3bc4832e00084b0a91f1afec7f8f
Reviewed-on: https://go-review.googlesource.com/18858
Reviewed-by: Rob Pike <r@golang.org>
Add amd64 instructions I promised to add for Go 1.6
at the beginning of January.
These may be the last instructions added by hand.
I intend to generate the whole set mechanically for Go 1.7.
Fixes#13822.
Change-Id: I8c6bae2efd25f717f9ec750402e50f408a911d2b
Reviewed-on: https://go-review.googlesource.com/18853
Reviewed-by: Rob Pike <r@golang.org>
Use the standard names, for discoverability.
Use the standard register arguments, for correctness.
Implement all possible arguments, for completeness.
Enable the corresponding tests now that everything is standard.
Update the uses in package runtime.
Fixes#14068.
Change-Id: I8e1af9a41e7d02d98c2a82af3d4cdb3e9204824f
Reviewed-on: https://go-review.googlesource.com/18852
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Generated by x86test, from https://golang.org/cl/18842
(still in progress).
The commented out lines are either missing or misspelled
or incorrectly handled instructions.
For #4816, #8037, #13822, #14068, #14069.
Change-Id: If309310c97d9d2a3c71fc64c51d4a957e9076ab7
Reviewed-on: https://go-review.googlesource.com/18850
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Not much testing yet, but the test now exists.
Another step toward #13822.
Change-Id: Idb2b06bf53a6113c83008150b4c0b631bb195279
Reviewed-on: https://go-review.googlesource.com/18844
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Also, remove output file if there are encoding errors.
The extra reports are convenient.
Removing the output file is very important.
Noticed while testing.
Change-Id: I0fab17d4078f93c5a0d6d1217d8d9a63ac789696
Reviewed-on: https://go-review.googlesource.com/18845
Reviewed-by: Rob Pike <r@golang.org>
Instead of two parallel files that look almost identical,
mark the expected differences in the original file.
The annotations being added here keep the tests passing,
but they also make clear a number of printing or parsing
errors that were not as easily seen when the data was
split across two files.
Fix a few diagnostic problems in cmd/internal/obj as well.
A step toward #13822.
Change-Id: I997172681ea6fa7da915ff0f0ab93d2b76f8dce2
Reviewed-on: https://go-review.googlesource.com/18823
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Transactional memory, will later be used for semaphore implementation.
Nacl not supported yet.
Change-Id: Ic18453dcaa08d07bb217c0b95461584f007d518b
Reviewed-on: https://go-review.googlesource.com/16479
Reviewed-by: Russ Cox <rsc@golang.org>
There was no documentation produced by "go doc cmd/asm".
Follow the style set by cmd/compile.
Fixes#13148.
Change-Id: I02e08ce2e7471f855bfafbbecee98ffdb7096995
Reviewed-on: https://go-review.googlesource.com/16997
Reviewed-by: Russ Cox <rsc@golang.org>
Error doesn't take a format string and appends its own newline. Phrase
the error like the other ones.
Change-Id: Ic3af857e5d4890207c74a6eb59a0d1067b503e1b
Reviewed-on: https://go-review.googlesource.com/16420
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
A panic was in place for an impossible condition that turned
out to be possible if one used a macro to define a macro.
Another go-fuzz "win".
Fixes#12654.
Change-Id: I0a7bb0f0eabb260c986bf7a2288860c78d8db1af
Reviewed-on: https://go-review.googlesource.com/14777
Reviewed-by: Andrew Gerrand <adg@golang.org>
Add some error catches to prevent looping at EOF.
Also give better diagnostics.
Also add tests for these cases.
Fixes#12656.
Change-Id: I1355fc149b71c868e740bfa53de29c25d160777d
Reviewed-on: https://go-review.googlesource.com/14710
Reviewed-by: Andrew Gerrand <adg@golang.org>
On amd64, the program
TEXT foo0(SB),7,$-8
ADDQ R520, R1
RET
used to trigger this error because R520 was being passed through to obj:
asm: doasm: notfound ft=23 tt=23 00000 (x.s:2) ADDQ 0, 0 23 23
Now it gets this one, as it is indeed a parse error:
x.s:2: illegal addressing mode for symbol R520
This couldn't be fixed until #12632 had been fixed for arm64.
Fixes#12470.
Change-Id: I19830c4ae9337887b93f85d9a239e2b89dbb2219
Reviewed-on: https://go-review.googlesource.com/14691
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Add CS as an alias for HS, and CC as an alias for LO, otherwise
CSINV CS, R1, R2, R3
was interpreted as
CSINV 0, R1, R2, R3
Also fix the corresponding faulty test.
Fixes#12632
Updates #12470
Change-Id: I974cfc7e5ced682d4754ba09b0b102cb08a46567
Reviewed-on: https://go-review.googlesource.com/14680
Reviewed-by: Rob Pike <r@golang.org>
More protection against random input bytes.
Fixes#12614.
Change-Id: Ie9f817de1376a10bb80b22ecee3bae4f1d26cc6c
Reviewed-on: https://go-review.googlesource.com/14563
Reviewed-by: Andrew Gerrand <adg@golang.org>
One (12466) was an actual logic error, backing up when there was
nothing there. The others were due to continuing to process an
instruction when it cannot work.
Methodically stop assembling an instruction when it's not going to
succeed.
Fixes#12466.
Fixes#12467.
Fixes#12468.
Change-Id: I88c568f2b9c1a8408043b2ac5a78f5e2ffd62abd
Reviewed-on: https://go-review.googlesource.com/14498
Reviewed-by: Andrew Gerrand <adg@golang.org>
The code parsing register lists involves an inner loop on
each range defined by the lo,hi bounds. The condition on
this loop (for lo<=hi) is fragile, because the bounds
are unsigned 16 bits numbers.
In some corner cases, the calculated upper bound is 2^16-1
leading to an infinite loop.
Parsing operand `[):[o-FP` results in:
- an infinite loop for non ARM architectures
- the generation of almost 2^16 errors for the ARM architecture
(which are then ignored)
This CL improves the code in 3 ways:
- bail out early when parsing non R prefixed registers
- make sure the register index is never negative
- make sure the number of iterations is limited by the
maximum size of the range (as a defensive measure).
Fixes#12469
Change-Id: Ib1e7e36fb8ad5a3a52c50fc6219d3cfe2b39cc34
Reviewed-on: https://go-review.googlesource.com/14314
Reviewed-by: Rob Pike <r@golang.org>
The lexer needs to process all #if[n]defs, even those found when processing is
disabled by a preceding failed conditional, or the first #endif in something
like:
#ifdef <undefined>
#ifdef whatever
#endif
#endif
terminates the first #ifdef and the second causes an error. And then the
processing of the inner #ifdefs needs to ignore their argument when they are
disabled by an outer failed condition.
Change-Id: Iba259498f1e16042f5b7580b9c000bb0599733d0
Reviewed-on: https://go-review.googlesource.com/14253
Reviewed-by: Rob Pike <r@golang.org>
These instructions are special cases that were missed in the translation.
The second argument must go into the Reg field not the To field.
Fixes#12458
For Go 1.5.1
Change-Id: Iad57c60c7e38e3bcfafda483ed5037ce670e8816
Reviewed-on: https://go-review.googlesource.com/14183
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
The parser tries to read as much information as possible,
issuing some errors when needed. Errors generally do not
stop the parsing.
With some pathological input, it may result in various
panics when the error message itself is built, or when the
next operand is parsed. It happens while parsing
pseudo-instructions.
For instance, the following lines all generate a panic:
TEXT
TEXT%
TEXT 1,1
TEXT $"toto", 0, $1
FUNCDATA
DATA 0
DATA(0),1
FUNCDATA(SB
GLOBL 0, 1
PCDATA 1
Added corresponding tests.
Introduced a writer in the parser to capture error messages
for testing purpose. It defaults to os.Stderr.
Added an explicit check when symbol names cannot be displayed.
Interrupted parsing early when the number of operands is wrong for
pseudo-instructions.
Note that the last point is a change of behavior, because some
operands will not get parsed anymore in case of early error.
IMO, it is acceptable, because only the first error of the line
is considered anyway. If it is not acceptable, it can probably
be improved at the price of a more verbose CL.
Fixes#11765Fixes#11760Fixes#11759
Change-Id: I9602a848132e358a1bccad794d7555e0823970dd
Reviewed-on: https://go-review.googlesource.com/13925
Reviewed-by: Rob Pike <r@golang.org>
Update #10994
CASE and BCASE were used by 5c in switch statements, cmd/compile
does not use them.
Change-Id: I7a578c461b52b94690e35460926849b28971b770
Reviewed-on: https://go-review.googlesource.com/14009
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
For ARM machines, the assembler supports list of registers
operands such as [R1,R2].
A list missing a ']' results in the parser issuing many errors
and consuming all the tokens. At EOF (i.e. end of the line),
it still loops.
Normally, a counter is maintained to make sure the parser
stops after 10 errors. However, multiple errors occuring on the
same line are simply ignored. Only the first one is reported.
At most one error per line is accounted.
Missing ']' in a register list therefore results in an
infinite loop.
Fixed the parser by explicitly checking for ']' to interrupt
this loops
In the operand tests, also fixed a wrong entry which I think was
not set on purpose (but still led to a successful result).
Fixes#11764
Change-Id: Ie87773388ee0d21b3a2a4cb941d4d911d0230ba4
Reviewed-on: https://go-review.googlesource.com/13920
Reviewed-by: Rob Pike <r@golang.org>
The parser treats (R1+R2) on ppc64 the same as (R1,R2) on arm,
but it is not strictly a "register pair". Improve the text.
No semantic change.
Change-Id: Ib8b14881c6467add0d53150a901c01e962afb28b
Reviewed-on: https://go-review.googlesource.com/12212
Reviewed-by: Russ Cox <rsc@golang.org>
They were missing from the inputs.
Unfortunately this means the .out files all have wrong line numbers,
but they are easy to update.
Change-Id: I254742f24ab803421f34d52d13b9afa93674edd6
Reviewed-on: https://go-review.googlesource.com/11958
Reviewed-by: Russ Cox <rsc@golang.org>
Also add a couple more errors, such as modulo with a zero divisor.
Change-Id: If24c95477f7ae86cf4aef5b3460e9ec249ea5ae2
Reviewed-on: https://go-review.googlesource.com/11535
Reviewed-by: Russ Cox <rsc@golang.org>
There are two conditions to worry about:
1) The shift count cannot be negative. Since the evaluator uses unsigned
arithmetic throughout, this means checking that the high bit of
the shift count is always off, which is done by converting to int64
and seeing if the result is negative.
2) For right shifts, the value cannot be negative. We don't want a
high bit in the value because right shifting a value depends on the
sign, and for clarity we always want unsigned shifts.
Next step is to build some testing infrastructure for the parser.
Change-Id: I4c46c79989d02c107fc64954403fc18613763f1d
Reviewed-on: https://go-review.googlesource.com/11326
Reviewed-by: Russ Cox <rsc@golang.org>
The change that "fixed" LSH was incorrect, and the fix for RSH was poor.
Make both use a correct, simple test: if the 64-bit value as a signed
integer is negative, it's an error.
Really fixes#11278.
Change-Id: I72cca03d7ad0d64fd649fa33a9ead2f31bd2977b
Reviewed-on: https://go-review.googlesource.com/11325
Reviewed-by: Andrew Gerrand <adg@golang.org>
In the parser, the shift value is always a uint64.
Change-Id: I9b50295a9f7d174ed1f6f9baf78ec0ed43db417f
Reviewed-on: https://go-review.googlesource.com/11322
Reviewed-by: Andrew Gerrand <adg@golang.org>
These were found by grepping the comments from the go code and feeding
the output to aspell.
Change-Id: Id734d6c8d1938ec3c36bd94a4dbbad577e3ad395
Reviewed-on: https://go-review.googlesource.com/10941
Reviewed-by: Aamir Khan <syst3m.w0rm@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
That which cannot happen has not happened.
No immediate changes to Addr or Prog size.
Change-Id: I4cb9315f2c9f5f92eda340bfc4abb46395fa467f
Reviewed-on: https://go-review.googlesource.com/10513
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
It is almost never set and Addr is large, so having the full struct
in the Prog wastes memory most of the time.
Before (on a 64-bit system):
$ sizeof -p cmd/internal/obj Addr Prog
Addr 80
Prog 376
$
After:
$ sizeof -p cmd/internal/obj Addr Prog
Addr 80
Prog 304
$
Change-Id: I491f201241f87543964a7d0f48b85830759be9d0
Reviewed-on: https://go-review.googlesource.com/10457
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
It shrinks Prog type from 448 bytes down to 376 bytes on amd64.
It also makes sense, because I don't know of any modern architecture
that have instructions which can write to two destinations, none of
which is a register (even x86 doesn't have such instructions).
Change-Id: I3061f1c9ac93d79ee2b92ecb9049641d0e0f6300
Reviewed-on: https://go-review.googlesource.com/10330
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
This CL removes the remaining visible uses of the "architecture letter" concept.
(They are no longer in tool names nor in source directory names.)
Because the architecture letter concept is now gone, delete GOCHAR
from "go env" output, and change go/build.ArchChar to return an
error always.
The architecture letter is still used in the compiler and linker sources
as a clumsy architecture enumeration, but that use is not visible to
Go users and can be cleaned up separately.
Change-Id: I4d97a38f372003fb610c9c5241bea440d9dbeb8d
Reviewed-on: https://go-review.googlesource.com/10289
Reviewed-by: Rob Pike <r@golang.org>
This is a follow up to rev 443a32e707 which reduces some of the
duplication between methods and functions that operate on obj.Biobuf.
obj.Biobuf has Flush and Write methods as well as helpers which duplicate
those methods, consolidate on the former and remove the latter.
Also, address a final comment from CL 9525.
Change-Id: I67deaf3a163bb489a9bb21bb39524785d7a2f6c5
Reviewed-on: https://go-review.googlesource.com/9527
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
These were lost in the transition from 8a/6a to asm.
Also, in the process, discover more aliases. I'm betting the missing
ones were a casualty of the recent merge of 386 and amd64.
Update #10385.
Change-Id: I1681034b25af3ffc103f75e5fc57baca5feb3fcd
Reviewed-on: https://go-review.googlesource.com/9431
Reviewed-by: Russ Cox <rsc@golang.org>
http://golang.org/cl/7623 refactored how line history works and
introduced a new TrimPathPrefix field to replace the existing Trimpath
field, but never removed the latter or updated its users.
Fixes#10503.
Change-Id: Ief90a55b6cef2e8062b59856a4c7dcc0df01d3f2
Reviewed-on: https://go-review.googlesource.com/9113
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Just an oversight. Plus the code had an unnecessary call to os.Exit
that now has a purpose.
Fixes#10372.
Change-Id: I456018f3a01ca05b4501c7f8a4961d48ab8c5e16
Reviewed-on: https://go-review.googlesource.com/8651
Reviewed-by: Minux Ma <minux@golang.org>
Add end to end tests for arm64 to support CL 8405.
There are several instruction forms commented out at the moment
they will be addressed in CL 8405 or later followups.
Change-Id: I6eeeb810c1e03cd49bb3c881bc46a29cdb817822
Reviewed-on: https://go-review.googlesource.com/8631
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
Add test, and while we're at here, also add a test for ARM.
Fixes#10343.
Change-Id: Ic914df8233d4f1f495e2cc0743fbd37b7671bc91
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/8472
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Rob Pike <r@golang.org>
It referred to the wrong architecture.
Fixes#10355.
Change-Id: I5b9d31c9f04f3106b93f94fa68c848b2518b128e
Reviewed-on: https://go-review.googlesource.com/8495
Reviewed-by: Dave Cheney <dave@cheney.net>
An interface{} is more in the spirit of the original union.
By my calculations, on 64-bit systems this reduces
Addr from 120 to 80 bytes, and Prog from 592 to 424 bytes.
Change-Id: I0d7b0981513c2a3c94c9ac76bb4f8816485b5a3c
Reviewed-on: https://go-review.googlesource.com/7744
Reviewed-by: Rob Pike <r@golang.org>
Pre/post-index addressing modes with writeback use .W and .P
instruction suffixes, like on ARM.
Complex addressing modes are not supported yet.
Change-Id: I537a1c3fe5b057c0812662677d0010bc8c468ffb
Reviewed-on: https://go-review.googlesource.com/7047
Reviewed-by: Rob Pike <r@golang.org>
The old, per-architecture operand printers didn't lock down the
format of the constant in the MRC and MCR instructions (a value
that could be presented more helpfully - maybe how the
input looks? - but that is an issue for another day). But there is
a portable standard printer now so we can enable tests for these
instructions.
Change-Id: I437a3b112ce63f4d6e1fe3450fc21d8c3372602f
Reviewed-on: https://go-review.googlesource.com/7420
Reviewed-by: Russ Cox <rsc@golang.org>
Just a trivial thing I noticed in passing.
Change-Id: I875069ceffd623f9e430d07feb5042ab9e69917e
Reviewed-on: https://go-review.googlesource.com/7472
Reviewed-by: Rob Pike <r@golang.org>
It's an oddball that needs special treatment because it is not really
an opcode, but a variant of MRC.
The String method of Prog still needs updating to print it nicely.
Change-Id: I6005b7f2234ccd3d4ac1f658948e3be97cf1f1c2
Reviewed-on: https://go-review.googlesource.com/7220
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
Remove the per-achitecture formatter for Prog and replace it with
a global String method. Clean up and regularize the output. Update
tests affected by the format; some tests are made correct now when
they were broken before (and known to be).
Also, related: Change the encoding of the (R1+R2) syntax on ppc64
to be equivalent to (R1)(R2*1), which means it needs no special
handling.
Delete the now unused STRINGSZ constant.
Change-Id: I7f6654d11f80065f3914a3f19353f2f12edfe310
Reviewed-on: https://go-review.googlesource.com/6931
Reviewed-by: Russ Cox <rsc@golang.org>
With the new unificiation, the flag must be TYPE_CONST to print
properly.
Change-Id: I7cd1c56355724f08cbe9afc6ab7a66904031adc9
Reviewed-on: https://go-review.googlesource.com/6903
Reviewed-by: Russ Cox <rsc@golang.org>
Support the old syntax for AX:DX by rewriting into the new form,
AX, DX. Delete now-unnecessary hacks for some special cases.
Change-Id: Icd42697c7617f8a50864ca8b0c69469321a2296e
Reviewed-on: https://go-review.googlesource.com/6901
Reviewed-by: Russ Cox <rsc@golang.org>
Make cmd/internal/obj/x86 support 32-bit mode and use
instead of cmd/internal/obj/i386. Delete cmd/internal/obj/i386.
Clean up encoding of PINSRQ, CMPSD to use explicit third arg
instead of jamming it into an unused slot of a different arg.
Also fix bug in old6a, which declared the wrong grammar.
The accepted (and encoded) arguments to CMPSD etc are mem,reg not reg,mem.
Code that did try to use mem,reg before would be rejected by liblink,
so only reg,reg ever worked, so existing code is not affected.
After this change, code can use mem,reg successfully.
The real bug here is that the encoding tables inverted the argument
order, making the comparisons all backward from what they say on the page.
It's too late to swap them, though: people have already written code that
expects the inverted comparisons (like in package math, and likely externally).
The best we can do is make the argument that should and can take a
memory operand accept it.
Bit-for-bit compatibility checked against tree without this CL.
Change-Id: Ife5685bc98c95001f64407f35066b34b4dae11c1
Reviewed-on: https://go-review.googlesource.com/6810
Reviewed-by: Rob Pike <r@golang.org>
The creation of liblink and subsequent introduction of more explicit
TLS handling broke 6l's (unsupported) -shared flag. This change adds
-shared flags to cmd/asm and 6g and changes liblink to generate shared-
library compatible instruction sequences when they are passed, and
changes 6l to emit the appropriate ELF relocation.
A proper fix probably also requires go tool changes.
Fixes#9652.
Change-Id: I7b7718fe7305c802ac994f4a5c8de68cfbe6c76b
Reviewed-on: https://go-review.googlesource.com/4321
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
The name g is an alias for R10 and R30, respectively. Have Rconv
print the alias, for consistency with the input language.
Change-Id: Ic3f40037884a0c8de5089d8c8a8efbcdc38c0d56
Reviewed-on: https://go-review.googlesource.com/6630
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Just a missed case in in the handling of branches.
Fixes#10065
Change-Id: I6be054d30bf1f383c12b4c7626abd5f8ae22b22e
Reviewed-on: https://go-review.googlesource.com/6631
Reviewed-by: Minux Ma <minux@golang.org>
Aconv is the pretty-printer for instruction opcodes like AMOVQ.
There was one for each architecture.
Make the space of A names have a different region for each architecture,
much as we did for the registers, so a single global Aconv function can
do the work. Each architecture registers its region as a slice of names
at a given offset.
The global names like CALL and JMP are now defined only once.
The A values are used for indexing tables, so make it easy to do the
indexing by making the offset maskable.
Remove a bunch of now-duplicated architecture-specific code.
Change-Id: Ib15647b7145a1c089e21e36543691a19e146b60e
Reviewed-on: https://go-review.googlesource.com/6620
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Have the implementations of each architecture declare the one-operand,
destination-writing instructions instead of splitting the information between
there and asm.
Change-Id: I44899435011a4a7a398ed03c0801e9f81cc8c905
Reviewed-on: https://go-review.googlesource.com/6490
Reviewed-by: Russ Cox <rsc@golang.org>
ARM operands for MOVM have lists of registers: [R1,R2,R5-R8].
Handle them cleanly.
It was TYPE_CONST with special handling, which meant operand printing
didn't work right and the special handling was ugly. Add a new TYPE_REGLIST
for this case and it all gets cleaner.
Change-Id: I4a64f70fb9765e63cb636619a7a8553611bfe970
Reviewed-on: https://go-review.googlesource.com/6300
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
These 8 registers are windows into the CR register. They are officially CR0
through CR7 and that is what the assembler accepts, but for some reason
they have always printed as C0 through C7. Fix the naming and printing.
Change-Id: I55822c0322c29d3e01a1f2776b3b210ebf9ded21
Reviewed-on: https://go-review.googlesource.com/6290
Reviewed-by: Russ Cox <rsc@golang.org>
Clean up the obj API by making Rconv (register pretty printer) a top-level
function. This means that Dconv (operand pretty printer) doesn't need
an Rconv argument.
To do this, we make the register numbers, which are arbitrary inside an
operand (obj.Addr), disjoint sets for each architecture. Each architecture
registers (ha) a piece of the space and then the global Rconv knows which
architecture-specific printer to use.
Clean up all the code that uses Dconv.
Now register numbers are large, so a couple of fields in Addr need to go
from int8 to int16 because they sometimes hold register numbers. Clean
up their uses, which meant regenerating the yacc grammars for the
assemblers. There are changes in this CL triggered by earlier changes
to yacc, which had not been run in this directory.
There is still cleanup to do in Addr, but we're getting closer to that being
easy to do.
Change-Id: I9290ebee013b62f7d24e886743ea5a6b232990ab
Reviewed-on: https://go-review.googlesource.com/6220
Reviewed-by: Russ Cox <rsc@golang.org>
It was just missing, and apparently always was.
Change-Id: I84c057bb0ec72940201075f3e6078262fe4bce05
Reviewed-on: https://go-review.googlesource.com/6120
Reviewed-by: Russ Cox <rsc@golang.org>
Each architecture had its own Dconv (operand printer) but the syntax is
close to uniform and the code overlap was considerable. Consolidate these
into a single top-level function. A similar but smaller unification is done
for Mconv ("Name" formatter) as well.
The signature is changed. The flag was unused so drop it. Add a
function argument, Rconv, that must be supplied by the caller.
TODO: A future change will unify Rconv as well and this argument
will go away.
Some formats changed, because of the automatic consistency
created by unification. For instance, 0(R1) always prints as (R1)
now, and foo+0(SB) is just foo(SB). Before, some made these
simplifications and some didn't; now they all do.
Update the asm tests that depend on the format.
Change-Id: I6e3310bc19814c0c784ff0b960a154521acd9532
Reviewed-on: https://go-review.googlesource.com/5920
Reviewed-by: Russ Cox <rsc@golang.org>
verifyAsm is still on, but this CL changes the order to asm then 6a.
Before, it was 6a then asm, but that meant that any bugs in asm
for bad input would be prevented from happening because 6a would
catch them. Now asm gets first crack, as it must.
Also implement the -trimpath flag in asm. It's necessary and trivial.
Change-Id: Ifb2ab870de1aa1b53dec76a78ac697a0d36fa80a
Reviewed-on: https://go-review.googlesource.com/5850
Reviewed-by: Russ Cox <rsc@golang.org>
Missing cases for JMP $4 and foo+4(SB):AX. Both are odd but 8a accepts them
and they seem valid.
Change-Id: Ic739f626fcc79ace1eaf646c5dfdd96da59df165
Reviewed-on: https://go-review.googlesource.com/5693
Reviewed-by: Russ Cox <rsc@golang.org>
Missing leading A on names.
Change-Id: I6f3a66bdd3a21220f45a898f0822930b6a7bfa38
Reviewed-on: https://go-review.googlesource.com/5801
Reviewed-by: Rob Pike <r@golang.org>
The alias should exist for both 386 and amd64.
There were a few others missing as well. Add them.
Change-Id: Ia0c3e71abc79f67a7a66941c0d932a8d5d6e9989
Reviewed-on: https://go-review.googlesource.com/5800
Reviewed-by: Russ Cox <rsc@golang.org>
This time for sure.
Change-Id: I77ed6b70d82a6f4ba371afba2f53c8b146ac110f
Reviewed-on: https://go-review.googlesource.com/5530
Reviewed-by: Rob Pike <r@golang.org>
Representation in printout of MRC instruction differs between
32- and 64-bit machines. It's just a hex dump. Fix this one day,
but for now just comment out the instruction.
Change-Id: I4709390659e2e0f2d18ff6f8e762f97cdbfb4c16
Reviewed-on: https://go-review.googlesource.com/5424
Reviewed-by: Rob Pike <r@golang.org>
Add trivial golden test that verifies output matches expectation.
The input is based on the old grammar and is intended to cover
the space of the input language.
PPC64 and ARM only for now; others to follow.
Change-Id: Ib5957822bcafd5b9d4c1dea1c03cc6ee1238f7ef
Reviewed-on: https://go-review.googlesource.com/5421
Reviewed-by: Russ Cox <rsc@golang.org>
As with the previous round for ppc64, this CL fixes a couple of things
that 5a supported but asm did not, both simple.
1) Allow condition code on MRC instruction; this was marked as a TODO.
2) Allow R(n) notation in ARM register shifts. The code needs a rethink
but the tests we're leading toward will make the rewrite easier to test and
trust.
Change-Id: I5b52ad25d177a74cf07e089dddfeeab21863c424
Reviewed-on: https://go-review.googlesource.com/5422
Reviewed-by: Russ Cox <rsc@golang.org>
Missed this one instruction in the previous pass.
Change-Id: Ic8cdae4d3bfd626c6bbe0ce49fce28b53db2ad1c
Reviewed-on: https://go-review.googlesource.com/5420
Reviewed-by: Russ Cox <rsc@golang.org>