On 29/08/2017 2:49 AM, Cecil Ward wrote:
I have written a few zero-overhead (fully inlining) D wrappers around certain new x64 instructions as an exercise to help me learn D and get used to GDC asm. I've also written D replacements for older processors. They are templated functions with customised variants supporting a variety of different word-widths.

1. Would anyone find these useful? Bet I'm inventing the wheel? (But still a good learning task for me.)

Sure, why not?

2. How best to get them reviewed for correct D-style and

Lets talk about 3.

3. how to package them up, expose them? They need to be usable by the caller in such a was as they get fully directly inlined with no subroutine calls or arg passing adaptation overhead so as to get the desired full 100% performance. For example a call with a literal constant argument should continue to mean an immediate operand in the generated code, which happens nicely currently in my testbeds. So I don't know, the user needs to see the lib fn _source_ or some equivalent GDC cleverness. (Like entire thing in a .h file. Yes, I know, I know. :-) )

Dub + force -inline.
Also you will need to support ldc and dmd.

4. I would like to do the same for LDC, unfortunately the asm system is rather different from GDC. I don't know if there is anything clever I can do to try to avoid duplication of effort / totally split sources and double maintenance? (Desperation? Preprocess the D sources with an external tool if all else fails! Yuck. Don't have one at hand right now anyway.)

Duplicate. Nothing wrong with that for such little code. Its already abstracted nicely out.

As long as you are using function arguments as part of you iasm, push/pop registers you use, it should be inlined correctly as per the arguments.
But I'd like to see some code before making any other remarks.

I highly suggest you hang out on IRC (#d Freenode) to help get interactive reviews+suggestions.
  • Cpu instructions exposed Cecil Ward via Digitalmars-d-learn
    • Re: Cpu instructions exposed rikki cattermole via Digitalmars-d-learn

Reply via email to