# cbe: avoid collisions with builtins and intrinsics · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/ce293c982e1b6d9db775e02fefb8905caa4ee748)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: ce293c982e1b6d9db775e02fefb8905caa4ee748

Requested commit: ce293c982e1b6d9db775e02fefb8905caa4ee748

Commit: ce293c982e1b6d9db775e02fefb8905caa4ee748

Tree: bb3a9a7ef4746efaeb656857aff91172520ee309

Author: kcbanner

Committer: kcbanner

## Message

````
cbe: avoid collisions with builtins and intrinsics

Changes:
- Add `isMangledIdent` to determine if `fmtIdent` would make any edits to the identifier
- Any function that has a mangled identifier is referred to using the mangled identifer
  within the current file, but if it is exported the first export will be with the non-mangled name.
- Add `zig_import` to import a symbol under a different name
- Add a level of indirection to float function names. Now, they are referred to as
  `zig_float_fn_<float type>_<operation>`. The definitions in zig.h are wrapped
  with `zig_import` to import the symbol under the real name.

The specific problem that sparked this change was the combination of
`zig_libc_name_f80(name) __##name##x` with the input `fma`, resulting
in `__fmax`, which is a new intrinsic in recent versions of cl.exe.

With the above changes in place, compiler_rt can output the following:

```
static zig_weak_linkage_fn zig_f80 zig_e___fmax(zig_f80, zig_f80, zig_f80);
zig_export(zig_weak_linkage_fn zig_f80 zig_e___fmax(zig_f80, zig_f80, zig_f80), __fmax, "__fmax");
```

Within compiler_rt, `zig_e___fmax` is used to refer to the function, but consumers
will import `__fmax`, which maps to their `zig_float_fn_f80_fma` definition from zig.h.

````

## Parents

- [58789cb054b16e87d0a9b69ed8484cd30664fdb0](https://git.cafe/gitcafe/zig/commit/58789cb054b16e87d0a9b69ed8484cd30664fdb0?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/ce293c982e1b6d9db775e02fefb8905caa4ee748?format=markdown)
