Graal compiler: AMD64 Intrinsics design

Doug Simon doug.simon at oracle.com
Thu Aug 16 10:21:02 UTC 2018


Hi Jp,

> On 15 Aug 2018, at 20:57, Halimi, Jean-Philippe <jean-philippe.halimi at intel.com> wrote:
> 
> Hello everyone,
> 
> I'm getting started with the Graal source code and I'd like to add support for new BMI intrinsics, along with these already in place. I'm looking for help from people who developed the existing intrinsics infrastructure. Namely, I would like to double check that my initial understanding is correct.
> 
> Could you please let me know if the following steps are correct and sufficient?
> 
> 1. org.graalvm.compiler.asm.amd64/src/org/graalvm/compiler/asm/amd64/ --> will need to add any new type of instructions there if necessary

Yes.

> 2. org.graalvm.compiler.replacements.amd64/src/org/graalvm/compiler/replacements/amd64/ --> will need to add new LIR types if necessary, typically in a new Node class that will represent the intrinsic. Design in pseudo code would be as follows:
> 
> public final class AMD64NewNode extends UnaryNode implements ArithmeticLirLowerable {
>   a. Constructor
>   b. tryFold(ValueNode value) method: will try convert the input value to the corresponding value if possible.
>   c. generate method: will generate the appropriate LIR containing the intrinsic in the builder.
> }

Yes. Also look at org.graalvm.compiler.replacements.amd64.AMD64CountTrailingZerosNode for inspiration.
> 
> 3. Add an entry in org.graalvm.compiler.replacements.amd64/src/org/graalvm/compiler/replacements/amd64/AMD64GraphBuilderPlugins.java in order to support the intrinsic in the graph builder if hardware is supported

Correct.

Seems like you're heading in the right direction. As soon as you have a PR at https://github.com/oracle/graal/pulls, it will be easier offer more detailed input.

-Doug


More information about the graal-dev mailing list