generate_mips_loadstore_multi.c Source File
Back to the index.
src
cpus
generate_mips_loadstore_multi.c
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2007-2009 Anders Gavare. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without
5
* modification, are permitted provided that the following conditions are met:
6
*
7
* 1. Redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer.
9
* 2. Redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution.
12
* 3. The name of the author may not be used to endorse or promote products
13
* derived from this software without specific prior written permission.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25
* SUCH DAMAGE.
26
*/
27
28
#include <stdio.h>
29
#include <string.h>
30
31
32
void
generate_multi
(
int
store,
int
endianness,
int
n)
33
{
34
int
i, nr;
35
36
printf(
"X(multi_%cw_%i_%ce)\n{\n"
,
37
store?
's'
:
'l'
, n, endianness?
'b'
:
'l'
);
38
39
printf(
"\tuint32_t *page;\n"
40
"\tMODE_uint_t rX = reg(ic[0].arg[1])"
);
41
for
(i=0; i<n; i++)
42
printf(
", r%i"
, i);
43
printf(
";\n"
);
44
45
for
(i=0; i<n; i++)
46
printf(
"\tMODE_uint_t addr%i = rX + (int32_t)ic[%i].arg[2];\n"
,
47
i, i);
48
for
(i=0; i<n; i++)
49
printf(
"\tuint32_t index%i = addr%i >> 12;\n"
, i, i);
50
51
printf(
"\tpage = (uint32_t *) cpu->cd.mips.host_%s[index0];\n"
,
52
store?
"store"
:
"load"
);
53
54
printf(
"\tif (cpu->delay_slot ||\n"
55
"\t page == NULL"
);
56
for
(i=0; i<n; i++)
57
printf(
" || (addr%i & 3)"
, i);
58
printf(
"\n\t "
);
59
for
(i=1; i<n; i++)
60
printf(
" || index%i != index0"
, i);
61
printf(
") {\n"
);
62
63
nr = 2*2;
64
if
(store)
65
nr += 8;
66
else
67
nr += 1;
68
if
(endianness)
69
nr += 16;
70
printf(
"\t\tmips32_loadstore[%i](cpu, ic);\n"
, nr);
71
72
printf(
"\t\treturn;\n\t}\n"
);
73
74
for
(i=0; i<n; i++)
75
printf(
"\taddr%i = (addr%i >> 2) & 0x3ff;\n"
, i, i);
76
77
if
(store) {
78
for
(i=0; i<n; i++)
79
printf(
"\tr%i = reg(ic[%i].arg[0]);\n"
, i, i);
80
for
(i=0; i<n; i++)
81
printf(
"\tr%i = %cE32_TO_HOST(r%i);\n"
, i,
82
endianness?
'B'
:
'L'
, i);
83
for
(i=0; i<n; i++)
84
printf(
"\tpage[addr%i] = r%i;\n"
, i, i);
85
}
else
{
86
for
(i=0; i<n; i++)
87
printf(
"\tr%i = page[addr%i];\n"
, i, i);
88
for
(i=0; i<n; i++)
89
printf(
"\tr%i = %cE32_TO_HOST(r%i);\n"
, i,
90
endianness?
'B'
:
'L'
, i);
91
for
(i=0; i<n; i++)
92
printf(
"\treg(ic[%i].arg[0]) = r%i;\n"
, i, i);
93
}
94
95
printf(
"\tcpu->n_translated_instrs += %i;\n"
, n - 1);
96
printf(
"\tcpu->cd.mips.next_ic += %i;\n"
, n - 1);
97
98
printf(
"}\n\n"
);
99
}
100
101
102
int
main
(
int
argc,
char
*argv[])
103
{
104
int
store, endianness, n;
105
106
printf(
"\n/* AUTOMATICALLY GENERATED! Do not edit. */\n\n"
);
107
108
for
(endianness=0; endianness<=1; endianness++)
109
for
(store=0; store<=1; store++)
110
for
(n=2; n<=4; n++)
111
generate_multi
(store, endianness, n);
112
113
return
0;
114
}
115
main
int main(int argc, char *argv[])
Definition:
generate_mips_loadstore_multi.c:102
generate_multi
void generate_multi(int store, int endianness, int n)
Definition:
generate_mips_loadstore_multi.c:32
Generated on Tue Mar 24 2020 14:04:48 for GXemul by
1.8.17