blob: bda63629f31ac95ede1947f4c61a9d5b7203747b [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- 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
Evan Chengb783fa32007-07-19 01:14:50 +000025class MipsInst<dag outs, dag ins, string asmstr, list<dag> pattern>:
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026 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
Evan Chengb783fa32007-07-19 01:14:50 +000037 dag OutOperandList = outs;
38 dag InOperandList = ins;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000039 let AsmString = asmstr;
40 let Pattern = pattern;
41}
42
43
44//===----------------------------------------------------------------------===//
45// Format R instruction class in Mips : <|opcode|rs|rt|rd|shamt|funct|>
46//===----------------------------------------------------------------------===//
47
Evan Chengb783fa32007-07-19 01:14:50 +000048class FR<bits<6> op, bits<6> _funct, dag outs, dag ins, string asmstr,
49 list<dag> pattern>:
50 MipsInst<outs, ins, asmstr, pattern>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000051{
52 bits<5> rd;
53 bits<5> rs;
54 bits<5> rt;
55 bits<5> shamt;
56 bits<6> funct;
57
58 let opcode = op;
59 let funct = _funct;
60
61 let Inst{25-21} = rs;
62 let Inst{20-16} = rt;
63 let Inst{15-11} = rd;
64 let Inst{10-6} = shamt;
65 let Inst{5-0} = funct;
66}
67
68//===----------------------------------------------------------------------===//
69// Format I instruction class in Mips : <|opcode|rs|rt|immediate|>
70//===----------------------------------------------------------------------===//
71
Evan Chengb783fa32007-07-19 01:14:50 +000072class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>:
73 MipsInst<outs, ins, asmstr, pattern>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074{
75 bits<5> rt;
76 bits<5> rs;
77 bits<16> imm16;
78
79 let opcode = op;
80
81 let Inst{25-21} = rs;
82 let Inst{20-16} = rt;
83 let Inst{15-0} = imm16;
84}
85
86//===----------------------------------------------------------------------===//
87// Format J instruction class in Mips : <|opcode|address|>
88//===----------------------------------------------------------------------===//
89
Evan Chengb783fa32007-07-19 01:14:50 +000090class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>:
91 MipsInst<outs, ins, asmstr, pattern>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092{
93 bits<26> addr;
94
95 let opcode = op;
96
97 let Inst{25-0} = addr;
98}