summaryrefslogtreecommitdiff
path: root/include/ultra64/asm.h
blob: d887673fa6743ec0996903a113d17dd3069ae195 (plain)
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
#ifndef ASM_H
#define ASM_H

#ifdef __sgi
#define _MIPS_ISA_MIPS1 1
#define _MIPS_ISA_MIPS2 2
#define _MIPS_ISA_MIPS3 3
#define _MIPS_ISA_MIPS4 4

#define _MIPS_SIM_ABI32     1   /* MIPS MSIG calling convention */
#define _MIPS_SIM_NABI32    2   /* MIPS new 32-bit abi */
                                /* NABI32 is 64bit calling convention but 32bit type sizes) */
#define _MIPS_SIM_ABI64     3   /* MIPS 64 calling convention */
#endif

#ifndef _LANGUAGE_C

#ifdef __GNUC__
#define TYPE(x, t) .type x, @t
#define SIZE(x)    .size x, . - x
#else
#define TYPE(x, t)
#define SIZE(x)
#endif

#define LEAF(x)                 \
    .align 2                   ;\
    .globl x                   ;\
    TYPE(x, function)          ;\
    .ent x, 0                  ;\
    x:                         ;\
        .frame sp, 0, ra

#define XLEAF(x)                \
    .align 2                   ;\
    .globl x                   ;\
    TYPE(x, function)          ;\
    .aent x, 0                 ;\
    x:

#define NESTED(x, fsize, ra)    \
    .globl x                   ;\
    .ent x, 0                  ;\
    x:                         ;\
        .frame sp, fsize, ra

#define XNESTED(x)              \
    .globl x                   ;\
    .aent x, 0                 ;\
    x:

#define END(x)                  \
    SIZE(x)                    ;\
    .end x

#define EXPORT(x)               \
    .globl x                   ;\
    x:

#ifdef __sgi
#define IMPORT(sym, size)       \
    .extern sym, size
#else
#define IMPORT(sym, size)
#endif

#define DATA(x)                 \
    .align 2                   ;\
    .globl x                   ;\
    TYPE(x, object)            ;\
    x:

#define ENDDATA(x)              \
    SIZE(x)

#define MFC0(dst, src) \
    .set noreorder; mfc0 dst, src; .set reorder
#define MTC0(dst, src) \
    .set noreorder; mtc0 dst, src; .set reorder

#define CACHE(op, base)  \
    .set noreorder; cache op, base; .set reorder

#define CFC1(dst, src) \
    .set noreorder; cfc1 dst, src; .set reorder
#define CTC1(src, dst) \
    .set noreorder; ctc1 src, dst; .set reorder

#define NOP \
    .set noreorder; nop; .set reorder

#define TLBWI \
    .set noreorder; tlbwi; .set reorder

#define TLBR \
    .set noreorder; tlbr; .set reorder

#define TLBP \
    .set noreorder; tlbp; .set reorder

#ifndef __GNUC__
#define ABS(x, y)   \
    .globl  x;      \
    x = y
#else
#define ABS(x, y)   \
    .globl x;       \
    .set x, y
#endif

#endif

/**
 *  Stack Alignment
 */
#if   (_MIPS_SIM == _ABIO32)
#define NARGSAVE 4      /* space for 4 args must be allocated */
#define ALSZ    (8-1)
#define ALMASK ~(8-1)
#elif (_MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64)
#define NARGSAVE 0      /* no caller responsibilities */
#define ALSZ    (16-1)
#define ALMASK ~(16-1)
#endif

#define FRAMESZ(size) (((size) + ALSZ) & ALMASK)

/**
 *  Register Size
 */
#if   (_MIPS_ISA == _MIPS_ISA_MIPS1 || _MIPS_ISA == _MIPS_ISA_MIPS2)
#define SZREG 4
#elif (_MIPS_ISA == _MIPS_ISA_MIPS3 || _MIPS_ISA == _MIPS_ISA_MIPS4)
#define SZREG 8
#endif

#endif