diff mbox

[MELT] Add a few tree primitives

Message ID CAF+LTedMEF=-whVi4Y_EUciUAP0FZBg7FJYbU8JLr03o8NoMiQ@mail.gmail.com
State New
Headers show

Commit Message

Romain Geissler Aug. 2, 2011, 3:02 p.m. UTC
Hi,

I added a few primitives about trees, plus a string_to_long
conversion primitive and a foreach_pair_between iterator
that allows to iterate between two pairs of the same list (and
thus iterate on sublist).

Note: again, it's a git patch for Pierre until Basil returns.

Romain

Comments

Basile Starynkevitch Aug. 2, 2011, 4:38 p.m. UTC | #1
On Tue, 2 Aug 2011 17:02:05 +0200
Romain Geissler <romain.geissler@gmail.com> wrote:

> Hi,
> 
> I added a few primitives about trees, plus a string_to_long
> conversion primitive and a foreach_pair_between iterator
> that allows to iterate between two pairs of the same list (and
> thus iterate on sublist).
> 
> Note: again, it's a git patch for Pierre until Basil returns.

I'm still near Paris for a few days.

I applied it to the MELT branch.
Transmitting file data ...
Committed revision 177195.

Romain, could you try to compile the latest MELT branch, please. I'm able to build it till
MELT stage3, but Pierre is not able to do that (& we spent several hours understanding
why without success). It does not build yet past xtramelt*.melt files (and it cannot be
installed). 

