This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Medium model support in GCC
- From: Richard Henderson <rth at redhat dot com>
- To: Jan Hubicka <jh at suse dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 6 Jul 2005 13:12:36 -0700
- Subject: Re: Medium model support in GCC
- References: <20050701181016.GW15982@kam.mff.cuni.cz>
On Fri, Jul 01, 2005 at 08:10:16PM +0200, Jan Hubicka wrote:
> + /* Variables which are this size or smaller are put in the data/bss
> + or ldata/lbss sections. */
> +
> + static int ix86_section_threshold = 65536;
You'll need to make this controlled by some sort of compiler switch.
> + if ((ix86_cmodel != CM_MEDIUM && ix86_cmodel != CM_MEDIUM_PIC)
> + || !ix86_in_large_data_p (decl))
> + default_elf_select_section (decl, reloc, align);
> + else
...
> + if (sname)
> + named_section (decl, sname, reloc);
> + else
> + default_elf_select_section (decl, reloc, align);
I think this would be better as
if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC)
&& ix86_in_large_data_p (decl))
{
...
if (sname)
{
named_section (decl, sname, reloc);
return;
}
}
default_elf_select_section (decl, reloc, align);
> + x86_64_elf_unique_section (tree decl, int reloc)
Likewise.
> + fprintf (file, ".largecomm ");
We usually use tabs.
> + case UNSPEC_GOTOFF:
> + /* For 64bit target we have to deal with GOTOFF as 64bit values,
> + for 32bit targets these are always part of addressing mode
> + there is no point to allow dealing with them separately -
> + doing so just increase register pressure. */
> + if (!TARGET_64BIT)
> + return false;
> + return local_symbolic_operand (XVECEXP (x, 0, 0), Pmode);
I don't like this.
Primarily becuase we should never be creating GOTOFF relocations to
non-local symbols, and thus there should be nothing to check. The
code here should be "return true", because the constant should, by
definition, ALWAYS be legitimate.
> if (GET_CODE (disp) == SYMBOL_REF
> ! && (ix86_cmodel == CM_SMALL_PIC
> ! || (ix86_cmodel == CM_MEDIUM_PIC
> ! && !SYMBOL_REF_FAR_ADDR_P (disp)))
> && SYMBOL_REF_LOCAL_P (disp))
Couldn't you just always test SYMBOL_REF_FAR_ADDR_P and ignore ix86_cmodel?
> + else if (TARGET_64BIT && local_symbolic_operand (addr, Pmode)
> + && ix86_cmodel != CM_SMALL_PIC)
Do easy tests first. I.e. the function call test last.
> + /* Flag to mark data that is in the large address area (addressable
> + via "addl", that is, within a 2GByte offset of 0. */
> + #define SYMBOL_FLAG_FAR_ADDR (SYMBOL_FLAG_MACH_DEP << 0)
Surely *not* addressable via addl.
> ! (and (ne (symbol_ref "flag_pic && ix86_cmodel == CM_SMALL_PIC")
> ! (const_int 0))
> ! (match_operand:DI 1 "symbolic_operand" ""))
This shouldn't be necessary. We'll have legitimized the move to
something else.
> + (define_insn "set_got_rex64"
> + [(set (match_operand:DI 0 "register_operand" "=r")
> + (unspec:DI [(const_int 0)] UNSPEC_SET_GOT))
> + (clobber (reg:CC 17))]
> + "TARGET_64BIT"
> + "lea{q}\t_GLOBAL_OFFSET_TABLE_(%%rip), %0"
This doesn't clobber reg:CC.
> Index: testsuite/gcc.dg/x86-64-medium-1.c
The new tests should go in gcc.target.
They also need some check vs lp64, otherwise you're going to fail the
32-bit multilib.
> + /* { dg-options "-fpic -mcmodel=medium" { target { { x86_64-*-* } && ilp32 } } } */
Huh? Why ilp32?
r~