mirror of
https://github.com/golang/go.git
synced 2025-10-19 19:13:18 +00:00
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:
parent
2ab210bc74
commit
195e64232d
1 changed files with 88 additions and 85 deletions
|
@ -5,22 +5,23 @@
|
||||||
/*
|
/*
|
||||||
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 .
|
||||||
|
|
||||||
version = uint32 . // used for backward compatibility
|
version = uint32 . // used for backward compatibility
|
||||||
flags = uint32 . // feature flags used across versions
|
flags = uint32 . // feature flags used across versions
|
||||||
sectionEnds = [10]uint32 . // defines section boundaries
|
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
|
||||||
SectionMeta
|
SectionMeta
|
||||||
SectionPosBase
|
SectionPosBase
|
||||||
SectionPkg // TODO(markfreeman) Define.
|
SectionPkg // TODO(markfreeman) Define.
|
||||||
|
@ -33,54 +34,55 @@ 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.
|
||||||
PackageRef // TODO(markfreeman): Define.
|
PackageRef // TODO(markfreeman): Define.
|
||||||
[ HasInit ]
|
[ HasInit ]
|
||||||
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
|
||||||
elements.
|
elements.
|
||||||
|
|
||||||
SectionPosBase = { PosBase } .
|
SectionPosBase = { PosBase } .
|
||||||
|
|
||||||
A base is either a file base or line base (produced by a line
|
A base is either a file base or line base (produced by a line
|
||||||
directive). Every base has a position, line, and column; these are
|
directive). Every base has a position, line, and column; these are
|
||||||
constant for file bases and hence not encoded.
|
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
|
||||||
|
@ -91,7 +93,7 @@ A source position Pos represents a file-absolute (line, column) pair
|
||||||
and a PosBase indicating the position Pos is relative to. Positions
|
and a PosBase indicating the position Pos is relative to. Positions
|
||||||
without a PosBase have no line or column.
|
without a PosBase have no line or column.
|
||||||
|
|
||||||
Pos = [ SyncPos ] // TODO(markfreeman): Define.
|
Pos = [ SyncPos ] // TODO(markfreeman): Define.
|
||||||
Bool // true if the position has a base
|
Bool // true if the position has a base
|
||||||
// The below is ommitted if the position has no base.
|
// The below is ommitted if the position has no base.
|
||||||
[ Ref[PosBase]
|
[ Ref[PosBase]
|
||||||
|
@ -100,33 +102,34 @@ 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.
|
||||||
RelocCount
|
RelocCount
|
||||||
{ Reloc }
|
{ Reloc }
|
||||||
.
|
.
|
||||||
// TODO(markfreeman): Rename to RefTableEntryCount.
|
// TODO(markfreeman): Rename to RefTableEntryCount.
|
||||||
RelocCount = Uint64 .
|
RelocCount = Uint64 .
|
||||||
// TODO(markfreeman): Rename to RefTableEntry.
|
// TODO(markfreeman): Rename to RefTableEntry.
|
||||||
Reloc = [ SyncReloc ] // TODO(markfreeman): Define.
|
Reloc = [ SyncReloc ] // TODO(markfreeman): Define.
|
||||||
SectionKind
|
SectionKind
|
||||||
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.
|
||||||
RelIndex
|
RelIndex
|
||||||
.
|
.
|
||||||
|
|
||||||
# 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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue