Le 10-10-01 23:31 , chevalma@iro.umontreal.ca a écrit :
I'm looking at the code for lt and eq, and I'm not sure what's going on exactly. The lt instruction between two registers is implemented as follows:
tltor.asm.cmp(opnds[1], opnds[0]);
cmp compares the two values and set the flags according to their relative values. Note that testing for opnds[0] < opnds[1] must be written cmp(opnds[1], opnds[0]), i.e. reversed, because we are using the AT&T operand order instead of the Intel one.
tltor.asm. mov($(immFalse), dest). cmovl(tltor.ctxImmTrue, dest);
And ctxImmTrue is defined as follows:
that.ctxImmTrue = mem(1 * that.REG_BYTE_WIDTH, irToAsm.config.context); that.ctxImmFalse = mem(2 * that.REG_BYTE_WIDTH, irToAsm.config.context);
My understanding is that cmovl can't move an immediate value into a register. I'm not sure what that definition for ctxImmTrue does. Is it allocating some memory location for the constant? Where is the actual value of the constant actually being set?
Contrary to what Marc wrote, cmove effectively cannot move an immediate value in a register, only a register or a memory value. Therefore I chose to put a true and a false value on the context object, respectively in the 2nd and 3rd slot, to have them handy.
mem(offset, register) accesses memory at the address contained in register + offset.
ctxImmTrue and ctxImmFalse and memory objects stored on translator to be used as operands for cmov.
The above code copies the false value in the destination register and overwrite this value with the true value stored in the context, only if opnds[0] < opnds[1].
The constant value is being set in dump_context_object(), which reserves space in the code stream for the context object and preassign some slots, for true and false values.
I'd like to actually change this code to use 1 for true and 0 for false.
You'll need to change the true and false value stored in the context object (see dump_context_object) and the immTrue and immFalse values used in the code. The only gotcha is that you should use a javascript number when directly generating a byte in the code stream using genXX:
tltor.asm.gen32(0); // passing the false value
but you should use an immediate value object when passing a constant as an operand for an instruction:
tltor.asm.mov($(0), dest); // using an immediate false value
Erick
- Maxime
Tachyon-list mailing list Tachyon-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/tachyon-list