diff --git a/llvm/lib/Target/ARC/ARCInstrFormats.td b/llvm/lib/Target/ARC/ARCInstrFormats.td --- a/llvm/lib/Target/ARC/ARCInstrFormats.td +++ b/llvm/lib/Target/ARC/ARCInstrFormats.td @@ -262,7 +262,8 @@ } // Single Operand Immediate Instructions. -// 1-register, unsigned 6-bit immediate Single Operand instruction. +// 1-register, unsigned 6-bit immediate Single Operand instruction with +// condition code. // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0| // |B[2-0] | 1| 1| subop| F|B[5-3] |U6 |1|cc | class F32_SOP_CC_RU6 major, bits<6> subop, bit F, dag outs, dag ins, @@ -352,6 +353,30 @@ let Inst{5-0} = A; } +// 2-register, unsigned 6-bit immediate Dual Operand instruction with +// condition code. This instruction uses B as the first 2 operands +// (i.e, add.cc B, B, u6). +// |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0| +// |B[2-0] | 1| 1| subop| F|B[5-3] |U6 |1|cc | +class F32_DOP_CC_RRU6 major, bits<6> subop, bit F, dag outs, dag ins, + string asmstr, list pattern> : + InstARC<4, outs, ins, asmstr, pattern> { + bits<5> cc; + bits<6> U6; + bits<6> B; + bits<6> A; + + let Inst{31-27} = major; + let Inst{26-24} = B{2-0}; + let Inst{23-22} = 0b11; + let Inst{21-16} = subop; + let Inst{15} = F; + let Inst{14-12} = B{5-3}; + let Inst{11-6} = U6; + let Inst{5} = 1; + let Inst{4-0} = cc; +} + // 2-register, signed 12-bit immediate Dual Operand instruction. // This instruction uses B as the first 2 operands (i.e., add B, B, -128). // |26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|9|8|7|6|5|4|3|2|1|0| diff --git a/llvm/lib/Target/ARC/ARCInstrInfo.td b/llvm/lib/Target/ARC/ARCInstrInfo.td --- a/llvm/lib/Target/ARC/ARCInstrInfo.td +++ b/llvm/lib/Target/ARC/ARCInstrInfo.td @@ -160,6 +160,23 @@ []> { let Defs = [STATUS32]; } + def _cc_rru6 : F32_DOP_CC_RRU6 { + let Uses = [STATUS32]; + let Constraints = "$A = $B"; + } + + def _cc_f_rru6 : F32_DOP_CC_RRU6 { + let Defs = [STATUS32]; + let Uses = [STATUS32]; + let Constraints = "$A = $B"; + } + // 2 register with 32-bit immediate variant. def _rrlimm : F32_DOP_RLIMM; defm SUB2 : ArcBinaryGEN4Inst<0b011000, "sub2">; defm SUB3 : ArcBinaryGEN4Inst<0b011001, "sub3">; +defm RSUB : ArcBinaryGEN4Inst<0b001110, "rsub">; defm OR : ArcBinaryGEN4Inst<0b000101, "or",1>; defm AND : ArcBinaryGEN4Inst<0b000100, "and",1>; defm XOR : ArcBinaryGEN4Inst<0b000111, "xor",1>; diff --git a/llvm/test/MC/Disassembler/ARC/alu.txt b/llvm/test/MC/Disassembler/ARC/alu.txt --- a/llvm/test/MC/Disassembler/ARC/alu.txt +++ b/llvm/test/MC/Disassembler/ARC/alu.txt @@ -104,3 +104,12 @@ # CHECK: sub3.f %fp, %fp, -1 0x99 0x23 0xff 0xbf + +# CHECK: rsub.eq %r0, %r0, 30 +0xce 0x20 0xa1 0x07 + +# CHECK: rsub.ne %r0, %r0, 31 +0xce 0x20 0xe2 0x07 + +# CHECK: rsub.ne.f %r0, %r0, 31 +0xce 0x20 0xe2 0x87 diff --git a/llvm/test/MC/Disassembler/ARC/misc.txt b/llvm/test/MC/Disassembler/ARC/misc.txt --- a/llvm/test/MC/Disassembler/ARC/misc.txt +++ b/llvm/test/MC/Disassembler/ARC/misc.txt @@ -16,6 +16,12 @@ # CHECK: mov %r1, 20 0x4a 0x21 0x00 0x05 +# CHECK: mov.eq %r0, 32 +0xca 0x20 0x21 0x08 + +# CHECK: mov.ne %r0, 0 +0xca 0x20 0x22 0x00 + # CHECK: st.aw %fp, [%sp,-4] 0xfc 0x1c 0xc8 0xb6