Related articles |
---|
Re: Inlining and global references meissner@osf.org (1991-05-03) |
Re: Inlining and global references pardo@june.cs.washington.edu (1991-05-05) |
Newsgroups: | comp.compilers |
From: | meissner@osf.org |
Keywords: | architecture, optimize |
Organization: | Compilers Central |
References: | <1991May2.212633.6893@beaver.cs.washington.edu> <1991May1.035622.25021@daffy.cs.wisc.edu> |
Date: | Fri, 3 May 91 14:39:12 -0400 |
| carter@cs.wisc.edu (Gregory Carter) writes:
| >[Optimize:
| > (1) local vars -> global vars
| > (2) replace subroutine calls with the subroutine code
| > (3) minimize stack frame usage]
|
| On many machines (RISC machines in particular), accesing global memory is
| no faster than accessing local variables.
Actually on RISC machines, accessing global memory may be slower than
accessing local variables. This is because RISC machines typically cannot
reference all of memory with one instruction. To reference x, they do two
instructions -- set a register with the high part of the address, and do
the memory reference with the loaded register, and the lower part of the
address as an offset. On the MIPS this would be:
lui $at,x ; load assembler temp with high 16 bits of x
lw $2,x ; load memory
Now, the MIPS assembler expands the 'lw' macro into the two instructions
above. Also, the MIPS software conventions has a dedicated register to
hold the address of a 64K pool, which small sized globals are placed, and
only one instruction is used if the assembler is told that the item is
located there.
--
Michael Meissner email: meissner@osf.org phone: 617-621-8861
Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142
[Even on CISCs like a Vax or a 386 a stack reference is shorter than an
absolute reference, since you can typically use a single-byte offset rather
than a 4-byte address. -John]
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.