Statistics
| Branch: | Revision:

root / tcg / sparc / tcg-target.h @ 65850a02

History | View | Annotate | Download (4.1 kB)

1 8289b279 blueswir1
/*
2 8289b279 blueswir1
 * Tiny Code Generator for QEMU
3 8289b279 blueswir1
 *
4 8289b279 blueswir1
 * Copyright (c) 2008 Fabrice Bellard
5 8289b279 blueswir1
 *
6 8289b279 blueswir1
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 8289b279 blueswir1
 * of this software and associated documentation files (the "Software"), to deal
8 8289b279 blueswir1
 * in the Software without restriction, including without limitation the rights
9 8289b279 blueswir1
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 8289b279 blueswir1
 * copies of the Software, and to permit persons to whom the Software is
11 8289b279 blueswir1
 * furnished to do so, subject to the following conditions:
12 8289b279 blueswir1
 *
13 8289b279 blueswir1
 * The above copyright notice and this permission notice shall be included in
14 8289b279 blueswir1
 * all copies or substantial portions of the Software.
15 8289b279 blueswir1
 *
16 8289b279 blueswir1
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 8289b279 blueswir1
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 8289b279 blueswir1
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 8289b279 blueswir1
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 8289b279 blueswir1
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 8289b279 blueswir1
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 8289b279 blueswir1
 * THE SOFTWARE.
23 8289b279 blueswir1
 */
24 8289b279 blueswir1
#define TCG_TARGET_SPARC 1
25 8289b279 blueswir1
26 8289b279 blueswir1
#if defined(__sparc_v9__) && !defined(__sparc_v8plus__)
27 8289b279 blueswir1
#define TCG_TARGET_REG_BITS 64
28 8289b279 blueswir1
#else
29 8289b279 blueswir1
#define TCG_TARGET_REG_BITS 32
30 8289b279 blueswir1
#endif
31 8289b279 blueswir1
32 8289b279 blueswir1
#define TCG_TARGET_WORDS_BIGENDIAN
33 8289b279 blueswir1
34 8289b279 blueswir1
#define TCG_TARGET_NB_REGS 32
35 8289b279 blueswir1
36 8289b279 blueswir1
enum {
37 8289b279 blueswir1
    TCG_REG_G0 = 0,
38 8289b279 blueswir1
    TCG_REG_G1,
39 8289b279 blueswir1
    TCG_REG_G2,
40 8289b279 blueswir1
    TCG_REG_G3,
41 8289b279 blueswir1
    TCG_REG_G4,
42 8289b279 blueswir1
    TCG_REG_G5,
43 8289b279 blueswir1
    TCG_REG_G6,
44 8289b279 blueswir1
    TCG_REG_G7,
45 8289b279 blueswir1
    TCG_REG_O0,
46 8289b279 blueswir1
    TCG_REG_O1,
47 8289b279 blueswir1
    TCG_REG_O2,
48 8289b279 blueswir1
    TCG_REG_O3,
49 8289b279 blueswir1
    TCG_REG_O4,
50 8289b279 blueswir1
    TCG_REG_O5,
51 8289b279 blueswir1
    TCG_REG_O6,
52 8289b279 blueswir1
    TCG_REG_O7,
53 8289b279 blueswir1
    TCG_REG_L0,
54 8289b279 blueswir1
    TCG_REG_L1,
55 8289b279 blueswir1
    TCG_REG_L2,
56 8289b279 blueswir1
    TCG_REG_L3,
57 8289b279 blueswir1
    TCG_REG_L4,
58 8289b279 blueswir1
    TCG_REG_L5,
59 8289b279 blueswir1
    TCG_REG_L6,
60 8289b279 blueswir1
    TCG_REG_L7,
61 8289b279 blueswir1
    TCG_REG_I0,
62 8289b279 blueswir1
    TCG_REG_I1,
63 8289b279 blueswir1
    TCG_REG_I2,
64 8289b279 blueswir1
    TCG_REG_I3,
65 8289b279 blueswir1
    TCG_REG_I4,
66 8289b279 blueswir1
    TCG_REG_I5,
67 8289b279 blueswir1
    TCG_REG_I6,
68 8289b279 blueswir1
    TCG_REG_I7,
69 8289b279 blueswir1
};
70 8289b279 blueswir1
71 8289b279 blueswir1
#define TCG_CT_CONST_S11 0x100
72 8289b279 blueswir1
#define TCG_CT_CONST_S13 0x200
73 8289b279 blueswir1
74 8289b279 blueswir1
/* used for function call generation */
75 e97b640d blueswir1
#define TCG_REG_CALL_STACK TCG_REG_I6
76 64e3257c blueswir1
#ifdef __arch64__
77 e97b640d blueswir1
// Reserve space for AREG0
78 f843e528 blueswir1
#define TCG_TARGET_STACK_MINFRAME (176 + 4 * (int)sizeof(long) + \
79 f843e528 blueswir1
                                   TCG_STATIC_CALL_ARGS_SIZE)
