Commit 38c28a25 by Aldy Hernandez Committed by Aldy Hernandez

frv.opt (moptimize-membar): New.

	* config/frv/frv.opt (moptimize-membar): New.

	* doc/invoke.texi: Document -moptimize-membar and its inverse.

	* config/frv/frv.h: Remove machine_function definition.

        * config/frv/frv.c (struct frv_io): New.
        (struct machine_function): Moved from frv.h.  Add has_membar_p.
        (frv_same_doubleword_p, frv_io_fixed_order_p, frv_io_union)
        (frv_extract_membar, frv_io_check_address, frv_io_handle_set)
        (frv_io_handle_use_1, frv_io_handle_use, frv_optimize_membar_local)
        (frv_optimize_membar_global, frv_optimize_membar): New functions.
        (frv_reorg): Call frv_optimize_membar when appropriate.
        (bdesc_loads, bdesc_stores): Use the membar code as the icode field.
        (frv_expand_builtin): Adjust calls accordingly.
        (frv_io_address_cookie): New function.
        (frv_expand_load_builtin, frv_expand_store_builtin): Emit a normal
        load or store rather than a special insn.  Add ccnstant address and
        io-type operands to the membar.
	(frv_ifcvt_modify_tests): Unsign regno.
	(frv_ifcvt_modify_tests): Same.

	* config/frv/frv.md: Remove UNSPEC_BUILTIN_{LOAD,STORE}.  Change
	UNSPEC_OPTIONAL_MEMBAR constant.
	(builtin_read_<mode>): Delete.
	(builtin_write_<mode>): Delete.
	("optional_membar_<mode>"): Add operand.

	* testsuite/gcc.target/frv/all-builtin-read8.c: Delete.
	* testsuite/gcc.target/frv/all-builtin-read16.c: Delete.
	* testsuite/gcc.target/frv/all-builtin-read32.c: Delete.
	* testsuite/gcc.target/frv/all-builtin-read64.c: Delete.
	* testsuite/gcc.target/frv/all-builtin-write8.c: Delete.
	* testsuite/gcc.target/frv/all-builtin-write16.c: Delete.
	* testsuite/gcc.target/frv/all-builtin-write32.c: Delete.
	* testsuite/gcc.target/frv/all-builtin-write64.c: Delete.
	* testsuite/gcc.target/frv/all-read-write-1.c: New.

