Mips64 arithmetic and logical instructions with one source register and
[oota-llvm.git] / lib / Target / Mips / Mips64InstrInfo.td
1 //===- Mips64InstrInfo.td - Mips64 Instruction Information -*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes Mips64 instructions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 // Mips64 Instruction Predicate Definitions.
16 //===----------------------------------------------------------------------===//
17 def HasMips64    : Predicate<"Subtarget.hasMips64()">;
18 def HasMips64r2  : Predicate<"Subtarget.hasMips64r2()">;
19
20 //===----------------------------------------------------------------------===//
21 // Mips Operand, Complex Patterns and Transformations Definitions.
22 //===----------------------------------------------------------------------===//
23
24 // Instruction operand types
25 def simm16_64      : Operand<i64>;
26
27 // Unsigned Operand
28 def uimm16_64      : Operand<i64> {
29   let PrintMethod = "printUnsignedImm";
30 }
31
32 //===----------------------------------------------------------------------===//
33 // Instructions specific format
34 //===----------------------------------------------------------------------===//
35
36 // Arithmetic 3 register operands
37 class ArithR64<bits<6> op, bits<6> func, string instr_asm, SDNode OpNode,
38                InstrItinClass itin, bit isComm = 0>:
39   FR<op, func, (outs CPU64Regs:$dst), (ins CPU64Regs:$b, CPU64Regs:$c),
40      !strconcat(instr_asm, "\t$dst, $b, $c"),
41      [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, CPU64Regs:$c))], itin> {
42   let isCommutable = isComm;
43 }
44
45 // Arithmetic 2 register operands
46 class ArithI64<bits<6> op, string instr_asm, SDNode OpNode,
47                Operand Od, PatLeaf imm_type> :
48   FI<op, (outs CPU64Regs:$dst), (ins CPU64Regs:$b, Od:$c),
49      !strconcat(instr_asm, "\t$dst, $b, $c"),
50      [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, imm_type:$c))], IIAlu>;
51
52 //  Logical
53 let isCommutable = 1 in
54 class LogicR64<bits<6> func, string instr_asm, SDNode OpNode>:
55   FR<0x00, func, (outs CPU64Regs:$dst), (ins CPU64Regs:$b, CPU64Regs:$c),
56      !strconcat(instr_asm, "\t$dst, $b, $c"),
57      [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, CPU64Regs:$c))], IIAlu>;
58
59 class LogicI64<bits<6> op, string instr_asm, SDNode OpNode>:
60   FI<op, (outs CPU64Regs:$dst), (ins CPU64Regs:$b, uimm16_64:$c),
61      !strconcat(instr_asm, "\t$dst, $b, $c"),
62      [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, immZExt16:$c))], IIAlu>;
63
64 //===----------------------------------------------------------------------===//
65 // Instruction definition
66 //===----------------------------------------------------------------------===//
67
68 /// Arithmetic Instructions (ALU Immediate)
69 def DADDiu   : ArithI64<0x19, "daddiu", add, simm16_64, immSExt16>;
70 def DANDi    : LogicI64<0x0c, "andi", and>;
71 def DORi     : LogicI64<0x0d, "ori",  or>;
72 def DXORi    : LogicI64<0x0e, "xori",  xor>;
73
74 /// Arithmetic Instructions (3-Operand, R-Type)
75 def DADDu    : ArithR64<0x00, 0x2d, "daddu", add, IIAlu, 1>;
76 def DSUBu    : ArithR64<0x00, 0x2f, "dsubu", sub, IIAlu, 1>;
77 def DAND     : LogicR64<0x24, "and", and>;
78 def DOR      : LogicR64<0x25, "or", or>;
79 def DXOR     : LogicR64<0x26, "xor", xor>;