cmd/compile/internal/noder: format grammar

This just wraps column width to 72 and indents production definitions
so they are easier to distinguish from prose.

Change-Id: I386b122b4f617db4b182ebb549fbee4f35a0122c
Reviewed-on: https://go-review.googlesource.com/c/go/+/673536
TryBot-Bypass: Mark Freeman <mark@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <mark@golang.org>
This commit is contained in:
Mark Freeman 2025-05-16 10:58:45 -04:00 committed by Gopher Robot
parent 2ab210bc74
commit 195e64232d

View file

@ -5,7 +5,8 @@
/* /*
The Unified IR (UIR) format is implicitly defined by the package noder. The Unified IR (UIR) format is implicitly defined by the package noder.
At the highest level, a package encoded in UIR follows the grammar below. At the highest level, a package encoded in UIR follows the grammar
below.
File = Header Payload fingerprint . File = Header Payload fingerprint .
Header = version [ flags ] sectionEnds elementEnds . Header = version [ flags ] sectionEnds elementEnds .
@ -16,8 +17,8 @@ sectionEnds = [10]uint32 . // defines section boundaries
elementEnds = []uint32 . // defines element boundaries elementEnds = []uint32 . // defines element boundaries
fingerprint = [8]byte . // sha256 fingerprint fingerprint = [8]byte . // sha256 fingerprint
The payload is a series of sections. Each section has a kind which determines The payload is a series of sections. Each section has a kind which
its index in the series. determines its index in the series.
SectionKind = Uint64 . SectionKind = Uint64 .
Payload = SectionString Payload = SectionString
@ -33,29 +34,30 @@ Payload = SectionString
. .
# Sections # Sections
A section is a series of elements of a type determined by the section's kind. A section is a series of elements of a type determined by the section's
Go constructs are mapped onto (potentially multiple) elements. Elements are kind. Go constructs are mapped onto (potentially multiple) elements.
accessed using an index relative to the start of the section. Elements are accessed using an index relative to the start of the
section.
// TODO(markfreeman): Rename to SectionIndex. // TODO(markfreeman): Rename to SectionIndex.
RelIndex = Uint64 . RelIndex = Uint64 .
## String Section ## String Section
String values are stored as elements in the string section. Elements outside String values are stored as elements in the string section. Elements
the string section access string values by reference. outside the string section access string values by reference.
SectionString = { String } . SectionString = { String } .
## Meta Section ## Meta Section
The meta section provides fundamental information for a package. It contains The meta section provides fundamental information for a package. It
exactly two elements a public root and a private root. contains exactly two elements a public root and a private root.
SectionMeta = PublicRoot SectionMeta = PublicRoot
PrivateRoot // TODO(markfreeman): Define. PrivateRoot // TODO(markfreeman): Define.
. .
The public root element identifies the package and provides references for all The public root element identifies the package and provides references
exported objects it contains. for all exported objects it contains.
PublicRoot = Relocs PublicRoot = Relocs
[ SyncPublic ] // TODO(markfreeman): Define. [ SyncPublic ] // TODO(markfreeman): Define.
@ -64,8 +66,8 @@ PublicRoot = Relocs
ObjectRefCount // TODO(markfreeman): Define. ObjectRefCount // TODO(markfreeman): Define.
{ ObjectRef } // TODO(markfreeman): Define. { ObjectRef } // TODO(markfreeman): Define.
. .
HasInit = Bool . // Whether the package uses any initialization HasInit = Bool . // Whether the package uses any
// functions. // initialization functions.
## PosBase Section ## PosBase Section
This section provides position information. It is a series of PosBase This section provides position information. It is a series of PosBase
@ -80,7 +82,7 @@ constant for file bases and hence not encoded.
PosBase = Relocs PosBase = Relocs
[ SyncPosBase ] // TODO(markfreeman): Define. [ SyncPosBase ] // TODO(markfreeman): Define.
StringRef // the (absolute) file name for the base StringRef // the (absolute) file name for the base
Bool // true if it is a file base, else a line base Bool // true if a file base, else a line base
// The below is ommitted for file bases. // The below is ommitted for file bases.
[ Pos [ Pos
Uint64 // line Uint64 // line
@ -100,8 +102,9 @@ Pos = [ SyncPos ] // TODO(markfreeman): Define.
. .
# References # References
A reference table precedes every element. Each entry in the table contains a A reference table precedes every element. Each entry in the table
section / index pair denoting the location of the referenced element. contains a section / index pair denoting the location of the referenced
element.
// TODO(markfreeman): Rename to RefTable. // TODO(markfreeman): Rename to RefTable.
Relocs = [ SyncRelocs ] // TODO(markfreeman): Define. Relocs = [ SyncRelocs ] // TODO(markfreeman): Define.
@ -116,8 +119,8 @@ Reloc = [ SyncReloc ] // TODO(markfreeman): Define.
RelIndex RelIndex
. .
Elements encode references to other elements as an index in the reference Elements encode references to other elements as an index in the
table not the location of the referenced element directly. reference table not the location of the referenced element directly.
// TODO(markfreeman): Rename to RefUse. // TODO(markfreeman): Rename to RefUse.
UseReloc = [ SyncUseReloc ] // TODO(markfreeman): Define. UseReloc = [ SyncUseReloc ] // TODO(markfreeman): Define.
@ -125,8 +128,8 @@ UseReloc = [ SyncUseReloc ] // TODO(markfreeman): Define.
. .
# Primitives # Primitives
Primitive encoding is handled separately by the pkgbits package. Check there Primitive encoding is handled separately by the pkgbits package. Check
for definitions of the below productions. there for definitions of the below productions.
* Bool * Bool
* Int64 * Int64