Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

operand swapping

10 views
Skip to first unread message

peterjo...@yahoo.com

unread,
May 15, 2008, 10:56:54 AM5/15/08
to
Hello,

I am a newbie in LCC, I wonder if anybody can help me out with a
problem which I think is quite fundamental. I understand that LCC’s
ADDI is a 3 operand operation in the form


%c = %0 + %1


My target machine can only handle a 2 operand ADD operation (ie ADD a,
b),


a = a + b


I inspected the x86.md machine description from the LCC installation
and discovered they use a rule similar to


reg: ADDI4 (reg,reg) “?mov %c,%0\nadd %c,%1\n”


This works if the first operand is the same as the destination
register, however, this will not work if the destination register is
the same as the second operand. I notice this problem when I tried to
do the following C operation


hr = k + hr

(where hr and k are locals)


What do I need to do to ensure LCC will swap the operands if the
destination register is the same as the second operand instead of the
first? I tried messing around with the function target(), however it
look as if the registers are not assigned at that point yet. I tried
to swap kids[0] and kids[1] in the function clobber(), however, that
produce a move to the same register

mov a,a
add a,b

I would very much appreciate any suggestions. Thank you.

peter

0 new messages