From patchwork Wed Jun 16 08:11:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jeremie.salvucci@free.fr X-Patchwork-Id: 55859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C030DB7D8B for ; Wed, 16 Jun 2010 18:11:38 +1000 (EST) Received: (qmail 31944 invoked by alias); 16 Jun 2010 08:11:36 -0000 Received: (qmail 31884 invoked by uid 22791); 16 Jun 2010 08:11:20 -0000 X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=BAYES_50, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from smtp5-g21.free.fr (HELO smtp5-g21.free.fr) (212.27.42.5) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 Jun 2010 08:11:14 +0000 Received: from zimbra30-e5.priv.proxad.net (zimbra30-e5.priv.proxad.net [172.20.243.180]) by smtp5-g21.free.fr (Postfix) with ESMTP id 7ED6ED48145 for ; Wed, 16 Jun 2010 10:11:04 +0200 (CEST) Date: Wed, 16 Jun 2010 10:11:03 +0200 (CEST) From: jeremie.salvucci@free.fr To: gcc-patches@gcc.gnu.org Message-ID: <2119007922.2926151276675863214.JavaMail.root@zimbra30-e5.priv.proxad.net> In-Reply-To: <1957517256.2926111276675794450.JavaMail.root@zimbra30-e5.priv.proxad.net> Subject: [PATCH] Real_cst on MELT branch MIME-Version: 1.0 X-Authenticated-User: jeremie.salvucci@free.fr X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello all, This patch is useful to handle real type in GIMPLE representation thanks to MELT. It's my first one, so this is the assignments reference : I am an intern with Basile Starynkevitch at CEA-LIST covered by RT 306238 CEA-LIST November 2006 In addition, I am student at the Universite Paris Est which signed GCC disclaimer few months ago. Paolo Bonzini has already checked that everything was done on legal issues. Tested on x86-64 GNU/Linux system. gcc/Changelog.MELT entry 2010-06-16 Jeremie Salvucci * melt-make.mk (warmelt*): Added dependancies on melt-predef.h. * melt-runtime.c: Added meltgc_new_real. * melt/warmelt-first.melt: Added instance of discr_real. * melt/warmelt-ana-base.melt: Added a cmatcher for real_cst. * melt-predef.list: Added discr_real. Cheers. Jeremie Salvucci Index: gcc/melt-make.mk =================================================================== --- gcc/melt-make.mk (revision 160746) +++ gcc/melt-make.mk (working copy) @@ -75,12 +75,12 @@ ## the invoking command could set MELT_MAKE_MODULE_XTRAMAKEFLAGS=-j2 MELT_MAKE_MODULE=$(MAKE) -f $(melt_make_module_makefile) $(MELT_MAKE_MODULE_XTRAMAKEFLAGS) VPATH=$(VPATH):. -warmelt-%.0.so: warmelt-%.0.c $(melt_make_module_makefile) +warmelt-%.0.so: warmelt-%.0.c $(melt_make_module_makefile) melt-predef.h echo in melt-make.mk melt_cflags= $(melt_cflags) $(MELT_MAKE_MODULE) meltmodule \ GCCMELT_CFLAGS="$(melt_cflags)" \ GCCMELT_MODULE_SOURCE=$< GCCMELT_MODULE_BINARY=$@ -warmelt-%.0.d.so: warmelt-%.0.c $(melt_make_module_makefile) +warmelt-%.0.d.so: warmelt-%.0.c $(melt_make_module_makefile) melt-predef.h $(MELT_MAKE_MODULE) meltmoduledynamic \ GCCMELT_CFLAGS="$(melt_cflags)" \ GCCMELT_MODULE_SOURCE=$< GCCMELT_MODULE_BINARY=$(shell basename $@ .d.so).so @@ -98,11 +98,11 @@ GCCMELT_CFLAGS="$(melt_cflags)" \ GCCMELT_MODULE_SOURCE=$< GCCMELT_MODULE_BINARY=$@ ## warmeltbig*.c is so big that it can only be compiled with -O0 -warmeltbig-%.so: warmeltbig-%.c $(melt_make_module_makefile) +warmeltbig-%.so: warmeltbig-%.c $(melt_make_module_makefile) melt-predef.h $(MELT_MAKE_MODULE) meltmodule \ GCCMELT_CFLAGS="$(melt_cflags) -O0" \ GCCMELT_MODULE_SOURCE=$< GCCMELT_MODULE_BINARY=$@ -warm%.so: warm%.c $(melt_make_module_makefile) +warm%.so: warm%.c $(melt_make_module_makefile) melt-predef.h $(MELT_MAKE_MODULE) meltmodule \ GCCMELT_CFLAGS="$(melt_cflags) $(MELT_FINAL_CFLAGS)" \ GCCMELT_MODULE_SOURCE=$< GCCMELT_MODULE_BINARY=$@ Index: gcc/melt/warmelt-first.melt =================================================================== --- gcc/melt/warmelt-first.melt (revision 160746) +++ gcc/melt/warmelt-first.melt (working copy) @@ -1475,6 +1475,14 @@ :disc_super discr_any_receiver :named_name '"DISCR_INTEGER") +;;; The discriminant for boxed reals. +(definstance discr_real class_discriminant + :doc #{The $DISCR_REAL is the discriminant of boxed reals. }# + :predef DISCR_REAL + :obj_num OBMAG_REAL + :disc_super discr_any_receiver + :named_name '"DISCR_REAL") + ;;; the discriminant for constant integers, like '123 (definstance discr_constant_integer class_discriminant :predef DISCR_CONSTANT_INTEGER @@ -3544,6 +3552,7 @@ discr_ppl_constraint_system discr_ppl_polyhedron discr_rawfile + discr_real discr_routine discr_strbuf discr_string Index: gcc/melt/xtramelt-ana-base.melt =================================================================== --- gcc/melt/xtramelt-ana-base.melt (revision 160746) +++ gcc/melt/xtramelt-ana-base.melt (working copy) @@ -1329,8 +1329,19 @@ #{ /*$treeintk !*/ $n = tree_low_cst(($tr), 0); }# ) - - +;;; pattern tree_real_cst +(defcmatcher tree_real_cst + (:tree tr) + (:value v) + treerealc + ;; test expander + #{ /* $treerealc ?*/ (($tr) && TREE_CODE($tr) == REAL_CST) }# + ;; fill expander + #{ /* treerealc! */ + $v = meltgc_new_real ((meltobject_ptr_t) MELT_PREDEF (DISCR_REAL), + TREE_REAL_CST(($tr))); }# +) + ;;; pattern for pointer types (defcmatcher tree_pointer_type_p (:tree tr) Index: gcc/melt-runtime.c =================================================================== --- gcc/melt-runtime.c (revision 160746) +++ gcc/melt-runtime.c (working copy) @@ -1973,7 +1973,32 @@ #undef object_discrv } +melt_ptr_t +meltgc_new_real (meltobject_ptr_t discr_p, REAL_VALUE_TYPE r) +{ + MELT_ENTERFRAME (2, NULL); +#define resv meltfram__.varptr[0] +#define discrv meltfram__.varptr[1] +#define object_discrv ((meltobject_ptr_t)(discrv)) +#define real_resv ((struct meltreal_st*) resv) + discrv = (void*) discr_p; + if (!discrv) + discrv = (meltobject_ptr_t) MELT_PREDEF (DISCR_REAL); + if (object_discrv->object_magic != OBMAG_REAL) + goto end; + resv = meltgc_allocate (sizeof (struct meltreal_st), 0); + real_resv->discr = object_discrv; + real_resv->val = r; +end: + MELT_EXITFRAME (); + return (melt_ptr_t) resv; +#undef resv +#undef discrv +#undef object_discrv +#undef real_resv +} + /* allocate a new routine object of given DISCR and of length LEN, with a DESCR-iptive string a a PROC-edure */ meltroutine_ptr_t @@ -2961,7 +2986,7 @@ return ((meltobject_ptr_t) cont)->obj_vartab[FCONTAINER_VALUE]; } -/* allocate a new boxed tree of given DISCR [or DISCR_TREE] & content +/* allocate a new boxedtree of given DISCR [or DISCR_TREE] & content VAL */ melt_ptr_t meltgc_new_tree (meltobject_ptr_t discr_p, tree tr) Index: gcc/melt-runtime.h =================================================================== --- gcc/melt-runtime.h (revision 160746) +++ gcc/melt-runtime.h (working copy) @@ -1522,6 +1522,7 @@ /* allocate a boxed long integer (or null if bad DISCR) fillen with NUM */ melt_ptr_t meltgc_new_int (meltobject_ptr_t discr, long num); +/* Retrieve an integer from a boxed integer or mixnumbers. */ static inline long melt_get_int (melt_ptr_t v) { @@ -1540,8 +1541,19 @@ } } +/* Make a boxed real from a real value. If discr is NULL, use DISCR_REAL. */ +melt_ptr_t meltgc_new_real(meltobject_ptr_t discr, REAL_VALUE_TYPE r); +/* Unbox real value. It returns 0 if not a boxed real. */ +static inline REAL_VALUE_TYPE +melt_get_real (melt_ptr_t v) +{ + if (melt_magic_discr (v) == OBMAG_REAL) + return ((struct meltreal_st*) v)->val; + return dconst0; +} + static inline long melt_obj_hash (melt_ptr_t v) { Index: gcc/melt-predef.list =================================================================== --- gcc/melt-predef.list (revision 160746) +++ gcc/melt-predef.list (working copy) @@ -96,6 +96,7 @@ DISCR_NAME_STRING DISCR_NULL_RECEIVER DISCR_PAIR + DISCR_REAL DISCR_ROUTINE DISCR_STRBUF DISCR_STRING