Skip to content

Proposal: syntax to load constants into a vector #11

@rasky

Description

@rasky

To load constant values into a vector, one needs to store the values in .data and then load them via load().

In theory, there could be a different syntax for that, such as:

vec16 foo;
foo = { 0x1234, 0x4567, 0x1212, 0x4040, 0xaaaa, 0xbbbb, 0xcccc,  0xdddd };

(I didn't think of the exact syntax, just the semantics).

This would create a .data variable automatically and load it.

Since it is pretty common to have some kind of repeated patterns in constant vectors, we could also detect special cases:

foo = { 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234, 0x1234 };

This could load a single lane with the constant and then broadcast it to the whole vector (eg: via vor).

There are also special constants that can be "materialized" like 0x0000 (via VZERO), 0xFFFF (via vnor with VZERO), power of two (copying them from the shift vectors), etc., which could generate special code for the user without them even knowing this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions