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 | // |
| 5 | // This file was developed by Bruno Cardoso Lopes and is distributed under the |
| 6 | // University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | //===----------------------------------------------------------------------===// |
| 11 | // Describe MIPS instructions format |
| 12 | // |
| 13 | // All the possible Mips fields are: |
| 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 | |
| 45 | |
| 46 | //===----------------------------------------------------------------------===// |
| 47 | // Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|> |
| 48 | //===----------------------------------------------------------------------===// |
| 49 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 50 | 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] | 51 | list<dag> pattern, InstrItinClass itin>: |
| 52 | MipsInst<outs, ins, asmstr, pattern, itin> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 53 | { |
| 54 | bits<5> rd; |
| 55 | bits<5> rs; |
| 56 | bits<5> rt; |
| 57 | bits<5> shamt; |
| 58 | bits<6> funct; |
| 59 | |
| 60 | let opcode = op; |
| 61 | let funct = _funct; |
| 62 | |
| 63 | let Inst{25-21} = rs; |
| 64 | let Inst{20-16} = rt; |
| 65 | let Inst{15-11} = rd; |
| 66 | let Inst{10-6} = shamt; |
| 67 | let Inst{5-0} = funct; |
| 68 | } |
| 69 | |
| 70 | //===----------------------------------------------------------------------===// |
| 71 | // Format I instruction class in Mips : <|opcode|rs|rt|immediate|> |
| 72 | //===----------------------------------------------------------------------===// |
| 73 | |
Bruno Cardoso Lopes | d5c93b0 | 2007-08-18 02:01:28 +0000 | [diff] [blame] | 74 | class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern, |
| 75 | InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 76 | { |
| 77 | bits<5> rt; |
| 78 | bits<5> rs; |
| 79 | bits<16> imm16; |
| 80 | |
| 81 | let opcode = op; |
| 82 | |
| 83 | let Inst{25-21} = rs; |
| 84 | let Inst{20-16} = rt; |
| 85 | let Inst{15-0} = imm16; |
| 86 | } |
| 87 | |
| 88 | //===----------------------------------------------------------------------===// |
| 89 | // Format J instruction class in Mips : <|opcode|address|> |
| 90 | //===----------------------------------------------------------------------===// |
| 91 | |
Bruno Cardoso Lopes | d5c93b0 | 2007-08-18 02:01:28 +0000 | [diff] [blame] | 92 | class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern, |
| 93 | InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin> |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 94 | { |
| 95 | bits<26> addr; |
| 96 | |
| 97 | let opcode = op; |
| 98 | |
| 99 | let Inst{25-0} = addr; |
| 100 | } |