[PATCH v4] PowerPC: Support for Elliptic Curve Cryptography Instructions (RFC02669)

Peter Bergner bergner@tenstorrent.com
Wed Jan 7 17:15:03 GMT 2026


On 1/6/26 3:16 AM, Abhay Kandpal wrote:
> opcodes/
>     * ppc-opc.c: (insert_s3, extract_s3):New functions.

s/:New/: New/




> +static uint64_t
> +insert_s3 (uint64_t insn,
> +	   int64_t value,
> +	   ppc_cpu_t dialect ATTRIBUTE_UNUSED,
> +	   const char **errmsg)
> +{
> +  if (value == 7)
> +    {
> +      *errmsg = _("invalid S value (must be 0 - 6)");

If we're trying to verify a value between [0, 6], then we need to
test for that.  Testing only for "value == 7" doesn't catch the error when
value == 8 or ....  Change the test to "if (value < 0 || value > 6)".




> +static int64_t
> +extract_s3 (uint64_t insn,
> +	    ppc_cpu_t dialect ATTRIBUTE_UNUSED,
> +	    int *invalid)
> +{
> +  int64_t value = (insn >> 8) & 0x7;
> +
> +  if (value == 7)
> +    *invalid = 1;

Whereas this test is fine, since the extraction by shift and mask
limits the range of values, so testing explicitly for 7 is ok.



> +   /* The P bit in Prefix XX4-form instruction. */

Two spaces before the */



> +/* The S field in XX3 form bit (21-23) as arithmetic function */

Missing a period at the end of the sentence and two spaces before the */


> +  /* The S1 bit an exponent in XX3 form bit (22) */

Likewise.



> +  /* The P bit in scaled multiply-sum XX3 form instructions (bit 21) */

Likewise.


> +  /* The S0 bit an exponent in XX3 form bit (21) */

Likewise.


> +  /* The S field in XX3 form bit (21-23) as arithmetic function */

Likewise.


> +  /* The S2 bit an exponent in XX3 form bit (23) */

Likewise.



I'll let Surya review the rest of the patch.

Peter




More information about the Binutils mailing list