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

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

Issue 1320006: Updates and fixes for MIPS support. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 7 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
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 default: 183 default:
184 return false; 184 return false;
185 }; 185 };
186 } 186 }
187 187
188 188
189 bool Instruction::IsLinkingInstruction() { 189 bool Instruction::IsLinkingInstruction() {
190 int op = OpcodeFieldRaw(); 190 int op = OpcodeFieldRaw();
191 switch (op) { 191 switch (op) {
192 case JAL: 192 case JAL:
193 case BGEZAL: 193 case REGIMM:
194 case BLTZAL: 194 switch (RtFieldRaw()) {
195 return true; 195 case BGEZAL:
196 case BLTZAL:
197 return true;
198 default:
199 return false;
200 };
196 case SPECIAL: 201 case SPECIAL:
197 switch (FunctionFieldRaw()) { 202 switch (FunctionFieldRaw()) {
198 case JALR: 203 case JALR:
199 return true; 204 return true;
200 default: 205 default:
201 return false; 206 return false;
202 }; 207 };
203 default: 208 default:
204 return false; 209 return false;
205 }; 210 };
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 case XOR: 259 case XOR:
255 case NOR: 260 case NOR:
256 case SLT: 261 case SLT:
257 case SLTU: 262 case SLTU:
258 case TGE: 263 case TGE:
259 case TGEU: 264 case TGEU:
260 case TLT: 265 case TLT:
261 case TLTU: 266 case TLTU:
262 case TEQ: 267 case TEQ:
263 case TNE: 268 case TNE:
269 case MOVZ:
270 case MOVN:
264 return kRegisterType; 271 return kRegisterType;
265 default: 272 default:
266 UNREACHABLE(); 273 UNREACHABLE();
267 }; 274 };
268 break; 275 break;
269 case SPECIAL2: 276 case SPECIAL2:
270 switch (FunctionFieldRaw()) { 277 switch (FunctionFieldRaw()) {
271 case MUL: 278 case MUL:
279 case CLZ:
280 return kRegisterType;
281 default:
282 UNREACHABLE();
283 };
284 break;
285 case SPECIAL3:
286 switch (FunctionFieldRaw()) {
287 case INS:
288 case EXT:
272 return kRegisterType; 289 return kRegisterType;
273 default: 290 default:
274 UNREACHABLE(); 291 UNREACHABLE();
275 }; 292 };
276 break; 293 break;
277 case COP1: // Coprocessor instructions 294 case COP1: // Coprocessor instructions
278 switch (FunctionFieldRaw()) { 295 switch (RsFieldRawNoAssert()) {
279 case BC1: // branch on coprocessor condition 296 case BC1: // branch on coprocessor condition
280 return kImmediateType; 297 return kImmediateType;
281 default: 298 default:
282 return kRegisterType; 299 return kRegisterType;
283 }; 300 };
284 break; 301 break;
285 // 16 bits Immediate type instructions. eg: addi dest, src, imm16 302 // 16 bits Immediate type instructions. eg: addi dest, src, imm16
286 case REGIMM: 303 case REGIMM:
287 case BEQ: 304 case BEQ:
288 case BNE: 305 case BNE:
289 case BLEZ: 306 case BLEZ:
290 case BGTZ: 307 case BGTZ:
291 case ADDI: 308 case ADDI:
292 case ADDIU: 309 case ADDIU:
293 case SLTI: 310 case SLTI:
294 case SLTIU: 311 case SLTIU:
295 case ANDI: 312 case ANDI:
296 case ORI: 313 case ORI:
297 case XORI: 314 case XORI:
298 case LUI: 315 case LUI:
299 case BEQL: 316 case BEQL:
300 case BNEL: 317 case BNEL:
301 case BLEZL: 318 case BLEZL:
302 case BGTZL: 319 case BGTZL:
303 case LB: 320 case LB:
321 case LH:
304 case LW: 322 case LW:
305 case LBU: 323 case LBU:
324 case LHU:
306 case SB: 325 case SB:
326 case SH:
307 case SW: 327 case SW:
308 case LWC1: 328 case LWC1:
309 case LDC1: 329 case LDC1:
310 case SWC1: 330 case SWC1:
311 case SDC1: 331 case SDC1:
312 return kImmediateType; 332 return kImmediateType;
313 // 26 bits immediate type instructions. eg: j imm26 333 // 26 bits immediate type instructions. eg: j imm26
314 case J: 334 case J:
315 case JAL: 335 case JAL:
316 return kJumpType; 336 return kJumpType;
317 default: 337 default:
318 UNREACHABLE(); 338 UNREACHABLE();
319 }; 339 };
320 return kUnsupported; 340 return kUnsupported;
321 } 341 }
322 342
343
344 // -----------------------------------------------------------------------------
345 // MIPS Assembly utils.
346
347 int32_t ISA_utils_instr_at(int32_t* pc) { return *pc; }
348 int32_t* ISA_utils_target_address_at(int32_t* pc) {
349 int32_t instr1 = ISA_utils_instr_at(pc);
350 int32_t instr2 = ISA_utils_instr_at(pc + 1);
351 // Check we have 2 instructions generated by li.
352 if (((instr1 & kOpcodeMask) == LUI && (instr2 & kOpcodeMask) == ORI) ||
353 ((instr1 == nopInstr) && ((instr2 & kOpcodeMask) == ADDI ||
354 (instr2 & kOpcodeMask) == ORI ||
355 (instr2 & kOpcodeMask) == LUI))) {
356 // Interpret these 2 instructions.
357 if (instr1 == nopInstr) {
358 if ((instr2 & kOpcodeMask) == ADDI) {
359 return reinterpret_cast<int32_t*>(((instr2 & kImm16Mask) << 16) >> 16);
360 } else if ((instr2 & kOpcodeMask) == ORI) {
361 return reinterpret_cast<int32_t*>(instr2 & kImm16Mask);
362 } else if ((instr2 & kOpcodeMask) == LUI) {
363 return reinterpret_cast<int32_t*>((instr2 & kImm16Mask) << 16);
364 }
365 } else if ((instr1 & kOpcodeMask) == LUI && (instr2 & kOpcodeMask) == ORI) {
366 // 32 bits value.
367 return reinterpret_cast<int32_t*>(
368 (instr1 & kImm16Mask) << 16 | (instr2 & kImm16Mask));
369 }
370
371 // We should never get here.
372 UNREACHABLE();
373 return reinterpret_cast<int32_t*>(0x0);
374
375 } else {
376 return reinterpret_cast<int32_t*>(*pc);
377 }
378 }
379
380
323 } } // namespace assembler::mips 381 } } // namespace assembler::mips
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698