ARM: More intrinsics
Andrew Haley
aph at redhat.com
Thu Mar 15 02:21:04 PDT 2012
On 03/15/2012 04:09 AM, pcpa at mandriva.com.br wrote:
>> Xerxes noticed an inconsistency in my patch. I've removed the unused
>> masks, and redefined the condition in the atomic operations to use ETT
>> (else, true, true) rather than the confused encoding I used before.
>>
>> So, it's now
>>
>> + it(codebuf, COND_EQ, IT_MASK_ETT);
>>
>> instead of
>>
>> - it(codebuf, COND_NE, IT_MASK_TEE);
>
> I feel there is something bogus here, because the first condition
> should be 'T' always, and the mask is based on bit 0 of the test
> condition. Talking this because I wrote support for arm thumb jit
> recently.
Well, that's how the ARM asm describes it, but that's not what
the encodings really do. It's a shame they chose to describe it
in that way.
>> I had to do this because it's the only way the encodings make any
>> sense. There isn't really any encoding for TEE that works with
>> COND_NE: it has to be expressed in the binary as COND_EQ:ETT.
>> (If cond is true, don't do X, but do Y and Z.)
>
> For easier viewing instead of pointing to some link, the code I use
> to encode it* is:
>
> static void
> _tcit(jit_state_t *_jit, unsigned int tc, int it)
> {
> int c;
> int m;
> c = (tc >> 28) & 1;
> assert(!(tc & 0xfffffff) && tc != ARM_CC_NV);
> switch (it) {
> case THUMB2_IT: m = 1<<3; break;
> case THUMB2_ITT: m = (c<<3)| (1<<2); break;
> case THUMB2_ITE: m = (!c<<3)| (1<<2); break;
> case THUMB2_ITTT: m = (c<<3)| (c<<2)| (1<<1); break;
> case THUMB2_ITET: m = (!c<<3)| (c<<2)| (1<<1); break;
> case THUMB2_ITTE: m = (c<<3)|(!c<<2)| (1<<1); break;
> case THUMB2_ITEE: m = (!c<<3)|(!c<<2)| (1<<1); break;
> case THUMB2_ITTTT: m = (c<<3)| (c<<2)| (c<<1)|1; break;
> case THUMB2_ITETT: m = (!c<<3)| (c<<2)| (c<<1)|1; break;
> case THUMB2_ITTET: m = (c<<3)|(!c<<2)| (c<<1)|1; break;
> case THUMB2_ITEET: m = (!c<<3)|(!c<<2)| (c<<1)|1; break;
> case THUMB2_ITTTE: m = (c<<3)| (c<<2)|(!c<<1)|1; break;
> case THUMB2_ITETE: m = (!c<<3)| (c<<2)|(!c<<1)|1; break;
> case THUMB2_ITTEE: m = (c<<3)|(!c<<2)|(!c<<1)|1; break;
> case THUMB2_ITEEE: m = (!c<<3)|(!c<<2)|(!c<<1)|1; break;
> default: abort();
> }
> assert(m && (tc != ARM_CC_AL || !(m & (m - 1))));
> is(0xbf00 | (tc >> 24) | m);
> }
LOL! That's just the sort of thing I was trying to avoid! :-)
I'd love to use this, but I think I probably can't. I could use this
idea for just the couple of conditions I actually use, though, without
requiring copyright assignment.
Thanks,
Andrew.
More information about the distro-pkg-dev
mailing list