source: release/1.7/source/lisp-kernel/m4macros.m4 @ 15267

Last change on this file since 15267 was 14880, checked in by rme, 8 years ago

Merge trunk changes.

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