1 //===-- Nios2InstrFormats.td - Nios2 Instruction Formats ---*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
11 // Describe NIOS2 instructions format
14 //===----------------------------------------------------------------------===//
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
19 class Format<bits<3> val> {
23 def Pseudo : Format<0>;
27 def FrmOther : Format<4>; // Instruction w/ a custom format
29 // Generic Nios2 Format
30 class Nios2Inst<dag outs, dag ins, string asmstr, list<dag> pattern, Format f>
35 let Namespace = "Nios2";
41 // Bottom 6 bits are the 'opcode' field
42 let Inst{5 - 0} = Opcode;
44 let OutOperandList = outs;
45 let InOperandList = ins;
47 let AsmString = asmstr;
48 let Pattern = pattern;
51 // Attributes specific to Nios2 instructions:
53 bits<3> FormBits = Form.Value;
55 // TSFlags layout should be kept in sync with Nios2InstrInfo.h.
56 let TSFlags{2 - 0} = FormBits;
58 let DecoderNamespace = "Nios2";
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> {
66 //===----------------------------------------------------------------------===//
67 // Format I instruction class in Nios2 : <|A|B|immediate|opcode|>
68 //===----------------------------------------------------------------------===//
70 class FI<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>
71 : InstSE<outs, ins, asmstr, pattern, FrmI> {
78 let Inst{31 - 27} = rA;
79 let Inst{26 - 22} = rB;
80 let Inst{21 - 6} = imm;
83 //===----------------------------------------------------------------------===//
84 // Format R instruction : <|A|B|C|opx|imm|opcode|>
85 //===----------------------------------------------------------------------===//
87 class FR<bits<6> opx, dag outs, dag ins, string asmstr, list<dag> pattern>
88 : InstSE<outs, ins, asmstr, pattern, FrmR> {
94 // opcode is always 0x3a for R instr.
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;
106 //===----------------------------------------------------------------------===//
107 // Format J instruction class in Nios2 : <|address|opcode|>
108 //===----------------------------------------------------------------------===//
110 class FJ<bits<6> op, dag outs, dag ins, string asmstr, list<dag> pattern>
111 : InstSE<outs, ins, asmstr, pattern, FrmJ> {
116 let Inst{31 - 6} = addr;