Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -2040,15 +2040,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::Ulh: @@ -2948,26 +2952,75 @@ warnIfNoMacro(IDLoc); - const MCOperand &RsRegOp = Inst.getOperand(0); + const MCOperand &RdRegOp = Inst.getOperand(0); + assert(RdRegOp.isReg() && "expected register operand kind"); + unsigned RdReg = RdRegOp.getReg(); + + const MCOperand &RsRegOp = Inst.getOperand(1); assert(RsRegOp.isReg() && "expected register operand kind"); unsigned RsReg = RsRegOp.getReg(); - const MCOperand &RtRegOp = Inst.getOperand(1); - 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"); @@ -3022,7 +3075,7 @@ emitII(Mips::BREAK, 0x7, 0, IDLoc, Instructions); if (!Signed) { - emitR(Mips::MFLO, RsReg, IDLoc, Instructions); + emitR(Mips::MFLO, RdReg, IDLoc, Instructions); return false; } @@ -3050,7 +3103,7 @@ emitRRI(Mips::SLL, ZeroReg, ZeroReg, 0, IDLoc, Instructions); emitII(Mips::BREAK, 0x6, 0, IDLoc, Instructions); } - emitR(Mips::MFLO, RsReg, IDLoc, Instructions); + emitR(Mips::MFLO, RdReg, IDLoc, Instructions); return false; } Index: lib/Target/Mips/MipsInstrInfo.td =================================================================== --- lib/Target/Mips/MipsInstrInfo.td +++ lib/Target/Mips/MipsInstrInfo.td @@ -2058,17 +2058,58 @@ // Once the tablegen-erated errors are made better, this needs to be fixed and // predicates needs to be restored. -def SDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), - "div\t$rs, $rt">; //, ISA_MIPS1_NOT_32R6_64R6; - -def UDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), - "divu\t$rs, $rt">; //, ISA_MIPS1_NOT_32R6_64R6; - -def DSDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), - "ddiv\t$rs, $rt">; //, ISA_MIPS64_NOT_64R6; +def SDivMacro : MipsAsmPseudoInst<(outs GPR32Opnd:$rd), + (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 DUDivMacro : MipsAsmPseudoInst<(outs), (ins GPR32Opnd:$rs, GPR32Opnd:$rt), - "ddivu\t$rs, $rt">; //, ISA_MIPS64_NOT_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,6 +48,101 @@ ddiv $0,$0 # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + 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] +# CHECK-NOTRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-NOTRAP: bne $6, $1, 20 # encoding: [0x14,0xc1,0x00,0x05] +# CHECK-NOTRAP: addiu $1, $zero, 1 # encoding: [0x24,0x01,0x00,0x01] +# CHECK-NOTRAP: dsll32 $1, $1, 31 # encoding: [0x00,0x01,0x0f,0xfc] +# CHECK-NOTRAP: bne $5, $1, 8 # encoding: [0x14,0xa1,0x00,0x02] +# 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] + + ddiv $4,$5,$0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + ddiv $4,$0,$0 +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + + 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] @@ -83,3 +178,95 @@ ddiv $0,$0 # CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + 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] +# 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 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + ddiv $4,$0,$0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] + + 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] Index: test/MC/Mips/macro-ddivu.s =================================================================== --- test/MC/Mips/macro-ddivu.s +++ test/MC/Mips/macro-ddivu.s @@ -33,6 +33,102 @@ # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] # CHECK-NOTRAP: mflo $zero # encoding: [0x00,0x00,0x00,0x12] + 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] +# CHECK-NOTRAP: 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] + + 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] + + 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] @@ -57,3 +153,96 @@ # 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-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] + + 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] +# 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] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + 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] Index: test/MC/Mips/macro-div.s =================================================================== --- test/MC/Mips/macro-div.s +++ test/MC/Mips/macro-div.s @@ -36,6 +36,100 @@ div $0,$0 # CHECK-NOTRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] + 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] +# CHECK-NOTRAP: addiu $1, $zero, -1 # encoding: [0x24,0x01,0xff,0xff] +# CHECK-NOTRAP: bne $6, $1, 16 # encoding: [0x14,0xc1,0x00,0x04] +# CHECK-NOTRAP: lui $1, 32768 # encoding: [0x3c,0x01,0x80,0x00] +# CHECK-NOTRAP: bne $5, $1, 8 # encoding: [0x14,0xa1,0x00,0x02] +# 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] + + 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,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] @@ -62,3 +156,94 @@ div $0,$0 # CHECK-TRAP: div $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1a] + + 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] +# 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 +# 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,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] Index: test/MC/Mips/macro-divu.s =================================================================== --- test/MC/Mips/macro-divu.s +++ test/MC/Mips/macro-divu.s @@ -1,49 +1,242 @@ -# RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 | \ -# RUN: FileCheck %s --check-prefix=CHECK-NOTRAP -# RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 \ -# RUN: -mattr=+use-tcc-in-div | FileCheck %s --check-prefix=CHECK-TRAP - - divu $25,$11 -# CHECK-NOTRAP: bnez $11, 8 # encoding: [0x15,0x60,0x00,0x02] -# CHECK-NOTRAP: divu $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1b] -# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] -# CHECK-NOTRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] - - divu $24,$12 -# CHECK-NOTRAP: bnez $12, 8 # encoding: [0x15,0x80,0x00,0x02] -# CHECK-NOTRAP: divu $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1b] -# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] -# CHECK-NOTRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] + # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 | \ + # RUN: FileCheck %s --check-prefix=CHECK-NOTRAP + # RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 \ + # RUN: -mattr=use-tcc-in-div | FileCheck %s --check-prefix=CHECK-TRAP + + divu $25,$11 + # CHECK-NOTRAP: bnez $11, 8 # encoding: [0x15,0x60,0x00,0x02] + # CHECK-NOTRAP: divu $zero, $25, $11 # encoding: [0x03,0x2b,0x00,0x1b] + # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + # CHECK-NOTRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] + + divu $24,$12 + # CHECK-NOTRAP: bnez $12, 8 # encoding: [0x15,0x80,0x00,0x02] + # CHECK-NOTRAP: divu $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1b] + # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + # CHECK-NOTRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] + + divu $25,$0 + # CHECK-NOTRAP: bnez $zero, 8 # encoding: [0x14,0x00,0x00,0x02] + # CHECK-NOTRAP: divu $zero, $25, $zero # encoding: [0x03,0x20,0x00,0x1b] + # CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] + # CHECK-NOTRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] + + divu $0,$9 + # CHECK-NOTRAP: divu $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1b] + + 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] +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,$0 +# CHECK-NOTRAP: bnez $zero, 8 # encoding: [0x14,0x00,0x00,0x02] +# CHECK-NOTRAP: divu $zero, $5, $zero # encoding: [0x00,0xa0,0x00,0x1b] +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$0,$0 +# CHECK-NOTRAP: bnez $zero, 8 # encoding: [0x14,0x00,0x00,0x02] +# CHECK-NOTRAP: divu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1b] +# CHECK-NOTRAP: break 7 # encoding: [0x00,0x07,0x00,0x0d] +# CHECK-NOTRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + 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] +# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] + + divu $24,$12 +# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] +# CHECK-TRAP: divu $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1b] +# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] divu $25,$0 -# CHECK-NOTRAP: bnez $zero, 8 # encoding: [0x14,0x00,0x00,0x02] -# CHECK-NOTRAP: divu $zero, $25, $zero # encoding: [0x03,0x20,0x00,0x1b] -# 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: divu $zero, $25, $zero # encoding: [0x03,0x20,0x00,0x1b] +# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] divu $0,$9 -# CHECK-NOTRAP: divu $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1b] +# CHECK-TRAP: divu $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1b] divu $0,$0 -# CHECK-NOTRAP: divu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1b] +# CHECK-TRAP: divu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1b] - 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] -# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] - - divu $24,$12 -# CHECK-TRAP: teq $12, $zero, 7 # encoding: [0x01,0x80,0x01,0xf4] -# CHECK-TRAP: divu $zero, $24, $12 # encoding: [0x03,0x0c,0x00,0x1b] -# CHECK-TRAP: mflo $24 # encoding: [0x00,0x00,0xc0,0x12] + divu $4,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - divu $25,$0 -# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] -# CHECK-TRAP: divu $zero, $25, $zero # encoding: [0x03,0x20,0x00,0x1b] -# CHECK-TRAP: mflo $25 # encoding: [0x00,0x00,0xc8,0x12] - - divu $0,$9 -# CHECK-TRAP: divu $zero, $zero, $9 # encoding: [0x00,0x09,0x00,0x1b] + divu $0,0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] - 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] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$5,$0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] +# CHECK-TRAP: divu $zero, $5, $zero # encoding: [0x00,0xa0,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + divu $4,$0,$0 +# CHECK-TRAP: teq $zero, $zero, 7 # encoding: [0x00,0x00,0x01,0xf4] +# CHECK-TRAP: divu $zero, $zero, $zero # encoding: [0x00,0x00,0x00,0x1b] +# CHECK-TRAP: mflo $4 # encoding: [0x00,0x00,0x20,0x12] + + 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]