numba / llvmlite

A lightweight LLVM python binding for writing JIT compilers
https://llvmlite.pydata.org/
BSD 2-Clause "Simplified" License
1.94k stars 322 forks source link

Added llvm based process triple partitioning #1063

Closed kc611 closed 5 months ago

kc611 commented 5 months ago

As titiled,

This PR aims to add a llvm based binding that uses the internal Triple object to partition the process triple string into it's respective parts.

Example:

from llvmlite import binding

triple_string = binding.get_default_triple()
triple_string = "armv6hl-none-linux-gnueabi"

triple_parts = binding.get_triple_parts(triple_string)

print("Triple String:", triple_string)
print("Triple Parts:", triple_parts)
# Triple String: armv6hl-none-linux-gnueabi
# Triple Parts: ('arm', 'v6hl', 'unknown', 'linux', 'gnueabi', 'ELF')
gmarkall commented 5 months ago

Following the addition of the above change, I wonder if it's worth also adding tests that check with the XCOFF, Wasm, MachO, and GOFF cases too (there seem to be no tests in the LLVM test suite that result in an unknown object format).

gmarkall commented 5 months ago

Source for the above object format enum is: https://github.com/llvm/llvm-project/blob/f28c006a5895fc0e329fe15fead81e37457cb1d1/llvm/include/llvm/ADT/Triple.h#L237-L246