Question about GCC / GDC / LDC syntax of inline asm advanced

Cecil Ward cecil at cecilward.com
Fri Jul 7 14:57:42 UTC 2023


On Friday, 7 July 2023 at 12:12:15 UTC, Iain Buclaw wrote:
> On Friday, 7 July 2023 at 11:39:44 UTC, Iain Buclaw wrote:
>> On Thursday, 6 July 2023 at 23:11:08 UTC, Cecil Ward wrote:
>>>[...]
>>
>> The first part is parsed as an 
>> [AssignExpression](https://dlang.org/spec/expression.html#assign_expressions), so you could have:
>>
>> ```
>> asm {
>>   (test ? "if-true-insn" : "if-false-insn")
>>   ~ buildAsmString(foo, bar)
>>   ~ test2() ? enumInsnTrue : enumInsnFalse // 
>> assign-expression finishes here
>>   : output-constraints
>>   : ...
>> }
>> ```
>> It's only at semantic-time that a "string-literal" result is 
>> enforced using CTFE.
>>
>
> As shown in compiler explorer: https://d.godbolt.org/z/eTqvW8o8E

Many thanks Iain. Much appreciated. I just had a go at checking 
for the ? : expression with a simple state machine. As I 
mentioned, I’m not doing a proper parse here, not by a million 
miles, just the bare minimum to get it to work.




More information about the Digitalmars-d mailing list