public inbox for cgen@sourceware.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rsandifo@cambridge.redhat.com>
To: cgen@sources.redhat.com
Subject: Couple of newbie questions
Date: Wed, 20 Dec 2000 05:34:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.21.0012201333380.27603-100000@host149.cambridge.redhat.com> (raw)

Hi,

I'm trying to learn CGEN by doing a mini 6502 port (yes, really).
I have a couple of questions...

1)

In a define-pmacro, is there a way of using .sym to create a symbol
name and then look it up as another pmacro?  I want to do something
like:

    (define-pmacro (create-insn MODE)
      (... (.expand foo- MODE) ... (.expand bar- MODE) ...))

where (create-insn immediate) would cause the definitions of
"foo-immediate" and "bar-immediate" to be substituted. I ended up adding
a new command to do this (patch attached in case anyone's interested).
But please tell me if it's already supported in some other way!

2)

What are the requirements for CGEN_INT_INSN_P?  All the 6502
instructions fit into 24 bits, so the macro is defined to be "1".
But cgen_get_insn_value() and cgen_put_insn_value() seem to expect
instructions to be 8, 16 or 32 bits wide.  Is this a common
assumption, or would it be safe to just change those two to
support 24 bits?  Or would it better to change the condition
for setting CGEN_INT_INSN_P?

Thanks,
Richard

-------------

Index: pmacros.scm
===================================================================
RCS file: /cvs/cvsfiles/devo/cgen/pmacros.scm,v
retrieving revision 1.28
diff -c -r1.28 pmacros.scm
*** pmacros.scm	2000/07/27 04:53:32	1.28
--- pmacros.scm	2000/12/20 11:47:04
***************
*** 494,499 ****
--- 494,513 ----
      (apply map (cons transformer (cons arg1 arg-rest))))
  )
  
+ ; .expand
+ 
+ (define -pmacro-expand-command
+   (lambda args
+     (let* ((name (apply -pmacro-sym args))
+ 	   (pmacro (-pmacro-lookup name)))
+       (if (not (-pmacro? pmacro))
+ 	  (-pmacro-error "not a pmacro" name))
+       (let ((transformer (-pmacro-transformer pmacro)))
+ 	(cond ((procedure? transformer)
+ 	       pmacro)
+ 	      (else transformer)))))
+ )
+ 
  ; .apply
  
  (define (-pmacro-apply pmacro arg-list)
***************
*** 546,551 ****
--- 560,568 ----
  		(-pmacro-make '.map '(macro-name arg1 . arg-rest) #f
  			      -pmacro-map
  			      "map a macro over a list of arguments"))
+   (-pmacro-set! '.expand
+ 		(-pmacro-make '.expand 'symbols #f -pmacro-expand-command
+ 			      "the macro corresponding to a synthetic name"))
    (-pmacro-set! '.apply
  		(-pmacro-make '.apply '(macro-name arg-list) #f -pmacro-apply
  			      "apply a macro, taking arguments from a list"))


             reply	other threads:[~2000-12-20  5:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-20  5:34 Richard Sandiford [this message]
2000-12-20  8:15 ` Doug Evans

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.21.0012201333380.27603-100000@host149.cambridge.redhat.com \
    --to=rsandifo@cambridge.redhat.com \
    --cc=cgen@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).