summaryrefslogtreecommitdiff
path: root/include/PR/asm.h
blob: d5058f5c1b74909173b94f62a1412991090cda31 (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
#ifndef PR_ASM_H
#define PR_ASM_H

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

#ifndef _LANGUAGE_C

#define LEAF(x)                 \
    .balign 4                  ;\
    .globl x                   ;\
    .type x, @function         ;\
    x:                         ;\
        .ent x, 0              ;\
        .frame $sp, 0, $ra

#define XLEAF(x)                \
    .balign 4                  ;\
    .globl x                   ;\
    .type x, @function         ;\
    x:                         ;\
        .aent x, 0

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

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

#define END(x)                  \
    .size x, . - x             ;\
    .end x

#define IMPORT(x, size)         \
    .extern x, size

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

#define DATA(x)                 \
    .balign 4                  ;\
    .globl x                   ;\
    .type x, @object           ;\
    x:

#define ENDDATA(x)              \
    .size x, . - x

#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