From 29a37c339e403c883a81fab903804a2f04ff4f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Fri, 16 Jun 2023 12:21:53 +0200 Subject: [PATCH] cmp: merge AST nodes CL:FUNCALL and FCALL into the latter The limit imposed on the number of arguments in the call is resolved in the second pass. We get rid of the AST node CL:FUNCALL. --- src/cmp/cmpbackend-cxx/cmppass2-call.lsp | 38 +++++++++++------------- src/cmp/cmppass1-call.lsp | 11 +++---- src/cmp/cmptables.lsp | 3 -- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/cmp/cmpbackend-cxx/cmppass2-call.lsp b/src/cmp/cmpbackend-cxx/cmppass2-call.lsp index b1ee2c4a5..0f8c70141 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-call.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-call.lsp @@ -2,20 +2,16 @@ ;;;; Copyright (c) 1984, Taiichi Yuasa and Masami Hagiya ;;;; Copyright (c) 1990, Giuseppe Attardi ;;;; Copyright (c) 2010, Juan Jose Garcia-Ripoll -;;;; Copyright (c) 2021, Daniel Kochmański +;;;; Copyright (c) 2023, Daniel Kochmański ;;;; -;;;; This program is free software; you can redistribute it and/or -;;;; modify it under the terms of the GNU Library General Public -;;;; License as published by the Free Software Foundation; either -;;;; version 2 of the License, or (at your option) any later version. -;;;; -;;;; See file '../Copyright' for full details. +;;;; See the file 'LICENSE' for the copyright details. ;;;; (in-package #:compiler) -;;; Functions that use MAYBE-SAVE-VALUE should rebind *temp*. +;;; Functions that use MAYBE-SAVE-VALUE should rebind *TEMP*. (defun maybe-save-value (value &optional (other-forms nil other-forms-flag)) + (declare (si::c-local)) (let ((name (c1form-name value))) (cond ((eq name 'LOCATION) (c1form-arg 0 value)) @@ -29,19 +25,10 @@ (c2expr* value) temp))))) -(defun c2funcall (c1form form args) - (declare (ignore c1form)) - (let* ((*inline-blocks* 0) - (*temp* *temp*) - (form-type (c1form-primary-type form)) - (function-p (and (subtypep form-type 'function) - (policy-assume-right-type))) - (loc (maybe-save-value form args))) - (unwind-exit (call-unknown-global-loc nil loc (inline-args args) function-p)) - (close-inline-blocks))) - (defun c2fcall (c1form form args) - (c2call-stack c1form form args nil)) + (if (> (length args) si:c-arguments-limit) + (c2call-stack c1form form args nil) + (c2call-unknown c1form form args))) (defun c2mcall (c1form form args) (c2call-stack c1form form args t)) @@ -118,6 +105,17 @@ (c1form-primary-type c1form))) (close-inline-blocks)))) +(defun c2call-unknown (c1form form args) + (declare (ignore c1form)) + (let* ((*inline-blocks* 0) + (*temp* *temp*) + (form-type (c1form-primary-type form)) + (function-p (and (subtypep form-type 'function) + (policy-assume-right-type))) + (loc (maybe-save-value form args))) + (unwind-exit (call-unknown-global-loc nil loc (inline-args args) function-p)) + (close-inline-blocks))) + (defun c2call-stack (c1form form args values-p) (declare (ignore c1form)) (let* ((*temp* *temp*) diff --git a/src/cmp/cmppass1-call.lsp b/src/cmp/cmppass1-call.lsp index 7cc4e15a1..322554327 100644 --- a/src/cmp/cmppass1-call.lsp +++ b/src/cmp/cmppass1-call.lsp @@ -2,7 +2,7 @@ ;;;; Copyright (c) 1984, Taiichi Yuasa and Masami Hagiya ;;;; Copyright (c) 1990, Giuseppe Attardi ;;;; Copyright (c) 2010, Juan Jose Garcia-Ripoll -;;;; Copyright (c) 2021, Daniel Kochmański +;;;; Copyright (c) 2023, Daniel Kochmański ;;;; ;;;; See the file 'LICENSE' for the copyright details. ;;;; @@ -10,11 +10,8 @@ (in-package #:compiler) (defun unoptimized-funcall (fun arguments) - (if (<= (length arguments) si:c-arguments-limit) - (make-c1form* 'CL:FUNCALL - :sp-change t :side-effects t :args (c1expr fun) (c1args* arguments)) - (make-c1form* 'FCALL - :sp-change t :side-effects t :args (c1expr fun) (c1args* arguments)))) + (make-c1form* 'FCALL :sp-change t :side-effects t + :args (c1expr fun) (c1args* arguments))) (defun optimized-lambda-call (lambda-form arguments apply-p) (multiple-value-bind (bindings body) @@ -96,7 +93,7 @@ (defun c1apply (args) (check-args-number 'CL:APPLY args 2) (flet ((default-apply (fun arguments) - (let ((form (c1funcall (list* '#'APPLY fun arguments)))) + (let ((form (c1funcall (list* '(function CL:APPLY) fun arguments)))) (when (function-form-p fun) (let* ((fname (second fun)) (type (get-return-type fname))) diff --git a/src/cmp/cmptables.lsp b/src/cmp/cmptables.lsp index 4af2ef47c..9b3c9eb14 100644 --- a/src/cmp/cmptables.lsp +++ b/src/cmp/cmptables.lsp @@ -32,7 +32,6 @@ (CL:PROGV symbols values form :side-effects) (CL:TAGBODY tag-var tag-body :pure) (CL:RETURN-FROM blk-var nonlocal value :side-effects) - (CL:FUNCALL fun-value (arg-value*) :side-effects) (FCALL fun-value (arg-value*) :side-effects) (MCALL fun-value (arg-value*) :side-effects) (CALL-LOCAL obj-fun (arg-value*) :side-effects) @@ -209,7 +208,6 @@ (defconstant +c2-dispatch-alist+ '((cl:block . c2block) (cl:return-from . c2return-from) - (cl:funcall . c2funcall) (fcall . c2fcall) (mcall . c2mcall) (call-global . c2call-global) @@ -266,7 +264,6 @@ (defconstant +p1-dispatch-alist+ '((cl:block . p1block) (cl:return-from . p1return-from) - (cl:funcall . p1trivial) (fcall . p1trivial) (mcall . p1trivial) (call-global . p1call-global)