Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers LCC > operand swappin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1043 of 1066
Post > Topic >>

operand swapping

by peterjones43211@[EMAIL PROTECTED] May 15, 2008 at 07:56 AM

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=92s
ADDI is a 3 operand operation in the form


%c =3D %0 + %1


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


a =3D 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) =93?mov %c,%0\nadd %c,%1\n=94


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 =3D 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
 




 1 Posts in Topic:
operand swapping
peterjones43211@[EMAIL PR  2008-05-15 07:56:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Sep 7 7:09:13 CDT 2008.