This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Ping] [PATCH, 7/10] aarch64: add function to output ccmp insn


On 10/11/2014 09:11 AM, Richard Henderson wrote:
> On 09/22/2014 11:45 PM, Zhenqiang Chen wrote:
>> +static unsigned int
>> +aarch64_code_to_nzcv (enum rtx_code code, bool inverse) {
>> +  switch (code)
>> +    {
>> +    case NE: /* NE, Z == 0.  */
>> +      return inverse ? AARCH64_CC_Z : 0;
>> +    case EQ: /* EQ, Z == 1.  */
>> +      return inverse ? 0 : AARCH64_CC_Z;
>> +    case LE: /* LE, !(Z == 0 && N == V).  */
>> +      return inverse ? AARCH64_CC_N | AARCH64_CC_V : AARCH64_CC_Z;
>> +    case GT: /* GT, Z == 0 && N == V.  */
>> +      return inverse ? AARCH64_CC_Z : AARCH64_CC_N | AARCH64_CC_V;
>> +    case LT: /* LT, N != V.  */
>> +      return inverse ? AARCH64_CC_N | AARCH64_CC_V : AARCH64_CC_N;
>> +    case GE: /* GE, N == V.  */
>> +      return inverse ? AARCH64_CC_N : AARCH64_CC_N | AARCH64_CC_V;
>> +    case LEU: /* LS, !(C == 1 && Z == 0).  */
>> +      return inverse ? AARCH64_CC_C: AARCH64_CC_Z;
>> +    case GTU: /* HI, C ==1 && Z == 0.  */
>> +      return inverse ? AARCH64_CC_Z : AARCH64_CC_C;
>> +    case LTU: /* CC, C == 0.  */
>> +      return inverse ? AARCH64_CC_C : 0;
>> +    case GEU: /* CS, C == 1.  */
>> +      return inverse ? 0 : AARCH64_CC_C;
>> +    default:
>> +      gcc_unreachable ();
>> +      return 0;
>> +    }
>> +}
>> +
> 
> I'm not overly fond of this, since "code" doesn't map 1-1.  It needs the
> context of a mode to provide a unique mapping.
> 
> I think it would be better to rearrange the existing aarch64_cond_code enum
> such that AARCH64_NE et al are meaningful wrt NZCV.  Then you can use
> aarch64_get_condition_code_1 to get this mapping.

Slight mistake in the advice here.  I think you should use
aarch64_get_conditional_code_1 to get an aarch64_cond_code, and use that to
index an array to get the nzcv bits.

Further, does it actually make sense to store both nzcv and its inverse, or
does it work to use nzcv and ~nzcv?


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]