Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -2046,17 +2046,22 @@ return expandCondBranches(Inst, IDLoc, Instructions) ? MER_Fail : MER_Success; case Mips::SDivMacro: + case Mips::SDivIMacro: return expandDiv(Inst, IDLoc, Instructions, false, true) ? MER_Fail : MER_Success; case Mips::DSDivMacro: + case Mips::DSDivIMacro: return expandDiv(Inst, IDLoc, Instructions, true, true) ? MER_Fail : MER_Success; case Mips::UDivMacro: + case Mips::UDivIMacro: return expandDiv(Inst, IDLoc, Instructions, false, false) ? MER_Fail : MER_Success; case Mips::DUDivMacro: + case Mips::DUDivIMacro: return expandDiv(Inst, IDLoc, Instructions, true, false) ? MER_Fail : MER_Success; + case Mips::PseudoTRUNC_W_S: return expandTrunc(Inst, false, false, IDLoc, Instructions) ? MER_Fail : MER_Success; @@ -2971,22 +2976,67 @@ assert(RsRegOp.isReg() && "expected register operand kind"); unsigned RsReg = RsRegOp.getReg(); - const MCOperand &RtRegOp = Inst.getOperand(2); - assert(RtRegOp.isReg() && "expected register operand kind"); - unsigned RtReg = RtRegOp.getReg(); + unsigned RtReg; + int32_t ImmValue; + + const MCOperand &RtOp = Inst.getOperand(2); + assert((RtOp.isReg() || RtOp.isImm()) && + "expected register or immediate operand kind"); + if (RtOp.isReg()) + RtReg = RtOp.getReg(); + else + ImmValue = RtOp.getImm(); + unsigned DivOp; unsigned ZeroReg; + unsigned SubOp; if (IsMips64) { DivOp = Signed ? Mips::DSDIV : Mips::DUDIV; ZeroReg = Mips::ZERO_64; + SubOp = Mips::DSUB; } else { DivOp = Signed ? Mips::SDIV : Mips::UDIV; ZeroReg = Mips::ZERO; + SubOp = Mips::SUB; } bool UseTraps = useTraps(); + if (RtOp.isImm()) { + unsigned ATReg = getATReg(IDLoc); + if (!ATReg) + return true; + + if (ImmValue == 0) { + if (RsReg == Mips::ZERO || RsReg == Mips::ZERO_64) + Warning(IDLoc, "dividing zero by zero"); + else + Warning(IDLoc, "division by zero"); + if (UseTraps) + emitRRI(Mips::TEQ, ZeroReg, ZeroReg, 0x7, IDLoc, Instructions); + else + emitII(Mips::BREAK, 0x7, 0, IDLoc, Instructions); + return false; + } + + if (ImmValue == 1) { + emitRRR(Mips::ADDu, RdReg, RsReg, Mips::ZERO, IDLoc, Instructions); + return false; + } else if (Signed && ImmValue == -1) { + emitRRR(SubOp, RdReg, Mips::ZERO, RsReg, IDLoc, Instructions); + return false; + } else { + if (loadImmediate(ImmValue, ATReg, Mips::NoRegister, true, false, + Inst.getLoc(), Instructions)) + return true; + emitRR(DivOp, RsReg, ATReg, IDLoc, Instructions); + emitR(Mips::MFLO, RdReg, IDLoc, Instructions); + return false; + } + return true; + } + if (RsReg == Mips::ZERO || RsReg == Mips::ZERO_64) { if (RtReg == Mips::ZERO || RtReg == Mips::ZERO_64) Warning(IDLoc, "dividing zero by zero"); Index: lib/Target/Mips/MipsInstrInfo.td =================================================================== --- lib/Target/Mips/MipsInstrInfo.td +++ lib/Target/Mips/MipsInstrInfo.td @@ -2062,27 +2062,54 @@ (ins GPR32Opnd:$rs, GPR32Opnd:$rt), "div\t$rd, $rs, $rt">, ISA_MIPS1_NOT_32R6_64R6; +def SDivIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), + (ins GPR32Opnd:$rs, simm16:$imm), + "div\t$rd, $rs, $imm">, + ISA_MIPS1_NOT_32R6_64R6; def UDivMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), "divu\t$rd, $rs, $rt">, ISA_MIPS1_NOT_32R6_64R6; +def UDivIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), + (ins GPR32Opnd:$rs, simm16:$imm), + "divu\t$rd, $rs, $imm">, + ISA_MIPS1_NOT_32R6_64R6; def : MipsInstAlias<"div $rt, $rs", (SDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; +def : MipsInstAlias<"div $rd, $imm", (SDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, + simm16:$imm), 0>, + ISA_MIPS1_NOT_32R6_64R6; def : MipsInstAlias<"divu $rt, $rs", (UDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; +def : MipsInstAlias<"divu $rd, $imm", (UDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, + simm16:$imm), 0>, + ISA_MIPS1_NOT_32R6_64R6; def DSDivMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), "ddiv\t$rd, $rs, $rt">, ISA_MIPS64_NOT_64R6; +def DSDivIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), + (ins GPR32Opnd:$rs, simm16:$imm), + "ddiv\t$rd, $rs, $imm">, + ISA_MIPS64_NOT_64R6; def DUDivMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), "ddivu\t$rd, $rs, $rt">, ISA_MIPS64_NOT_64R6; +def DUDivIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), + (ins GPR32Opnd:$rs, simm16:$imm), + "ddivu\t$rd, $rs, $imm">, + ISA_MIPS64_NOT_64R6; def : MipsInstAlias<"ddiv $rt, $rs", (DSDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; +def : MipsInstAlias<"ddiv $rd, $imm", (DSDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, + simm16:$imm), 0>, ISA_MIPS64_NOT_64R6; def : MipsInstAlias<"ddivu $rt, $rs", (DUDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>; +def : MipsInstAlias<"ddivu $rd, $imm", (DUDivIMacro GPR32Opnd:$rd, + GPR32Opnd:$rd, simm16:$imm), 0>, + ISA_MIPS64_NOT_64R6; def Ulh : MipsAsmPseudoInst<(outs GPR32Opnd:$rt), (ins mem:$addr), "ulh\t$rt, $addr">; //, ISA_MIPS1_NOT_32R6_64R6; Index: test/MC/Mips/macro-ddiv.s =================================================================== --- test/MC/Mips/macro-ddiv.s +++ test/MC/Mips/macro-ddiv.s @@ -48,7 +48,45 @@ ddiv $0,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] - ddiv $4,$5,$6 + ddiv $4,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddiv $0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddiv $4,1 +# CHECK-NOTRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + ddiv $4,-1 +# CHECK-NOTRAP: dsub $4, $zero, $4 # encoding: [0x00,0x04,0x20,0x2e] + + ddiv $4,2 +# CHECK-NOTRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,$6 # CHECK-NOTRAP: bne $6, $zero, 8 # encoding: [0x14,0xc0,0x00,0x02] # CHECK-NOTRAP: ddiv $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1e] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] @@ -61,15 +99,53 @@ # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] - ddiv $4,$5,$0 + ddiv $4,$5,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] - ddiv $4,$0,$0 + ddiv $4,$0,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] ddiv $0, $4, $5 # CHECK-NOTRAP: ddiv $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1e] + ddiv $4,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddiv $4,$5,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddiv $4,$5,1 +# CHECK-NOTRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + ddiv $4,$5,-1 +# CHECK-NOTRAP: dsub $4, $zero, $5 # encoding: [0x00,0x05,0x20,0x2e] + + ddiv $4,$5,2 +# CHECK-NOTRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + ddiv $25,$11 # CHECK-TRAP: teq $11, $zero, 7 # encoding: [0x01,0x60,0x01,0xf4] # CHECK-TRAP: ddiv $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1e] @@ -106,7 +182,45 @@ ddiv $0,$0 # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $4,$5,$6 + ddiv $4,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $4,1 +# CHECK-TRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + ddiv $4,-1 +# CHECK-TRAP: dsub $4, $zero, $4 # encoding: [0x00,0x04,0x20,0x2e] + + ddiv $4,2 +# CHECK-TRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,$6 # CHECK-TRAP: teq $6, $zero, 7 # encoding: [0x00,0xc0,0x01,0xf4] # CHECK-TRAP: ddiv $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1e] # CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] @@ -116,11 +230,49 @@ # CHECK-TRAP: teq $5, $1, 6 # encoding: [0x00,0xa1,0x01,0xb4] # CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] - ddiv $4,$5,$0 + ddiv $4,$5,$0 # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $4,$0,$0 + ddiv $4,$0,$0 # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $0, $4, $5 + ddiv $0,$4,$5 # CHECK-TRAP: ddiv $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1e] + + ddiv $4,$0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $4,$5,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $4,$5,1 +# CHECK-TRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + ddiv $4,$5,-1 +# CHECK-TRAP: dsub $4, $zero, $5 # encoding: [0x00,0x05,0x20,0x2e] + + ddiv $4,$5,2 +# CHECK-TRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] \ No newline at end of file Index: test/MC/Mips/macro-ddivu.s =================================================================== --- test/MC/Mips/macro-ddivu.s +++ test/MC/Mips/macro-ddivu.s @@ -33,7 +33,42 @@ # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] - ddivu $4,$5,$6 + ddivu $4,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddivu $0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddivu $4,1 +# CHECK-NOTRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + ddivu $4,-1 +# CHECK-NOTRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,$6 # CHECK-NOTRAP: bne $6, $zero, 8 # encoding: [0x14,0xc0,0x00,0x02] # CHECK-NOTRAP: ddivu $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] @@ -54,6 +89,49 @@ ddivu $0, $4, $5 # CHECK-NOTRAP: ddivu $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1f] + ddivu $4,$5,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddivu $4,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddivu $0,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddivu $4,$5,1 +# CHECK-NOTRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + ddivu $4,$5,-1 +# CHECK-NOTRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,2 +# CHECK-NOTRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + ddivu $25, $11 # CHECK-TRAP: teq $11, $zero, 7 # encoding: [0x01,0x60,0x01,0xf4] # CHECK-TRAP: ddivu $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1f] @@ -79,7 +157,42 @@ # CHECK-TRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] # CHECK-TRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] - ddivu $4,$5,$6 + ddivu $4,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddivu $0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddivu $4,1 +# CHECK-TRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + ddivu $4,-1 +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,$6 # CHECK-TRAP: teq $6, $zero, 7 # encoding: [0x00,0xc0,0x01,0xf4] # CHECK-TRAP: ddivu $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1f] # CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] @@ -94,5 +207,48 @@ # CHECK-TRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] # CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] - ddivu $0, $4, $5 + ddivu $0,$4,$5 # CHECK-TRAP: ddivu $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1f] + + ddivu $4,$5,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddivu $4,$0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddivu $0,$0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddivu $4,$5,1 +# CHECK-TRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + ddivu $4,$5,-1 +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,2 +# CHECK-TRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] \ No newline at end of file Index: test/MC/Mips/macro-div.s =================================================================== --- test/MC/Mips/macro-div.s +++ test/MC/Mips/macro-div.s @@ -36,7 +36,45 @@ div $0,$0 # CHECK-NOTRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] - div $4,$5,$6 + div $4,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + div $0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + div $4,1 +# CHECK-NOTRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + div $4,-1 +# CHECK-NOTRAP: neg $4, $4 # encoding: [0x00,0x04,0x20,0x22] + + div $4,2 +# CHECK-NOTRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-NOTRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,$6 # CHECK-NOTRAP: bnez $6, 8 # encoding: [0x14,0xc0,0x00,0x02] # CHECK-NOTRAP: div $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1a] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] @@ -48,15 +86,53 @@ # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] - div $4,$5,$0 + div $4,$5,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] - div $4,$0,$0 + div $4,$0,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] div $0, $4, $5 # CHECK-NOTRAP: div $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1a] + div $4,$5,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + div $4,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + div $4,$5,1 +# CHECK-NOTRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + div $4,$5,-1 +# CHECK-NOTRAP: neg $4, $5 # encoding: [0x00,0x05,0x20,0x22] + + div $4,$5,2 +# CHECK-NOTRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-NOTRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + div $25, $11 # CHECK-TRAP: teq $11, $zero, 7 # encoding: [0x01,0x60,0x01,0xf4] # CHECK-TRAP: div $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1a] @@ -84,7 +160,45 @@ div $0,$0 # CHECK-TRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] - div $4,$5,$6 + div $4,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + div $0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + div $4,1 +# CHECK-TRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + div $4,-1 +# CHECK-TRAP: neg $4, $4 # encoding: [0x00,0x04,0x20,0x22] + + div $4,2 +# CHECK-TRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-TRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: div $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,$6 # CHECK-TRAP: teq $6, $zero, 7 # encoding: [0x00,0xc0,0x01,0xf4] # CHECK-TRAP: div $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1a] # CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] @@ -93,11 +207,49 @@ # CHECK-TRAP: teq $5, $1, 6 # encoding: [0x00,0xa1,0x01,0xb4] # CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] - div $4,$5,$0 + div $4,$5,$0 # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - div $4,$0,$0 + div $4,$0,$0 # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] div $0, $4, $5 -# CHECK-TRAP: div $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1a] \ No newline at end of file +# CHECK-TRAP: div $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1a] + + div $4,$5,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + div $4,$0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + div $4,$5,1 +# CHECK-TRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + div $4,$5,-1 +# CHECK-TRAP: neg $4, $5 # encoding: [0x00,0x05,0x20,0x22] + + div $4,$5,2 +# CHECK-TRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-TRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + div $4,$5,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: div $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1a] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] \ No newline at end of file Index: test/MC/Mips/macro-divu.s =================================================================== --- test/MC/Mips/macro-divu.s +++ test/MC/Mips/macro-divu.s @@ -27,6 +27,46 @@ divu $0,$0 # CHECK-NOTRAP: divu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1b] + divu $4,0 + # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + divu $0,0 + # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + divu $4,1 + # CHECK-NOTRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + divu $4,-1 +# CHECK-NOTRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-NOTRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,2 +# CHECK-NOTRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-NOTRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + divu $4,$5,$6 # CHECK-NOTRAP: bnez $6, 8 # encoding: [0x14,0xc0,0x00,0x02] # CHECK-NOTRAP: divu $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1b] @@ -48,6 +88,46 @@ divu $0, $4, $5 # CHECK-NOTRAP: divu $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1b] + divu $4,$5,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + divu $4,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + divu $4,$5,1 +# CHECK-NOTRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + divu $4,$5,-1 +# CHECK-NOTRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-NOTRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,2 +# CHECK-NOTRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-NOTRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,0x8000 +# CHECK-NOTRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-NOTRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,-0x8000 +# CHECK-NOTRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-NOTRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,0x10000 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,0x1a5a5 +# CHECK-NOTRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-NOTRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-NOTRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + divu $25, $11 # CHECK-TRAP: teq $11, $zero, 7 # encoding: [0x01,0x60,0x01,0xf4] # CHECK-TRAP: divu $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1b] @@ -69,6 +149,40 @@ divu $0,$0 # CHECK-TRAP: divu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1b] + divu $4,1 +# CHECK-TRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + divu $4,-1 +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,2 +# CHECK-TRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-TRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: divu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + divu $4,$5,$6 # CHECK-TRAP: teq $6, $zero, 7 # encoding: [0x00,0xc0,0x01,0xf4] # CHECK-TRAP: divu $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1b] @@ -86,3 +200,43 @@ divu $0, $4, $5 # CHECK-TRAP: divu $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1b] + + divu $4,$5,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + divu $4,$0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + divu $4,$5,1 +# CHECK-TRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] + + divu $4,$5,-1 +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,2 +# CHECK-TRAP: addiu $1, $zero, 2 # encoding: [0x24,0x01,0x00,0x02] +# CHECK-TRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,0x8000 +# CHECK-TRAP: ori $1, $zero, 32768 # encoding: [0x34,0x01,0x80,0x00] +# CHECK-TRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,-0x8000 +# CHECK-TRAP: addiu $1, $zero, -32768 # encoding: [0x24,0x01,0x80,0x00] +# CHECK-TRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,0x10000 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,0x1a5a5 +# CHECK-TRAP: lui $1, 1 # encoding: [0x3c,0x01,0x00,0x01] +# CHECK-TRAP: ori $1, $1, 42405 # encoding: [0x34,0x21,0xa5,0xa5] +# CHECK-TRAP: divu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] \ No newline at end of file