https://issues.dlang.org/show_bug.cgi?id=20594

--- Comment #1 from Iain Buclaw <ibuc...@gdcproject.org> ---
(In reply to Iain Buclaw from comment #0)
> Then going one further and replacing the colons with commas.
> 
> asm pure nothrow @nogc {
>     "cmoveq %1, %2, %[result]",   // insn
>     [result = "=r": result],      // outputs
>     ["r": test, "r": newvalue,    // inputs
>      "[result]": oldvalue],
>     ["memory"];                   // clobbers
> }
> 

Could even drop the order dependency and re-use struct literal syntax of using
labels to denote "fields" of the asm statement.

asm pure nothrow @nogc {
    insn:     "cmoveq %1, %2, %[result]",
    clobbers: ["memory"],
    inputs:   ["r": test, "r": newvalue,
               "[result]": oldvalue],
    outputs:  [result = "=r": result],
}

And so in the last example.

> int main()
> {
>     int iInt = 1;
> top:
>     asm nothrow @nogc {
>         "some assembler instructions here",
>         [/* No outputs. */],
>         ["q": iInt, "X": char.sizeof + 1, "i": 42],
>         [/* No clobbers. */],
>         [top];
>     }
> }

It can be abbreviated to:

int main()
{
    int iInt = 1;
top:
    asm nothrow @nogc {
        "some assembler instructions here",
        inputs: ["q": iInt, "X": char.sizeof + 1, "i": 42],
        labels: [top];
    }
}

--

Reply via email to