I had an idea to ease the process of creating D plus asm code using GDC's extended asm syntax. I'd like to get rid of the need to insert \n\t markers all over the place by, say, having separate strings and getting the D compiler to concatenate them. But I'm open to other suggestions. My attempt failed, because concatenating D strings unfortunately doesn't work in GDC at compile-time and I need CTFE. It's a requirement, as you'd expect, that this piece of sugar has zero cost.
I need to do something with mixin, I suspect. Any tips on where to go and how to stay within CTFE?
GDC is buggy in that the AssemblerTemplate in extended inline ASM is supposed to be a compile-time generate string, but actually isn't. What you can do is generate the string, put all the ASM stuff around it, and mix it in. I've been using something similar for a custom syscall implementation (which still inlines).
But frankly, that looks horrifying. It would be easier and more aesthetically pleasing to create a template to handle all of this for you, which takes an array of strings. You could implement extra stuffs in the template for handling certain opcodes and adding constraints automatically based on them. That would enable the code to work on DMD and LDC too, if you wanted it to. And you can use a bit of compile-time magic to work this all out. (EDIT) This actually works.
NOTES:
=to output constraints, you may want to combineIOpandOOpand differentiate input and output based on constraints (see the GCC docs for output constraints that work). Everything else would constitute input operands under the sharedstruct Opor similar.BTW, thanks for making me think of this! I need to implement it for my own stuff now.