Ignore:
Timestamp:
Mar 5, 2006, 1:24:46 AM (14 years ago)
Author:
gb
Message:

New constructor, so that we can keep track of defined target-archs.
Hash table in each arch structure, for arch-dependent macros.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/compiler/arch.lisp

    r3572 r3601  
    175175(defconstant operand-fake 28)
    176176
    177 (defstruct (target-arch (:conc-name target-))
     177(defvar *known-target-archs* ())
     178
     179(defstruct (target-arch (:conc-name target-)
     180                        (:constructor %make-target-arch))
    178181  (name nil)
    179182  (lisp-node-size 0)
     
    222225  (function-tag nil)
    223226  (function-tag-is-subtag nil)
    224   (big-endian t))
     227  (big-endian t)
     228  (target-macros (make-hash-table :test #'eq)))
    225229 
     230(defun make-target-arch (&rest keys)
     231  (declare (dynamic-extent keys))
     232  (let* ((arch (apply #'%make-target-arch keys))
     233         (tail (member (target-name arch) *known-target-archs*
     234                       :key #'target-name
     235                       :test #'eq)))
     236    (if tail
     237      (rplaca tail arch)
     238      (push arch *known-target-archs*))
     239    arch))
     240
     241(defun find-target-arch (name)
     242  (car (member name *known-target-archs*
     243               :key #'target-name
     244               :test #'eq)))
     245
     246(defun target-arch-macros (arch-name)
     247  (let* ((arch (or (find-target-arch arch-name)
     248                   (error "unknown arch: ~s" arch-name))))
     249    (target-target-macros arch)))
     250
     251(defmacro defarchmacro (arch-name name arglist &body body &environment env)
     252  (let* ((lambda-form (ccl::parse-macro-1 name arglist body env)))
     253    `(progn
     254      (setf (gethash ',name (target-arch-macros ',arch-name))
     255       (ccl::nfunction ,name ,lambda-form))
     256      ',name)))
     257
     258(defun arch-macro-function (arch-name name)
     259  (gethash name (target-arch-macros arch-name)))
     260   
    226261
    227262
Note: See TracChangeset for help on using the changeset viewer.