[Webkit-unassigned] [Bug 99706] MIPS LLInt implementation.
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Thu Oct 18 11:22:28 PDT 2012
https://bugs.webkit.org/show_bug.cgi?id=99706
--- Comment #14 from Filip Pizlo <fpizlo at apple.com> 2012-10-18 11:23:23 PST ---
(From update of attachment 169392)
View in context: https://bugs.webkit.org/attachment.cgi?id=169392&action=review
You should move lowering phases that are identical into a separate file. If they are almost identical except for some constant, then the phase should take a constant as an argument. If two phases just have some lowering in common but others are different (like lowering of branch ops for bmul) then you can split the phase in two - one phase for just bmul, which is common, and another phase for the rest, which is separate.
> Source/JavaScriptCore/offlineasm/mips.rb:278
> + when "bmulio"
> + tmp1 = Tmp.new(node.codeOrigin, :gpr)
> + tmp2 = Tmp.new(node.codeOrigin, :gpr)
> + newList << Instruction.new(node.codeOrigin, "smulli", [node.operands[0], node.operands[1], node.operands[1], tmp1])
> + newList << Instruction.new(node.codeOrigin, "rshifti", [node.operands[-2], Immediate.new(node.codeOrigin, 31), tmp2])
> + newList << Instruction.new(node.codeOrigin, "bineq", [tmp1, tmp2, node.operands[-1]])
> + when /^bmuli/
> + condition = $~.post_match
> + newList << Instruction.new(node.codeOrigin, "muli", node.operands[0..-2])
> + newList << Instruction.new(node.codeOrigin, "bti" + condition, [node.operands[-2], node.operands[-1]])
This is identical to the cases in armV7LowerBranchOps.
> Source/JavaScriptCore/offlineasm/mips.rb:357
> +def mipsSanitizeShift(operand, list)
> + return operand if operand.immediate?
> +
> + tmp = Tmp.new(operand.codeOrigin, :gpr)
> + list << Instruction.new(operand.codeOrigin, "andi", [operand, Immediate.new(operand.codeOrigin, 31), tmp])
> + tmp
> +end
> +
> +def mipsLowerShiftOps(list)
> + newList = []
> + list.each {
> + | node |
> + if node.is_a? Instruction
> + case node.opcode
> + when "lshifti", "rshifti", "urshifti", "lshiftp", "rshiftp", "urshiftp"
> + if node.operands.size == 2
> + newList << Instruction.new(node.codeOrigin, node.opcode, [mipsSanitizeShift(node.operands[0], newList), node.operands[1]])
> + else
> + newList << Instruction.new(node.codeOrigin, node.opcode, [node.operands[0], mipsSanitizeShift(node.operands[1], newList), node.operands[2]])
> + raise "Wrong number of operands for shift at #{node.codeOriginString}" unless node.operands.size == 3
> + end
> + else
> + newList << node
> + end
> + else
> + newList << node
> + end
> + }
> + newList
> +end
This is identical to armv7SanitizeShift
> Source/JavaScriptCore/offlineasm/mips.rb:392
> +class Node
> + def mipsLowerMalformedAddressesRecurse(list)
> + mapChildren {
> + | node |
> + node.mipsLowerMalformedAddressesRecurse(list)
> + }
> + end
> +end
> +
> +class Address
> + def mipsLowerMalformedAddressesRecurse(list)
> + if offset.value < -0xffff or offset.value > 0xffff
> + tmp = Tmp.new(codeOrigin, :gpr)
> + list << Instruction.new(codeOrigin, "move", [offset, tmp])
> + list << Instruction.new(codeOrigin, "addp", [base, tmp])
> + Address.new(codeOrigin, tmp, Immediate.new(codeOrigin, 0))
> + else
> + self
> + end
> + end
> +end
> +
This is identical to armV7LowerMalformedAddressesRecurse except for the acceptable range.
> Source/JavaScriptCore/offlineasm/mips.rb:398
> + if scaleShift == 0
> + tmp0 = Tmp.new(codeOrigin, :gpr)
> + list << Instruction.new(codeOrigin, "addp", [base, index, tmp0])
> + Address.new(codeOrigin, tmp0, Immediate.new(codeOrigin, offset.value));
scaleShift will never be 0.
> Source/JavaScriptCore/offlineasm/mips.rb:423
> +class AbsoluteAddress
> + def mipsLowerMalformedAddressesRecurse(list)
> + tmp = Tmp.new(codeOrigin, :gpr)
> + list << Instruction.new(codeOrigin, "move", [address, tmp])
> + Address.new(codeOrigin, tmp, Immediate.new(codeOrigin, 0))
> + end
> +end
> +
> +def mipsLowerMalformedAddresses(list)
> + newList = []
> + list.each {
> + | node |
> + newList << node.mipsLowerMalformedAddressesRecurse(newList)
> + }
> + newList
> +end
This is identical to armV7LowerMalformedAddresses
> Source/JavaScriptCore/offlineasm/mips.rb:468
> +class Node
> + def mipsDoubleAddress(list)
> + self
> + end
> +end
> +
> +class BaseIndex
> + def mipsDoubleAddress(list)
> + tmp = Tmp.new(codeOrigin, :gpr)
> + list << Instruction.new(codeOrigin, "leap", [self, tmp])
> + Address.new(codeOrigin, tmp, Immediate.new(codeOrigin, 0))
> + end
> +end
> +
> +def mipsLowerMalformedAddressesDouble(list)
> + newList = []
> + list.each {
> + | node |
> + if node.is_a? Instruction
> + case node.opcode
> + when "loadd"
> + newList << Instruction.new(node.codeOrigin, "loadd", [node.operands[0].mipsDoubleAddress(newList), node.operands[1]])
> + when "stored"
> + newList << Instruction.new(node.codeOrigin, "stored", [node.operands[0], node.operands[1].mipsDoubleAddress(newList)])
> + else
> + newList << node
> + end
> + else
> + newList << node
> + end
> + }
> + newList
> +end
You don't need this, if on MIPS you're always lowering BaseIndex anyway.
> Source/JavaScriptCore/offlineasm/mips.rb:571
> +class Node
> + def mipsLowerMalformedImmediatesRecurse(list)
> + mapChildren {
> + | node |
> + node.mipsLowerMalformedImmediatesRecurse(list)
> + }
> + end
> +end
> +
> +class Address
> + def mipsLowerMalformedImmediatesRecurse(list)
> + self
> + end
> +end
> +
> +class BaseIndex
> + def mipsLowerMalformedImmediatesRecurse(list)
> + self
> + end
> +end
> +
> +class AbsoluteAddress
> + def mipsLowerMalformedImmediatesRecurse(list)
> + self
> + end
> +end
> +
> +class Immediate
> + def mipsLowerMalformedImmediatesRecurse(list)
> + if value < -0xffff or value > 0xffff
> + tmp = Tmp.new(codeOrigin, :gpr)
> + list << Instruction.new(codeOrigin, "move", [self, tmp])
> + tmp
This whole swath of code is identical to armV7LowerMalformedImmediates
> Source/JavaScriptCore/offlineasm/mips.rb:654
> +def mipsAsRegister(preList, postList, operand, suffix, needStore)
> + return operand unless operand.address?
> +
> + tmp = Tmp.new(operand.codeOrigin, if suffix == "d" then :fpr else :gpr end)
> + preList << Instruction.new(operand.codeOrigin, "load" + suffix, [operand, tmp])
> + if needStore
> + postList << Instruction.new(operand.codeOrigin, "store" + suffix, [tmp, operand])
> + end
> + tmp
> +end
> +
> +def mipsAsRegisters(preList, postList, operands, suffix)
> + newOperands = []
> + operands.each_with_index {
> + | operand, index |
> + newOperands << mipsAsRegister(preList, postList, operand, suffix, index == operands.size - 1)
> + }
> + newOperands
> +end
> +
> +def mipsLowerMisplacedAddresses(list)
> + newList = []
> + list.each {
> + | node |
> + if node.is_a? Instruction
> + postInstructions = []
> + case node.opcode
> + when "addi", "addp", "addis", "andi", "andp", "lshifti", "lshiftp", "muli", "mulp", "negi",
> + "negp", "noti", "ori", "oris", "orp", "rshifti", "urshifti", "rshiftp", "urshiftp", "subi",
> + "subp", "subis", "xori", "xorp", /^bi/, /^bp/, /^bti/, /^btp/, /^ci/, /^cp/, /^ti/
> + newList << Instruction.new(node.codeOrigin,
> + node.opcode,
> + mipsAsRegisters(newList, postInstructions, node.operands, "i"))
> + when "bbeq", "bbneq", "bba", "bbaeq", "bbb", "bbbeq", "btbo", "btbz", "btbnz", "tbz", "tbnz",
> + "tbo", "cbeq", "cbneq", "cba", "cbaeq", "cbb", "cbbeq"
> + newList << Instruction.new(node.codeOrigin,
> + node.opcode,
> + mipsAsRegisters(newList, postInstructions, node.operands, "b"))
Again, this looks identical to armV7LowerMisplacedAddresses
> Source/JavaScriptCore/offlineasm/mips.rb:768
> +def mipsLowerRegisterReuse(list)
> + newList = []
> + list.each {
> + | node |
> + if node.is_a? Instruction
> + case node.opcode
> + when "cieq", "cineq", "cia", "ciaeq", "cib", "cibeq", "cigt", "cigteq", "cilt", "cilteq",
> + "cpeq", "cpneq", "cpa", "cpaeq", "cpb", "cpbeq", "cpgt", "cpgteq", "cplt", "cplteq",
> + "tio", "tis", "tiz", "tinz", "tbo", "tbs", "tbz", "tbnz", "tpo", "tps", "tpz", "tpnz",
> + "cbeq", "cbneq", "cba", "cbaeq", "cbb", "cbbeq", "cbgt", "cbgteq", "cblt", "cblteq"
> + if node.operands.size == 2
> + if node.operands[0] == node.operands[1]
> + tmp = Tmp.new(node.codeOrigin, :gpr)
> + newList << Instruction.new(node.codeOrigin, "move", [node.operands[0], tmp])
> + newList << Instruction.new(node.codeOrigin, node.opcode, [tmp, node.operands[1]])
> + else
> + newList << node
> + end
> + else
> + raise "Wrong number of arguments at #{node.codeOriginString}" unless node.operands.size == 3
> + if node.operands[0] == node.operands[2]
> + tmp = Tmp.new(node.codeOrigin, :gpr)
> + newList << Instruction.new(node.codeOrigin, "move", [node.operands[0], tmp])
> + newList << Instruction.new(node.codeOrigin, node.opcode, [tmp, node.operands[1], node.operands[2]])
> + elsif node.operands[1] == node.operands[2]
> + tmp = Tmp.new(node.codeOrigin, :gpr)
> + newList << Instruction.new(node.codeOrigin, "move", [node.operands[1], tmp])
> + newList << Instruction.new(node.codeOrigin, node.opcode, [node.operands[0], tmp, node.operands[2]])
> + else
> + newList << node
> + end
> + end
> + else
> + newList << node
> + end
> + else
> + newList << node
> + end
> + }
> + newList
Again! Identical to armV7LowerRegisterReuse!
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list