func (mach X86) binaryIntCompareOp(code gen.RegCoder, cond uint8, a, b values.Operand) (result values.Operand) { result = values.ConditionFlagsOperand(values.Condition(cond)) targetReg, _, own := mach.opBorrowMaybeResultReg(code, a, false) if own { defer code.FreeReg(a.Type, targetReg) } if b.Storage == values.VarMem { Cmp.opFromStack(code, a.Type, targetReg, b.VarMemOffset()) return } var sourceReg regs.R if b.Storage.IsReg() { sourceReg = b.Reg() } else { if b.Storage == values.Imm { if value := b.ImmValue(); value >= -0x80000000 && value < 0x80000000 { Cmp.opImm(code, a.Type, targetReg, int32(value)) return } } sourceReg = regScratch mach.OpMove(code, sourceReg, b, false) } Cmp.opFromReg(code, a.Type, targetReg, sourceReg) code.Consumed(b) return }
func (mach X86) binaryFloatCompareOp(code gen.RegCoder, cond uint8, a, b values.Operand) values.Operand { aReg, _, own := mach.opBorrowMaybeResultReg(code, a, true) if own { defer code.FreeReg(a.Type, aReg) } bReg, _, own := mach.opBorrowMaybeScratchReg(code, b, false) if own { defer code.FreeReg(b.Type, bReg) } UcomisSSE.opFromReg(code, a.Type, aReg, bReg) return values.ConditionFlagsOperand(values.Condition(cond)) }