cmpc: move the c-inliner fully to the cmpc backend module

This commit is contained in:
Daniel Kochmański 2023-06-20 13:41:32 +02:00
parent 49668f8dda
commit 6d60cf294a
8 changed files with 30 additions and 29 deletions

View file

@ -806,3 +806,8 @@
(def-inline clos:funcallable-standard-instance-access :unsafe (clos:funcallable-standard-object fixnum) t "(#0)->instance.slots[#1]"))
*inline-information*))
;;; XXX this should be part of the initializer for the compiler instance (but
;;; currently the compiler is a singleton).
(setf (machine-inline-information *default-machine*)
(make-inline-information *default-machine*))

View file

@ -14,8 +14,18 @@
(in-package "COMPILER")
(setf (machine-inline-information *default-machine*)
(make-inline-information *default-machine*))
(defstruct (inline-info)
name ;;; Function name
arg-rep-types ;;; List of representation types for the arguments
return-rep-type ;;; Representation type for the output
arg-types ;;; List of lisp types for the arguments
return-type ;;; Lisp type for the output
exact-return-type ;;; Only use this expansion when the output is
;;; declared to have a subtype of RETURN-TYPE
multiple-values ;;; Works with all destinations, including VALUES / RETURN
expansion ;;; C template containing the expansion
one-liner ;;; Whether the expansion spans more than one line
)
(defun inlined-arg-loc (arg)
(second arg))
@ -47,8 +57,8 @@
;;; returns NIL if inline expansion of the function is not possible
;;;
(defun inline-function (fname arg-types return-type &optional (return-rep-type 'any))
;; Those functions that use INLINE-FUNCTION must rebind
;; the variable *INLINE-BLOCKS*.
;; Those functions that use INLINE-FUNCTION must rebind the variable
;; *INLINE-BLOCKS*.
(and (inline-possible fname)
(not (gethash fname *c2-dispatch-table*))
(let* (;; (dest-rep-type (loc-representation-type *destination*))

View file

@ -17,8 +17,6 @@
sorted-types
inline-information)
;;; FIXME currently all definitions assume C machine (see cmpc-machine.lsp).
(defstruct (rep-type (:constructor %make-rep-type))
(index 0) ; Precedence order in the type list
(name t)

View file

@ -24,7 +24,7 @@
:one-liner t :side-effects nil))))
((floatp name)
(let* ((value name)
(type (type-of value))
(type (type-of value))
(loc-type (case type
(cl:single-float 'single-float-value)
(cl:double-float 'double-float-value)

View file

@ -10,6 +10,7 @@
(defvar *opened-c-braces* 0)
(defvar *emitted-local-funs* nil)
(defvar *inline-information* nil)
;;; Compiled code uses the following kinds of variables:
;;; 1. Vi, declared explicitely, either unboxed or not (*lcl*, next-lcl)
@ -67,7 +68,11 @@
(*temp* 0)
(*max-temp* 0)
(*next-cfun* 0)
(*last-label* 0))
(*last-label* 0)
(*inline-information*
(ext:if-let ((r (machine-inline-information *machine*)))
(si:copy-hash-table r)
(make-inline-information *machine*))))
,@body))
(defun-cached env-var-name (n) eql

View file

@ -22,7 +22,6 @@
(defvar *inline-max-depth* 3
"Depth at which inlining of functions stops.")
(defvar *inline-information* nil)
;;; --cmputil.lsp--
;;;
@ -267,9 +266,5 @@ be deleted if they have been opened with LoadLibrary.")
(*clines-string-list* '())
(si::*defun-inline-hook* 'maybe-install-inline-function)
(*machine* (or *machine* *default-machine*))
(*optimizable-constants* (make-optimizable-constants *machine*))
(*inline-information*
(ext:if-let ((r (machine-inline-information *machine*)))
(si:copy-hash-table r)
(make-inline-information *machine*)))))
(*optimizable-constants* (make-optimizable-constants *machine*))))

View file

@ -49,16 +49,3 @@
(format t "~% ~D > ~A, parent ~A" *c1form-level* form (c1form-parents form))
(print-c1forms (c1form-args form))
form)))
(defstruct (inline-info)
name ;;; Function name
arg-rep-types ;;; List of representation types for the arguments
return-rep-type ;;; Representation type for the output
arg-types ;;; List of lisp types for the arguments
return-type ;;; Lisp type for the output
exact-return-type ;;; Only use this expansion when the output is
;;; declared to have a subtype of RETURN-TYPE
multiple-values ;;; Works with all destinations, including VALUES / RETURN
expansion ;;; C template containing the expansion
one-liner ;;; Whether the expansion spans more than one line
)

View file

@ -48,9 +48,10 @@
"src:cmp;cmpbackend-cxx;cmpc-util.lsp"
"src:cmp;cmpbackend-cxx;cmpc-mach.lsp"
"src:cmp;cmpbackend-cxx;cmpc-wt.lsp"
"src:cmp;cmpbackend-cxx;cmpc-inl-sysfun.lsp"
"src:cmp;cmpbackend-cxx;cmpc-inl-lspfun.lsp"
"src:cmp;cmpbackend-cxx;cmpc-inliner.lsp"
;; Inliner definitions
"src:cmp;cmpbackend-cxx;cmpc-inl-lspfun.lsp"
"src:cmp;cmpbackend-cxx;cmpc-inl-sysfun.lsp"
"src:cmp;cmpbackend-cxx;cmpc-opt-inl.lsp"
"src:cmp;cmpbackend-cxx;cmpc-opt-num.lsp"
"src:cmp;cmpbackend-cxx;cmpc-opt-ct.lsp"