Lack of asm volatile qualifier (explicitly) again.
Cecil Ward
cecil at cecilward.com
Tue Jul 28 06:57:36 UTC 2020
I read recently that all asm in D is regarded as ‘volatile’ in
the GCC sense, which I take to mean that it is assume to
potentially have side effects, and so cannot be optimised away to
nothing by the compiler despite the lack of any outputs.
I would like to be able to either use the asm volatile qualifier
now and have it do absolutely nothing or else have an alternative
way of expressing the licence for optimisation allowed by the
designer. If it is now way too late to declare that suddenly the
_lack_ of volatile means that the compiler can go
optimisation-crazy, then we need some alternative
‘is_optimisable’ keyword.
Even if we think that we need an ‘is-optimisable’ qualifier, then
I would still like to be able to include the asm volatile
qualifier or similar just to document the designer’s intent in
cases where we genuinely do have a non-obvious side effect in the
asm.
What do others think? If others agree, how could a very small DIP
be set in motion ?
That would mean just adding one or two new keywords for the asm
qualifier(s), which do precisely nothing at present.
If GCC and LDC were willing to start optimising at some point
then it would be a matter of doing what the sibling C compilers
do with volatile and non-volatile.
More information about the Digitalmars-d-learn
mailing list