<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62919>62919</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            AArch64 feature macros don't respect -march=+nofeature
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          john-brawn-arm
      </td>
    </tr>
</table>

<pre>
    If you have the following
```
float fn(float x) {
#ifdef __ARM_FEATURE_BF16
  asm("bfcvt %h0, %s0" : "=w"(x));
  return x;
#else
  return x;
#endif
}
```
and compile it with `--target=aarch64-none-eabi -march=armv8.6-a+nobf16` then you get
```
tmp.c:3:7: error: instruction requires: bf16
  asm("bfcvt %h0, %s0" : "=w"(x));
      ^
```
The `__ARM_FEATURE` macros are supposed to be defined when the target supports the feature, but when an architecture version supports a feature by default then `+nofeature` is ignored when it comes to defining the macro.

These macros are also defined by the arm target, but there it appears to correctly handle `+nofeature` and the `__ARM_FEATURE` macro is not defined as expected.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslM2uozgQhZ_GbEpEpAhOWLAgkxtpFrNp9ayvDBTglrEZu0hu3n5k8tM9UtSriZAwtqvqfMflqBD0YIkqURxFcUrUwqPz1Q832rTx6mpT5aekcd2t-rOHm1tgVBcCHgl6Z4y7ajuI7CSyWsjs8ayfvXGKobcCD_fhl8ASxP742I257jvq4fOz_vbX5_mj_v73t4_P43kr7xsAVJgEHgRi07cXBoHFmAn8Iw5CJhBB5DUIRJGfrvGFh1giPvnxmcMTL97C12tKYE4m0G_Xbaf7x9f-9BZO2Q5aN83aEGiGq-YRhMzSlJUfiEV-Usq3o9yl1llKSTUa0ilOxSU_XQ4bmSqBR-uafiuFzKKjdvU3xr-rydO8aUVe5yKv9xGdvHc-DrQN7JeWtbPg6Z9Fewpxfk39P5oZf6L4eKvu-0jRgf-cZsSaVOtdAOUJwjLPLlAH7KAh6KjXljq4RvDYT3fv7ts8h3uPkeLFU1TaLHzfqyxEJzVTG9fgQj5E9FegeoZBc4tl1GL47m-UG01_ppUZ6AB6sM4_lWiOJ0shqlwlajusUlaSzQP-yRzoV0JlgntxNbc1TPnpQfaE4JH82jZqnkn5tVLrvKeWzQ1GZTtD75TGpuPf2RxZrOOXAhWAvmZqmbpN0lV5V-alSqjaysOuzGVZYDJWe2qoL7BpFWKfbcuSiPZSFlLmqseDTHSFGeZZgbvtLkMsNvteHfJ-l-XFNqOukGKX0aS02RhzmTbOD4kOYaFKYrktE6MaMmH9e0FsjbKDyOveO8tku9hpxSnxVQxNm2UIYpcZHTj8TMaaDVV1vd6n18k-XO-cFbhn8BQi6M9L9qt5yeJNNTLP8VYIPAs8D5rHpdm0bhJ4jqUer3T27ge1LPC8QgSB55Xj3wAAAP__rGaVEg">