~mpu/qbe

Add missing documentation for union types and VAL. v1 APPLIED

Chenguang Wang: 1
 Add missing documentation for union types and VAL.

 1 files changed, 28 insertions(+), 2 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mpu/qbe/patches/48176/mbox | git am -3
Learn more about email & git

[PATCH] Add missing documentation for union types and VAL. Export this patch

See previous discussion here[1]. It's unclear to me how to preview HTML page
generated from the .txt file, though.

[1]: https://lists.sr.ht/~mpu/qbe/%3C87cz1jq26k.fsf%40greenfork.me%3E
---
 doc/il.txt | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/doc/il.txt b/doc/il.txt
index cc3e021..b036273 100644
--- a/doc/il.txt
+++ b/doc/il.txt
@@ -15,7 +15,7 @@
  2. <@ Types >
      * <@ Simple Types >
      * <@ Subtyping >
  3. <@ Constants >
  3. <@ Constants & Values >
  4. <@ Linkage >
  5. <@ Definitions >
      * <@ Aggregate Types >
@@ -168,7 +168,7 @@ The rationale is that a word can be signed or unsigned, so
extending it to a long could be done in two ways, either
by zero-extension, or by sign-extension.

- 3. Constants
- 3. Constants & Values
--------------

    `bnf
@@ -182,6 +182,10 @@ by zero-extension, or by sign-extension.
        CONST
      | 'thread' $IDENT  # Thread-local symbol

    VAL :=
        DYNCONST
      | %IDENT

Constants come in two kinds: compile-time constants and
dynamic constants.  Dynamic constants include compile-time
constants and other symbol variants that are only known at
@@ -221,6 +225,10 @@ When the `thread` keyword prefixes a symbol name, the
symbol's numeric value is resolved at runtime in the
thread-local storage.

Values are used in regular, phi, and jump instructions
within function definitions.  They could be either constants
or function-scope temporaries.

- 4. Linkage
------------

@@ -293,6 +301,15 @@ using linkage flags.
        '{'
            ( SUBTY [NUMBER] ),
        '}'
      | # Union type
        'type' :IDENT '=' ['align' NUMBER]
        '{'
            (
                '{'
                    ( SUBTY [NUMBER] ),
                '}'
            )+
        '}'
      | # Opaque type
        'type' :IDENT '=' 'align' NUMBER '{' NUMBER '}'

@@ -318,6 +335,15 @@ explicitly specified by the programmer.

    type :cryptovector = align 16 { w 4 }

Union types allows the same chunk of memory to be
reinterpreted using different layouts.  They are defined by
enclosing multiple regular aggregate type bodies in another
pair of curly braces.  Size and alignment of union types are
determined by the max size and alignment of each variation,
or for the case of alignment, could be explicitly specified.

    type :un9 = { { b } { s } }

Opaque types are used when the inner structure of an
aggregate cannot be specified; the alignment for opaque
types is mandatory.  They are defined simply by enclosing
-- 
2.42.0
Super work, thanks!

It's now merged in master.