Thread overview |
---|
November 12, 2019 How can I add attributes to __asm statement? | ||||
---|---|---|---|---|
| ||||
In gdc I can use the following: ``` asm @nogc @safe nothrow pure { ... } ``` but it doesn't work in case of ldc2. I can use a lambda: ``` () @nogc @trusted nothrow pure { __asm (...) } ``` but the lambda is inlined only in release mode. Additional stack frame or using only release mode is not convenient in my case. Is there another way to add attributes to __asm statement? |
November 12, 2019 Re: How can I add attributes to __asm statement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to drug | On Tuesday, 12 November 2019 at 16:33:28 UTC, drug wrote: > In gdc I can use the following: > ``` > asm @nogc @safe nothrow pure { > ... > } > ``` > but it doesn't work in case of ldc2. I can use a lambda: > ``` > () @nogc @trusted nothrow pure { > __asm (...) > } > ``` > but the lambda is inlined only in release mode. Additional stack frame or using only release mode is not convenient in my case. Is there another way to add attributes to __asm statement? LDC's `__asm` is not a statement, but a special function. It's already `pure nothrow @nogc`; if you want to call it in a @safe function, use `__asm_trusted` instead. See https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/llvmasm.di. |
November 12, 2019 Re: How can I add attributes to __asm statement? | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | 12.11.2019 21:20, kinke пишет:
> LDC's `__asm` is not a statement, but a special function. It's already `pure nothrow @nogc`; if you want to call it in a @safe function, use `__asm_trusted` instead. See https://github.com/ldc-developers/druntime/blob/ldc/src/ldc/llvmasm.di.
Thank you.
|
Copyright © 1999-2021 by the D Language Foundation