<commit_before>(cl:in-package #:sicl-direct-extrinsic-compiler)

;;;; The purpose of this component is to remove non-trivial literal
;;;; constants.  Here, non-trivial means that it can not be
;;;; represented as an immediate value for the particular processor.  
;;;;
;;;; It is assumed that trivial constants have already been replaced
;;;; by immediate inputs, so that the constants remaining in the
;;;; program are all non-trivial.
;;;;
;;;; There are two types of constants that we eliminate.  The first
;;;; type consists of constant function names as input to the
;;;; FDEFINITION-INSTRUCTION.  The second type consists of literal
;;;; inputs to other instructions.

(defun process-fdefinition-instruction (instruction static-env constants)
  (let* ((inputs (cleavir-ir:inputs instruction))
	 (function-name (cleavir-ir:value (first inputs)))
	 (output (first (cleavir-ir:outputs instruction)))
	 (temp1 (cleavir-ir:new-temporary))
	 (temp2 (cleavir-ir:new-temporary)))
    ;; Insert the instruction that takes the CAR of the
    ;; function cell. 
    (cleavir-ir:insert-instruction-before
     (cleavir-ir:make-car-instruction
      temp1 output instruction)<commit_msg>Added comment for function processing FDEFINITION.<commit_after>(cl:in-package #:sicl-direct-extrinsic-compiler)

;;;; The purpose of this component is to remove non-trivial literal
;;;; constants.  Here, non-trivial means that it can not be
;;;; represented as an immediate value for the particular processor.  
;;;;
;;;; It is assumed that trivial constants have already been replaced
;;;; by immediate inputs, so that the constants remaining in the
;;;; program are all non-trivial.
;;;;
;;;; There are two types of constants that we eliminate.  The first
;;;; type consists of constant function names as input to the
;;;; FDEFINITION-INSTRUCTION.  The second type consists of literal
;;;; inputs to other instructions.

;;; An FDEFINITION-INSTRUCTION with a constant function name as input
;;; is replaced by a reference to an item in the static environment.
;;; That item is assumed to be a CONS cell where the CAR contains the
;;; function to be called or otherwise referred to. 
;;;
;;; At the moment, we assume that the function cell is located in the
;;; vector that is the CAR of the list representing the static
;;; environment.  Later, we will remove this assumption.
;;;
;;; STATIC-ENVIRONMENT is a lexical location that holds the static
;;; environment at runtime.  CONSTANTS is a list of constants
;;; collected so far.  The length of that list determines the index in
;;; the environment vector of the function cell.
;;;
;;; This function returns the list of constants, augmented with an
;;; entry for the function cell.  Right now, the new entry is added
;;; unconditionally.  Later we will add it only if there is not
;;; already a similar entry in the list of contestants.
(defun process-fdefinition-instruction (instruction static-env constants)
  (let* ((inputs (cleavir-ir:inputs instruction))
	 (function-name (cleavir-ir:value (first inputs)))
	 (output (first (cleavir-ir:outputs instruction)))
	 (temp1 (cleavir-ir:new-temporary))
	 (temp2 (cleavir-ir:new-temporary)))
    ;; Insert the instruction that takes the CAR of the
    ;; function cell. 
    (cleavir-ir:insert-instruction-before
     (cleavir-ir:make-car-instruction
      temp1 output instruction)
{'fraction_non_alphanumeric': 0.10133729569093611, 'fraction_numerical': 0.0017830609212481426, 'mean_word_length': 4.482084690553746, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7591294', 'n_tokens_mistral': 937, 'n_tokens_neox': 860, 'n_words': 403}