Testers required for tool for LDC - asm_parse
Cecil Ward
cecil at cecilward.com
Fri Jul 7 00:28:48 UTC 2023
On Thursday, 6 July 2023 at 23:01:19 UTC, Cecil Ward wrote:
> On Thursday, 6 July 2023 at 21:43:18 UTC, kinke wrote:
>> I think adding symbol-names support in LDC directly would be
>> quite straight-forward - by replacing the symbol names in the
>> assembly template string with the operand's underlying numeric
>> ID. See
>> https://github.com/ldc-developers/ldc/blob/d4f2bed3a45688b32434d429e39c22dea5a9ffda/gen/asm-gcc.cpp#L186-L196. The raw string would be `insn`.
>
> Indeed, that’s what I did, that and removing the name
> definitions from inside the constraint blocks. It turned out to
> be a pain to parse the whole thing properly though, and as I’m
> both very rusty and very unwell it took me quite a while. The
> forum was extremely helpful.
I hope I have the transformed syntax correct. I always write with
GDC and always use variable names, but I don’t have much
experience at all.
Here’s a test run:
0237: Module Test::
source:
asm=[asm @safe pure nothrow nogc
{
.intel_syntax
add %[ p1 ], %[ p2 ]
mov %[ p3 ], %[ p1 ]
.att_syntax
: /* output */
[ p1 ] "+r" ( sum ),
[ p3 ] "=r" ( dest )
: /* input */
[ p2 ] "rm" ( plus )
: /* clobbers */
;
}
]
result=[asm @safe pure nothrow nogc
{
.intel_syntax
add %0, %2
mov %1, %0
.att_syntax
: /* output */
"+r" ( sum ),
"=r" ( dest )
: /* input */
"rm" ( plus )
: /* clobbers */
;
}
];
More information about the digitalmars-d-ldc
mailing list