[mips][microMIPSr6] Implement MUL, MUH, MULU and MUHU instructions
[oota-llvm.git] / lib / Target / Mips / MicroMips32r6InstrInfo.td
1 //=- MicroMips32r6InstrInfo.td - MicroMips r6 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 microMIPSr6 instructions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 //
16 // Instruction Encodings
17 //
18 //===----------------------------------------------------------------------===//
19 class ADD_MMR6_ENC : ARITH_FM_MMR6<"add", 0x110>;
20 class ADDIU_MMR6_ENC : ADDI_FM_MMR6<"addiu", 0xc>;
21 class ADDU_MMR6_ENC : ARITH_FM_MMR6<"addu", 0x150>;
22 class BALC_MMR6_ENC  : BRANCH_OFF26_FM<0b101101>;
23 class BC_MMR6_ENC : BRANCH_OFF26_FM<0b100101>;
24 class BITSWAP_MMR6_ENC : POOL32A_BITSWAP_FM_MMR6<0b101100>;
25 class CACHE_MMR6_ENC : CACHE_PREF_FM_MMR6<0b001000, 0b0110>;
26 class MUL_MMR6_ENC : ARITH_FM_MMR6<"mul", 0x18>;
27 class MUH_MMR6_ENC : ARITH_FM_MMR6<"muh", 0x58>;
28 class MULU_MMR6_ENC : ARITH_FM_MMR6<"mulu", 0x98>;
29 class MUHU_MMR6_ENC : ARITH_FM_MMR6<"muhu", 0xd8>;
30 class PREF_MMR6_ENC : CACHE_PREF_FM_MMR6<0b011000, 0b0010>;
31 class SUB_MMR6_ENC : ARITH_FM_MMR6<"sub", 0x190>;
32 class SUBU_MMR6_ENC : ARITH_FM_MMR6<"subu", 0x1d0>;
33
34 //===----------------------------------------------------------------------===//
35 //
36 // Instruction Descriptions
37 //
38 //===----------------------------------------------------------------------===//
39
40 class ADD_MMR6_DESC : ArithLogicR<"add", GPR32Opnd>;
41 class ADDIU_MMR6_DESC : ArithLogicI<"addiu", simm16, GPR32Opnd>;
42 class ADDU_MMR6_DESC : ArithLogicR<"addu", GPR32Opnd>;
43 class MUL_MMR6_DESC : ArithLogicR<"mul", GPR32Opnd>;
44 class MUH_MMR6_DESC : ArithLogicR<"muh", GPR32Opnd>;
45 class MULU_MMR6_DESC : ArithLogicR<"mulu", GPR32Opnd>;
46 class MUHU_MMR6_DESC : ArithLogicR<"muhu", GPR32Opnd>;
47
48 class BC_MMR6_DESC_BASE<string instr_asm, DAGOperand opnd>
49     : BRANCH_DESC_BASE, MMR6Arch<instr_asm> {
50   dag InOperandList = (ins opnd:$offset);
51   dag OutOperandList = (outs);
52   string AsmString = !strconcat(instr_asm, "\t$offset");
53   bit isBarrier = 1;
54 }
55
56 class BALC_MMR6_DESC : BC_MMR6_DESC_BASE<"balc", brtarget26> {
57   bit isCall = 1;
58   list<Register> Defs = [RA];
59 }
60 class BC_MMR6_DESC : BC_MMR6_DESC_BASE<"bc", brtarget26>;
61 class SUB_MMR6_DESC : ArithLogicR<"sub", GPR32Opnd>;
62 class SUBU_MMR6_DESC : ArithLogicR<"subu", GPR32Opnd>;
63
64 class BITSWAP_MMR6_DESC_BASE<string instr_asm, RegisterOperand GPROpnd>
65     : MMR6Arch<instr_asm> {
66   dag OutOperandList = (outs GPROpnd:$rd);
67   dag InOperandList = (ins GPROpnd:$rt);
68   string AsmString = !strconcat(instr_asm, "\t$rd, $rt");
69   list<dag> Pattern = [];
70 }
71
72 class BITSWAP_MMR6_DESC : BITSWAP_MMR6_DESC_BASE<"bitswap", GPR32Opnd>;
73
74 class CACHE_HINT_MMR6_DESC<string instr_asm, Operand MemOpnd,
75                            RegisterOperand GPROpnd> : MMR6Arch<instr_asm> {
76   dag OutOperandList = (outs);
77   dag InOperandList = (ins MemOpnd:$addr, uimm5:$hint);
78   string AsmString = !strconcat(instr_asm, "\t$hint, $addr");
79   list<dag> Pattern = [];
80   string DecoderMethod = "DecodeCacheOpMM";
81 }
82
83 class CACHE_MMR6_DESC : CACHE_HINT_MMR6_DESC<"cache", mem_mm_12, GPR32Opnd>;
84 class PREF_MMR6_DESC : CACHE_HINT_MMR6_DESC<"pref", mem_mm_12, GPR32Opnd>;
85
86 //===----------------------------------------------------------------------===//
87 //
88 // Instruction Definitions
89 //
90 //===----------------------------------------------------------------------===//
91
92 let DecoderNamespace = "MicroMips32r6" in {
93 def ADD_MMR6 : StdMMR6Rel, ADD_MMR6_DESC, ADD_MMR6_ENC, ISA_MICROMIPS32R6;
94 def ADDIU_MMR6 : StdMMR6Rel, ADDIU_MMR6_DESC, ADDIU_MMR6_ENC, ISA_MICROMIPS32R6;
95 def ADDU_MMR6 : StdMMR6Rel, ADDU_MMR6_DESC, ADDU_MMR6_ENC, ISA_MICROMIPS32R6;
96 def BALC_MMR6 : R6MMR6Rel, BALC_MMR6_ENC, BALC_MMR6_DESC, ISA_MICROMIPS32R6;
97 def BC_MMR6 : R6MMR6Rel, BC_MMR6_ENC, BC_MMR6_DESC, ISA_MICROMIPS32R6;
98 def BITSWAP_MMR6 : R6MMR6Rel, BITSWAP_MMR6_ENC, BITSWAP_MMR6_DESC,
99                    ISA_MICROMIPS32R6;
100 def CACHE_MMR6 : R6MMR6Rel, CACHE_MMR6_ENC, CACHE_MMR6_DESC, ISA_MICROMIPS32R6;
101 def MUL_MMR6 : R6MMR6Rel, MUL_MMR6_DESC, MUL_MMR6_ENC, ISA_MICROMIPS32R6;
102 def MUH_MMR6 : R6MMR6Rel, MUH_MMR6_DESC, MUH_MMR6_ENC, ISA_MICROMIPS32R6;
103 def MULU_MMR6 : R6MMR6Rel, MULU_MMR6_DESC, MULU_MMR6_ENC, ISA_MICROMIPS32R6;
104 def MUHU_MMR6 : R6MMR6Rel, MUHU_MMR6_DESC, MUHU_MMR6_ENC, ISA_MICROMIPS32R6;
105 def PREF_MMR6 : R6MMR6Rel, PREF_MMR6_ENC, PREF_MMR6_DESC, ISA_MICROMIPS32R6;
106 def SUB_MMR6 : StdMMR6Rel, SUB_MMR6_DESC, SUB_MMR6_ENC, ISA_MICROMIPS32R6;
107 def SUBU_MMR6 : StdMMR6Rel, SUBU_MMR6_DESC, SUBU_MMR6_ENC, ISA_MICROMIPS32R6;
108 }