llvm.org GIT mirror llvm / 0db5379
[PowerPC] Support compare mnemonics with implied CR0 Just like for branch mnemonics (where support was recently added), the assembler is supposed to support extended mnemonics for the compare instructions where no condition register is specified explicitly (and CR0 is assumed implicitly). This patch adds support for those extended compare mnemonics. Index: llvm-head/test/MC/PowerPC/ppc64-encoding-ext.s =================================================================== --- llvm-head.orig/test/MC/PowerPC/ppc64-encoding-ext.s +++ llvm-head/test/MC/PowerPC/ppc64-encoding-ext.s @@ -449,21 +449,37 @@ # CHECK: cmpdi 2, 3, 128 # encoding: [0x2d,0x23,0x00,0x80] cmpdi 2, 3, 128 +# CHECK: cmpdi 0, 3, 128 # encoding: [0x2c,0x23,0x00,0x80] + cmpdi 3, 128 # CHECK: cmpd 2, 3, 4 # encoding: [0x7d,0x23,0x20,0x00] cmpd 2, 3, 4 +# CHECK: cmpd 0, 3, 4 # encoding: [0x7c,0x23,0x20,0x00] + cmpd 3, 4 # CHECK: cmpldi 2, 3, 128 # encoding: [0x29,0x23,0x00,0x80] cmpldi 2, 3, 128 +# CHECK: cmpldi 0, 3, 128 # encoding: [0x28,0x23,0x00,0x80] + cmpldi 3, 128 # CHECK: cmpld 2, 3, 4 # encoding: [0x7d,0x23,0x20,0x40] cmpld 2, 3, 4 +# CHECK: cmpld 0, 3, 4 # encoding: [0x7c,0x23,0x20,0x40] + cmpld 3, 4 # CHECK: cmpwi 2, 3, 128 # encoding: [0x2d,0x03,0x00,0x80] cmpwi 2, 3, 128 +# CHECK: cmpwi 0, 3, 128 # encoding: [0x2c,0x03,0x00,0x80] + cmpwi 3, 128 # CHECK: cmpw 2, 3, 4 # encoding: [0x7d,0x03,0x20,0x00] cmpw 2, 3, 4 +# CHECK: cmpw 0, 3, 4 # encoding: [0x7c,0x03,0x20,0x00] + cmpw 3, 4 # CHECK: cmplwi 2, 3, 128 # encoding: [0x29,0x03,0x00,0x80] cmplwi 2, 3, 128 +# CHECK: cmplwi 0, 3, 128 # encoding: [0x28,0x03,0x00,0x80] + cmplwi 3, 128 # CHECK: cmplw 2, 3, 4 # encoding: [0x7d,0x03,0x20,0x40] cmplw 2, 3, 4 +# CHECK: cmplw 0, 3, 4 # encoding: [0x7c,0x03,0x20,0x40] + cmplw 3, 4 # FIXME: Trap mnemonics Index: llvm-head/lib/Target/PowerPC/PPCInstrInfo.td =================================================================== --- llvm-head.orig/lib/Target/PowerPC/PPCInstrInfo.td +++ llvm-head/lib/Target/PowerPC/PPCInstrInfo.td @@ -2201,3 +2201,12 @@ defm : BranchExtendedMnemonic<"ne", 68>; defm : BranchExtendedMnemonic<"nu", 100>; defm : BranchExtendedMnemonic<"ns", 100>; +def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>; +def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>; +def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>; +def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>; +def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm:$imm)>; +def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>; +def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm:$imm)>; +def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>; + git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184435 91177308-0d34-0410-b5e6-96231b3b80d8 Ulrich Weigand 7 years ago
2 changed file(s) with 25 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
22002200 defm : BranchExtendedMnemonic<"nu", 100>;
22012201 defm : BranchExtendedMnemonic<"ns", 100>;
22022202
2203 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
2204 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
2205 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
2206 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
2207 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm:$imm)>;
2208 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
2209 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm:$imm)>;
2210 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
2211
448448
449449 # CHECK: cmpdi 2, 3, 128 # encoding: [0x2d,0x23,0x00,0x80]
450450 cmpdi 2, 3, 128
451 # CHECK: cmpdi 0, 3, 128 # encoding: [0x2c,0x23,0x00,0x80]
452 cmpdi 3, 128
451453 # CHECK: cmpd 2, 3, 4 # encoding: [0x7d,0x23,0x20,0x00]
452454 cmpd 2, 3, 4
455 # CHECK: cmpd 0, 3, 4 # encoding: [0x7c,0x23,0x20,0x00]
456 cmpd 3, 4
453457 # CHECK: cmpldi 2, 3, 128 # encoding: [0x29,0x23,0x00,0x80]
454458 cmpldi 2, 3, 128
459 # CHECK: cmpldi 0, 3, 128 # encoding: [0x28,0x23,0x00,0x80]
460 cmpldi 3, 128
455461 # CHECK: cmpld 2, 3, 4 # encoding: [0x7d,0x23,0x20,0x40]
456462 cmpld 2, 3, 4
463 # CHECK: cmpld 0, 3, 4 # encoding: [0x7c,0x23,0x20,0x40]
464 cmpld 3, 4
457465
458466 # CHECK: cmpwi 2, 3, 128 # encoding: [0x2d,0x03,0x00,0x80]
459467 cmpwi 2, 3, 128
468 # CHECK: cmpwi 0, 3, 128 # encoding: [0x2c,0x03,0x00,0x80]
469 cmpwi 3, 128
460470 # CHECK: cmpw 2, 3, 4 # encoding: [0x7d,0x03,0x20,0x00]
461471 cmpw 2, 3, 4
472 # CHECK: cmpw 0, 3, 4 # encoding: [0x7c,0x03,0x20,0x00]
473 cmpw 3, 4
462474 # CHECK: cmplwi 2, 3, 128 # encoding: [0x29,0x03,0x00,0x80]
463475 cmplwi 2, 3, 128
476 # CHECK: cmplwi 0, 3, 128 # encoding: [0x28,0x03,0x00,0x80]
477 cmplwi 3, 128
464478 # CHECK: cmplw 2, 3, 4 # encoding: [0x7d,0x03,0x20,0x40]
465479 cmplw 2, 3, 4
480 # CHECK: cmplw 0, 3, 4 # encoding: [0x7c,0x03,0x20,0x40]
481 cmplw 3, 4
466482
467483 # FIXME: Trap mnemonics
468484