Statistics
| Branch: | Revision:

root / tcg / ppc / tcg-target.h @ 0a878c47

History | View | Annotate | Download (2.8 kB)

1 2662e13f bellard
/*
2 2662e13f bellard
 * Tiny Code Generator for QEMU
3 2662e13f bellard
 *
4 2662e13f bellard
 * Copyright (c) 2008 Fabrice Bellard
5 2662e13f bellard
 *
6 2662e13f bellard
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 2662e13f bellard
 * of this software and associated documentation files (the "Software"), to deal
8 2662e13f bellard
 * in the Software without restriction, including without limitation the rights
9 2662e13f bellard
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 2662e13f bellard
 * copies of the Software, and to permit persons to whom the Software is
11 2662e13f bellard
 * furnished to do so, subject to the following conditions:
12 2662e13f bellard
 *
13 2662e13f bellard
 * The above copyright notice and this permission notice shall be included in
14 2662e13f bellard
 * all copies or substantial portions of the Software.
15 2662e13f bellard
 *
16 2662e13f bellard
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 2662e13f bellard
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 2662e13f bellard
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 2662e13f bellard
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 2662e13f bellard
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 2662e13f bellard
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 2662e13f bellard
 * THE SOFTWARE.
23 2662e13f bellard
 */
24 2662e13f bellard
#define TCG_TARGET_PPC 1
25 2662e13f bellard
26 2662e13f bellard
#define TCG_TARGET_REG_BITS 32
27 2662e13f bellard
#define TCG_TARGET_WORDS_BIGENDIAN
28 2662e13f bellard
#define TCG_TARGET_NB_REGS 32
29 2662e13f bellard
30 2662e13f bellard
enum {
31 2662e13f bellard
    TCG_REG_R0 = 0,
32 2662e13f bellard
    TCG_REG_R1,
33 2662e13f bellard
    TCG_REG_R2,
34 2662e13f bellard
    TCG_REG_R3,
35 2662e13f bellard
    TCG_REG_R4,
36 2662e13f bellard
    TCG_REG_R5,
37 2662e13f bellard
    TCG_REG_R6,
38 2662e13f bellard
    TCG_REG_R7,
39 2662e13f bellard
    TCG_REG_R8,
40 2662e13f bellard
    TCG_REG_R9,
41 2662e13f bellard
    TCG_REG_R10,
42 2662e13f bellard
    TCG_REG_R11,
43 2662e13f bellard
    TCG_REG_R12,
44 2662e13f bellard
    TCG_REG_R13,
45 2662e13f bellard
    TCG_REG_R14,
46 2662e13f bellard
    TCG_REG_R15,
47 2662e13f bellard
    TCG_REG_R16,
48 2662e13f bellard
    TCG_REG_R17,
49 2662e13f bellard
    TCG_REG_R18,
50 2662e13f bellard
    TCG_REG_R19,
51 2662e13f bellard
    TCG_REG_R20,
52 2662e13f bellard
    TCG_REG_R21,
53 2662e13f bellard
    TCG_REG_R22,
54 2662e13f bellard
    TCG_REG_R23,
55 2662e13f bellard
    TCG_REG_R24,
56 2662e13f bellard
    TCG_REG_R25,
57 2662e13f bellard
    TCG_REG_R26,
58 2662e13f bellard
    TCG_REG_R27,
59 2662e13f bellard
    TCG_REG_R28,
60 2662e13f bellard
    TCG_REG_R29,
61 2662e13f bellard
    TCG_REG_R30,
62 2662e13f bellard
    TCG_REG_R31
63 2662e13f bellard
};
64 2662e13f bellard
65 2662e13f bellard
/* used for function call generation */
66 2662e13f bellard
#define TCG_REG_CALL_STACK TCG_REG_R1
67 2662e13f bellard
#define TCG_TARGET_STACK_ALIGN 16
68 2662e13f bellard
#define TCG_TARGET_CALL_STACK_OFFSET 8
69 2662e13f bellard
#define TCG_TARGET_CALL_ALIGN_ARGS 1
70 2662e13f bellard
71 2662e13f bellard
/* optional instructions */
72 2662e13f bellard
#define TCG_TARGET_HAS_neg_i32
73 2662e13f bellard
74 2662e13f bellard
#define TCG_AREG0 TCG_REG_R27
75 2662e13f bellard
#define TCG_AREG1 TCG_REG_R24
76 2662e13f bellard
#define TCG_AREG2 TCG_REG_R25
77 2662e13f bellard
#define TCG_AREG3 TCG_REG_R26
78 2662e13f bellard
79 2662e13f bellard
/* taken directly from tcg-dyngen.c */
80 2662e13f bellard
#define MIN_CACHE_LINE_SIZE 8 /* conservative value */
81 2662e13f bellard
82 2662e13f bellard
static inline void flush_icache_range(unsigned long start, unsigned long stop)
83 2662e13f bellard
{
84 2662e13f bellard
    unsigned long p;
85 2662e13f bellard
86 2662e13f bellard
    start &= ~(MIN_CACHE_LINE_SIZE - 1);
87 2662e13f bellard
    stop = (stop + MIN_CACHE_LINE_SIZE - 1) & ~(MIN_CACHE_LINE_SIZE - 1);
88 2662e13f bellard
89 2662e13f bellard
    for (p = start; p < stop; p += MIN_CACHE_LINE_SIZE) {
90 2662e13f bellard
        asm volatile ("dcbst 0,%0" : : "r"(p) : "memory");
91 2662e13f bellard
    }
92 2662e13f bellard
    asm volatile ("sync" : : : "memory");
93 2662e13f bellard
    for (p = start; p < stop; p += MIN_CACHE_LINE_SIZE) {
94 2662e13f bellard
        asm volatile ("icbi 0,%0" : : "r"(p) : "memory");
95 2662e13f bellard
    }
96 2662e13f bellard
    asm volatile ("sync" : : : "memory");
97 2662e13f bellard
    asm volatile ("isync" : : : "memory");
98 2662e13f bellard
}