Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -2046,15 +2046,19 @@ 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: @@ -2954,8 +2958,8 @@ } bool MipsAsmParser::expandDiv(MCInst &Inst, SMLoc IDLoc, - SmallVectorImpl &Instructions, - const bool IsMips64, const bool Signed) { + SmallVectorImpl &Instructions, + const bool IsMips64, const bool Signed) { warnIfNoMacro(IDLoc); const MCOperand &RdRegOp = Inst.getOperand(0); @@ -2966,22 +2970,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; + int64_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, isInt<32>(ImmValue), + 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"); @@ -2996,7 +3045,7 @@ return false; } } else { - emitRR(DivOp, RsReg, RtReg, IDLoc, Instructions); + emitRR(DivOp, RsReg, RtReg, IDLoc, Instructions); return false; } } Index: lib/Target/Mips/MipsInstrInfo.td =================================================================== --- lib/Target/Mips/MipsInstrInfo.td +++ lib/Target/Mips/MipsInstrInfo.td @@ -531,7 +531,7 @@ def uimm20 : Operand { } - +def simm64 : Operand; def simm16_64 : Operand { let DecoderMethod = "DecodeSimm16"; } @@ -2062,30 +2062,58 @@ (ins GPR32Opnd:$rs, GPR32Opnd:$rt), "div\t$rd, $rs, $rt">, ISA_MIPS1_NOT_32R6_64R6; +def SDivIMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), + (ins GPR32Opnd:$rs, simm32:$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, simm32:$imm), + "divu\t$rd, $rs, $imm">, + ISA_MIPS1_NOT_32R6_64R6; def : MipsInstAlias<"div $rt, $rs", (SDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS1_NOT_32R6_64R6; +def : MipsInstAlias<"div $rd, $imm", (SDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, + simm32:$imm), 0>, + ISA_MIPS1_NOT_32R6_64R6; def : MipsInstAlias<"divu $rt, $rs", (UDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS1_NOT_32R6_64R6; +def : MipsInstAlias<"divu $rd, $imm", (UDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, + simm32:$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, simm64:$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, simm64:$imm), + "ddivu\t$rd, $rs, $imm">, + ISA_MIPS64_NOT_64R6; def : MipsInstAlias<"ddiv $rt, $rs", (DSDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS64_NOT_64R6; +def : MipsInstAlias<"ddiv $rd, $imm", (DSDivIMacro GPR32Opnd:$rd, GPR32Opnd:$rd, + simm64:$imm), 0>, + ISA_MIPS64_NOT_64R6; def : MipsInstAlias<"ddivu $rt, $rs", (DUDivMacro GPR32Opnd:$rt, GPR32Opnd:$rt, GPR32Opnd:$rs), 0>, ISA_MIPS64_NOT_64R6; +def : MipsInstAlias<"ddivu $rd, $imm", (DUDivIMacro GPR32Opnd:$rd, + GPR32Opnd:$rd, simm64:$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 @@ -3,7 +3,7 @@ # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips64r2 \ # RUN: -mattr=+use-tcc-in-div | FileCheck %s --check-prefix=CHECK-TRAP - ddiv $25, $11 + ddiv $25,$11 # CHECK-NOTRAP: bne $11, $zero, 8 # encoding: [0x15,0x60,0x00,0x02] # CHECK-NOTRAP: ddiv $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1e] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] @@ -15,6 +15,14 @@ # CHECK-NOTRAP: sll $zero, $zero, 0 # encoding: [0x00,0x00,0x00,0x00] # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] +# CHECK-TRAP: teq $11, $zero, 7 # encoding: [0x01,0x60,0x01,0xf4] +# CHECK-TRAP: ddiv $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1e] +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: bne $11, $1, 12 # encoding: [0x15,0x61,0x00,0x03] +# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] +# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] +# CHECK-TRAP: teq $25, $1, 6 # encoding: [0x03,0x21,0x01,0xb4] +# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] ddiv $24,$12 # CHECK-NOTRAP: bne $12, $zero, 8 # encoding: [0x15,0x80,0x00,0x02] @@ -28,9 +36,18 @@ # CHECK-NOTRAP: sll $zero, $zero, 0 # encoding: [0x00,0x00,0x00,0x00] # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] +# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] +# CHECK-TRAP: ddiv $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1e] +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: bne $12, $1, 12 # encoding: [0x15,0x81,0x00,0x03] +# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] +# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] +# CHECK-TRAP: teq $24, $1, 6 # encoding: [0x03,0x01,0x01,0xb4] +# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] ddiv $25,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] ddiv $0,$9 # CHECK-NOTRAP: bne $9, $zero, 8 # encoding: [0x15,0x20,0x00,0x02] @@ -44,11 +61,135 @@ # CHECK-NOTRAP: sll $zero, $zero, 0 # encoding: [0x00,0x00,0x00,0x00] # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] +# CHECK-TRAP: teq $9, $zero, 7 # encoding: [0x01,0x20,0x01,0xf4] +# CHECK-TRAP: ddiv $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1e] +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: bne $9, $1, 12 # encoding: [0x15,0x21,0x00,0x03] +# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] +# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] +# CHECK-TRAP: teq $zero, $1, 6 # encoding: [0x00,0x01,0x01,0xb4] +# CHECK-TRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] ddiv $0,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $4,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $4,1 +# CHECK-NOTRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] +# CHECK-TRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + ddiv $4,-1 +# CHECK-NOTRAP: dsub $4, $zero, $4 # encoding: [0x00,0x04,0x20,0x2e] +# CHECK-TRAP: 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] +# 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-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] +# 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-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] +# 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-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] +# 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-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] +# 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,0xfffffff +# CHECK-NOTRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0x10000000 +# CHECK-NOTRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] - ddiv $4,$5,$6 + ddiv $4,0xfffffffe +# CHECK-NOTRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + + ddiv $4,0xffffffff +# CHECK-NOTRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-NOTRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-TRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-TRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,0xfffffffff +# CHECK-NOTRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddiv $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# 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-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] @@ -60,67 +201,139 @@ # CHECK-NOTRAP: sll $zero, $zero, 0 # encoding: [0x00,0x00,0x00,0x00] # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# 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] +# CHECK-TRAP: bne $6, $1, 12 # encoding: [0x14,0xc1,0x00,0x03] +# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] +# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] +# 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-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $4,$0,$0 + ddiv $4,$0,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $0, $4, $5 + ddiv $0,$4,$5 # CHECK-NOTRAP: ddiv $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1e] +# CHECK-TRAP: ddiv $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1e] - 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] -# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] -# CHECK-TRAP: bne $11, $1, 12 # encoding: [0x15,0x61,0x00,0x03] -# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] -# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] -# CHECK-TRAP: teq $25, $1, 6 # encoding: [0x03,0x21,0x01,0xb4] -# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] - - ddiv $24,$12 -# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] -# CHECK-TRAP: ddiv $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1e] -# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] -# CHECK-TRAP: bne $12, $1, 12 # encoding: [0x15,0x81,0x00,0x03] -# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] -# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] -# CHECK-TRAP: teq $24, $1, 6 # encoding: [0x03,0x01,0x01,0xb4] -# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] + ddiv $4,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $25,$0 + ddiv $4,$5,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $0,$9 -# CHECK-TRAP: teq $9, $zero, 7 # encoding: [0x01,0x20,0x01,0xf4] -# CHECK-TRAP: ddiv $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1e] -# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] -# CHECK-TRAP: bne $9, $1, 12 # encoding: [0x15,0x21,0x00,0x03] -# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] -# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] -# CHECK-TRAP: teq $zero, $1, 6 # encoding: [0x00,0x01,0x01,0xb4] -# CHECK-TRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] + ddiv $4,$5,1 +# CHECK-NOTRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] +# CHECK-TRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] - ddiv $0,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + ddiv $4,$5,-1 +# CHECK-NOTRAP: dsub $4, $zero, $5 # encoding: [0x00,0x05,0x20,0x2e] +# CHECK-TRAP: dsub $4, $zero, $5 # encoding: [0x00,0x05,0x20,0x2e] - 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] -# CHECK-TRAP: bne $6, $1, 12 # encoding: [0x14,0xc1,0x00,0x03] -# CHECK-TRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] -# CHECK-TRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] -# CHECK-TRAP: teq $5, $1, 6 # encoding: [0x00,0xa1,0x01,0xb4] + 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] +# 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,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + 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] +# 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-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] +# 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-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] +# 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-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] +# 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] + + ddiv $4,$5,0xfffffff +# CHECK-NOTRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0x10000000 +# CHECK-NOTRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0xfffffffe +# CHECK-NOTRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0xffffffff +# CHECK-NOTRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-NOTRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-TRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddiv $4,$5,0xfffffffff +# CHECK-NOTRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: ddiv $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1e] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] - ddiv $4,$0,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddiv $0, $4, $5 -# CHECK-TRAP: ddiv $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1e] Index: test/MC/Mips/macro-ddivu.s =================================================================== --- test/MC/Mips/macro-ddivu.s +++ test/MC/Mips/macro-ddivu.s @@ -8,91 +8,306 @@ # CHECK-NOTRAP: ddivu $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] +# CHECK-TRAP: teq $11, $zero, 7 # encoding: [0x01,0x60,0x01,0xf4] +# CHECK-TRAP: ddivu $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1f] +# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] ddivu $24,$12 # CHECK-NOTRAP: bne $12, $zero, 8 # encoding: [0x15,0x80,0x00,0x02] # CHECK-NOTRAP: ddivu $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] +# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] +# CHECK-TRAP: ddivu $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1f] +# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] ddivu $25,$0 # CHECK-NOTRAP: bne $zero, $zero, 8 # encoding: [0x14,0x00,0x00,0x02] # CHECK-NOTRAP: ddivu $zero, $25, $zero # encoding: [0x03,0x20,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] +# CHECK-TRAP: ddivu $zero, $25, $zero # encoding: [0x03,0x20,0x00,0x1f] +# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] ddivu $0,$9 # CHECK-NOTRAP: bne $9, $zero, 8 # encoding: [0x15,0x20,0x00,0x02] # CHECK-NOTRAP: ddivu $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] +# CHECK-TRAP: teq $9, $zero, 7 # encoding: [0x01,0x20,0x01,0xf4] +# CHECK-TRAP: ddivu $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1f] +# CHECK-TRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] ddivu $0,$0 # CHECK-NOTRAP: bne $zero, $zero, 8 # encoding: [0x14,0x00,0x00,0x02] # CHECK-NOTRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] +# CHECK-TRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] +# CHECK-TRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] + + ddivu $4,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddivu $0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddivu $4,1 +# CHECK-NOTRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] +# CHECK-TRAP: 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] +# 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-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] +# 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-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] +# 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,$5,$6 + 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] +# 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-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] +# 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,0xfffffff +# CHECK-NOTRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0x10000000 +# CHECK-NOTRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0xfffffffe +# CHECK-NOTRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0xffffffff +# CHECK-NOTRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-NOTRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-TRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-TRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,0xfffffffff +# CHECK-NOTRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddivu $zero, $4, $1 # encoding: [0x00,0x81,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# 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-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] # CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# 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] ddivu $4,$5,$0 # CHECK-NOTRAP: bne $zero, $zero, 8 # encoding: [0x14,0x00,0x00,0x02] # CHECK-NOTRAP: ddivu $zero, $5, $zero # encoding: [0x00,0xa0,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] +# CHECK-TRAP: ddivu $zero, $5, $zero # encoding: [0x00,0xa0,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] ddivu $4,$0,$0 # CHECK-NOTRAP: bne $zero, $zero, 8 # encoding: [0x14,0x00,0x00,0x02] # CHECK-NOTRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] +# CHECK-TRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] ddivu $0, $4, $5 # CHECK-NOTRAP: ddivu $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1f] +# CHECK-TRAP: ddivu $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1f] - 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] -# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] + ddivu $4,$5,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddivu $24,$12 -# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] -# CHECK-TRAP: ddivu $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1f] -# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] + ddivu $4,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - ddivu $25,$0 + ddivu $0,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] -# CHECK-TRAP: ddivu $zero, $25, $zero # encoding: [0x03,0x20,0x00,0x1f] -# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] - ddivu $0,$9 -# CHECK-TRAP: teq $9, $zero, 7 # encoding: [0x01,0x20,0x01,0xf4] -# CHECK-TRAP: ddivu $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1f] -# CHECK-TRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] + ddivu $4,$5,1 +# CHECK-NOTRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] +# CHECK-TRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] - ddivu $0,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] -# CHECK-TRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] -# CHECK-TRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] + 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] +# 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,$6 -# CHECK-TRAP: teq $6, $zero, 7 # encoding: [0x00,0xc0,0x01,0xf4] -# CHECK-TRAP: ddivu $zero, $5, $6 # encoding: [0x00,0xa6,0x00,0x1f] + 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] +# 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,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] -# CHECK-TRAP: ddivu $zero, $5, $zero # encoding: [0x00,0xa0,0x00,0x1f] + 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] +# 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,$0,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] -# CHECK-TRAP: ddivu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1f] + 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] +# 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 $0, $4, $5 -# CHECK-TRAP: ddivu $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1f] + 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] +# 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-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] +# 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] + + ddivu $4,$5,0xfffffff +# CHECK-NOTRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4095 # encoding: [0x3c,0x01,0x0f,0xff] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,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,0x10000000 +# CHECK-NOTRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 4096 # encoding: [0x3c,0x01,0x10,0x00] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0xfffffffe + +# CHECK-NOTRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: ori $1, $zero, 65535 # encoding: [0x34,0x01,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65534 # encoding: [0x34,0x21,0xff,0xfe] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0xffffffff +# CHECK-NOTRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-NOTRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: lui $1, 65535 # encoding: [0x3c,0x01,0xff,0xff] +# CHECK-TRAP: dsrl32 $1, $1, 0 # encoding: [0x00,0x01,0x08,0x3e] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + ddivu $4,$5,0xfffffffff +# CHECK-NOTRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-NOTRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-NOTRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# CHECK-TRAP: addiu $1, $zero, 15 # encoding: [0x24,0x01,0x00,0x0f] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: dsll $1, $1, 16 # encoding: [0x00,0x01,0x0c,0x38] +# CHECK-TRAP: ori $1, $1, 65535 # encoding: [0x34,0x21,0xff,0xff] +# CHECK-TRAP: ddivu $zero, $5, $1 # encoding: [0x00,0xa1,0x00,0x1f] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] Index: test/MC/Mips/macro-div.s =================================================================== --- test/MC/Mips/macro-div.s +++ test/MC/Mips/macro-div.s @@ -14,6 +14,13 @@ # CHECK-NOTRAP: nop # encoding: [0x00,0x00,0x00,0x00] # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] +# CHECK-TRAP: teq $11, $zero, 7 # encoding: [0x01,0x60,0x01,0xf4] +# CHECK-TRAP: div $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1a] +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: bne $11, $1, 8 # encoding: [0x15,0x61,0x00,0x02] +# CHECK-TRAP: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x00] +# CHECK-TRAP: teq $25, $1, 6 # encoding: [0x03,0x21,0x01,0xb4] +# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] div $24,$12 # CHECK-NOTRAP: bnez $12, 8 # encoding: [0x15,0x80,0x00,0x02] @@ -26,17 +33,85 @@ # CHECK-NOTRAP: nop # encoding: [0x00,0x00,0x00,0x00] # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] +# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] +# CHECK-TRAP: div $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1a] +# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-TRAP: bne $12, $1, 8 # encoding: [0x15,0x81,0x00,0x02] +# CHECK-TRAP: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x00] +# CHECK-TRAP: teq $24, $1, 6 # encoding: [0x03,0x01,0x01,0xb4] +# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] div $25,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] div $0,$9 # CHECK-NOTRAP: div $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1a] +# CHECK-TRAP: div $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1a] div $0,$0 # CHECK-NOTRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] +# CHECK-TRAP: 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] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + div $0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + div $4,1 +# CHECK-NOTRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] +# CHECK-TRAP: move $4, $4 # encoding: [0x00,0x80,0x20,0x21] + + div $4,-1 +# CHECK-NOTRAP: neg $4, $4 # encoding: [0x00,0x04,0x20,0x22] +# CHECK-TRAP: 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] +# 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-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] +# 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-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] +# 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-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] +# 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-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] +# 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-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] @@ -47,57 +122,80 @@ # CHECK-NOTRAP: nop # encoding: [0x00,0x00,0x00,0x00] # CHECK-NOTRAP: break 6 # encoding: [0x00,0x06,0x00,0x0d] # CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] +# 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] +# CHECK-TRAP: bne $6, $1, 8 # encoding: [0x14,0xc1,0x00,0x02] +# CHECK-TRAP: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x00] +# 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-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - div $4,$0,$0 -# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + div $4,$0,$0 +# CHECK-NOTRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] +# CHECK-TRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] - div $0, $4, $5 + div $0,$4,$5 # CHECK-NOTRAP: div $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1a] +# CHECK-TRAP: div $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1a] - 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] -# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] -# CHECK-TRAP: bne $11, $1, 8 # encoding: [0x15,0x61,0x00,0x02] -# CHECK-TRAP: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x00] -# CHECK-TRAP: teq $25, $1, 6 # encoding: [0x03,0x21,0x01,0xb4] -# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] - - div $24,$12 -# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] -# CHECK-TRAP: div $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1a] -# CHECK-TRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] -# CHECK-TRAP: bne $12, $1, 8 # encoding: [0x15,0x81,0x00,0x02] -# CHECK-TRAP: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x00] -# CHECK-TRAP: teq $24, $1, 6 # encoding: [0x03,0x01,0x01,0xb4] -# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] + div $4,$5,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - div $25,$0 + div $4,$0,0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - div $0,$9 -# CHECK-TRAP: div $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1a] + div $4,$5,1 +# CHECK-NOTRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] +# CHECK-TRAP: move $4, $5 # encoding: [0x00,0xa0,0x20,0x21] - div $0,$0 -# CHECK-TRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] + div $4,$5,-1 +# CHECK-NOTRAP: neg $4, $5 # encoding: [0x00,0x05,0x20,0x22] +# CHECK-TRAP: neg $4, $5 # encoding: [0x00,0x05,0x20,0x22] - 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] -# CHECK-TRAP: bne $6, $1, 8 # encoding: [0x14,0xc1,0x00,0x02] -# CHECK-TRAP: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x00] -# CHECK-TRAP: teq $5, $1, 6 # encoding: [0x00,0xa1,0x01,0xb4] + 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] +# 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,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + 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] +# 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,$0,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + 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] +# 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-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] +# 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 $0, $4, $5 -# CHECK-TRAP: div $zero, $4, $5 # encoding: [0x00,0x85,0x00,0x1a] \ No newline at end of file + 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] +# 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