blob: caeabd5b5e7ef437329649d5cc4a506b5f0d88cf [file] [log] [blame]
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00001//===- MipsRegisterInfo.td - Mips Register defs -----------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +00007//
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 Lopese88c3682007-08-18 02:01:28 +000025class MipsInst<dag outs, dag ins, string asmstr, list<dag> pattern,
26 InstrItinClass itin>: Instruction
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000027{
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 Cheng64d80e32007-07-19 01:14:50 +000037 dag OutOperandList = outs;
Bruno Cardoso Lopese88c3682007-08-18 02:01:28 +000038 dag InOperandList = ins;
39
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000040 let AsmString = asmstr;
41 let Pattern = pattern;
Bruno Cardoso Lopesedeede22007-08-21 16:06:45 +000042 let Itinerary = itin;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000043}
44
Bruno Cardoso Lopese78080c2007-10-09 02:55:31 +000045// Mips Pseudo Instructions Format
46class PseudoInstMips<dag outs, dag ins, string asmstr, list<dag> pattern>:
47 MipsInst<outs, ins, asmstr, pattern, IIPseudo>;
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000048
49//===----------------------------------------------------------------------===//
50// Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|>
51//===----------------------------------------------------------------------===//
52
Evan Cheng64d80e32007-07-19 01:14:50 +000053class FR<bits<6> op, bits<6> _funct, dag outs, dag ins, string asmstr,
Bruno Cardoso Lopese88c3682007-08-18 02:01:28 +000054 list<dag> pattern, InstrItinClass itin>:
55 MipsInst<outs, ins, asmstr, pattern, itin>
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000056{
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 Lopese88c3682007-08-18 02:01:28 +000077class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
78 InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin>
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000079{
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 Lopese88c3682007-08-18 02:01:28 +000095class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
96 InstrItinClass itin>: MipsInst<outs, ins, asmstr, pattern, itin>
Bruno Cardoso Lopes972f5892007-06-06 07:42:06 +000097{
98 bits<26> addr;
99
100 let opcode = op;
101
102 let Inst{25-0} = addr;
103}
Bruno Cardoso Lopese78080c2007-10-09 02:55:31 +0000104