Commit 9e747f5f authored by jjgarcia's avatar jjgarcia
Browse files

*** empty log message ***

parent d664bee3
;;;; CMPCT -- Optimizer for several constant values
;;;; Copyright (c) 2003, Juan Jose Garcia Ripoll.
;;;; ECoLisp 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.
(in-package "COMPILER")
(defvar +optimizable-constant+ '())
(defun c1constant-value (val always-p)
((let ((x (assoc val +optimizable-constant+)))
(and x (c1expr (cdr x)))))
((eq val nil) (c1nil))
((eq val t) (c1t))
((sys::fixnump val)
(make-c1form* 'LOCATION :type 'FIXNUM :args (list 'FIXNUM-VALUE val)))
((characterp val)
(make-c1form* 'LOCATION :type 'CHARACTER
:args (list 'CHARACTER-VALUE (char-code val))))
((typep val 'LONG-FLOAT)
(make-c1form* 'LOCATION :type 'LONG-FLOAT
:args (list 'LONG-FLOAT-VALUE val (add-object val))))
((typep val 'SHORT-FLOAT)
(make-c1form* 'LOCATION :type 'SHORT-FLOAT
:args (list 'SHORT-FLOAT-VALUE val (add-object val))))
(make-c1form* 'LOCATION :type (object-type val)
:args (list 'VV (add-object val))))
(t nil)))
#'(lambda (record)
(let* ((name (first record))
(c-value (second record))
(value (symbol-value name))
(type (lisp-type->rep-type (type-of value))))
(push (cons value `(c-inline () () ,type ,c-value :one-liner t :side-effects nil))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment