;;; -*- Mode:Common-Lisp; Package:L; Base:10; -*-
;;;
;;; Instructions patch file for preasm.
;;;
;;; jsp 5/10/88


(defun %call-function (fn code-node link-reg args)
  (apply #'output-psuedo-inst `(,code-node ,link-reg call ,fn ,@args)))

;;;; support code for the above forms
;;;
;;; aea 5/12:removed check for null operands, copying of lists,
;;; check for initial null code stream. changed psuedo to pseudo.

(defun output-pseudo-inst (inst code-node &rest args)
  (push (cons inst args) (code-node-code-stream code-node)))

(defun output-no-dest-inst (inst code-node &rest args)
  (push (cons inst args) (code-node-code-stream code-node)))

(defun output-inst (dest inst code-node &rest sources)
  (push (list* dest inst sources) (code-node-code-stream code-node)))

(defun output-special-inst (dest inst code-node &rest sources)
  (push (list* dest inst sources) (code-node-special-code-stream code-node)))



;;; make an operand to represent a constant

(defun make-constant-operand (type value fn &optional name &rest initial-values)
  (let* ((decl (if (not (null name))
		   (l-declare-constant name fn value type '())
		   (loop for sym being the hash-elements of (fn-declarations fn) do
			 (when (and (declaration? sym)
				    (eq KIND-CONST (declaration-kind  sym))
				    (eq value      (declaration-value sym))
;				    (eq type       (declaration-type-upperbound sym))
				    )
			   (return sym))
			 finally (return (l-declare-constant (gen-constant-name) fn value type '()))
			 )))
	 (tname (declaration-symbol decl))
	 (type (declaration-type-upperbound decl)))
    (apply #'new-operand `(:name ,tname :fn ,fn :type ,type :value ,value ,@initial-values))))