80 f843e528 blueswir1
#define TCG_TARGET_CALL_STACK_OFFSET (2047 - 16)
81 77fcd093 blueswir1
#define TCG_TARGET_STACK_ALIGN 16
82 b3db8758 blueswir1
#else
83 baf8cc52 blueswir1
// AREG0 + one word for alignment
84 f843e528 blueswir1
#define TCG_TARGET_STACK_MINFRAME (92 + (2 + 1) * (int)sizeof(long) + \
85 f843e528 blueswir1
                                   TCG_STATIC_CALL_ARGS_SIZE)
86 e97b640d blueswir1
#define TCG_TARGET_CALL_STACK_OFFSET TCG_TARGET_STACK_MINFRAME
87 77fcd093 blueswir1
#define TCG_TARGET_STACK_ALIGN 8
88 b3db8758 blueswir1
#endif
89 b3db8758 blueswir1
90 8289b279 blueswir1
/* optional instructions */
91 583d1215 Richard Henderson
#define TCG_TARGET_HAS_div_i32
92 36828256 Richard Henderson
// #define TCG_TARGET_HAS_rot_i32
93 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext8s_i32
94 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext16s_i32
95 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext8u_i32
96 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext16u_i32
97 36828256 Richard Henderson
// #define TCG_TARGET_HAS_bswap16_i32
98 36828256 Richard Henderson
// #define TCG_TARGET_HAS_bswap32_i32
99 4b5a85c1 Richard Henderson
#define TCG_TARGET_HAS_neg_i32
100 be6551b1 Richard Henderson
#define TCG_TARGET_HAS_not_i32
101 dc69960d Richard Henderson
#define TCG_TARGET_HAS_andc_i32
102 18c8f7a3 Richard Henderson
#define TCG_TARGET_HAS_orc_i32
103 4b5a85c1 Richard Henderson
104 cc6dfecf Richard Henderson
#if TCG_TARGET_REG_BITS == 64
105 36828256 Richard Henderson
#define TCG_TARGET_HAS_div_i64
106 36828256 Richard Henderson
// #define TCG_TARGET_HAS_rot_i64
107 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext8s_i64
108 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext16s_i64
109 cc6dfecf Richard Henderson
#define TCG_TARGET_HAS_ext32s_i64
110 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext8u_i64
111 36828256 Richard Henderson
// #define TCG_TARGET_HAS_ext16u_i64
112 cc6dfecf Richard Henderson
#define TCG_TARGET_HAS_ext32u_i64
113 36828256 Richard Henderson
// #define TCG_TARGET_HAS_bswap16_i64
114 36828256 Richard Henderson
// #define TCG_TARGET_HAS_bswap32_i64
115 36828256 Richard Henderson
// #define TCG_TARGET_HAS_bswap64_i64
116 4b5a85c1 Richard Henderson
#define TCG_TARGET_HAS_neg_i64
117 be6551b1 Richard Henderson
#define TCG_TARGET_HAS_not_i64
118 dc69960d Richard Henderson
#define TCG_TARGET_HAS_andc_i64
119 18c8f7a3 Richard Henderson
#define TCG_TARGET_HAS_orc_i64
120 cc6dfecf Richard Henderson
#endif
121 cc6dfecf Richard Henderson
122 e97b640d blueswir1
/* Note: must be synced with dyngen-exec.h and Makefile.target */
123 dfe5fff3 Juan Quintela
#ifdef CONFIG_SOLARIS
124 8289b279 blueswir1
#define TCG_AREG0 TCG_REG_G2
125 8289b279 blueswir1
#define TCG_AREG1 TCG_REG_G3
126 8289b279 blueswir1
#define TCG_AREG2 TCG_REG_G4
127 8289b279 blueswir1
#elif defined(__sparc_v9__)
128 e97b640d blueswir1
#define TCG_AREG0 TCG_REG_G5
129 e97b640d blueswir1
#define TCG_AREG1 TCG_REG_G6
130 e97b640d blueswir1
#define TCG_AREG2 TCG_REG_G7
131 8289b279 blueswir1
#else
132 8289b279 blueswir1
#define TCG_AREG0 TCG_REG_G6
133 8289b279 blueswir1
#define TCG_AREG1 TCG_REG_G1
134 8289b279 blueswir1
#define TCG_AREG2 TCG_REG_G2
135 8289b279 blueswir1
#endif
136 8289b279 blueswir1
137 8289b279 blueswir1
static inline void flush_icache_range(unsigned long start, unsigned long stop)
138 8289b279 blueswir1
{
139 8289b279 blueswir1
    unsigned long p;
140 8289b279 blueswir1
141 8289b279 blueswir1
    p = start & ~(8UL - 1UL);
142 8289b279 blueswir1
    stop = (stop + (8UL - 1UL)) & ~(8UL - 1UL);
143 8289b279 blueswir1
144 8289b279 blueswir1
    for (; p < stop; p += 8)
145 8289b279 blueswir1
        __asm__ __volatile__("flush\t%0" : : "r" (p));
146 8289b279 blueswir1
}