aboutsummaryrefslogtreecommitdiffstats
path: root/test/src
diff options
context:
space:
mode:
authorAndrea Corallo2020-11-01 09:57:06 +0100
committerAndrea Corallo2020-11-01 14:27:42 +0100
commit047fe3292d2f102c9aed4dc305de165b627bcddd (patch)
tree0b78cffaef1612677af8f86c99f10acc383df496 /test/src
parentf7f5d59ab4c4cc1a7db46d7f1d462655254e1a87 (diff)
downloademacs-047fe3292d2f102c9aed4dc305de165b627bcddd.tar.gz
emacs-047fe3292d2f102c9aed4dc305de165b627bcddd.zip
* Rework some native compiler test infrastructure
* test/src/comp-tests.el (comp-tests-map-checker): New function returning a list holding checker results. (comp-tests-tco-checker, comp-tests-fw-prop-checker-1) (comp-tests-pure-checker-1, comp-tests-pure-checker-2): Make use of `comp-tests-map-checker'.
Diffstat (limited to 'test/src')
-rw-r--r--test/src/comp-tests.el79
1 files changed, 45 insertions, 34 deletions
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index 446a61549d9..4834e21fba3 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -686,28 +686,29 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
686 'comment) 686 'comment)
687 (comp-tests-mentioned-p-1 x insn))) 687 (comp-tests-mentioned-p-1 x insn)))
688 688
689(defun comp-tests-make-insn-checker (func-name checker) 689(defun comp-tests-map-checker (func-name checker)
690 "Apply CHECKER to each insn in FUNC-NAME. 690 "Apply CHECKER to each insn of FUNC-NAME.
691CHECKER should always return nil to have a pass." 691Return a list of results."
692 (should-not 692 (cl-loop
693 (cl-loop 693 with func-c-name = (comp-c-func-name (or func-name 'anonymous-lambda) "F" t)
694 named checker-loop
695 with func-c-name = (comp-c-func-name func-name "F" t)
696 with f = (gethash func-c-name (comp-ctxt-funcs-h comp-ctxt)) 694 with f = (gethash func-c-name (comp-ctxt-funcs-h comp-ctxt))
697 for bb being each hash-value of (comp-func-blocks f) 695 for bb being each hash-value of (comp-func-blocks f)
698 do (cl-loop 696 nconc
699 for insn in (comp-block-insns bb) 697 (cl-loop
700 when (funcall checker insn) 698 for insn in (comp-block-insns bb)
701 do (cl-return-from checker-loop 'mentioned))))) 699 collect (funcall checker insn))))
702 700
703(defun comp-tests-tco-checker (_) 701(defun comp-tests-tco-checker (_)
704 "Check that inside `comp-tests-tco-f' we have no recursion." 702 "Check that inside `comp-tests-tco-f' we have no recursion."
705 (comp-tests-make-insn-checker 703 (should
706 'comp-tests-tco-f 704 (cl-notany
707 (lambda (insn) 705 #'identity
708 (or (comp-tests-mentioned-p 'comp-tests-tco-f insn) 706 (comp-tests-map-checker
709 (comp-tests-mentioned-p (comp-c-func-name 'comp-tests-tco-f "F" t) 707 'comp-tests-tco-f
710 insn))))) 708 (lambda (insn)
709 (or (comp-tests-mentioned-p 'comp-tests-tco-f insn)
710 (comp-tests-mentioned-p (comp-c-func-name 'comp-tests-tco-f "F" t)
711 insn)))))))
711 712
712(comp-deftest tco () 713(comp-deftest tco ()
713 "Check for tail recursion elimination." 714 "Check for tail recursion elimination."
@@ -728,11 +729,14 @@ CHECKER should always return nil to have a pass."
728 729
729(defun comp-tests-fw-prop-checker-1 (_) 730(defun comp-tests-fw-prop-checker-1 (_)
730 "Check that inside `comp-tests-fw-prop-f' `concat' and `length' are folded." 731 "Check that inside `comp-tests-fw-prop-f' `concat' and `length' are folded."
731 (comp-tests-make-insn-checker 732 (should
732 'comp-tests-fw-prop-1-f 733 (cl-notany
733 (lambda (insn) 734 #'identity
734 (or (comp-tests-mentioned-p 'concat insn) 735 (comp-tests-map-checker
735 (comp-tests-mentioned-p 'length insn))))) 736 'comp-tests-fw-prop-1-f
737 (lambda (insn)
738 (or (comp-tests-mentioned-p 'concat insn)
739 (comp-tests-mentioned-p 'length insn)))))))
736 740
737(comp-deftest fw-prop () 741(comp-deftest fw-prop ()
738 "Some tests for forward propagation." 742 "Some tests for forward propagation."
@@ -751,21 +755,28 @@ CHECKER should always return nil to have a pass."
751(defun comp-tests-pure-checker-1 (_) 755(defun comp-tests-pure-checker-1 (_)
752 "Check that inside `comp-tests-pure-caller-f' `comp-tests-pure-callee-f' is 756 "Check that inside `comp-tests-pure-caller-f' `comp-tests-pure-callee-f' is
753 folded." 757 folded."
754 (comp-tests-make-insn-checker 758 (should
755 'comp-tests-pure-caller-f 759 (cl-notany
756 (lambda (insn) 760 #'identity
757 (or (comp-tests-mentioned-p 'comp-tests-pure-callee-f insn) 761 (comp-tests-map-checker
758 (comp-tests-mentioned-p (comp-c-func-name 'comp-tests-pure-callee-f "F" t) 762 'comp-tests-pure-caller-f
759 insn))))) 763 (lambda (insn)
764 (or (comp-tests-mentioned-p 'comp-tests-pure-callee-f insn)
765 (comp-tests-mentioned-p (comp-c-func-name
766 'comp-tests-pure-callee-f "F" t)
767 insn)))))))
760 768
761(defun comp-tests-pure-checker-2 (_) 769(defun comp-tests-pure-checker-2 (_)
762 "Check that `comp-tests-pure-fibn-f' is folded." 770 "Check that `comp-tests-pure-fibn-f' is folded."
763 (comp-tests-make-insn-checker 771 (should
764 'comp-tests-pure-fibn-entry-f 772 (cl-notany
765 (lambda (insn) 773 #'identity
766 (or (comp-tests-mentioned-p 'comp-tests-pure-fibn-f insn) 774 (comp-tests-map-checker
767 (comp-tests-mentioned-p (comp-c-func-name 'comp-tests-pure-fibn-f "F" t) 775 'comp-tests-pure-fibn-entry-f
768 insn))))) 776 (lambda (insn)
777 (or (comp-tests-mentioned-p 'comp-tests-pure-fibn-f insn)
778 (comp-tests-mentioned-p (comp-c-func-name 'comp-tests-pure-fibn-f "F" t)
779 insn)))))))
769 780
770(comp-deftest pure () 781(comp-deftest pure ()
771 "Some tests for pure functions optimization." 782 "Some tests for pure functions optimization."