You should build MELT in an empty build tree. Please give us the log file of your make
(don't use make -j, only a sequential make).

Cheers.
Romain Geissler Aug. 2, 2011, 5:13 p.m. UTC | #2
Le 2 août 2011 à 18:38, Basile Starynkevitch a écrit :

> On Tue, 2 Aug 2011 17:02:05 +0200
> Romain Geissler <romain.geissler@gmail.com> wrote:
> 
>> Hi,
>> 
>> I added a few primitives about trees, plus a string_to_long
>> conversion primitive and a foreach_pair_between iterator
>> that allows to iterate between two pairs of the same list (and
>> thus iterate on sublist).
>> 
>> Note: again, it's a git patch for Pierre until Basil returns.
> 
> I'm still near Paris for a few days.
> 
> I applied it to the MELT branch.
> Transmitting file data ...
> Committed revision 177195.
> 
> Romain, could you try to compile the latest MELT branch, please. I'm able to build it till
> MELT stage3, but Pierre is not able to do that (& we spent several hours understanding
> why without success). It does not build yet past xtramelt*.melt files (and it cannot be
> installed). 

I tried to built two different revision this afternoon, each time with an empty build directory, and none worked (same error as Pierre got, it stops at Melt stage 1). IIRC the last one was at revision **162 or something near this one. I do fully bootstrap GCC unlike you, but the error occurs at GCC stage 1, so GCC bootstrapping might not be the cause.

> 
> You should build MELT in an empty build tree. Please give us the log file of your make
> (don't use make -j, only a sequential make).

Ok, i'll send you that tomorrow. Tell me if you want that i explore this issue on my configuration.


> Cheers.
> 
> 
> -- 
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mine, sont seulement les miennes} ***
> 
> -- 
> Message from the http://groups.google.com/group/gcc-melt group.
> About GCC MELT http://gcc-melt.org/ a high level domain specific language to code extensions to the Gnu Compiler Collection
Basile Starynkevitch Aug. 2, 2011, 7:59 p.m. UTC | #3
On Tue, 2 Aug 2011 19:13:04 +0200
Romain Geissler <romain.geissler@gmail.com> wrote:
> > You should build MELT in an empty build tree. Please give us the log file of your make
> > (don't use make -j, only a sequential make).
> 
> Ok, i'll send you that tomorrow. Tell me if you want that i explore this issue on my configuration.

Yes please. I don't understand why on my system the builds go till melt-stage3 while on
Pierre's machine it fails before melt-stage2, and we looked together (by IRC) several
hours.

Cheers

PS Being on vacation, I probably won't MELT much tomorrow :-)
Romain Geissler Aug. 3, 2011, 1:06 p.m. UTC | #4
Hi

2011/8/2 Basile Starynkevitch <basile@starynkevitch.net>:
> On Tue, 2 Aug 2011 19:13:04 +0200
> Romain Geissler <romain.geissler@gmail.com> wrote:
>> > You should build MELT in an empty build tree. Please give us the log file of your make
>> > (don't use make -j, only a sequential make).
>>
>> Ok, i'll send you that tomorrow. Tell me if you want that i explore this issue on my configuration.
>
> Yes please. I don't understand why on my system the builds go till melt-stage3 while on
> Pierre's machine it fails before melt-stage2, and we looked together (by IRC) several
> hours.
>
> Cheers
>
> PS Being on vacation, I probably won't MELT much tomorrow :-)
>
>
> --
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mine, sont seulement les miennes} ***
>
> --
> Message from the http://groups.google.com/group/gcc-melt group.
> About GCC MELT http://gcc-melt.org/ a high level domain specific language to code extensions to the Gnu Compiler Collection
>

I've made a few changes so that Melt bootstraps. But it still fails at
the final check-melt-runtime for a simple reason: Melt won't load
modules as we don't give it the melt-workdir where all *.so reside.
I realized that all those recent changes had made the melt-modules
directory completely useless as you always look for
my-module.MD5.FLAVOR.so that are in melt-workdir, and bypass the
melt-modules symlinks. I don't really know what exact behavior you are
expecting from the melt-modules, melt-workdir and melt-tempdir
directories so i don't really know how to correct the issue.

Find attached the log for check-melt-runtime, but it might not be
useful, i already gave you the reason of the error.

Romain
diff mbox

Patch

From a4d3037f8b0c032f2ba56b89a35f41fe7939d75a Mon Sep 17 00:00:00 2001
From: Romain Geissler <romain.geissler@st.com>
Date: Tue, 2 Aug 2011 16:55:02 +0200
Subject: [PATCH] Add a few functions.

---
 gcc/melt/warmelt-first.melt     |   28 +++++++++++++++++++++
 gcc/melt/xtramelt-ana-base.melt |   51 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 0 deletions(-)

diff --git a/gcc/melt/warmelt-first.melt b/gcc/melt/warmelt-first.melt
index ef8affd..33383dc 100644
--- a/gcc/melt/warmelt-first.melt
+++ b/gcc/melt/warmelt-first.melt
@@ -1162,6 +1162,12 @@  an integer $I if $I is greater than $N.}#
   :doc #{Test that value string $S1 is greater than $S2.}#
   #{melt_string_less((melt_ptr_t)($s2), (melt_ptr_t)($s1))}#)
 
+(defprimitive string_to_long (string) :long
+	:doc #{Read a string value and returns the corresponding
+	long stuff. 0 is returned if an error occurs while reading.}#
+	#{
+		atol(melt_string_str($string))
+	}#)
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3225,6 +3231,26 @@  nil.}#
 
 ;;;;;;;;;;;;;;;;
 
+;;; citerator on pairs
+(defciterator foreach_pair_between
+  (start_pair end_pair) ;start formals 
+  eachpair ;state
+  (curpair curcomp) ;local formals
+  :doc #{The $FOREACH_PAIR_BETWEEN iterator goes between two (linked) pairs,
+  given by the start formal $START_PAIR and $END_PAIR. Local formals are $CURPAIR,
+  bound to the current pair, and $CURCOMP, bound to the current component within
+  the pair.}#
+   #{/* start $eachpair */
+   for ($curpair = $start_pair;
+	melt_magic_discr($curpair) == MELTOBMAG_PAIR;
+        $curpair = melt_pair_tail($curpair)) {
+	$curcomp = melt_pair_head($curpair); }#
+   #{
+      if ($curpair == $end_pair) {
+         break;
+      }
+   } /* end $eachpair */}#
+)
 
 ;;; citerator on lists
 (defciterator foreach_in_list 
@@ -4085,6 +4111,7 @@  also $CLASS_ANY_BINDING and $CLASS_ENVIRONMENT.}#
  shortbacktrace_dbg
  string<
  string>
