File: asm-base.h

package info (click to toggle)
smlnj-runtime 110.44-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,968 kB
  • ctags: 5,368
  • sloc: ansic: 24,674; asm: 4,195; makefile: 1,353; sh: 91
file content (176 lines) | stat: -rw-r--r-- 4,420 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* asm-base.h
 *
 * COPYRIGHT (c) 1992 AT&T Bell Laboratories
 *
 * Common definitions for assembly files in the SML/NJ system.
 */

#ifndef _ASM_BASE_
#define _ASM_BASE_

#ifndef _ML_BASE_
#include "ml-base.h"
#endif

/* bool_t values for assembly code */
#define FALSE	0
#define TRUE	1

#if (!defined(GLOBALS_HAVE_UNDERSCORE)) && (defined(OPSYS_SUNOS) || (defined(OPSYS_FREEBSD) && !defined(__ELF__)) || (defined(OPSYS_NETBSD) && !defined(__ELF__)) || defined(OPSYS_NEXTSTEP) || defined(OPSYS_WIN32) || defined(OPSYS_DARWIN) || defined(OPSYS_CYGWIN))
#  define GLOBALS_HAVE_UNDERSCORE
#endif

/* we should probably consider factoring this out into ml-unixdep.h -- JHR */
#ifdef GLOBALS_HAVE_UNDERSCORE
#  define CSYM(ID)	CONCAT(_,ID)
#else
#  define CSYM(ID)	ID
#endif

#if defined(HOST_SPARC)
#  if defined(OPSYS_SUNOS)
#    include <machine/asm_linkage.h>
#    include <machine/trap.h>
#    undef ENTRY
#  elif defined(OPSYS_SOLARIS)
#    define _ASM
#    include <sys/stack.h>
#    include <sys/trap.h>
#  endif
#  define CGLOBAL(ID)	.global	CSYM(ID)
#  define LABEL(ID)	ID:
#  define ALIGN4        .align 4
#  define WORD(W)       .word W
#  if defined(OPSYS_NEXTSTEP)
#    define TEXT          .text
#    define DATA          .data
#  else
#    define TEXT          .seg "text"
#    define DATA          .seg "data"
#  endif
#  define BEGIN_PROC(P)
#  define END_PROC(P)

#elif defined(HOST_MIPS)
#  if defined(OPSYS_MACH)
#    include <mips/regdef.h>
#  elif defined(OPSYS_IRIX5)
#    define _MIPS_SIM	1	/* IRIX 5.x needs this in <regdef.h> */
#    include <regdef.h>
#  else
#    include <regdef.h>
#  endif
#  define CGLOBAL(ID)	.globl	CSYM(ID)
#  define LABEL(ID)	ID:
#  define ALIGN4        .align 2
#  define WORD(W)       .word W
#  define TEXT          .text
#  define DATA          .data
#  define BEGIN_PROC(P)	.ent CSYM(P)
#  define END_PROC(P)	.end CSYM(P)

#elif defined(HOST_ALPHA32)
#  if defined(OPSYS_LINUX)
#    include <alpha/regdef.h>
#  else
#    include <regdef.h>
#  endif
#  define CGLOBAL(ID)	.globl  CSYM(ID)
#  define LABEL(ID)	ID:
#  define ALIGN4	.align 2
#  define WORD(W)	.word W
#  define TEXT		.text
#  define DATA		.data
#  define BEGIN_PROC(P)	.align 3; .ent CSYM(P)
#  define END_PROC(P)	.end CSYM(P)

#elif defined(HOST_HPPA)
#  define CGLOBAL(ID)    .export ID,DATA
#  define LABEL(ID)     .label ID
#  define ALIGN4        .align 8
#  define BEGIN_PROC(P)
#  define END_PROC(P)
#  define __SC__	!

#elif (defined(HOST_RS6000) || defined(HOST_PPC))
#  if defined(OPSYS_AIX)
#    define CFUNSYM(ID)	CONCAT(.,ID)
#    define USE_TOC
#   if defined(HOST_RS6000)
#    define GLOBAL(ID)	.globl CSYM(ID)
#   endif
#    define CGLOBAL(ID)	.globl CSYM(ID)
#    define TEXT	.csect [PR]
#    define DATA	.csect [RW]
#    define RO_DATA	.csect [RO]
#    define ALIGN4	.align 2
#    define ALIGN8	.align 3
#    define DOUBLE(V)	.double V
#    define LABEL(ID)   ID:

#  elif (defined(OPSYS_LINUX) && defined(TARGET_PPC))
#    define CFUNSYM(ID)	ID
#    define CGLOBAL(ID)	.globl CSYM(ID)
#    define TEXT	.section ".text"
#    define DATA	.section ".data"
#    define RO_DATA	.section ".rodata"
#    define ALIGN4	.align 2
#    define ALIGN8	.align 3
#    define DOUBLE(V)	.double V
#    define LABEL(ID)	ID:

#  elif (defined(OPSYS_DARWIN) && defined(TARGET_PPC))
#    define CFUNSYM(ID) CSYM(ID)
#    define CGLOBAL(ID)  .globl  CSYM(ID)
#    define TEXT        .text
#    define DATA        .data
#    define RO_DATA     .data
#    define ALIGN4      .align 2
#    define ALIGN8	.align 3
#    define DOUBLE(V)	.double V
#    define LABEL(ID)	ID:
#    define __SC__      @
#  endif

#  define CENTRY(ID)		\
    .globl CFUNSYM(ID) __SC__	\
    LABEL(CFUNSYM(ID))

#elif defined(HOST_X86)
#  if defined(OPSYS_WIN32)
#    include "x86-masm.h"
#    define WORD(W)     WORD32(W)
#  else
#    define CGLOBAL(ID)	  GLOBAL CSYM(ID)
#    define LABEL(ID)	  ID:
#    define IMMED(ID)	  $ID
#    define ALIGN4        .align 2
#    define WORD(W)       .word W
#    define TEXT          .text
#    define DATA          .data
#    define BEGIN_PROC(P) .ent P
#    define END_PROC(P)	  .end P

#  endif

#else

#  error missing asm definitions

#endif

#ifndef __SC__
#  define __SC__ 	;
#endif

#define ENTRY(ID)				\
    CGLOBAL(ID) __SC__				\
    LABEL(CSYM(ID))

#define ML_CODE_HDR(name)			\
	    CGLOBAL(name) __SC__		\
	    ALIGN4 __SC__			\
    LABEL(CSYM(name))

#endif /* !_ASM_BASE_ */