packed_simd icon indicating copy to clipboard operation
packed_simd copied to clipboard

Consider adding a SimdABI type parameter to select ABI

Open gnzlbg opened this issue 6 years ago • 3 comments

We could extend Simd<[T; N]> to Simd<[T; N], SimdABI = DefaultSimdABI> to enable users to, for example, use Simd<[f32; 4], AVX> and generate code that assumes that AVX is available.

cc @rkruppe

gnzlbg avatar May 24 '19 14:05 gnzlbg

I don't understand how this could allow changing the (function call) ABI. The instructions used by operations on that ytpe, sure (though probably with all the same problems of mismatched target_features), but how could it affect the type is passed between functions in LLVM IR / machine code?

hanna-kruppe avatar May 24 '19 15:05 hanna-kruppe

My plan was to duplicate the implementation of the whole API per ABI, and for each ABI, #[target_feature(enable = "SimdAbi")] all functions and methods.

gnzlbg avatar May 24 '19 16:05 gnzlbg

The type passed is the same (#[repr(simd)] struct(f32,f32,f32,f32) => <4 x float>) - that does not change per "ABI" in this scheme. The only thing that would change is the target feature on that type's methods.

Something like a target-feature propagation pass in LLVM would deal with the rest: https://bugs.llvm.org/show_bug.cgi?id=41138

gnzlbg avatar May 24 '19 16:05 gnzlbg