source: trunk/source/lisp-kernel/m4macros.m4 @ 15111

Last change on this file since 15111 was 15111, checked in by gb, 8 years ago

ARM-specific changes, mostly.

When running lisp code (in almost all cases), keep the constant 0.0d0
in the d7 register (and therefore 0.0s0 in s14 and s15). We use d7 as
a vector header when saving non-volatile FPRs on the stack; we
actually only modify s14, so we now restore s14 after it's been used
this way. The value used in the header in lisp and kernel code is
loaded from PC-relative memory, which means that we no longer use
fmsr/fmdrr or similar instructions.

When starting a lisp thread or entering one via a callback, initialize
d7.

This all basically means that we can get 0.0[d|s]0 into an FPR (or
exploit the fact that it's already in one) a bit easier, and that's
generally a good thing. It's an ABI change, which means that the
FASL and image versions (for the ARM port only) changed; new binaries
are included in this commit.

The kernel changes to support the use of d7 are mostly pretty obvious.
In working on them, I noticed that "local labels" and "macro labels"
were in the same namespace, and we were only avoiding conflicts by
accident. For 10 years or so. (I also noticed that GAS doesn't fully
support PC-relative operands, so did that by hand.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.0 KB
Line 
1changecom(`/*',`*/')
2
3
4
5/*   Copyright (C) 1994-2001 Digitool, Inc  */
6/*   Copyright (c) 2009 Clozure Associates */
7/*   This file is part of Clozure CL.    */
8
9/*   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public  */
10/*   License , known as the LLGPL and distributed with Clozure CL as the  */
11/*   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,  */
12/*   which is distributed with Clozure CL as the file "LGPL".  Where these  */
13/*   conflict, the preamble takes precedence.    */
14
15/*   Clozure CL is referenced in the preamble as the "LIBRARY."  */
16
17/*   The LLGPL is also available online at  */
18/*   http://opensource.franz.com/preamble.html  */
19
20
21
22/*  BSD debugging information (line numbers, etc) is a little different  */
23/*  from ELF/SVr4 debugging information.  There are probably lots more  */
24/*  differences, but this helps us to distinguish between what LinuxPPC  */
25/*  (ELF/SVr4) wants and what Darwin(BSD) wants.  */
26
27
28define(`BSDstabs',`1')
29define(`ELFstabs',`2')
30define(`COFFstabs',`3')
31undefine(`EABI')
32undefine(`POWEROPENABI')
33undefine(`rTOC')
34
35
36ifdef(`DARWIN',`define(`SYSstabs',`BSDstabs')
37                define(`DarwinAssembler',`')
38                define(`CNamesNeedUnderscores',`')
39                define(`LocalLabelPrefix',`L')
40                define(`MacroLabelPrefix',`L__')
41                define(`StartTextLabel',`Ltext0')
42                define(`EndTextLabel',`Letext')
43                ifdef(`PPC',`
44                define(`POWEROPENABI',`')')
45                ifdef(`X86',`
46                define(`SYSCALL_SETS_CARRY_ON_ERROR',`')
47                define(`SSE2_MATH_LIB',`')')
48')
49
50ifdef(`LINUX',`define(`SYSstabs',`ELFstabs')
51               define(`HaveWeakSymbols',`')
52               define(`LocalLabelPrefix',`.L')
53               define(`MacroLabelPrefix',`.L__')
54               define(`StartTextLabel',`.Ltext0')
55               define(`EndTextLabel',`.Letext')
56               ifdef(`PPC64',`
57               define(`POWEROPENABI',`')
58               define(`rTOC',`r2')', `
59               define(`EABI',`')')')
60
61ifdef(`FREEBSD',`define(`SYSstabs',`ELFstabs')
62               define(`HaveWeakSymbols',`')
63               define(`LocalLabelPrefix',`.L')
64               define(`MacroLabelPrefix',`.L__')
65               define(`StartTextLabel',`.Ltext0')
66               define(`EndTextLabel',`.Letext')'
67                ifdef(`X86',`
68                define(`SYSCALL_SETS_CARRY_ON_ERROR',`')')
69)
70
71ifdef(`SOLARIS',`define(`SYSstabs',`ELFstabs')
72               define(`HaveWeakSymbols',`')
73               define(`LocalLabelPrefix',`.L')
74               define(`MacroLabelPrefix',`.L__')
75               define(`StartTextLabel',`.Ltext0')
76               define(`EndTextLabel',`.Letext')')
77
78ifdef(`WINDOWS',`define(`SYSstabs',`COFFstabs')
79        ifdef(`WIN_32',`define(`CNamesNeedUnderscores',`')')
80               define(`LocalLabelPrefix',`L')
81               define(`MacroLabelPrefix',`L__')
82               define(`StartTextLabel',`Ltext0')
83               define(`EndTextLabel',`Letext')')
84
85
86/*  Names exported to (or imported from) C may need leading underscores.  */
87/*  Still.  After all these years.  Why ?  */
88
89define(`C',`ifdef(`CNamesNeedUnderscores',``_'$1',`$1')')
90
91define(`_linecounter_',0)
92
93define(`_emit_BSD_source_line_stab',`
94ifdef(`X86',`
95# __line__ "__file__" 1',`
96        .stabd 68,0,$1
97')')
98
99
100/*  We don't really do "weak importing" of symbols from a separate  */
101/*  subprims library anymore; if we ever do and the OS supports it,  */
102/*  here's how to say that we want it ...  */
103
104define(`WEAK',`ifdef(`HaveWeakSymbols',`
105        .weak $1
106',`
107        .globl $1
108')')
109
110define(`_emit_ELF_source_line_stab',`
111  define(`_linecounter_',incr(_linecounter_))
112        .stabn 68,0,$1,`.LM'_linecounter_`-'__func_name
113`.LM'_linecounter_:
114')
115
116define(`_emit_COFF_source_line_stab',`
117        _emit_ELF_source_line_stab($1)
118')
119
120
121define(`emit_source_line_stab',`
122        ifelse(eval(SYSstabs),
123             eval(BSDstabs),
124              `_emit_BSD_source_line_stab($1)',
125              eval(SYSstabs),
126              eval(ELFstabs),
127              `_emit_ELF_source_line_stab($1)',
128              `_emit_COFF_source_line_stab($1)')')
129
130
131
132
133
134
135/*  Assemble a reference to the high half of a 32-bit constant,  */
136/*  possibly adjusted for sign-extension of thw low half.  */
137
138
139define(`HA',`ifdef(`DARWIN',`ha16($1)',`$1@ha')')
140
141 
142/*  Likewise for the low half, and for the high half without  */
143/*  concern for sign-extension of the low half.  */
144
145define(`LO',`ifdef(`DARWIN',`lo16($1)',`$1@l')')
146define(`HI',`ifdef(`DARWIN',`hi16($1)',`$1@hi')')
147
148/*  Note that m4 macros that could be expanded in the .text segment  */
149/*  need to advertise the current line number after they have finished  */
150/*  expanding.  That shouldn't be too onerous, if only because there  */
151/*  should not be too many of them.  */
152
153
154define(`N_FUN',36)
155define(`N_SO',100)
156
157/*    I wish that there was a less-dumb way of doing this.  */
158
159define(`pwd0',esyscmd(`/bin/pwd'))
160define(`__pwd__',substr(pwd0,0,decr(len(pwd0)))`/')
161
162/*   _beginfile() -- gets line/file in synch, generates N_SO for file,  */
163/*   starts .text section  */
164
165
166define(`_beginfile',`
167        .stabs "__pwd__",N_SO,0,0,StartTextLabel()
168        .stabs "__file__",N_SO,0,0,StartTextLabel()
169ifdef(`PPC64',`
170ifdef(`DARWIN',`
171        .machine ppc64
172')')
173        .text
174StartTextLabel():
175# __line__ "__file__"
176')
177
178define(`_endfile',`
179        .stabs "",N_SO,0,0,EndTextLabel()
180EndTextLabel():
181# __line__
182')
183
184define(`_startfn',`define(`__func_name',$1)
185# __line__
186        ifelse(eval(SYSstabs),eval(ELFstabs),`
187        .type $1,ifdef(`ARM',%function,@function)
188')
189
190$1:
191ifdef(`WINDOWS',`
192        .def    $1;     .scl    2;      .type   32;     .endef
193',`
194        .stabd 68,0,__line__
195')
196        .stabs "$1:F1",36,0,__line__,$1
197        .set func_start,$1
198# __line__ "__file__" 1 ')
199
200
201
202define(`_exportfn',`
203        .globl $1
204        _startfn($1)
205ifdef(`PPC64',`
206ifdef(`LINUX',`
207        .global `.'$1
208`.'$1:
209')')
210# __line__
211')
212
213
214define(`_endfn',`
215LocalLabelPrefix`'__func_name`999':
216ifdef(`WINDOWS',`
217',`
218        .stabs "",36,0,0,LocalLabelPrefix`'__func_name`999'-__func_name
219        .line __line__
220        ifelse(eval(SYSstabs),eval(ELFstabs),`
221        .size __func_name,LocalLabelPrefix`'__func_name`999'-__func_name
222')
223')
224        undefine(`__func_name')
225')
226
227
228/* _struct(name,start_offset)  */
229/*   This just generates a bunch of assembler equates; m4  */
230/*   doesn't remember much of it ..  */
231
232define(`_struct', `define(`__struct_name',$1)
233 define(`_struct_org_name', _$1_org)
234 define(`_struct_base_name', _$1_base)
235        .set _struct_org_name,$2
236        .set _struct_base_name,_struct_org_name
237 ifelse($3,`',`
238  undefine(`_struct_fixed_size_name')
239  ',`
240  define(`_struct_fixed_size_name', _$1_fixed_size)
241        .set _struct_fixed_size_name,$3
242  ')
243')
244
245define(`_struct_pad',`
246        .set _struct_org_name,_struct_org_name + $1
247')
248 
249define(`_struct_label',`
250        .set __struct_name`.'$1, _struct_org_name
251')
252
253/*  _field(name,size)   */
254define(`_field',`_struct_label($1) _struct_pad($2)')
255
256define(`_halfword', `_field($1, 2)')
257define(`_word', `_field($1, 4)')
258define(`_dword',`_field($1, 8)')
259define(`_node', `_field($1, node_size)')
260
261define(`_ends',`ifdef(`_struct_fixed_size_name',`
262        .set  __struct_name`.size',_struct_fixed_size_name
263        ',`
264        .set  __struct_name`.size', _struct_org_name-_struct_base_name
265        ')
266')
267
268
269/*   Lisp fixed-size objects always have a 1-word header  */
270/*   and are always accessed from a "fulltag_misc"-tagged pointer.  */
271/*   We also want to define STRUCT_NAME.element_count for each  */
272/*   such object.  */
273
274
275define(`_structf',`
276        _struct($1,ifelse($2,`',-misc_bias,$2))
277        _node(header)
278')
279
280define(`_endstructf',`
281        .set __struct_name.`element_count',((_struct_org_name-node_size)-_struct_base_name)/node_size
282        _ends
283')
284
285
286define(`__',`emit_source_line_stab(__line__)
287        $@
288        ')
289
290define(`__local_label_counter__',0)
291define(`__macro_label_counter__',0)
292
293define(`new_local_labels',
294  `define(`__local_label_counter__',incr(__local_label_counter__))')
295
296define(`new_macro_labels',
297  `define(`__macro_label_counter__',incr(__macro_label_counter__))')
298
299define(`_local_label',`LocalLabelPrefix()`'$1')
300define(`_macro_label',`MacroLabelPrefix()`'$1')
301
302define(`local_label',`_local_label($1`'__local_label_counter__)')
303
304define(`macro_label',`_macro_label($1`'__macro_label_counter__)')
305
306
307/* The Darwin assembler doesn't seem to support .ifdef/.ifndef, but  */
308/* does understand .if.    */
309/* Note that using M4's own ifdef is certainly possible, but it's  */
310/* hard to generate source line information when doing so.  */
311
312 
313define(`__ifdef',`ifdef(`$1',`.if 1',`.if 0')')
314define(`__ifndef',`ifdef(`$1',`.if 0',`.if 1')')
315define(`__else',`.else')
316define(`__endif',`.endif')
317define(`__if',`.if $1')
318
319define(`equate_if_defined',`ifdef($1,`
320`$1' = 1
321',`
322`$1' = 0
323')')
324
325equate_if_defined(`DARWIN')
326equate_if_defined(`LINUX')
327equate_if_defined(`FREEBSD')
328equate_if_defined(`SOLARIS')
329equate_if_defined(`WIN_64')
330equate_if_defined(`PPC64')
331equate_if_defined(`X8664')
332equate_if_defined(`WIN_32')
333equate_if_defined(`WINDOWS')
334
335equate_if_defined(`HAVE_TLS')
336
337equate_if_defined(`TCR_IN_GPR')
338
339/* Well, so much for that. Maybe this will go away soon ? */
340equate_if_defined(`WIN32_ES_HACK')
341equate_if_defined(`SYSCALL_SETS_CARRY_ON_ERROR')
342
343
344
345/* We use (more-or-less) a PowerOpen C frame, except on LinuxPPC32  */
346
347define(`USE_POWEROPEN_C_FRAME',`')
348undefine(`USE_EABI_C_FRAME')
349
350ifdef(`LINUX',`
351ifdef(`PPC64',`',`
352define(`USE_EABI_C_FRAME',`')
353undefine(`USE_POWEROPEN_C_FRAME')
354')')
355
356
357
358
Note: See TracBrowser for help on using the repository browser.