Query target features?

Hi everyone,

Is there a target equivalent to getHostCPUFeatures?

https://llvm.org/doxygen/namespacellvm_1_1sys.html#a768d54e5ada846d513f72d9e43e89ef6

Additionally, is it possible to query target vector widths, and the number of vector registers (e.g. 16 for x86 with AVX, 32 with AVX512, but only 8 if in 32-bit mode)?

I have been using getHostCPUFeatures for features, and then on x86 I’ve added some simple logic to pick vector width and number of registers. For other architecutres, I’m using some generic values. LLVM has all this information, so it’d be great if I could use it for other architectures like ARM and POWER (and for x86 too), but I’m not sure how to access it myself.

Background:
I’m the author of a somewhat experimental Julia library called “LoopVectorization.jl” that autovectorizes loops.
The optimization decisions it makes are target specific, and the final generated code itself is as well, and not always in a manner that backends can handle if incorrect, e.g. it might use something like @llvm.x86.avx512.mask.pternlog.q.512.
I’ve been making the assumption that the host is the target (and using getHostCPUFeatures). This isn’t always the case, which has resulted in crashes before for some users.

Thanks everyone,
Chris