This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
How do I get pc-relative constant loads?
- From: Peter Barada <pbarada at mail dot wm dot sps dot mot dot com>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 25 Mar 2002 18:06:22 -0500
- Subject: How do I get pc-relative constant loads?
I'm trying to fix up some of my COldFire v4e code generation, and the
following code:
double a(double x, double y)
{
return (x + 1.0 / (y-2.0)) * 5.0;
}
compiles into:
a:
link.w %a6,#0
fmove.d %fp2,-(%sp)
fmove.d 16(%a6),%fp1
lea .LC0,%a0
fmove.d (%a0),%fp0
fsub.d %fp0,%fp1
lea .LC1,%a0
fmove.d (%a0),%fp2
fmove.d %fp2,%fp0
fdiv.d %fp1,%fp0
fadd.d 8(%a6),%fp0
lea .LC2,%a0
fmove.d (%a0),%fp1
fmul.d %fp1,%fp0
fmovem.d -8(%a6),#0x20
unlk %a6
rts
Where .LC0, .LC1, .LC2 are the double constants.
I'd like to change this so that I don't need to load the address of
those constants into address registers, but instead use PC-relative
addressing to access the constants (which would save an address
register and 32 bits of instruction).
So instead of:
lea .LC0,%a0
fmove.d (%a0),%fp0
I'd like to get:
fmove.d (.LC0:w,%pc),%fp0
So my questions are:
1) How can I force the double constants into the .text secgment so I
can access them with PC-relative addressing?
2) What's the proper syntax for pc-relative addressing(in the 68k)? is it:
fmove.d (.LC0:w,%pc),%fp0
to access .LC0 in the .text segment via pc-relative addressing?
3) How can I tell the compiler to produce an operand of that type
instead of using a symbol-ref which gets reloaded into an address
register ?
4) Better yet, how do I set up a constraint that allows pc-relative
addressing so the address *doesn't* get reloaded but combined into
the instruction? Are there examples in gcc-3.0.4?
Thanks for any suggestions in advance...
--
Peter Barada Peter.Barada@motorola.com
Wizard 781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola) 781-270-0193 (fax)