Changeset 150644 in webkit for trunk/Source/JavaScriptCore/offlineasm/sh4.rb
- Timestamp:
- May 24, 2013, 9:46:10 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/offlineasm/sh4.rb
r149403 r150644 319 319 if node.is_a? Instruction 320 320 case node.opcode 321 when "bd nequn", "bdgtequn", "bdltun", "bdltequn", "bdgtun"322 # Handle floating point unordered opcodes.321 when "bdltun", "bdgtun" 322 # Handle specific floating point unordered opcodes. 323 323 tmp1 = Tmp.new(codeOrigin, :gpr) 324 324 tmp2 = Tmp.new(codeOrigin, :gpr) … … 326 326 newList << Instruction.new(codeOrigin, "bdnan", [node.operands[1], node.operands[2], tmp1, tmp2]) 327 327 newList << Instruction.new(codeOrigin, node.opcode[0..-3], node.operands) 328 when "bdnequn", "bdgtequn", "bdltequn" 329 newList << Instruction.new(codeOrigin, node.opcode[0..-3], node.operands) 330 when "bdneq", "bdgteq", "bdlteq" 331 # Handle specific floating point ordered opcodes. 332 tmp1 = Tmp.new(codeOrigin, :gpr) 333 tmp2 = Tmp.new(codeOrigin, :gpr) 334 outlabel = LocalLabel.unique("out_#{node.opcode}") 335 outref = LocalLabelReference.new(codeOrigin, outlabel) 336 newList << Instruction.new(codeOrigin, "bdnan", [node.operands[0], outref, tmp1, tmp2]) 337 newList << Instruction.new(codeOrigin, "bdnan", [node.operands[1], outref, tmp1, tmp2]) 338 newList << Instruction.new(codeOrigin, node.opcode, node.operands) 339 newList << outlabel 328 340 else 329 341 newList << node … … 430 442 end 431 443 432 def emitSH4LoadConstant(constant, operand) 433 if constant == 0x40000000 444 def emitSH4Load32(constant, dest) 445 outlabel = LocalLabel.unique("load32out") 446 constlabel = LocalLabel.unique("load32const") 447 $asm.puts "mov.l #{LocalLabelReference.new(codeOrigin, constlabel).asmLabel}, #{dest.sh4Operand}" 448 $asm.puts "bra #{LocalLabelReference.new(codeOrigin, outlabel).asmLabel}" 449 $asm.puts "nop" 450 $asm.puts ".balign 4" 451 constlabel.lower("SH4") 452 $asm.puts ".long #{constant}" 453 outlabel.lower("SH4") 454 end 455 456 def emitSH4Load32AndJump(constant, scratch) 457 constlabel = LocalLabel.unique("load32const") 458 $asm.puts "mov.l #{LocalLabelReference.new(codeOrigin, constlabel).asmLabel}, #{scratch.sh4Operand}" 459 $asm.puts "jmp @#{scratch.sh4Operand}" 460 $asm.puts "nop" 461 $asm.puts ".balign 4" 462 constlabel.lower("SH4") 463 $asm.puts ".long #{constant}" 464 end 465 466 def emitSH4LoadImm(operands) 467 if operands[0].value == 0x40000000 434 468 # FirstConstantRegisterIndex const is often used (0x40000000). 435 469 # It's more efficient to "build" the value with 3 opcodes without branch. 436 $asm.puts "mov #64, #{operand.sh4Operand}" 437 $asm.puts "shll16 #{operand.sh4Operand}" 438 $asm.puts "shll8 #{operand.sh4Operand}" 439 else 470 $asm.puts "mov #64, #{operands[1].sh4Operand}" 471 $asm.puts "shll16 #{operands[1].sh4Operand}" 472 $asm.puts "shll8 #{operands[1].sh4Operand}" 473 elsif (-128..127).include? operands[0].value 474 $asm.puts "mov #{sh4Operands(operands)}" 475 elsif (-32768..32767).include? operands[0].value 440 476 constlabel = LocalLabel.unique("loadconstant") 441 $asm.puts ".balign 4" 442 $asm.puts "mov.l @(8, PC), #{operand.sh4Operand}" 477 $asm.puts "mov.w @(6, PC), #{operands[1].sh4Operand}" 443 478 $asm.puts "bra #{LocalLabelReference.new(codeOrigin, constlabel).asmLabel}" 444 479 $asm.puts "nop" 445 $asm.puts "nop" 446 $asm.puts ".long #{constant}" 480 $asm.puts ".word #{operands[0].value}" 447 481 constlabel.lower("SH4") 482 else 483 emitSH4Load32(operands[0].value, operands[1]) 448 484 end 449 485 end … … 481 517 $asm.puts "nop" 482 518 else 483 $asm.puts ".balign 4" 484 $asm.puts "mov.l @(8, PC), #{SH4_TMP_GPRS[0].sh4Operand}" 485 $asm.puts "jmp @#{SH4_TMP_GPRS[0].sh4Operand}" 486 $asm.puts "nop" 487 $asm.puts "nop" 488 $asm.puts ".long #{label.asmLabel}" 519 emitSH4Load32AndJump(label.asmLabel, SH4_TMP_GPRS[0]) 489 520 end 490 521 outlabel.lower("SH4") … … 520 551 scrint = operands[3] 521 552 553 notNaNlabel = LocalLabel.unique("notnan") 554 notNaNref = LocalLabelReference.new(codeOrigin, notNaNlabel) 555 constlabel1 = LocalLabel.unique("notnanConst1") 556 constlabel2 = LocalLabel.unique("notnanConst2") 557 522 558 # If we don't have "E = Emax + 1", it's not a NaN. 523 notNaNlabel = LocalLabel.unique("notnan")524 559 $asm.puts "fcnvds #{dblop.sh4Operand}, fpul" 525 560 $asm.puts "sts fpul, #{scrint.sh4Operand}" 526 emitSH4LoadConstant(0x7f800000, scrmask)561 $asm.puts "mov.l #{LocalLabelReference.new(codeOrigin, constlabel1).asmLabel}, #{scrmask.sh4Operand}" 527 562 $asm.puts "and #{sh4Operands([scrmask, scrint])}" 528 563 $asm.puts "cmp/eq #{sh4Operands([scrmask, scrint])}" 529 $asm.puts "bf #{ LocalLabelReference.new(codeOrigin, notNaNlabel).asmLabel}"564 $asm.puts "bf #{notNaNref.asmLabel}" 530 565 531 566 # If we have "E = Emax + 1" and "f != 0", then it's a NaN. 532 567 $asm.puts "sts fpul, #{scrint.sh4Operand}" 533 emitSH4LoadConstant(0x003fffff, scrmask)568 $asm.puts "mov.l #{LocalLabelReference.new(codeOrigin, constlabel2).asmLabel}, #{scrmask.sh4Operand}" 534 569 $asm.puts "tst #{sh4Operands([scrmask, scrint])}" 535 $asm.puts "bf #{labelop.asmLabel}" 570 $asm.puts "bt #{notNaNref.asmLabel}" 571 $asm.puts "bra #{labelop.asmLabel}" 572 $asm.puts "nop" 573 574 $asm.puts ".balign 4" 575 constlabel1.lower("SH4") 576 $asm.puts ".long 0x7f800000" 577 constlabel2.lower("SH4") 578 $asm.puts ".long 0x003fffff" 536 579 537 580 notNaNlabel.lower("SH4") … … 540 583 def emitSH4DoubleCondBranch(cmpOpcode, neg, operands) 541 584 if cmpOpcode == "lt" 542 if !neg 543 outlabel = LocalLabel.unique("dcbout") 544 $asm.puts "fcmp/gt #{sh4Operands([operands[1], operands[0]])}" 545 $asm.puts "bt #{LocalLabelReference.new(codeOrigin, outlabel).asmLabel}" 546 $asm.puts "fcmp/eq #{sh4Operands([operands[1], operands[0]])}" 547 $asm.puts "bf #{operands[2].asmLabel}" 548 outlabel.lower("SH4") 549 else 550 $asm.puts "fcmp/gt #{sh4Operands([operands[1], operands[0]])}" 551 $asm.puts "bt #{operands[2].asmLabel}" 552 $asm.puts "fcmp/eq #{sh4Operands([operands[1], operands[0]])}" 553 $asm.puts "bt #{operands[2].asmLabel}" 554 end 585 $asm.puts "fcmp/gt #{sh4Operands([operands[0], operands[1]])}" 555 586 else 556 587 $asm.puts "fcmp/#{cmpOpcode} #{sh4Operands([operands[1], operands[0]])}" 557 emitSH4BranchIfT(operands[2], neg)558 e nd588 end 589 emitSH4BranchIfT(operands[2], neg) 559 590 end 560 591 … … 729 760 end 730 761 when "jmpf" 731 $asm.puts ".balign 4" 732 $asm.puts "mov.l @(8, PC), #{operands[0].sh4Operand}" 733 $asm.puts "jmp @#{operands[0].sh4Operand}" 734 $asm.puts "nop" 735 $asm.puts "nop" 736 $asm.puts ".long #{operands[1].asmLabel}" 762 emitSH4Load32AndJump(operands[1].asmLabel, operands[0]) 737 763 when "ret" 738 764 $asm.puts "rts" … … 747 773 $asm.puts "mov.l #{sh4Operands(operands)}" 748 774 when "move" 749 if operands[0].is_a? Immediate and (operands[0].value < -128 or operands[0].value > 127)750 emitSH4Load Constant(operands[0].value, operands[1])751 elsif operands[0].is_a? LabelReference752 emitSH4Load Constant(operands[0].asmLabel, operands[1])775 if operands[0].is_a? LabelReference 776 emitSH4Load32(operands[0].asmLabel, operands[1]) 777 elsif operands[0].is_a? Immediate 778 emitSH4LoadImm(operands) 753 779 else 754 780 $asm.puts "mov #{sh4Operands(operands)}"
Note:
See TracChangeset
for help on using the changeset viewer.