Template lowering of druntime hooks that CTFE cannot interpret

max haughton maxhaton at gmail.com
Mon Jan 17 15:39:51 UTC 2022


On Monday, 17 January 2022 at 15:25:57 UTC, Teodor Dutu wrote:
> Hi,
>
> The current workflow of the compiler is that semantic analysis 
> deduces types for all expressions in the AST. Then, if CTFE is 
> required, the compiler performs the interpretation in 
> `dinterpret.d`.
> ```d
> bool f()
> {
> // ...
> }
> static assert(f());
> ```
> Before the backend can generate the code, the intermediate code 
> generator performs lowerings from expressions such as `a ~= b` 
> (when `b` is an array) to `_d_arrayappendT(a, b)` 
> [here](https://github.com/dlang/dmd/blob/25bf00749406171f4e7b52dbf0b6df9cb1181854/src/dmd/e2ir.d#L2715-L2734).
>
> [...]

Moving rewriting steps further up the compiler is a good thing. 
In this case it seems like a practical necessity anyway because 
ldc and GDC will have to do this eventually and they do not use 
e2ir et al, at all.


More information about the Digitalmars-d mailing list