]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/lib/Target/Nios2/Nios2InstrFormats.td
Merge llvm, clang, lld, lldb, compiler-rt and libc++ r304149, and update
[FreeBSD/FreeBSD.git] / contrib / llvm / lib / Target / Nios2 / Nios2InstrFormats.td
1 //===-- Nios2InstrFormats.td - Nios2 Instruction Formats ---*- 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 //===----------------------------------------------------------------------===//
11 //  Describe NIOS2 instructions format
12 //
13 //
14 //===----------------------------------------------------------------------===//
15
16 // Format specifies the encoding used by the instruction.  This is part of the
17 // ad-hoc solution used to emit machine instruction encodings by our machine
18 // code emitter.
19 class Format<bits<3> val> {
20   bits<3> Value = val;
21 }
22
23 def Pseudo : Format<0>;
24 def FrmI : Format<1>;
25 def FrmR : Format<2>;
26 def FrmJ : Format<3>;
27 def FrmOther : Format<4>; // Instruction w/ a custom format
28
29 // Generic Nios2 Format
30 class Nios2Inst<dag outs, dag ins, string asmstr, list<dag> pattern, Format f>
31     : Instruction {
32   field bits<32> Inst;
33   Format Form = f;
34
35   let Namespace = "Nios2";
36
37   let Size = 4;
38
39   bits<6> Opcode = 0;
40
41   // Bottom 6 bits are the 'opcode' field
42   let Inst{5 - 0} = Opcode;
43
44   let OutOperandList = outs;
45   let InOperandList = ins;
46
47   let AsmString = asmstr;
48   let Pattern = pattern;
49
50   //
51   // Attributes specific to Nios2 instructions:
52   //
53   bits<3> FormBits = Form.Value;
54
55   // TSFlags layout should be kept in sync with Nios2InstrInfo.h.
56   let TSFlags{2 - 0} = FormBits;
57
58   let DecoderNamespace = "Nios2";
59 }
60
61 // Nios2 Instruction Format
62 class InstSE<dag outs, dag ins, string asmstr, list<dag> pattern, Format f>
63     : Nios2Inst<outs, ins, asmstr, pattern, f> {
64 }
65
66 //===----------------------------------------------------------------------===//
67 // Format I instruction class in Nios2 : <|A|B|immediate|opcode|>
68 //===----------------------------------------------------------------------===//
69
70 class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>
71     : InstSE<outs, ins, asmstr, pattern, FrmI> {
72   bits<5> rA;
73   bits<5> rB;
74   bits<16> imm;
75
76   let Opcode = op;
77
78   let Inst{31 - 27} = rA;
79   let Inst{26 - 22} = rB;
80   let Inst{21 - 6} = imm;
81 }
82
83 //===----------------------------------------------------------------------===//
84 // Format R instruction : <|A|B|C|opx|imm|opcode|>
85 //===----------------------------------------------------------------------===//
86
87 class FR<bits<6> opx, dag outs, dag ins, string asmstr, list<dag> pattern>
88     : InstSE<outs, ins, asmstr, pattern, FrmR> {
89   bits<5> rA;
90   bits<5> rB;
91   bits<5> rC;
92   bits<5> imm = 0;
93
94   // opcode is always 0x3a for R instr.
95   let Opcode = 0x3a;
96
97   let Inst{31 - 27} = rA;
98   let Inst{26 - 22} = rB;
99   let Inst{21 - 17} = rC;
100   // opx stands for opcode extension
101   let Inst{16 - 11} = opx;
102   // optional 5-bit immediate value
103   let Inst{10 - 6}  = imm;
104 }
105
106 //===----------------------------------------------------------------------===//
107 // Format J instruction class in Nios2 : <|address|opcode|>
108 //===----------------------------------------------------------------------===//
109
110 class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>
111     : InstSE<outs, ins, asmstr, pattern, FrmJ> {
112   bits<26> addr;
113
114   let Opcode = op;
115
116   let Inst{31 - 6} = addr;
117 }