Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===- MipsRegisterInfo.td - Mips Register defs -----------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | //===----------------------------------------------------------------------===// |
| 11 | // Describe MIPS instructions format |
| 12 | // |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 13 | // CPU INSTRUCTION FORMATS |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 14 | // |
| 15 | // opcode - operation code. |
| 16 | // rs - src reg. |
| 17 | // rt - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr). |
| 18 | // rd - dst reg, only used on 3 regs instr. |
| 19 | // shamt - only used on shift instructions, contains the shift amount. |
| 20 | // funct - combined with opcode field give us an operation code. |
| 21 | // |
| 22 | //===----------------------------------------------------------------------===// |
| 23 | |
| 24 | // Generic Mips Format |
Bruno Cardoso Lopes | d5c93b0 | 2007-08-18 02:01:28 +0000 | [diff] [blame] | 25 | class MipsInst<dag outs, dag ins, string asmstr, list<dag> pattern, |
| 26 | InstrItinClass itin>: Instruction |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 27 | { |
| 28 | field bits<32> Inst; |
| 29 | |
| 30 | let Namespace = "Mips"; |
| 31 | |
| 32 | bits<6> opcode; |
| 33 | |
| 34 | // Top 5 bits are the 'opcode' field |
| 35 | let Inst{31-26} = opcode; |
| 36 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 37 | dag OutOperandList = outs; |
Bruno Cardoso Lopes | d5c93b0 | 2007-08-18 02:01:28 +0000 | [diff] [blame] | 38 | dag InOperandList = ins; |
| 39 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 40 | let AsmString = asmstr; |
| 41 | let Pattern = pattern; |
Bruno Cardoso Lopes | 75971a0 | 2007-08-21 16:06:45 +0000 | [diff] [blame] | 42 | let Itinerary = itin; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 43 | } |
| 44 | |
Bruno Cardoso Lopes | 2cacce9 | 2007-10-09 02:55:31 +0000 | [diff] [blame] | 45 | // Mips Pseudo Instructions Format |
Bruno Cardoso Lopes | ed7723d | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 46 | class MipsPseudo<dag outs, dag ins, string asmstr, list<dag> pattern>: |
Bruno Cardoso Lopes | 2cacce9 | 2007-10-09 02:55:31 +0000 | [diff] [blame] | 47 | MipsInst<outs, ins, asmstr, pattern, IIPseudo>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 48 | |
| 49 | //===----------------------------------------------------------------------===// |
| 50 | // Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|> |
| 51 | //===----------------------------------------------------------------------===// |
| 52 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 53 | class FR<bits<6> op, bits<6> _funct, dag outs, dag ins, string asmstr, |
Bruno Cardoso Lopes | d5c93b0 | 2007-08-18 02:01:28 +0000 | [diff] [blame] | 54 | list<dag> pattern, InstrItinClass itin>: |
| 55 | MipsInst<outs, ins, asmstr, pattern, itin> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 56 | { |
| 57 | bits<5> rd; |
| 58 | bits<5> rs; |
| 59 | bits<5> rt; |
| 60 | bits<5> shamt; |
| 61 | bits<6> funct; |
| 62 | |
| 63 | let opcode = op; |
| 64 | let funct = _funct; |
| 65 | |
| 66 | let Inst{25-21} = rs; |
| 67 | let Inst{20-16} = rt; |
| 68 | let Inst{15-11} = rd; |
| 69 | let Inst{10-6} = shamt; |
| 70 | let Inst{5-0} = funct; |
| 71 | } |
| 72 | |
| 73 | //===----------------------------------------------------------------------===// |
| 74 | // Format I instruction class in Mips : <|opcode|rs|rt|immediate|> |
| 75 | //===----------------------------------------------------------------------===// |
| 76 | |
Bruno Cardoso Lopes | d5c93b0 | 2007-08-18 02:01:28 +0000 | [diff] [blame] | 77 | class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern, |
| 78 | InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 79 | { |
| 80 | bits<5> rt; |
| 81 | bits<5> rs; |
| 82 | bits<16> imm16; |
| 83 | |
| 84 | let opcode = op; |
| 85 | |
| 86 | let Inst{25-21} = rs; |
| 87 | let Inst{20-16} = rt; |
| 88 | let Inst{15-0} = imm16; |
| 89 | } |
| 90 | |
| 91 | //===----------------------------------------------------------------------===// |
| 92 | // Format J instruction class in Mips : <|opcode|address|> |
| 93 | //===----------------------------------------------------------------------===// |
| 94 | |
Bruno Cardoso Lopes | d5c93b0 | 2007-08-18 02:01:28 +0000 | [diff] [blame] | 95 | class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern, |
| 96 | InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 97 | { |
| 98 | bits<26> addr; |
| 99 | |
| 100 | let opcode = op; |
| 101 | |
| 102 | let Inst{25-0} = addr; |
| 103 | } |
Bruno Cardoso Lopes | 2cacce9 | 2007-10-09 02:55:31 +0000 | [diff] [blame] | 104 | |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 105 | //===----------------------------------------------------------------------===// |
| 106 | // |
Bruno Cardoso Lopes | 6801170 | 2008-07-09 04:45:36 +0000 | [diff] [blame^] | 107 | // FLOATING POINT INSTRUCTION FORMATS |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 108 | // |
| 109 | // opcode - operation code. |
| 110 | // fs - src reg. |
| 111 | // ft - dst reg (on a 2 regs instr) or src reg (on a 3 reg instr). |
| 112 | // fd - dst reg, only used on 3 regs instr. |
| 113 | // fmt - double or single precision. |
| 114 | // funct - combined with opcode field give us an operation code. |
| 115 | // |
| 116 | //===----------------------------------------------------------------------===// |
| 117 | |
| 118 | //===----------------------------------------------------------------------===// |
| 119 | // Format FR instruction class in Mips : <|opcode|fmt|ft|fs|fd|funct|> |
| 120 | //===----------------------------------------------------------------------===// |
| 121 | |
| 122 | class FFR<bits<6> op, bits<6> _funct, bits<5> _fmt, dag outs, dag ins, |
Bruno Cardoso Lopes | 4fb1f54 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 123 | string asmstr, list<dag> pattern> : |
| 124 | MipsInst<outs, ins, asmstr, pattern, NoItinerary> |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 125 | { |
| 126 | bits<5> fd; |
| 127 | bits<5> fs; |
| 128 | bits<5> ft; |
| 129 | bits<5> fmt; |
| 130 | bits<6> funct; |
| 131 | |
| 132 | let opcode = op; |
| 133 | let funct = _funct; |
| 134 | let fmt = _fmt; |
| 135 | |
| 136 | let Inst{25-21} = fmt; |
| 137 | let Inst{20-16} = ft; |
| 138 | let Inst{15-11} = fs; |
| 139 | let Inst{10-6} = fd; |
| 140 | let Inst{5-0} = funct; |
| 141 | } |
| 142 | |
| 143 | //===----------------------------------------------------------------------===// |
Bruno Cardoso Lopes | 4fb1f54 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 144 | // Format FI instruction class in Mips : <|opcode|base|ft|immediate|> |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 145 | //===----------------------------------------------------------------------===// |
| 146 | |
Bruno Cardoso Lopes | 4fb1f54 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 147 | class FFI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>: |
| 148 | MipsInst<outs, ins, asmstr, pattern, NoItinerary> |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 149 | { |
| 150 | bits<5> ft; |
Bruno Cardoso Lopes | 4fb1f54 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 151 | bits<5> base; |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 152 | bits<16> imm16; |
| 153 | |
| 154 | let opcode = op; |
Bruno Cardoso Lopes | 4fb1f54 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 155 | |
| 156 | let Inst{25-21} = base; |
| 157 | let Inst{20-16} = ft; |
| 158 | let Inst{15-0} = imm16; |
| 159 | } |
| 160 | |
| 161 | //===----------------------------------------------------------------------===// |
| 162 | // Compare instruction class in Mips : <|010001|fmt|ft|fs|0000011|condcode|> |
| 163 | //===----------------------------------------------------------------------===// |
| 164 | |
| 165 | class FCC<bits<5> _fmt, dag outs, dag ins, string asmstr, list<dag> pattern> : |
| 166 | MipsInst<outs, ins, asmstr, pattern, NoItinerary> |
| 167 | { |
| 168 | bits<5> fs; |
| 169 | bits<5> ft; |
| 170 | bits<4> cc; |
| 171 | bits<5> fmt; |
| 172 | |
| 173 | let opcode = 0x11; |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 174 | let fmt = _fmt; |
| 175 | |
| 176 | let Inst{25-21} = fmt; |
| 177 | let Inst{20-16} = ft; |
Bruno Cardoso Lopes | 4fb1f54 | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 178 | let Inst{15-11} = fs; |
| 179 | let Inst{10-6} = 0; |
| 180 | let Inst{5-4} = 0b11; |
| 181 | let Inst{3-0} = cc; |
Bruno Cardoso Lopes | 60727e3 | 2008-06-08 01:39:36 +0000 | [diff] [blame] | 182 | } |