From-SVN: r102455
parent 47c504ea
2005-07-27 Aldy Hernandez <aldyh@redhat.com>
* config/frv/frv.opt (moptimize-membar): New.
* doc/invoke.texi: Document -moptimize-membar and its inverse.
* config/frv/frv.h: Remove machine_function definition.
* config/frv/frv.c (struct frv_io): New.
(struct machine_function): Moved from frv.h. Add has_membar_p.
(frv_same_doubleword_p, frv_io_fixed_order_p, frv_io_union)
(frv_extract_membar, frv_io_check_address, frv_io_handle_set)
(frv_io_handle_use_1, frv_io_handle_use, frv_optimize_membar_local)
(frv_optimize_membar_global, frv_optimize_membar): New functions.
(frv_reorg): Call frv_optimize_membar when appropriate.
(bdesc_loads, bdesc_stores): Use the membar code as the icode field.
(frv_expand_builtin): Adjust calls accordingly.
(frv_io_address_cookie): New function.
(frv_expand_load_builtin, frv_expand_store_builtin): Emit a normal
load or store rather than a special insn. Add ccnstant address and
io-type operands to the membar.
(frv_ifcvt_modify_tests): Unsign regno.
(frv_ifcvt_modify_tests): Same.
* config/frv/frv.md: Remove UNSPEC_BUILTIN_{LOAD,STORE}. Change
UNSPEC_OPTIONAL_MEMBAR constant.
(builtin_read_<mode>): Delete.
(builtin_write_<mode>): Delete.
("optional_membar_<mode>"): Add operand.
* testsuite/gcc.target/frv/all-builtin-read8.c: Delete.
* testsuite/gcc.target/frv/all-builtin-read16.c: Delete.
* testsuite/gcc.target/frv/all-builtin-read32.c: Delete.
* testsuite/gcc.target/frv/all-builtin-read64.c: Delete.
* testsuite/gcc.target/frv/all-builtin-write8.c: Delete.
* testsuite/gcc.target/frv/all-builtin-write16.c: Delete.
* testsuite/gcc.target/frv/all-builtin-write32.c: Delete.
* testsuite/gcc.target/frv/all-builtin-write64.c: Delete.
* testsuite/gcc.target/frv/all-read-write-1.c: New.
2005-07-28 Kaz Kojima <kkojima@gcc.gnu.org>
* df.c (df_uses_record): Handle SCRATCH.
......
......@@ -1492,13 +1492,6 @@ typedef struct frv_stack {
address of other frames. */
#define RETURN_ADDR_RTX(COUNT, FRAMEADDR) frv_return_addr_rtx (COUNT, FRAMEADDR)
/* This function contains machine specific function data. */
struct machine_function GTY(())
{
/* True if we have created an rtx that relies on the stack frame. */
int frame_needed;
};
#define RETURN_POINTER_REGNUM LR_REGNO
/* A C expression whose value is RTL representing the location of the incoming
......
......@@ -41,9 +41,7 @@
(UNSPEC_EH_RETURN_EPILOGUE 6)
(UNSPEC_GOT 7)
(UNSPEC_LDD 8)
(UNSPEC_BUILTIN_LOAD 9)
(UNSPEC_BUILTIN_STORE 10)
(UNSPEC_OPTIONAL_MEMBAR 11)
(UNSPEC_OPTIONAL_MEMBAR 9)
(UNSPEC_GETTLSOFF 200)
(UNSPEC_TLS_LOAD_GOTTLSOFF12 201)
......@@ -2168,41 +2166,17 @@
FAIL;
}")
;; The load part of a __builtin_read* function.
;; Use UNSPECs to distinguish these patterns from normal moves.
(define_insn "builtin_read_<mode>"
[(set (match_operand:SI 0 "register_operand" "=d")
(zero_extend:SI (unspec:IMODE
[(match_operand:IMODE 1 "memory_operand" "m")]
UNSPEC_BUILTIN_LOAD)))]
""
"ld<BREADsuffix>%I1%U1 %M1,%0"
[(set_attr "length" "4")
(set_attr "type" "gload")])
;; The store part of a __builtin_write* function.
(define_insn "builtin_write_<mode>"
[(set (match_operand:IMODE 0 "memory_operand" "=m")
(unspec:IMODE [(match_operand:IMODE 1 "reg_or_0_operand" "dO")]
UNSPEC_BUILTIN_STORE))]
""
"st<IMODEsuffix>%I0%U0 %z1, %M0"
[(set_attr "length" "4")
(set_attr "type" "gstore")])
;; This one has a different predicate for operand 1.
(define_insn "builtin_write64"
[(set (match_operand:DI 0 "memory_operand" "=m")
(unspec:DI [(match_operand:DI 1 "register_operand" "d")]
UNSPEC_BUILTIN_STORE))]
""
"std%I0%U0 %z1, %M0"
[(set_attr "length" "4")
(set_attr "type" "gstore")])
;; The "membar" part of a __builtin_read* or __builtin_write* function.
;; Operand 0 is a volatile reference to the memory that the function reads
;; or writes. Operand 1 is the address being accessed, or zero if the
;; address isn't a known constant. Operand 2 describes the __builtin
;; function (either FRV_IO_READ or FRV_IO_WRITE).
(define_insn "optional_membar_<mode>"
[(set (match_operand:IMODE 0 "memory_operand" "=m")
(unspec:IMODE [(const_int 0)] UNSPEC_OPTIONAL_MEMBAR))]
(unspec:IMODE [(match_operand 1 "const_int_operand" "")
(match_operand 2 "const_int_operand" "")]
UNSPEC_OPTIONAL_MEMBAR))]
""
"membar"
[(set_attr "length" "4")])
......
......@@ -157,6 +157,10 @@ mno-eflags
Target RejectNegative
Do not mark ABI switches in e_flags
moptimize-membar
Target Report Mask(OPTIMIZE_MEMBAR)
Remove redundant membars
mpack
Target Report Mask(PACK)
Pack VLIW instructions
......
......@@ -482,6 +482,7 @@ Objective-C and Objective-C++ Dialects}.
-mlinked-fp -mlong-calls -malign-labels @gol
-mlibrary-pic -macc-4 -macc-8 @gol
-mpack -mno-pack -mno-eflags -mcond-move -mno-cond-move @gol
-moptimize-membar -mno-optimize-membar @gol
-mscc -mno-scc -mcond-exec -mno-cond-exec @gol
-mvliw-branch -mno-vliw-branch @gol
-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec @gol
......@@ -8526,6 +8527,18 @@ Disable nested conditional execution optimizations.
This switch is mainly for debugging the compiler and will likely be removed
in a future version.
@item -moptimize-membar
@opindex moptimize-membar
This switch removes redundant @code{membar} instructions from the
compiler generated code. It is enabled by default.
@item -mno-optimize-membar
@opindex mno-optimize-membar
This switch disables the automatic removal of redundant @code{membar}
instructions from the generated code.
@item -mtomcat-stats
@opindex mtomcat-stats
......
/* { dg-do compile } */
unsigned short z;
void foo (void *x)
{
z = __builtin_read16 (x);
}
/* { dg-final { scan-assembler "lduh" } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do compile } */
/* { dg-options "-O" } */
unsigned long z;
void foo (void *x)
{
z = __builtin_read32 (x);
}
/* { dg-final { scan-assembler "ld " } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do compile } */
unsigned long long z;
void foo (void *x)
{
z = __builtin_read64 (x);
}
/* { dg-final { scan-assembler "ldd" } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do compile } */
unsigned char z;
void foo (void *x)
{
z = __builtin_read8 (x);
}
/* { dg-final { scan-assembler "ldub" } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do compile } */
unsigned short *addr;
unsigned short datum;
void foo ()
{
__builtin_write16 (addr, datum);
}
/* { dg-final { scan-assembler "sth" } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do compile } */
unsigned long *addr;
unsigned long datum;
void foo ()
{
__builtin_write32 (addr, datum);
}
/* { dg-final { scan-assembler "st " } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do compile } */
unsigned long long *addr;
unsigned long long datum;
void foo ()
{
__builtin_write64 (addr, datum);
}
/* { dg-final { scan-assembler "std " } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do compile } */
unsigned char *addr;
unsigned char datum;
void foo ()
{
__builtin_write8 (addr, datum);
}
/* { dg-final { scan-assembler "stb" } } */
/* { dg-final { scan-assembler "membar" } } */
/* { dg-do run } */
extern void abort (void);
extern void exit (int);
volatile unsigned long long x[2];
int main ()
{
volatile char *addr = (volatile char *) &x[0];
x[0] = ~0ULL;
x[1] = ~0ULL;
__builtin_write64 (addr, 0x1122334455667788ULL);
__builtin_write32 (addr + 8, 0x12345678);
__builtin_write16 (addr + 12, 0xaabb);
__builtin_write8 (addr + 14, 0xcc);
if (x[0] != 0x1122334455667788ULL
|| x[1] != 0x12345678aabbccffULL
|| __builtin_read8 (addr) != 0x11
|| __builtin_read16 (addr + 2) != 0x3344
|| __builtin_read32 (addr + 4) != 0x55667788
|| __builtin_read64 (addr + 8) != 0x12345678aabbccffULL)
abort ();
__builtin_write64 (addr, 0);
__builtin_write32 (addr + 8, 0);
__builtin_write16 (addr + 12, 0);
__builtin_write8 (addr + 14, 0);
if (x[0] != 0 || x[1] != 0xff)
abort ();
exit (0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment