[PTLsim-devel] translation of lea op

Indu Bhagat
Tue Oct 16 09:59:02 EDT 2007


I have a question related to the decoder functionality in PTLsim. I was 
looking at some instances of the lea x86 instruction which in binary 
exist as :

 400b89:   4c 8d 5a 02             lea    0x2(%rdx),%r11

but the effective translation of this "add and move equivalent lea" 
operation by the decoder is

rip                 opcode ra       rb         rc       rd     
rbimm          rcimm size   eom
0x400b89        add     rdx     imm     zero    tr8     0x2             
0x0     3       0
0x400b89        add     tr8     imm     zero    r11     0x0             
0x0     3       1

Clearly, the same operation could have been translated into just a 
single operation :

0x400b89        add     rdx     imm     zero    r11     0x2             
0x0     3       1

A cursory look points that the value for /imm_is_not_encodable/ (in 
decode-core.cpp) for the above operation is 1. Hence, first the decoder 
generates an add operation to evaluate the result and put it into a 
temporary register (REG_temp8) and then adds another operation to 
move(using OP_add) the result to the destination register. I would like 
to know :

1. What is the significance of "imm_is_not_encodable" as it checks 
(apart from checking whether imm is 64 or 32 bits appropriately for 
mem/non-mem operations) and another condition like  
lowbits(memref.mem.offset, memref.mem.size) which is 2 in this case, 
btw, which makes imm_is_not_encodable = 1 in this specific case.

2. However, I am not too sure...is there some other reason why this 
extra operation is being generated? Ideally one would like only a single 
operation to be generated for this case.

Thanks,
Indu




More information about the PTLsim-devel mailing list