| 1 |
;;;; -*- Mode: Lisp; Syntax: Common-Lisp; indent-tabs-mode: nil; Package: C -*- |
| 2 |
;;;; vim: set filetype=lisp tabstop=8 shiftwidth=2 expandtab: |
| 3 |
|
| 4 |
;;;; |
| 5 |
;;;; Copyright (c) 2010, Juan Jose Garcia-Ripoll |
| 6 |
;;;; |
| 7 |
;;;; See file 'LICENSE' for the copyright details. |
| 8 |
|
| 9 |
;;;; |
| 10 |
;;;; CMPGLOBALS -- Global variables and flag definitions |
| 11 |
;;;; |
| 12 |
|
| 13 |
(in-package "COMPILER") |
| 14 |
|
| 15 |
;;; |
| 16 |
;;; VARIABLES |
| 17 |
;;; |
| 18 |
|
| 19 |
(defvar *inline-max-depth* 3 |
| 20 |
"Depth at which inlining of functions stops.") |
| 21 |
|
| 22 |
;;; --cmputil.lsp-- |
| 23 |
;;; |
| 24 |
;;; Variables and constants for error handling |
| 25 |
;;; |
| 26 |
(defvar *current-form* '|compiler preprocess|) |
| 27 |
(defvar *current-c1form*) |
| 28 |
(defvar *current-toplevel-form* '|compiler preprocess|) |
| 29 |
(defvar *compile-file-position* -1) |
| 30 |
(defvar *active-protection* nil) |
| 31 |
(defvar *pending-actions* nil) |
| 32 |
(defvar *empty-loc* (gensym)) |
| 33 |
(defvar *inline-loc* (gensym)) |
| 34 |
|
| 35 |
(defvar *compiler-conditions* '() |
| 36 |
"This variable determines whether conditions are printed or just accumulated.") |
| 37 |
|
| 38 |
(defvar *compile-print* nil |
| 39 |
"This variable controls whether the compiler displays messages about |
| 40 |
each form it processes. The default value is NIL.") |
| 41 |
|
| 42 |
(defvar *compile-verbose* nil |
| 43 |
"This variable controls whether the compiler should display messages about its |
| 44 |
progress. The default value is T.") |
| 45 |
|
| 46 |
(defvar *compiler-features* |
| 47 |
'#.(if (not (boundp '*compiler-features*)) nil *compiler-features*) |
| 48 |
"This alternative list of features contains keywords that were gathered from |
| 49 |
running the compiler. It may be updated by running ") |
| 50 |
|
| 51 |
(defvar *suppress-compiler-messages* |
| 52 |
#+ecl-min 'compiler-debug-note #-ecl-min 'compiler-note |
| 53 |
"A type denoting which compiler messages and conditions are _not_ displayed.") |
| 54 |
|
| 55 |
(defvar *compiler-break-enable* nil) |
| 56 |
|
| 57 |
(defvar *compiler-in-use* nil) |
| 58 |
(defvar *compiler-output1*) |
| 59 |
(defvar *compiler-output2*) |
| 60 |
|
| 61 |
;;; --cmpcbk.lsp-- |
| 62 |
;;; |
| 63 |
;;; List of callbacks to be generated |
| 64 |
;;; |
| 65 |
(defvar *callbacks* nil) |
| 66 |
(defvar *functions* nil) |
| 67 |
|
| 68 |
;;; --cmpc-machine.lsp, cmpffi.lsp --- |
| 69 |
(defvar *machine* nil) |
| 70 |
|
| 71 |
;;; --cmpcall.lsp-- |
| 72 |
(defvar *compiler-declared-globals*) |
| 73 |
|
| 74 |
;;; --cmpenv.lsp-- |
| 75 |
;;; |
| 76 |
;;; Default optimization settings. |
| 77 |
;;; |
| 78 |
(defvar *safety* 2) |
| 79 |
(defvar *speed* 3) |
| 80 |
(defvar *space* 0) |
| 81 |
(defvar *debug* 0) |
| 82 |
(defvar *compilation-speed* 2) |
| 83 |
|
| 84 |
(defvar *current-function* nil) |
| 85 |
|
| 86 |
(defvar *cmp-env* nil |
| 87 |
"The compiler environment consists of a pair or cons of two |
| 88 |
lists, one containing variable records, the other one macro and |
| 89 |
function recors: |
| 90 |
|
| 91 |
variable-record = (:block block-name) | |
| 92 |
(:tag ({tag-name}*)) | |
| 93 |
(:function function-name) | |
| 94 |
(var-name {:special | nil} bound-p) | |
| 95 |
(symbol si:symbol-macro macro-function) | |
| 96 |
(:declare type arguments) | |
| 97 |
SI:FUNCTION-BOUNDARY | |
| 98 |
SI:UNWIND-PROTECT-BOUNDARY |
| 99 |
|
| 100 |
macro-record = (function-name function) | |
| 101 |
(macro-name si:macro macro-function) | |
| 102 |
(:declare name declaration) | |
| 103 |
SI:FUNCTION-BOUNDARY | |
| 104 |
SI:UNWIND-PROTECT-BOUNDARY |
| 105 |
|
| 106 |
A *-NAME is a symbol. A TAG-ID is either a symbol or a number. A MACRO-FUNCTION |
| 107 |
is a function that provides us with the expansion for that local macro or symbol |
| 108 |
macro. BOUND-P is true when the variable has been bound by an enclosing form, |
| 109 |
while it is NIL if the variable-record corresponds just to a special |
| 110 |
declaration. SI:FUNCTION-BOUNDARY and SI:UNWIND-PROTECT-BOUNDARY are only used |
| 111 |
by the C compiler and they denote function and unwind-protect boundaries. Note |
| 112 |
that compared with the bytecodes compiler, these records contain an additional |
| 113 |
variable, block, tag or function object at the end.") |
| 114 |
|
| 115 |
(defvar *cmp-env-root* |
| 116 |
(cons nil (list (list '#:no-macro 'si:macro (constantly nil)))) |
| 117 |
"This is the common environment shared by all toplevel forms. It can |
| 118 |
only be altered by DECLAIM forms and it is used to initialize the |
| 119 |
value of *CMP-ENV*.") |
| 120 |
|
| 121 |
;;; --cmpmain.lsp-- |
| 122 |
;;; |
| 123 |
;;; Do we debug the compiler? Then we need files not to be deleted. |
| 124 |
|
| 125 |
(defvar *debug-compiler* nil) |
| 126 |
(defvar *delete-files* t) |
| 127 |
(defvar *files-to-be-deleted* '()) |
| 128 |
|
| 129 |
(defvar *user-ld-flags* '() |
| 130 |
"DEPRECATED Flags and options to be passed to the linker when building FASL, |
| 131 |
shared libraries and standalone programs. It is not required to surround values |
| 132 |
with quotes or use slashes before special characters.") |
| 133 |
|
| 134 |
(defvar *user-linker-flags* '() |
| 135 |
"Command line flags for additional options (e.g. \"-Wl,foo\" flags) to |
| 136 |
be passed to the linker when building FASL, shared libraries and |
| 137 |
standalone programs. It is not required to surround values with quotes |
| 138 |
or use slashes before special characters.") |
| 139 |
|
| 140 |
(defvar *user-linker-libs* '() |
| 141 |
"Command line flags for additional libraries (e.g. \"-lfoo\" flags) to |
| 142 |
be passed to the linker when building FASL, shared libraries and |
| 143 |
standalone programs. It is not required to surround values with quotes |
| 144 |
or use slashes before special characters.") |
| 145 |
|
| 146 |
(defvar *user-cc-flags* '() |
| 147 |
"Flags and options to be passed to the C compiler when building FASL, shared libraries |
| 148 |
and standalone programs. It is not required to surround values with quotes or use |
| 149 |
slashes before special characters.") |
| 150 |
|
| 151 |
(defvar *use-precompiled-headers* nil |
| 152 |
"This variable controls whether the C compiler uses precompiled header files.") |
| 153 |
(defvar *precompiled-header-flags* nil) |
| 154 |
(defvar *precompiled-header-cc-config* nil) |
| 155 |
|
| 156 |
;;; |
| 157 |
;;; Compiler program and flags. |
| 158 |
;;; |
| 159 |
|
| 160 |
;;; --cmptop.lsp-- |
| 161 |
;;; |
| 162 |
(defvar *do-type-propagation* t |
| 163 |
"Flag for switching on the type propagation phase. Use with care, experimental.") |
| 164 |
|
| 165 |
(defvar *compiler-phase* nil) |
| 166 |
|
| 167 |
(defvar *volatile*) |
| 168 |
(defvar *setjmps* 0) |
| 169 |
|
| 170 |
(defvar *compile-toplevel* T |
| 171 |
"Holds NIL or T depending on whether we are compiling a toplevel form.") |
| 172 |
|
| 173 |
(defvar *clines-string-list* '() |
| 174 |
"List of strings containing C/C++ statements which are directly inserted |
| 175 |
in the translated C/C++ file. Notice that it is unspecified where these |
| 176 |
lines are inserted, but the order is preserved") |
| 177 |
|
| 178 |
(defvar *compile-time-too* nil) |
| 179 |
(defvar *not-compile-time* nil) |
| 180 |
|
| 181 |
;;; Determines whether the object may be released after the initialization |
| 182 |
(defvar *permanent-data* nil) |
| 183 |
(defvar *referenced-objects* nil) ; holds { vv-record }* |
| 184 |
|
| 185 |
(defvar *load-objects* nil) ; hash with association object -> vv-location |
| 186 |
(defvar *load-time-values* nil) ; holds { ( vv-index form ) }*, |
| 187 |
;;; where each vv-index should be given an object before |
| 188 |
;;; defining the current function during loading process. |
| 189 |
|
| 190 |
(defvar si:*compiler-constants* nil) ; a vector with all constants only used |
| 191 |
; in COMPILE |
| 192 |
|
| 193 |
(defvar *global-vars* nil) ; variables declared special |
| 194 |
(defvar *global-funs* nil) ; holds { fun }* |
| 195 |
(defvar *use-c-global* nil) ; honor si::c-global declaration |
| 196 |
(defvar *top-level-forms* nil) ; holds { top-level-form }* |
| 197 |
(defvar *make-forms* nil) ; holds { top-level-form }* |
| 198 |
|
| 199 |
(defvar *objects-being-created* nil) ; helps detecting circular references |
| 200 |
(defvar *objects-init-deferred* nil) ; helps avoiding circularity |
| 201 |
|
| 202 |
;;; |
| 203 |
;;; top-level-form: |
| 204 |
;;; ( 'DEFUN' fun-name cfun lambda-expr doc-vv sp ) |
| 205 |
;;; | ( 'DEFMACRO' macro-name cfun lambda-expr doc-vv sp ) |
| 206 |
;;; | ( 'ORDINARY' expr ) |
| 207 |
;;; | ( 'DECLARE' var-name-vv ) |
| 208 |
;;; | ( 'DEFVAR' var-name-vv expr doc-vv ) |
| 209 |
;;; | ( 'CLINES' string* ) |
| 210 |
;;; | ( 'LOAD-TIME-VALUE' vv ) |
| 211 |
|
| 212 |
(defvar *self-destructing-fasl* '() |
| 213 |
"A value T means that, when a FASL module is being unloaded (for |
| 214 |
instance during garbage collection), the associated file will be |
| 215 |
deleted. We need this for #'COMPILE because windows DLLs cannot |
| 216 |
be deleted if they have been opened with LoadLibrary.") |
| 217 |
|
| 218 |
(defvar *undefined-vars* nil) |
| 219 |
|
| 220 |
;;; Only these flags are set by the user. |
| 221 |
;;; If (safe-compile) is ON, some kind of run-time checks are not |
| 222 |
;;; included in the compiled code. The default value is OFF. |
| 223 |
|
| 224 |
(defvar +init-env-form+ |
| 225 |
'((*gensym-counter* 0) |
| 226 |
(*compiler-in-use* t) |
| 227 |
(*compiler-phase* 't1) |
| 228 |
(*callbacks* nil) |
| 229 |
(*functions* nil) |
| 230 |
(*cmp-env-root* (copy-tree *cmp-env-root*)) |
| 231 |
(*cmp-env* nil) |
| 232 |
(*load-objects* (make-hash-table :size 128 :test #'equal)) |
| 233 |
(*make-forms* nil) |
| 234 |
(*referenced-objects* (make-array 256 :adjustable t :fill-pointer 0)) |
| 235 |
(*global-vars* nil) |
| 236 |
(*global-funs* nil) |
| 237 |
(*undefined-vars* nil) |
| 238 |
(*top-level-forms* nil) |
| 239 |
(*compile-time-too* nil) |
| 240 |
(*clines-string-list* '()) |
| 241 |
(si::*defun-inline-hook* 'maybe-install-inline-function) |
| 242 |
(*machine* (or *machine* *default-machine*)))) |
| 243 |
|