From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24961 invoked by alias); 20 Jun 2003 04:47:08 -0000 Mailing-List: contact cgen-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cgen-owner@sources.redhat.com Received: (qmail 24929 invoked from network); 20 Jun 2003 04:47:06 -0000 Received: from unknown (HELO neon-gw.transmeta.com) (63.209.4.196) by sources.redhat.com with SMTP; 20 Jun 2003 04:47:06 -0000 Received: (from root@localhost) by neon-gw.transmeta.com (8.9.3/8.9.3) id VAA26284; Thu, 19 Jun 2003 21:46:59 -0700 Received: from mailhost.transmeta.com(10.1.1.15) by neon-gw.transmeta.com via smap (V2.1) id xma026272; Thu, 19 Jun 03 21:46:43 -0700 Received: from casey.transmeta.com (casey.transmeta.com [10.10.25.22]) by deepthought.transmeta.com (8.11.6/8.11.6) with ESMTP id h5K4knB08293; Thu, 19 Jun 2003 21:46:49 -0700 (PDT) Received: (from dje@localhost) by casey.transmeta.com (8.9.3/8.7.3) id VAA05713; Thu, 19 Jun 2003 21:46:49 -0700 From: Doug Evans MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <16114.37304.990591.444315@casey.transmeta.com> Date: Fri, 20 Jun 2003 04:47:00 -0000 To: Michael Meissner Cc: cgen@sources.redhat.com Subject: Nested define-pmacro's In-Reply-To: <20030620023527.GA24021@tiktok.the-meissners.org> References: <20030620023527.GA24021@tiktok.the-meissners.org> X-SW-Source: 2003-q2/txt/msg00120.txt.bz2 Michael Meissner writes: > When I run it with -v -v -v, I see by the trace that > only the second function is defined. > > I see pmacros.scm has this little comment in it: > > ; ??? Nested pmacros don't bind their arguments the way nested lambda's do. > ; Should they? > > I'm hoping tomorrow to go into MIT and get a real book on scheme, but pointers > and online sources would be appreciated. Dybvig's book is the place to start IMO. The Little Schemer is too cutesie for me. Both of these are refered to on the cgen home page. Woohoo! News flash, this just in. I did a google search for Kent+Dybvig and found http://www.scheme.com/tspl2d/ We gotta add this to the cgen page. > Here the source. I've tried various different ways of coding the define-pmacro > call. Got some example uses so I can play with it myself? > ;; name: base function name > ;; comment: base comment string > ;; attrs: attribute list > ;; syntax1: initial part of syntax string before the size field > ;; syntax2: syntax string after adding the size field, not including $DREG=$S1REG,$S2REG or $DREG=$S1REG,IMM8 > ;; format: format list of the instruction fields, not include the 2 sources or destination > ;; imm-bit: bit to set for the immediate form of the instruction > ;; u: "U" if unsigned, "" if signed > ;; semantics: macro that when expanded does the operation, args are result, arg1, arg2, and mode > ;; timing: timing list > > (define-pmacro (expand-osize name comment attrs syntax1 syntax2 format imm-bit bit-21 u semantics timing) > (begin > > ;; 64-bit reg/reg format > (dni (.sym name "-64bit-reg-reg") > (.str comment ", 64 bit, reg,reg format") > attrs > (.str syntax1 syntax2 " " "$DREG" "=" "$S1REG" "," "$S2REG") > (.splice + > (.unsplice format) > OSIZE_64 > DREG > S2REG > S1REG > ) > > (sequence () > (semantics DREG S1REG S2REG (.sym u DI)) > ) > > timing > ) > > ;; 32-bit reg/reg format > (dni (.sym name "-32bit-reg-reg") > (.str comment ", 32 bit, reg,reg format") > attrs > (.str syntax1 ".32" syntax2 " " "$DREG" "=" "$S1REG" "," "$S2REG"") > (.splice + > (.unsplice format) > OSIZE_32 > DREG > S2REG > S1REG > ) > > (sequence () > (semantics (subword (.sym u SI) DREG 0) (subword (.sym u SI) S1REG 0) (subword (.sym u SI) S2REG 0) (.sym u SI)) > (semantics (subword (.sym u SI) DREG 1) (subword (.sym u SI) S1REG 1) (subword (.sym u SI) S2REG 1) (.sym u SI)) > ) > > timing > ) > > ;; other 6 formats deleted in the name of brevity > ) > ) > > (define-pmacro (macro-add ret arg1 arg2 mode) (begin (set ret (add mode arg1 arg2)))) > (expand-osize add > "add operation" ; comment > () ; attrs > "add" ; syntax before size field > "" ; syntax after size field, without args > ; format > (OPCODE_ADD > OTHER_BITS) > > BIT_35_1 ; bit 35 is the immediate bit > "" ; signed operation > macro-add ; macro to do add operation > () ; timing attributes > )