Provide a Uniform Compiler Info Syntax
Version | 1 |
Created | 2015-02-03 |
Status | Draft |
Last modified | -- |
Author | Orvid King |
Abstract
The purpose of this DIP is to provide a unified way of providing additional information to an optimizing compiler in a way that is portable across implementations.
Rationale
DIP56 would create a way to manually control inlining, but would do it in a way that could cause issues with compilers that don’t support it. LDC and GDC also both have a couple of their own attributes used to specify certain compiler information.
Description
By providing an attribute at the language level to allow the user to provide additional information to an optimizing compiler, we can speed the acceptance of the addition of new facets of the attributes in the individual implementations, because each implementation will vary in their ability to handle the attributes. If a compiler cannot handle a specific attribute, it will simply ignore it. If the user has specified -vcompiler on the command line, then information about the attributes that are ignored will be dumped. This is an acceptable way to handle a compiler not supporting a specific attribute, because the only attributes that belong in this section are ones that have no functional change. That is to say, the code they are applied on will produce the same result regardless of if a compiler supports the attribute or not.
Usage
It is proposed that this be implemented in a fashion similar to UDA’s, except that arbitrary identifiers will be allowed within the parenthesis. For DIP56 the result would be:
@compiler(inline, never)
@compiler(inline, always)
@compiler(inline, default)
Copyright
This document has been placed in the Public Domain.