595ef1da6116357ff0ce00ed16714de517b0a958
[oota-llvm.git] / lib / Target / MBlaze / MBlazeInstrFormats.td
1 //===- MBlazeInstrFormats.td - MB Instruction defs ---------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // Format specifies the encoding used by the instruction.  This is part of the
11 // ad-hoc solution used to emit machine instruction encodings by our machine
12 // code emitter.
13 class Format<bits<6> val> {
14       bits<6> Value = val;
15 }
16
17 def FPseudo : Format<0>;
18 def FRRR    : Format<1>;
19 def FRRI    : Format<2>;
20 def FRIR    : Format<3>;
21 def FFSL    : Format<4>;
22 def FFSLD   : Format<5>;
23 def FFSLT   : Format<6>;
24 def FFSLTD  : Format<7>;
25 def FR      : Format<8>;
26 def FI      : Format<9>;
27 def FRR     : Format<10>;
28 def FRI     : Format<11>;
29
30 //===----------------------------------------------------------------------===//
31 //  Describe MBlaze instructions format
32 //
33 //  CPU INSTRUCTION FORMATS
34 //
35 //  opcode  - operation code.
36 //  rd      - dst reg.
37 //  ra      - first src. reg.
38 //  rb      - second src. reg.
39 //  imm16   - 16-bit immediate value.
40 //
41 //===----------------------------------------------------------------------===//
42
43 // Generic MBlaze Format
44 class MBlazeInst<bits<6> op, Format form, dag outs, dag ins, string asmstr, 
45                  list<dag> pattern, InstrItinClass itin> : Instruction 
46 {
47   let Namespace = "MBlaze";
48   field bits<32> Inst;
49
50   bits<6> opcode = op;
51   Format Form = form;
52   bits<6> FormBits = Form.Value;
53
54   // Top 6 bits are the 'opcode' field
55   let Inst{0-5} = opcode;   
56   
57   dag OutOperandList = outs;
58   dag InOperandList  = ins;
59
60   let AsmString   = asmstr;
61   let Pattern     = pattern;
62   let Itinerary   = itin;
63
64   // TSFlags layout should be kept in sync with MBlazeInstrInfo.h.
65   let TSFlags{5-0}   = FormBits;
66 }
67
68 //===----------------------------------------------------------------------===//
69 // Pseudo instruction class
70 //===----------------------------------------------------------------------===//
71 class MBlazePseudo<dag outs, dag ins, string asmstr, list<dag> pattern>:
72       MBlazeInst<0x0, FPseudo, outs, ins, asmstr, pattern, IIPseudo>;
73
74 //===----------------------------------------------------------------------===//
75 // Type A instruction class in MBlaze : <|opcode|rd|ra|rb|flags|>
76 //===----------------------------------------------------------------------===//
77
78 class TA<bits<6> op, bits<11> flags, dag outs, dag ins, string asmstr,
79          list<dag> pattern, InstrItinClass itin> : 
80          MBlazeInst<op,FRRR,outs, ins, asmstr, pattern, itin> 
81 {
82   bits<5> rd;
83   bits<5> ra;
84   bits<5> rb;
85
86   let Inst{6-10}  = rd;
87   let Inst{11-15} = ra; 
88   let Inst{16-20} = rb;
89   let Inst{21-31} = flags;
90 }
91
92 //===----------------------------------------------------------------------===//
93 // Type B instruction class in MBlaze : <|opcode|rd|ra|immediate|>
94 //===----------------------------------------------------------------------===//
95
96 class TB<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
97          InstrItinClass itin> : 
98          MBlazeInst<op, FRRI, outs, ins, asmstr, pattern, itin> 
99 {
100   bits<5>  rd;
101   bits<5>  ra;
102   bits<16> imm16;
103
104   let Inst{6-10}  = rd;
105   let Inst{11-15} = ra; 
106   let Inst{16-31} = imm16;
107 }
108
109 //===----------------------------------------------------------------------===//
110 // Type B instruction class in MBlaze but with the operands reversed in
111 // the LLVM DAG : <|opcode|rd|ra|immediate|>
112 //===----------------------------------------------------------------------===//
113 class TBR<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern,
114          InstrItinClass itin> : 
115          TB<op, outs, ins, asmstr, pattern, itin> {
116   bits<5>  rrd;
117   bits<16> rimm16;
118   bits<5>  rra;
119
120   let Form = FRIR;
121
122   let rd = rrd;
123   let ra = rra;
124   let imm16 = rimm16;
125 }