Skip to content

Load/store default alignment? #158

Closed

Description

@AndrewScheidecker

I can't find anything in the spec interpreter that defines the default alignment of loads/stores. If an align= attribute is omitted, then the memop's align member is None, and the evaluator just ignores the alignment. Can it be made more explicit what the default alignment is?

Activity

  1. lukewagner commented on Nov 2, 2015

    @lukewagner
    Member

    The evaluator always ignores alignment. The intention is that None means "no hint" and therefore natural alignment. But I guess I can see confusion with None meaning "completely unaligned" (i.e., align=1), so it'd be just as well to remove the option and make align an int that parser.mly fills in when missing.

  2. jcbeyler commented on Nov 3, 2015

    @jcbeyler

    Plus we should perhaps define this in the design no? I looked quickly and did not see much information about the lack of information on alignment and what it implied.

  3. lukewagner commented on Nov 3, 2015

    @lukewagner
    Member

    If we keep alignment an option, then yes, it'd make sense for AstSemantics.md to say the hint is optional and, when not present, natural alignment should be assumed. If the alignment is changed to a non-optional int, then it's a syntactic sugar detail of the sexpr language that the align immediate is optional.

  4. jcbeyler commented on Nov 3, 2015

    @jcbeyler

    Seems bizarre to me to say that we have to do align for a load but the immediate is optional.

    (i32.load align (i32.const 0)) seems just overkill. I really think that the default should be that it is optional and if not there, it is defined in the AstSemantics.md as then meaning the load is of natural alignment.

  5. titzer commented on Nov 3, 2015

    @titzer
    Contributor

    I think Luke was suggesting that the hint missing means that the access is
    assumed to be aligned.

    So:

    (i32.load (i32.const 0))

    and

    (i32.load unaligned (i32.const 1))

    ?

    On Tue, Nov 3, 2015 at 6:52 AM, jcbeyler [email protected] wrote:

    Seems bizarre to me to say that we have to do align for a load but the
    immediate is optional.

    (i32.load align (i32.const 0)) seems just overkill. I really think that
    the default should be that it is optional and if not there, it is defined
    in the AstSemantics.md as then meaning the load is of natural alignment.

    —
    Reply to this email directly or view it on GitHub
    #158 (comment).

  6. lukewagner commented on Nov 4, 2015

    @lukewagner
    Member

    The s-expr language offers a variety of syntactic sugar wherein you can omit things and the obvious default AST node is generated. Having a missing align attribute imply natural alignment seems to be no different. Thus, (i32.load (i32.const 0)) would imply align=4. From AstSemantics.md POV (as it is currently written), there is always an alignment immediate, so no need to say what the default is. However, as I said above, we could change AstSemantics.md to say "alignment is optional, when missing natural alignment is assumed". I think it's all just a matter of subjective preference until we get to the binary encoding.

  7. rossberg commented on Feb 25, 2016

    @rossberg
    Member

    This has been resolved.

  8. added a commit that references this issue on Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions