Initial Mips support, here we go! =)
[oota-llvm.git] / lib / Target / Mips / MipsInstrFormats.td
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
25 class MipsInst<dag ops, string asmstr, list<dag> pattern>: 
26       Instruction 
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   
37   dag OperandList = ops;
38   let AsmString   = asmstr;
39   let Pattern     = pattern;
40 }
41
42
43 //===----------------------------------------------------------------------===//
44 // Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|>
45 //===----------------------------------------------------------------------===//
46
47 class FR<bits<6> op, bits<6> _funct, dag ops, string asmstr, list<dag> pattern>:
48       MipsInst<ops, asmstr, pattern> 
49 {
50   bits<5>  rd;
51   bits<5>  rs;
52   bits<5>  rt;
53   bits<5>  shamt;
54   bits<6>  funct;
55
56   let opcode = op;
57   let funct  = _funct;
58
59   let Inst{25-21} = rs;
60   let Inst{20-16} = rt; 
61   let Inst{15-11} = rd;
62   let Inst{10-6}  = shamt;
63   let Inst{5-0}   = funct;
64 }
65
66 //===----------------------------------------------------------------------===//
67 // Format I instruction class in Mips : <|opcode|rs|rt|immediate|>
68 //===----------------------------------------------------------------------===//
69
70 class FI<bits<6> op, dag ops, string asmstr, list<dag> pattern>: 
71       MipsInst<ops, asmstr, pattern> 
72 {
73   bits<5>  rt;
74   bits<5>  rs;
75   bits<16> imm16;
76
77   let opcode = op;
78
79   let Inst{25-21} = rs;
80   let Inst{20-16} = rt; 
81   let Inst{15-0}  = imm16;
82 }
83
84 //===----------------------------------------------------------------------===//
85 // Format J instruction class in Mips : <|opcode|address|>
86 //===----------------------------------------------------------------------===//
87
88 class FJ<bits<6> op, dag ops, string asmstr, list<dag> pattern>: 
89       MipsInst<ops, asmstr, pattern> 
90 {
91   bits<26> addr;
92
93   let opcode = op;
94   
95   let Inst{25-0} = addr;
96 }