/[gxemul]/upstream/0.4.5.1/src/cpus/generate_mips_loadstore_multi.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /upstream/0.4.5.1/src/cpus/generate_mips_loadstore_multi.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (show annotations)
Mon Oct 8 16:22:20 2007 UTC (16 years, 9 months ago) by dpavlin
File MIME type: text/plain
File size: 3611 byte(s)
0.4.5.1
1 /*
2 * Copyright (C) 2007 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 * $Id: generate_mips_loadstore_multi.c,v 1.1 2007/01/30 19:21:54 debug Exp $
29 */
30
31 #include <stdio.h>
32 #include <string.h>
33
34
35 void generate_multi(int store, int endianness, int n)
36 {
37 int i, nr;
38
39 printf("X(multi_%cw_%i_%ce)\n{\n",
40 store? 's' : 'l', n, endianness? 'b' : 'l');
41
42 printf("\tuint32_t *page;\n"
43 "\tMODE_uint_t rX = reg(ic[0].arg[1])");
44 for (i=0; i<n; i++)
45 printf(", r%i", i);
46 printf(";\n");
47
48 for (i=0; i<n; i++)
49 printf("\tMODE_uint_t addr%i = rX + (int32_t)ic[%i].arg[2];\n",
50 i, i);
51 for (i=0; i<n; i++)
52 printf("\tuint32_t index%i = addr%i >> 12;\n", i, i);
53
54 printf("\tpage = (uint32_t *) cpu->cd.mips.host_%s[index0];\n",
55 store? "store" : "load");
56
57 printf("\tif (cpu->delay_slot ||\n"
58 "\t page == NULL");
59 for (i=0; i<n; i++)
60 printf(" || (addr%i & 3)", i);
61 printf("\n\t ");
62 for (i=1; i<n; i++)
63 printf(" || index%i != index0", i);
64 printf(") {\n");
65
66 nr = 2*2;
67 if (store)
68 nr += 8;
69 else
70 nr += 1;
71 if (endianness)
72 nr += 16;
73 printf("\t\tmips32_loadstore[%i](cpu, ic);\n", nr);
74
75 printf("\t\treturn;\n\t}\n");
76
77 for (i=0; i<n; i++)
78 printf("\taddr%i = (addr%i >> 2) & 0x3ff;\n", i, i);
79
80 if (store) {
81 for (i=0; i<n; i++)
82 printf("\tr%i = reg(ic[%i].arg[0]);\n", i, i);
83 for (i=0; i<n; i++)
84 printf("\tr%i = %cE32_TO_HOST(r%i);\n", i,
85 endianness? 'B' : 'L', i);
86 for (i=0; i<n; i++)
87 printf("\tpage[addr%i] = r%i;\n", i, i);
88 } else {
89 for (i=0; i<n; i++)
90 printf("\tr%i = page[addr%i];\n", i, i);
91 for (i=0; i<n; i++)
92 printf("\tr%i = %cE32_TO_HOST(r%i);\n", i,
93 endianness? 'B' : 'L', i);
94 for (i=0; i<n; i++)
95 printf("\treg(ic[%i].arg[0]) = r%i;\n", i, i);
96 }
97
98 printf("\tcpu->n_translated_instrs += %i;\n", n - 1);
99 printf("\tcpu->cd.mips.next_ic += %i;\n", n - 1);
100
101 printf("}\n\n");
102 }
103
104
105 int main(int argc, char *argv[])
106 {
107 int store, endianness, n;
108
109 printf("\n/* AUTOMATICALLY GENERATED! Do not edit. */\n\n");
110
111 for (endianness=0; endianness<=1; endianness++)
112 for (store=0; store<=1; store++)
113 for (n=2; n<=4; n++)
114 generate_multi(store, endianness, n);
115
116 return 0;
117 }
118

  ViewVC Help
Powered by ViewVC 1.1.26