source: branches/arm/lisp-kernel/m4macros.m4 @ 13669

Last change on this file since 13669 was 13669, checked in by gb, 11 years ago

Have to say '%function' vice '@function', since '@' is
"comment-to-end-of-line" in ARM as.

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