Related articles |
---|
how to generate code for (a,b):=(b,a) anton@mips.complang.tuwien.ac.at (1997-05-05) |
Re: how to generate code for (a,b):=(b,a) chase@world.std.com (David Chase) (1997-05-08) |
how to generate code for (a,b):=(b,a) Dave@occl-cam.demon.co.uk (Dave Lloyd) (1997-05-08) |
Re: how to generate code for (a,b):=(b,a) bart@time.cirl.uoregon.edu (1997-05-08) |
Re: how to generate code for (a,b):=(b,a) Robert.Harley@inria.fr (1997-05-08) |
Re: how to generate code for (a,b):=(b,a) dlmoore@ix.netcom.com (David L Moore) (1997-05-08) |
Re: how to generate code for (a,b):=(b,a) preston@cs.rice.edu (1997-05-08) |
Re: how to generate code for (a,b):=(b,a) cliffc@risc.sps.mot.com (Cliff Click) (1997-05-12) |
Re: how to generate code for (a,b):=(b,a) wilson@cs.utexas.edu (1997-05-12) |
Re: how to generate code for (a,b):=(b,a) tim@wfn-shop.Princeton.EDU (1997-05-13) |
Re: how to generate code for (a,b):=(b,a) cdg@nullstone.com (Christopher Glaeser) (1997-05-13) |
Re: how to generate code for (a,b):=(b,a) genew@vip.net (1997-05-13) |
[14 later articles] |
From: | David L Moore <dlmoore@ix.netcom.com> |
Newsgroups: | comp.compilers |
Date: | 8 May 1997 21:47:18 -0400 |
Organization: | Netcom |
References: | 97-05-058 |
Keywords: | optimize, code |
Anton Ertl wrote:
[Exchange contents of several registers quickly]
If you have a free register, you can clearly do this with n+1 moves,
where n is the number of registers to exchange - just save off 1
register in the free register, then move into it the value it is to
receive. This frees up a second register on which you can repeat the
algorithm.
This terminates when the next register to be moved is the original
register. You move the saved value to this last register.
At this point, either all registers have been moved or else there are
still unmoved registers (their are seperable subchains in the chains
of source/destination registers).
In the latter case, just move another register into the temporary and
repeat.
The problem is harder on a multi-issue machine like the Alpha since
you want to issue the maximum number of instructions per cycle. You
end up with a nice little packing problem.
When you don't have any free registers, it should be possible to achieve
the same result with a series of xors instead of moves. For example, two
registers can be exchanged with the sequence:
xor a,b
xor b,a
xor a,b
This whole thing sounds like a nice term project.
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.