Math intrinsics

But that opens up two questions:

  1. What to do with llvm.my_special_math_function in a backend that doesn’t have special lowering? Fallback to libc calls (which means having all recognition stuff both in clang and backwards in the backends)? It also won’t work for non-libc systems as of yet (though that is hopefully fixed at some point). We could ask the target but that has other problems too. It’s also not only a frontend issue as middle end passes, e.g., Enzyme, generate such math calls and would need to know what is available, what is an intrinsic, etc. Right now, the rough assumption is that all targets have all 10 math intrinsics or none of them, and in the latter case we see things already falling apart.
  2. Why do we need intrinsics in the first place? It can’t be only about the recognition logic, right? If we start with builtins, maybe, but if we start with my_special_math_function as a call in user code we still do libcall recognition in clang. And if we want other frontends to benefit we duplicate the recognition logic for them.