Please format the intrinsics reference so it is machine parsable
#2
Open
opened 6 years ago by lu-zero
·
7 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Ideally would be great to either have custom attributes on the docbook or, even better, have a rigid dialect that can be then converted to the docbook markup and the eventual conformance verifiers such as the one implemented in rust stdsimd.
To elaborate on what @lu-zero mentioned, currently, the specification is in XML format (https://github.com/OpenPOWERFoundation/ELFv2-ABI/tree/master/specification) but due to the current way in which the XML its been structured, it is really hard to process these files.
What we want to do is: read the spec file, find all intrinsics part of the C API, extract their name, their arguments name and types, their return type, whether any args are immediates, their doc string, and that's pretty much it. I have no idea about how to do that easily with the XML files provided.
OTOH, Intel makes this trivial (https://raw.githubusercontent.com/rust-lang-nursery/stdsimd/master/crates/stdsimd-verify/x86-intel.xml):
And ARM makes this easy as well (although not as easy as Intel):
I could imagine that if somebody wouldn't have done the manual labor already, LLVM would actually prefer to generate TableGen files from the spec, that are then used to generate the headers.
Hi, folks...
I appreciate the suggestions. Unfortunately this isn't an "official" project, but
something that I try to work on in what little spare time I have. (It's taken me
over a year to get to the point that it's at, and I'm hopeful that I can finish a
first pass of the document by the end of the year, but can't commit to it.)
The XML format follows the OpenPOWER Foundation documentation guidelines. I'm not
an XML expert, so modifying XML schemas and so forth would require research time
that I don't have. So without contributions from others, this is the form that a
first version of the document is going to take.
If you would like to contribute the necessary XML code to format intrinsics in a
way that's convenient to your needs, I can look into adding that as time goes on.
Just be aware of my constraints; when things get busy, there are sometimes gaps
of several months between my own contributions.
Thanks,
Bill
On 8/20/18 6:23 AM, gnzlbg wrote:
This remains desirable, and there's some discussion about a machine-readable file to drive some of these documents. That probably won't happen before first publication of this, though.
Would a JSON format like this be sufficient?
Something that could be fed to something like https://github.com/rust-lang/stdarch/tree/master/crates/stdarch-gen would be optimal, that json seems something that could be used to speed up moving from hand-crafted to automatically generated.
Thanks for the pointer! It looks like there are a couple of files relevant to this discussion:
neon.spec
src/main.rs
For
neon.spec
, there are stanzas, and a representative is:I presume an appropriate new mapping would be something like:
name
: defined as "The prefix of the function", which leaves a lot to the imagination ;-) I don't yet understand this.fn
: defined as "The function to call in rust-land.", which I don't yet understand.arm
,aarch64
: seem to be the name of the intrinsic in the respective ISAs? This might be akin tomnemonic
in the JSON above?a
,b
: testing input data, presumably associated with the input parameter types; maps to fields likea
and the associated types fora
inlist
in the JSON; likely hand-crafted?validate
: testing output data, presumably associated with the output type; maps tor
and the associated types forr
inlist
in the JSON; in the absence of algorithmic information in thespec
file, this is also hand-crafted?generate
: this seems to be types, although it's not completely clear... is it assuming thata
andb
are the same type which could be any of the 4 listed types?For
src/main.rs
, this parsesneon.spec
and produces an appropriatesrc/{arm,aarch64}/neon/generated.rs
file. This generated file contains...? I stumbled around, and it looks like it ends up at https://github.com/rust-lang/stdarch/blob/master/crates/core_arch/src/aarch64/neon/generated.rs, is that right? This appears to be implementations of the intrinsics, but I'm not sure how the spec file data gets transformed into an implementation.Note: my expertise in rust can be easily counted in minutes.
the final endpoint is core::arch with the arch-specific module e.g. the arm one.
In the example we have vorr that in source is defined
in stdarch we have two kind of tests, one that checks the expected mnemonic appears in while disassembling a testcase that the
assert_instr()
decorator generates for us and another is making sure that the instruction itself behaves as expected, and that's thevalidate
entry.the
fn
field is used for one-liners that might call any rust code.link-arm
andlink-aarch64
is a shorthand for linking llvm-specific symbol to a function name and then call it.I hope it helps :) I can probably try to poke the author of the script to document it a little better.