Clang has recently gained the ability to do a -mtune
flag. This flag from GCC tells the compiler to emit instructions for some (probably ancient, like generic x86-64) CPU, but schedule (order) the instructions for a (probably more common, like a broadwell or a znver2) one. On the LLVM side, this is handled through a tune-cpu
attribute, although at present only the x86 backend cares about it.
Rustc should make this a -C
flag for users to take advantage of this feature.
Alright, so I poked around this a bit. It seems that for LLVM all that needs to be done is to tag all the functions with it like we are already doing for target-cpu
. (The linker doesn't care about it, so there's nothing to be done there. Same for the LLVM target object.)
For AVR-GCC I haven't found a good way to pass in the -mtune
yet, since target
only accepts a String
. (NUL
-deliminated fields maybe? nope nope nope)