3 ms·
The JSON file exists because there's more than one place that needs to know about the intrinsics---they allow generating the corresponding `extern` blocks---and
by dbaupp 10y ago
The JSON file exists because there's more than one place that needs to know about the intrinsics---they allow generating the corresponding `extern` blocks---and because there's classes of very similar functions that can be factored out into a single definition. Keeping things in sync manually is error prone and exceedingly annoying. However, I agree that the JSON syntax is a... slightly complicated.
In any case, I'm not sure why you think you need a separate load intrinsic: the compiler knows how to generate code for loading data. E.g. if you know data is aligned, casting to a `*const i32x4` and loading that does the right thing. The unaligned case is a little more subtle but it also can be made to work via #[repr(packed)].
- sanxiyn 10y agoI think when we receive PR modifying generated Rust code, we should say "that's autogenerated; can you change JSON instead? If you think it's too much, we can figure out JSON change ourselves". I think the later half is important.
- valarauca1 10y ago>They allow generating the corresponding `extern` blocks Really? I was able to call the intrinsic I sloppy patched into the auto generated files fine via extern platform. >In any case, I'm not sure why you think you need a separate load intrinsic Because it's a systems programming language?
- dbaupp 10y ago> Really? I was able to call the intrinsic I sloppy patched into the auto generated files fine via extern platform. Err... yes, that is exactly my point. You needed an `extern` block to call the functions. It is much nicer if the `extern` block is written down once (just like the _mmintrn.h files for gcc/clang) so that there's no risk of mistakes or mismatches. The JSON files make this easy: both the compiler internals and the external `extern` block are guaranteed to match. Note that this is particularly important on a platform like AArch64, where there are hundreds of intrinsics: hand-transcribing them twice (once for the compiler, once for the libraries) is time consuming and error-prone. > Because it's a systems programming language? This is meaningless: being a systems language doesn't mean having intrinsics for every possible operation, it just means being able to do everything; these are not the same. The remainder of the paragraph you quoted explained how the functionality already exists. The only benefit of having an intrinsic function to call is that there is a function instead of built-in syntax, it doesn't add any new power: Rust is just as systems-y with or without the intrinsic.