RFR: 8328998: Encoding support for Intel APX extended general-purpose registers

Steve Dohrmann duke at openjdk.org
Fri May 3 19:40:55 UTC 2024


On Tue, 9 Apr 2024 19:44:26 GMT, Dean Long <dlong at openjdk.org> wrote:

>> Add instruction encoding support for Intel APX extended general-purpose registers:
>> 
>> Intel Advanced Performance Extensions (APX) doubles the number of general-purpose registers, from 16 to 32. For more information about APX, see https://www.intel.com/content/www/us/en/developer/articles/technical/advanced-performance-extensions-apx.html.
>> 
>> By specification, instruction encoding remains unchanged for instructions using only the lower 16 GPRs. For cases where one or more instruction operands reference extended GPRs (Egprs), encoding targets either REX2, an extension of REX encoding, or an extended version of EVEX encoding. These new encoding schemes extend or modify existing instruction prefixes only when Egprs are used.
>
> How can we be confident that the encoding is correct?  Would it be possible to write tests for this?  Maybe one that disassembles it and compares the result to a 3rd party disassembler offline or in-process hsdis?

In response to @dean-long, @theRealAph wrote:
> When we wrote the AArch64 port, there was no available hardware to test it on. So, we wrote a simulator to test it. However, we ran the risk that if our understanding of instruction encoding was wrong, our assembler and our simulator might appear to work correctly when used together, but the result would not run on real AArch64 hardware once it arrived. So, as well as a simulator for the architecture, we verified the internal HotSpot assembler by checking its encoding against GNU `as`. See /test/hotspot/gtest/aarch64, where a Python program generates source for both the HotSpot internal assembler and GNU `as`. I strongly suggest you do something similar. (As a matter for the historical record, this did work. The test found several encoding bugs. Once we got the first real AArch64 hardware, the port worked almost immediately.)

Thanks for the description.  It would be great to create a similar tool for x86.  I tested the encoding manually using the SDE as the authoritative source.  It is tedious though and very time consuming.  

A subsequent PR in [JDK-8329030](https://bugs.openjdk.org/browse/JDK-8329030), perhaps the one that adds encoding support for New Data Destination variants, should include such a tool.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/18476#issuecomment-2093653696


More information about the hotspot-compiler-dev mailing list