+ string_to_long
  stringconst2val
  the_meltcallcount
  the_callcount
@@ -4207,6 +4234,7 @@  also $CLASS_ANY_BINDING and $CLASS_ENVIRONMENT.}#
 
 ;; export the citerators & cmatchers defined above
 (export_values
+ foreach_pair_between
  foreach_in_list
  foreach_in_mapobject
  foreach_in_mapstring
diff --git a/gcc/melt/xtramelt-ana-base.melt b/gcc/melt/xtramelt-ana-base.melt
index 34afcf2..af29fde 100644
--- a/gcc/melt/xtramelt-ana-base.melt
+++ b/gcc/melt/xtramelt-ana-base.melt
@@ -1494,6 +1494,51 @@ 
 (defprimitive tree_uid (:tree tr) :long
   #{(($tr) ? (long) DECL_UID($tr) : NULL)}#)
 
+(defprimitive tree_chain_prepend (:tree purpose value chain) :tree
+	:doc #{Create a new TREE_LIST node with $PURPOSE and $VALUE trees
+	and chain it at the begining of $CHAIN. Returns the newly created
+	chain.}#
+	#{
+		tree_cons ($PURPOSE, $VALUE, $CHAIN)
+	}#)
+
+(defprimitive tree_chain_append (:tree purpose value chain) :tree
+	:doc #{Create a new TREE_LIST node with $PURPOSE and $VALUE trees
+	and chain it at the end of $CHAIN. Returns the newly created
+	chain (different from $CHAIN if $CHAIN is NULL_TREE).}#
+	#{
+		chainon ($CHAIN, tree_cons ($PURPOSE, $VALUE, NULL_TREE))
+	}#)
+
+(defprimitive tree_chain_join (:tree chain1 chain2) :tree
+	:doc #{Append $CHAIN2 to $CHAIN1 and returns the newly created
+	chain (different from $CHAIN1 if $CHAIN1 is NULL_TREE).}#
+	#{
+		chainon ($CHAIN1, $CHAIN2)
+	}#)
+
+(defprimitive build_identifier_tree (name) :tree
+	:doc #{Create and returns a new IDENTIFIER_NODE tree whose
+	name is $NAME.}#
+	#{
+		get_identifier (melt_string_str ($NAME))
+	}#)
+
+(defprimitive build_string_tree (string_value) :tree
+	:doc #{Create and returns a new STRING_CST tree whose
+	value is $STRING_VALUE.}#
+	#{
+		build_string (strlen (melt_string_str ($STRING_VALUE)), melt_string_str ($STRING_VALUE))
+	}#)
+
+(defprimitive build_int_tree (int_value) :tree
+	:doc #{Create and returns a new INTEGER_CST tree whose
+	value is $INT_VALUE and type is the default language
+	integer type.}#
+	#{
+		build_int_cst (integer_type_node, (int)melt_get_int ($INT_VALUE))
+	}#)
+
 
 ;;;;;;;;;;;;;;;;
 ;;;;;;;;;;;;;;;;
@@ -3409,6 +3454,9 @@  and discriminant $DIS, usually $DISCR_MIXED_LOCATION.}#
  basicblock_nb_succ
  basicblock_phinodes
  basicblock_single_succ 
+ build_identifier_tree
+ build_int_tree
+ build_string_tree
  cfun_decl
  cfun_gimple_body
  cfun_has_cfg
@@ -3656,6 +3704,9 @@  and discriminant $DIS, usually $DISCR_MIXED_LOCATION.}#
  tree_array_ref_full
  tree_array_type
  tree_block
+ tree_chain_append
+ tree_chain_join
+ tree_chain_prepend
  tree_component_ref
  tree_component_ref_full
  tree_component_ref_typed
-- 
1.7.6