aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/asm/internal/lex
AgeCommit message (Collapse)Author
2026-02-03all: prealloc slice with possible minimum capabilitiesShulhan
2025-11-11std,cmd: go fix -any std cmdAlan Donovan
This change mechanically replaces all occurrences of interface{} by 'any' (where deemed safe by the 'any' modernizer) throughout std and cmd, minus their vendor trees. Since this fix is relatively numerous, it gets its own CL. Also, 'go generate go/types'. Change-Id: I14a6b52856c3291c1d27935409bca8d5fd4242a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/719702 Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Alan Donovan <adonovan@google.com>
2024-09-06cmd/asm/internal: use slices.ContainsTobias Klauser
Now that Go 1.22.6 is the minimum bootstrap toolchain (cf. CL 606156), the slices package (introduced in Go 1.21) can be used in packages built using the bootstrap toolchain. For #64751 Change-Id: I0115213da4b1f0a1fa0ef7ad34456fbf52e00fae Reviewed-on: https://go-review.googlesource.com/c/go/+/611095 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-08-29cmd/asm: stop using "" as the local package prefixMatthew Dempsky
Now that cmd/asm always knows its package path, we can create symbols with the appropriate package prefix instead of "". Change-Id: I56864089e8f1b38ff4197b3158131f976b329572 Reviewed-on: https://go-review.googlesource.com/c/go/+/523336 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-29cmd: simplify some handling of package pathsMatthew Dempsky
We have obj.Link.Pkgpath, so we don't need to pass it redundantly in places where we already have an *obj.Link. Also, renaming the parser's "compilingRuntime" field to "allowABI", to match the "AllowAsmABI" name used by objabi.LookupPkgSpecial. Finally, push the handling of GOEXPERIMENT_* flags up to cmd/asm's main entry point, by simply appending them to flags.D. Change-Id: I6ada134522b0cbc90d35bcb145fbe045338fefb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/523297 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-22cmd/asm,cmd/dist,cmd/go: remove asm -compiling-runtime flagAustin Clements
Currently, dist and go pass a -compiling-runtime flag to asm if they're compiling a runtime package. However, now that we always pass the package path to asm, it can make that determination just as well as its callers can. This CL moves that check into asm and drops the flag. This in turn makes dist's copy of IsRuntimePackagePath unnecessary, so we delete it. Change-Id: I6ecf2d50b5b83965012af34dbe5f9a973ba0778b Reviewed-on: https://go-review.googlesource.com/c/go/+/521697 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-06-29cmd/asm/internal/lex: fix comment, remove the first "has"Jes Cok
Change-Id: I429f0fa6c99ef576fe83c7bd0d1c1e176ecbb179 GitHub-Last-Rev: fb581b7f271f026182de0737c4fe5c360d5dea96 GitHub-Pull-Request: golang/go#61066 Reviewed-on: https://go-review.googlesource.com/c/go/+/507097 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-09-08cmd/asm: use strings.Buildercuiweixie
Change-Id: I2ec419f475f9c5d5ef1d4557cb5862a55a699d9c Reviewed-on: https://go-review.googlesource.com/c/go/+/428284 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-04all: clean up TODO after fixing issue 44505hopehook
For #44505 Change-Id: I89220be02372b5340cb987bf2ac870a9346a8c8f Reviewed-on: https://go-review.googlesource.com/c/go/+/421079 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-04-12cmd/asm: update comment to refer to #44505hopehook
Updates #44505 Change-Id: I400110c33e69decf133fe9c4b582a450b7258b39 Reviewed-on: https://go-review.googlesource.com/c/go/+/399514 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-03-18internal/buildcfg: extract logic specific to cmd/goBryan C. Mills
cmd/go/internal/cfg duplicates many of the fields of internal/buildcfg, but initializes them from a Go environment file in addition to the usual process environment. internal/buildcfg doesn't (and shouldn't) know or care about that environment file, but prior to this CL it exposed hooks for cmd/go/internal/cfg to write data back to internal/buildcfg to incorporate information from the file. It also produced quirky GOEXPERIMENT strings when a non-trivial default was overridden, seemingly so that 'go env' would produce those same quirky strings in edge-cases where they are needed. This change reverses that information flow: internal/buildcfg now exports a structured type with methods — instead of top-level functions communicating through global state — so that cmd/go can utilize its marshaling and unmarshaling functionality without also needing to write results back into buildcfg package state. The quirks specific to 'go env' have been eliminated by distinguishing between the raw GOEXPERIMENT value set by the user (which is what we should report from 'go env') and the cleaned, canonical equivalent (which is what we should use in the build cache key). For #51461. Change-Id: I4ef5b7c58b1fb3468497649a6d2fb6c19aa06c70 Reviewed-on: https://go-review.googlesource.com/c/go/+/393574 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-04-16internal/buildcfg: move build configuration out of cmd/internal/objabiRuss Cox
The go/build package needs access to this configuration, so move it into a new package available to the standard library. Change-Id: I868a94148b52350c76116451f4ad9191246adcff Reviewed-on: https://go-review.googlesource.com/c/go/+/310731 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
2021-04-08internal/goexperiment,cmd: consolidate GOEXPERIMENTs into a new packageAustin Clements
Currently there's knowledge about the list of GOEXPERIMENTs in a few different places. This CL introduces a new package and consolidates the list into one place: the internal/goexperiment.Flags struct type. This package gives us a central place to document the experiments as well as the GOEXPERIMENT environment variable itself. It will also give us a place to put built-time constants derived from the enabled experiments. Now the objabi package constructs experiment names by reflecting over this struct type rather than having a separate list of these names (this is similar to how the compiler handles command-line flags and debug options). We also expose a better-typed API to the toolchain for propagating enabled experiments. Change-Id: I06e026712b59fe2bd7cd11a869aedb48ffe5a4b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/307817 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08cmd/asm,runtime: reduce spellings of GOEXPERIMENTsAustin Clements
Currently, the objabi.Experiment fields use Go-standard CamelCase, the GOEXPERIMENT environment variable flags and build tags use all lowercase, and the asm macros use upper-case with underscores. This CL makes asm use the lowercase names for macros so there is one less spelling, e.g., GOEXPERIMENT_regabiargs. This also makes them consistent with the GOOS_* and GOARCH_* macros, which also use lower case. Change-Id: I305cd89af5e8cd1a89cc148746c034bcfd76db3c Reviewed-on: https://go-review.googlesource.com/c/go/+/307816 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-03-18all: explode GOEXPERIMENT=regabi into 5 sub-experimentsAustin Clements
This separates GOEXPERIMENT=regabi into five sub-experiments: regabiwrappers, regabig, regabireflect, regabidefer, and regabiargs. Setting GOEXPERIMENT=regabi now implies the working subset of these (currently, regabiwrappers, regabig, and regabireflect). This simplifies testing, helps derisk the register ABI project, and will also help with performance comparisons. This replaces the -abiwrap flag to the compiler and linker with the regabiwrappers experiment. As part of this, regabiargs now enables registers for all calls in the compiler. Previously, this was statically disabled in regabiEnabledForAllCompilation, but now that we can control it independently, this isn't necessary. For #40724. Change-Id: I5171e60cda6789031f2ef034cc2e7c5d62459122 Reviewed-on: https://go-review.googlesource.com/c/go/+/302070 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: David Chase <drchase@google.com>
2021-03-11cmd: move GOEXPERIMENT knob from make.bash to cmd/goMatthew Dempsky
This CL changes GOEXPERIMENT to act like other GO[CONFIG] environment variables. Namely, that it can be set at make.bash time to provide a default value used by the toolchain, but then can be manually set when running either cmd/go or the individual tools (compiler, assembler, linker). For example, it's now possible to test rsc.io/tmp/fieldtrack by simply running: GOEXPERIMENT=fieldtrack go test -gcflags=-l rsc.io/tmp/fieldtrack \ -ldflags=-k=rsc.io/tmp/fieldtrack.tracked without needing to re-run make.bash. (-gcflags=-l is needed because the compiler's inlining abilities have improved, so calling a function with a for loop is no longer sufficient to suppress inlining.) Fixes #42681. Change-Id: I2cf8995d5d0d05f6785a2ee1d3b54b2cfb3331ca Reviewed-on: https://go-review.googlesource.com/c/go/+/300991 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-10-13cmd/asm: reject misplaced go:build commentsRuss Cox
We are converting from using error-prone ad-hoc syntax // +build lines to less error-prone, standard boolean syntax //go:build lines. The timeline is: Go 1.16: prepare for transition - Builds still use // +build for file selection. - Source files may not contain //go:build without // +build. - Builds fail when a source file contains //go:build lines without // +build lines. <<< Go 1.17: start transition - Builds prefer //go:build for file selection, falling back to // +build for files containing only // +build. - Source files may contain //go:build without // +build (but they won't build with Go 1.16). - Gofmt moves //go:build and // +build lines to proper file locations. - Gofmt introduces //go:build lines into files with only // +build lines. - Go vet rejects files with mismatched //go:build and // +build lines. Go 1.18: complete transition - Go fix removes // +build lines, leaving behind equivalent // +build lines. This CL provides part of the <<< marked line above in the Go 1.16 step: rejecting files containing //go:build but not // +build. Reject any //go:build comments found after actual assembler code (include #include etc directives), because the go command itself doesn't read that far. For #41184. Change-Id: Ib460bfd380cce4239993980dd208afd07deff3f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/240602 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-02all: use "reports whether" consistently in the few places that didn'tBrad Fitzpatrick
Go documentation style for boolean funcs is to say: // Foo reports whether ... func Foo() bool (rather than "returns true if") This CL also replaces 4 uses of "iff" with the same "reports whether" wording, which doesn't lose any meaning, and will prevent people from sending typo fixes when they don't realize it's "if and only if". In the past I think we've had the typo CLs updated to just say "reports whether". So do them all at once. (Inspired by the addition of another "returns true if" in CL 146938 in fd_plan9.go) Created with: $ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true iff" | grep -v vendor) $ perl -i -npe 's/returns true if/reports whether/' $(git grep -l "returns true if" | grep -v vendor) Change-Id: Ided502237f5ab0d25cb625dbab12529c361a8b9f Reviewed-on: https://go-review.googlesource.com/c/147037 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-02-26cmd/compile: track line directives w/ column informationRobert Griesemer
Extend cmd/internal/src.PosBase to track column information, and adjust the meaning of the PosBase position to mean the position at which the PosBase's relative (line, col) position starts (rather than indicating the position of the //line directive). Because this semantic change is made in the compiler's noder, it doesn't affect the logic of src.PosBase, only its test setup (where PosBases are constructed with corrected incomming positions). In short, src.PosBase now matches syntax.PosBase with respect to the semantics of src.PosBase.pos. For #22662. Change-Id: I5b1451cb88fff3f149920c2eec08b6167955ce27 Reviewed-on: https://go-review.googlesource.com/96535 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-11-13cmd/compile: record original and absolute file names for line directivesgriesemer
Also, with this change, error locations don't print absolute positions in [] brackets following positions relative to line directives. To get the absolute positions as well, specify the -L flag. Fixes #22660. Change-Id: I9ecfa254f053defba9c802222874155fa12fee2c Reviewed-on: https://go-review.googlesource.com/77090 Reviewed-by: David Crawshaw <crawshaw@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2017-04-19cmd/internal/objabi: extract shared functionality from objMatthew Dempsky
Now only cmd/asm and cmd/compile depend on cmd/internal/obj. Changing the assembler backends no longer requires reinstalling cmd/link or cmd/addr2line. There's also now one canonical definition of the object file format in cmd/internal/objabi/doc.go, with a warning to update all three implementations. objabi is still something of a grab bag of unrelated code (e.g., flag and environment variable handling probably belong in a separate "tool" package), but this is still progress. Fixes #15165. Fixes #20026. Change-Id: Ic4b92fac7d0d35438e0d20c9579aad4085c5534c Reviewed-on: https://go-review.googlesource.com/40972 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2017-01-09[dev.inline] cmd/internal/src: replace src.Pos with syntax.PosRobert Griesemer
This replaces the src.Pos LineHist-based position tracking with the syntax.Pos implementation and updates all uses. The LineHist table is not used anymore - the respective code is still there but should be removed eventually. CL forthcoming. Passes toolstash -cmp when comparing to the master repo (with the exception of a couple of swapped assembly instructions, likely due to different instruction scheduling because the line-based sorting has changed; though this is won't affect correctness). The sizes of various important compiler data structures have increased significantly (see the various sizes_test.go files); this is probably the reason for an increase of compilation times (to be addressed). Here are the results of compilebench -count 5, run on a "quiet" machine (no apps running besides a terminal): name old time/op new time/op delta Template 256ms ± 1% 280ms ±15% +9.54% (p=0.008 n=5+5) Unicode 132ms ± 1% 132ms ± 1% ~ (p=0.690 n=5+5) GoTypes 891ms ± 1% 917ms ± 2% +2.88% (p=0.008 n=5+5) Compiler 3.84s ± 2% 3.99s ± 2% +3.95% (p=0.016 n=5+5) MakeBash 47.1s ± 1% 47.2s ± 2% ~ (p=0.841 n=5+5) name old user-ns/op new user-ns/op delta Template 309M ± 1% 326M ± 2% +5.18% (p=0.008 n=5+5) Unicode 165M ± 1% 168M ± 4% ~ (p=0.421 n=5+5) GoTypes 1.14G ± 2% 1.18G ± 1% +3.47% (p=0.008 n=5+5) Compiler 5.00G ± 1% 5.16G ± 1% +3.12% (p=0.008 n=5+5) Change-Id: I241c4246cdff627d7ecb95cac23060b38f9775ec Reviewed-on: https://go-review.googlesource.com/34273 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2016-02-25cmd/asm: fix EOF message on operand parsing errors.Tal Shprecher
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>
2015-11-08cmd/asm/internal/lex: format error correctlyDominik Honnef
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>
2015-09-21cmd/asm: fix crash triggered by nested #defineRob Pike
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>
2015-09-18asm: handle EOF betterRob Pike
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>
2015-09-04cmd/asm: fix handling of nested #if[n]defsMichael Hudson-Doyle
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>
2015-05-15cmd/internal/obj: update callers to Linkline{fmt,hist} and removeMatthew Dempsky
Does the TODOs added by https://golang.org/cl/7623. Passes rsc.io/toolstash/buildall. Change-Id: I23913a8f03834640e9795d48318febb3f88c10f9 Reviewed-on: https://go-review.googlesource.com/9160 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-21[dev.cc] cmd/asm: add end-to-end testRob Pike
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>
2015-02-19[dev.cc] cmd/asm: accept #define A /* nothing */Rob Pike
Was rejected but should be legal. Change-Id: I0189e3bef6b67c6ba390c75a48a8d9d8f39b7636 Reviewed-on: https://go-review.googlesource.com/5286 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-17[dev.cc] cmd/asm: fix macro definition bug in the lexerRob Pike
Because text/scanner hides the spaces, the lexer treated #define A(x) and #define A (x) the same, but they are not: the first is an argument with macros, the second is a simple one-word macro whose definition contains parentheses. Fix this by noticing the relative column number as we move from A to (. Hacky but simple. Also add a helper to recognize the peculiar ARM shifted register operators. Change-Id: I2cad22f5f1e11d8dad40ad13955793d178afb3ae Reviewed-on: https://go-review.googlesource.com/4872 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-11[dev.cc] cmd/asm: final fixups for correct assembly of runtime, the last ↵Rob Pike
package to verify - obj: add a missing setting of the context for a generated JMP instruction - asm: correct the encoding of mode (R)(R*scale) - asm: fix a silly bug in the test for macro recursion. - asm: accept address mode sym(R)(R*8); was an oversight Change-Id: I27112eaaa1faa0d2ba97e414f0571b70733ea087 Reviewed-on: https://go-review.googlesource.com/4502 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-09[dev.cc] cmd/asm: rewrite to work with new obj APIRob Pike
Considerable rewriting of the parser and assembler (code generator) but it's simpler and shorter now. The internal Addr type is gone; so is the package that held it. Parsing of operands goes directly into obj.Addrs now. There is a horrible hack regarding register pairs. It uses the Class field to store the second register since it needs _some_ place to put it but none is provided in the API. An alternative would be nice but this works for now. Once again creates identical .6 and .8 files as the old assembler. Change-Id: I8207d6dfdfdb5bbed0bd870cb34ee0fe61c2fbfd Reviewed-on: https://go-review.googlesource.com/4062 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-03[dev.cc] asm: fix handling of statics (data<>) and symbolsRob Pike
A typo limited the number of center-dot substitutions to one. Fixed. With these changes, plus a recent fix to 6a, the are no differences, down to the bit level, in object code for any assembly files in std between asm and 6a. (Runtime has not been checked yet, but I expect no errors.) Change-Id: I0e8045b4414223d937e7f8919c8768860554b7d5 Reviewed-on: https://go-review.googlesource.com/3820 Reviewed-by: Russ Cox <rsc@golang.org>
2015-02-02[dev.cc] cmd/asm: fix a few minor issuesRob Pike
Fix one place where semicolons were not recognized and fix the pattern match for the syntax of some pseudo ops. Also clean up a couple of unreachable code pieces. There is still an undiagnosed bit difference betwen old and new .6 files. TBD. With these fixes, asm can successfully compile and test the entire tree. (Verified by turn off verifyAsm in cmd/go make.bash cp $GOROOT/bin/asm $GOROOT/pkg/tool/darwin_amd64/6a go test -short std ) Change-Id: I91ea892098f76ef4f129fd2530e0c63ffd8745a9 Reviewed-on: https://go-review.googlesource.com/3688 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-30[dev.cc] cmd/asm: handle the case where a macro is named without argumentsRob Pike
Given #define X() foo X() X cpp produces foo X Asm does now as well. Change-Id: Ia36b88a23ce1660e6a02559c4f730593d62066f1 Reviewed-on: https://go-review.googlesource.com/3611 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-30[dev.cc] cmd/asm: rewrite the macro processorRob Pike
The previous one was too broken, so just rewrite the code that invokes a macro. Basically it was evaluating things too early, and mishandling nested invocations. It's also easier to understand now. Keep backslash-newline around in macro definitions. They get processed when the body is evaluated. Write some golden tests. Change-Id: I27435f77f258a0873f80932bdc8d13ad39821ac1 Reviewed-on: https://go-review.googlesource.com/3550 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-28[dev.cc] cmd/asm: fix the expression parser and add testsRob Pike
Rewrite the grammar to have one more production so it parses ~0*0 correctly and write tests to prove it. Change-Id: I0dd652baf65b48a3f26c9287c420702db4eaec59 Reviewed-on: https://go-review.googlesource.com/3443 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-24[dev.cc] cmd/asm: changes to get identical output as new6aRob Pike
Fix up a couple of minor things pointed out in the last review. Also: 1. If the symbol starts with center dot, prefix the name with "". 2. If there is no locals size specified, use ArgsSizeUnknown (sic). 3. Do not emit a history point at the start of a macro invocation, since we do not pop it at the end, behavior consistent with the old code. With these changes, old and new assemblers produce identical output at least for my simple test case, so that provides a verifiable check for future cleanups. Change-Id: Iaa91d8e453109824b4be44321ec5e828f39f0299 Reviewed-on: https://go-review.googlesource.com/3242 Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-23[dev.cc] cmd/asm: add lex internal packageRob Pike
Add the lexing code for the new portable assembler. It is internal to the assembler, so lives in a subdirectory of cmd/asm/internal. Its only new dependency is the flags package for the assembler, so add that too; it's trivial. That package manages the command-line flags in a central place. The lexer builds on text/scanner to lex the input, including doing a Plan 9-level implementation of the C preprocessor. Change-Id: I262e8717b8c797010afaa5051920839906c0dd19 Reviewed-on: https://go-review.googlesource.com/3195 Reviewed-by: Russ Cox <rsc@golang.org>