Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: src/mips/constants-mips.cc

Issue 549079: Support for MIPS in architecture independent files.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #include "v8.h"
2 #include "constants-mips.h"
3
4 namespace assembler {
5 namespace mips {
6
7 namespace v8i = v8::internal;
8
9
10 // -----------------------------------------------------------------------------
11 // Registers
12
13
14 // These register names are defined in a way to match the native disassembler
15 // formatting. See for example the command "objdump -d <binary file>".
16 const char* Registers::names_[kNumRegisters] = {
17 "zero_reg",
18 "at",
19 "v0", "v1",
20 "a0", "a1", "a2", "a3",
21 "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7",
22 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
23 "t8", "t9",
24 "k0", "k1",
25 "gp",
26 "sp",
27 "fp",
28 "ra"
29 };
30
31 // List of alias names which can be used when referring to MIPS registers.
32 const Registers::RegisterAlias Registers::aliases_[] = {
33 {0, "zero"},
34 {23, "cp"},
35 {30, "s8"},
36 {30, "s8_fp"},
37 {kInvalidRegister, NULL}
38 };
39
40 const char* Registers::Name(int reg) {
41 const char* result;
42 if ((0 <= reg) && (reg < kNumRegisters)) {
43 result = names_[reg];
44 } else {
45 result = "noreg";
46 }
47 return result;
48 }
49
50
51 int Registers::Number(const char* name) {
52 // Look through the canonical names.
53 for (int i = 0; i < kNumRegisters; i++) {
54 if (strcmp(names_[i], name) == 0) {
55 return i;
56 }
57 }
58
59 // Look through the alias names.
60 int i = 0;
61 while (aliases_[i].reg != kInvalidRegister) {
62 if (strcmp(aliases_[i].name, name) == 0) {
63 return aliases_[i].reg;
64 }
65 i++;
66 }
67
68 // No register with the reguested name found.
69 return kInvalidRegister;
70 }
71
72
73 const char* CRegisters::names_[kNumCRegisters] = {
74 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11",
75 "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21",
76 "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"
77 };
78
79 // List of alias names which can be used when referring to MIPS registers.
80 const CRegisters::RegisterAlias CRegisters::aliases_[] = {
81 {kInvalidRegister, NULL}
82 };
83
84 const char* CRegisters::Name(int creg) {
85 const char* result;
86 if ((0 <= creg) && (creg < kNumCRegisters)) {
87 result = names_[creg];
88 } else {
89 result = "nocreg";
90 }
91 return result;
92 }
93
94
95 int CRegisters::Number(const char* name) {
96 // Look through the canonical names.
97 for (int i = 0; i < kNumRegisters; i++) {
98 if (strcmp(names_[i], name) == 0) {
99 return i;
100 }
101 }
102
103 // Look through the alias names.
104 int i = 0;
105 while (aliases_[i].creg != kInvalidRegister) {
106 if (strcmp(aliases_[i].name, name) == 0) {
107 return aliases_[i].creg;
108 }
109 i++;
110 }
111
112 // No Cregister with the reguested name found.
113 return kInvalidCRegister;
114 }
115
116
117 // -----------------------------------------------------------------------------
118 // Instruction
119
120 bool Instruction::isForbiddenInBranchDelay() {
121 int op = OpcodeFieldRaw();
122 switch (op) {
123 case J:
124 case JAL:
125 case BEQ:
126 case BNE:
127 case BLEZ:
128 case BGTZ:
129 case BEQL:
130 case BNEL:
131 case BLEZL:
132 case BGTZL:
133 return true;
antonm 2010/01/21 13:10:45 ditto
Alexandre 2010/01/22 23:08:42 Fixed. On 2010/01/21 13:10:45, antonm wrote:
134 break;
135 case REGIMM:
136 switch (rtFieldRaw()) {
137 case BLTZ:
138 case BGEZ:
139 case BLTZAL:
140 case BGEZAL:
141 return true;
142 break;
143 default:
144 return false;
145 };
146 break;
147 case SPECIAL:
148 switch (functionFieldRaw()) {
149 case JR:
150 case JALR:
151 return true;
152 default:
153 return false;
154 };
155 break;
156 default:
157 return false;
158 };
159 }
160
161
162 bool Instruction::isLinkingInstruction() {
163 int op = OpcodeFieldRaw();
164 switch (op) {
165 case JAL:
166 case BGEZAL:
167 case BLTZAL:
168 return true;
169 break;
170 case SPECIAL:
171 switch (functionFieldRaw()) {
172 case JALR:
173 return true;
174 default:
175 return false;
176 };
177 default:
178 return false;
179 };
180 }
181
182
183 int Instruction::instrType() {
184 switch(OpcodeFieldRaw()) {
185 case SPECIAL:
186 switch(functionFieldRaw()) {
187 case JR:
188 case JALR:
189 return 3;
190 break;
191 case BREAK:
192 UNIMPLEMENTED();
193 break;
194 case SLL:
195 case SRL:
196 case SRA:
197 case SLLV:
198 case SRLV:
199 case SRAV:
200 case MFHI:
201 case MFLO:
202 case MULT:
203 case MULTU:
204 case DIV:
205 case DIVU:
206 case ADD:
207 case ADDU:
208 case SUB:
209 case SUBU:
210 case AND:
211 case OR:
212 case XOR:
213 case NOR:
214 case SLT:
215 case SLTU:
216 case TGE:
217 case TGEU:
218 case TLT:
219 case TLTU:
220 case TEQ:
221 case TNE:
222 return 1;
223 break;
224 default:
225 UNREACHABLE();
226 break;
227 };
228 break;
229 case SPECIAL2:
230 switch(functionFieldRaw()) {
231 case MUL:
232 return 1;
233 break;
234 default:
235 UNREACHABLE();
236 break;
237 };
238 break;
239 case COP1: // Coprocessor instructions
240 switch(functionFieldRaw()) {
241 case BC1: // branch on coprocessor condition
242 return 2;
243 default:
244 return 1;
245 };
246 break;
247 // 16 bits Immediate type instructions. eg: addi dest, src, imm16
248 case REGIMM:
249 case BEQ:
250 case BNE:
251 case BLEZ:
252 case BGTZ:
253 case ADDI:
254 case ADDIU:
255 case SLTI:
256 case SLTIU:
257 case ANDI:
258 case ORI:
259 case XORI:
260 case LUI:
261 case BEQL:
262 case BNEL:
263 case BLEZL:
264 case BGTZL:
265 case LB:
266 case LW:
267 case LBU:
268 case SB:
269 case SW:
270 case LWC1:
271 case LDC1:
272 case SWC1:
273 case SDC1:
274 return 2;
275 break;
276 // 26 bits immediate type instructions. eg: j imm26
277 case J:
278 case JAL:
279 return 3;
280 break;
281 default:
282 UNREACHABLE();
283 };
284
285 UNREACHABLE();
286 return -1;
287 }
288
289 } } // namespace assembler::mips
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698