Skip to content

Commit 82ecbdc

Browse files
committed
[RTGTest] Improved register representation
1 parent 98b463d commit 82ecbdc

29 files changed

+1387
-287
lines changed

include/circt-c/Dialect/RTGTest.h

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,201 @@ MLIR_CAPI_EXPORTED MlirAttribute rtgtestCPUAttrGet(MlirContext ctxt,
4545
/// Returns the core ID represented by the CPU attribute.
4646
MLIR_CAPI_EXPORTED unsigned rtgtestCPUAttrGetId(MlirAttribute attr);
4747

48+
// Registers.
49+
//===----------------------------------------------------------------------===//
50+
51+
/// If the type is an RTGTest RegZeroAttr.
52+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegZero(MlirAttribute attr);
53+
54+
/// Creates an RTGTest RegZero attribute in the context.
55+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegZeroAttrGet(MlirContext ctxt);
56+
57+
/// If the attribute is an RTGTest RegRaAttr.
58+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegRa(MlirAttribute attr);
59+
60+
/// Creates an RTGTest RegRa attribute in the context.
61+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegRaAttrGet(MlirContext ctxt);
62+
63+
/// If the attribute is an RTGTest RegSpAttr.
64+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegSp(MlirAttribute attr);
65+
66+
/// Creates an RTGTest RegSp attribute in the context.
67+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegSpAttrGet(MlirContext ctxt);
68+
69+
/// If the attribute is an RTGTest RegGpAttr.
70+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegGp(MlirAttribute attr);
71+
72+
/// Creates an RTGTest RegGp attribute in the context.
73+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegGpAttrGet(MlirContext ctxt);
74+
75+
/// If the attribute is an RTGTest RegTpAttr.
76+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegTp(MlirAttribute attr);
77+
78+
/// Creates an RTGTest RegTp attribute in the context.
79+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegTpAttrGet(MlirContext ctxt);
80+
81+
/// If the attribute is an RTGTest RegT0Attr.
82+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegT0(MlirAttribute attr);
83+
84+
/// Creates an RTGTest RegT0 attribute in the context.
85+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegT0AttrGet(MlirContext ctxt);
86+
87+
/// If the attribute is an RTGTest RegT1Attr.
88+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegT1(MlirAttribute attr);
89+
90+
/// Creates an RTGTest RegT1 attribute in the context.
91+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegT1AttrGet(MlirContext ctxt);
92+
93+
/// If the attribute is an RTGTest RegT2Attr.
94+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegT2(MlirAttribute attr);
95+
96+
/// Creates an RTGTest RegT2 attribute in the context.
97+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegT2AttrGet(MlirContext ctxt);
98+
99+
/// If the attribute is an RTGTest RegS0Attr.
100+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS0(MlirAttribute attr);
101+
102+
/// Creates an RTGTest RegS0 attribute in the context.
103+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS0AttrGet(MlirContext ctxt);
104+
105+
/// If the attribute is an RTGTest RegS1Attr.
106+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS1(MlirAttribute attr);
107+
108+
/// Creates an RTGTest RegS1 attribute in the context.
109+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS1AttrGet(MlirContext ctxt);
110+
111+
/// If the attribute is an RTGTest RegA0Attr.
112+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA0(MlirAttribute attr);
113+
114+
/// Creates an RTGTest RegA0 attribute in the context.
115+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA0AttrGet(MlirContext ctxt);
116+
117+
/// If the attribute is an RTGTest RegA1Attr.
118+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA1(MlirAttribute attr);
119+
120+
/// Creates an RTGTest RegA1 attribute in the context.
121+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA1AttrGet(MlirContext ctxt);
122+
123+
/// If the attribute is an RTGTest RegA2Attr.
124+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA2(MlirAttribute attr);
125+
126+
/// Creates an RTGTest RegA2 attribute in the context.
127+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA2AttrGet(MlirContext ctxt);
128+
129+
/// If the attribute is an RTGTest RegA3Attr.
130+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA3(MlirAttribute attr);
131+
132+
/// Creates an RTGTest RegA3 attribute in the context.
133+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA3AttrGet(MlirContext ctxt);
134+
135+
/// If the attribute is an RTGTest RegA4Attr.
136+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA4(MlirAttribute attr);
137+
138+
/// Creates an RTGTest RegA4 attribute in the context.
139+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA4AttrGet(MlirContext ctxt);
140+
141+
/// If the attribute is an RTGTest RegA5Attr.
142+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA5(MlirAttribute attr);
143+
144+
/// Creates an RTGTest RegA5 attribute in the context.
145+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA5AttrGet(MlirContext ctxt);
146+
147+
/// If the attribute is an RTGTest RegA6Attr.
148+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA6(MlirAttribute attr);
149+
150+
/// Creates an RTGTest RegA6 attribute in the context.
151+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA6AttrGet(MlirContext ctxt);
152+
153+
/// If the attribute is an RTGTest RegA7Attr.
154+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegA7(MlirAttribute attr);
155+
156+
/// Creates an RTGTest RegA7 attribute in the context.
157+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegA7AttrGet(MlirContext ctxt);
158+
159+
/// If the attribute is an RTGTest RegS2Attr.
160+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS2(MlirAttribute attr);
161+
162+
/// Creates an RTGTest RegS2 attribute in the context.
163+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS2AttrGet(MlirContext ctxt);
164+
165+
/// If the attribute is an RTGTest RegS3Attr.
166+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS3(MlirAttribute attr);
167+
168+
/// Creates an RTGTest RegS3 attribute in the context.
169+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS3AttrGet(MlirContext ctxt);
170+
171+
/// If the attribute is an RTGTest RegS4Attr.
172+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS4(MlirAttribute attr);
173+
174+
/// Creates an RTGTest RegS4 attribute in the context.
175+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS4AttrGet(MlirContext ctxt);
176+
177+
/// If the attribute is an RTGTest RegS5Attr.
178+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS5(MlirAttribute attr);
179+
180+
/// Creates an RTGTest RegS5 attribute in the context.
181+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS5AttrGet(MlirContext ctxt);
182+
183+
/// If the attribute is an RTGTest RegS6Attr.
184+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS6(MlirAttribute attr);
185+
186+
/// Creates an RTGTest RegS6 attribute in the context.
187+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS6AttrGet(MlirContext ctxt);
188+
189+
/// If the attribute is an RTGTest RegS7Attr.
190+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS7(MlirAttribute attr);
191+
192+
/// Creates an RTGTest RegS7 attribute in the context.
193+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS7AttrGet(MlirContext ctxt);
194+
195+
/// If the attribute is an RTGTest RegS8Attr.
196+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS8(MlirAttribute attr);
197+
198+
/// Creates an RTGTest RegS8 attribute in the context.
199+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS8AttrGet(MlirContext ctxt);
200+
201+
/// If the attribute is an RTGTest RegS9Attr.
202+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS9(MlirAttribute attr);
203+
204+
/// Creates an RTGTest RegS9 attribute in the context.
205+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS9AttrGet(MlirContext ctxt);
206+
207+
/// If the attribute is an RTGTest RegS10Attr.
208+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS10(MlirAttribute attr);
209+
210+
/// Creates an RTGTest RegS10 attribute in the context.
211+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS10AttrGet(MlirContext ctxt);
212+
213+
/// If the attribute is an RTGTest RegS11Attr.
214+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegS11(MlirAttribute attr);
215+
216+
/// Creates an RTGTest RegS11 attribute in the context.
217+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegS11AttrGet(MlirContext ctxt);
218+
219+
/// If the attribute is an RTGTest RegT3Attr.
220+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegT3(MlirAttribute attr);
221+
222+
/// Creates an RTGTest RegT3 attribute in the context.
223+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegT3AttrGet(MlirContext ctxt);
224+
225+
/// If the attribute is an RTGTest RegT4Attr.
226+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegT4(MlirAttribute attr);
227+
228+
/// Creates an RTGTest RegT4 attribute in the context.
229+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegT4AttrGet(MlirContext ctxt);
230+
231+
/// If the attribute is an RTGTest RegT5Attr.
232+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegT5(MlirAttribute attr);
233+
234+
/// Creates an RTGTest RegT5 attribute in the context.
235+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegT5AttrGet(MlirContext ctxt);
236+
237+
/// If the attribute is an RTGTest RegT6Attr.
238+
MLIR_CAPI_EXPORTED bool rtgtestAttrIsARegT6(MlirAttribute attr);
239+
240+
/// Creates an RTGTest RegT6 attribute in the context.
241+
MLIR_CAPI_EXPORTED MlirAttribute rtgtestRegT6AttrGet(MlirContext ctxt);
242+
48243
#ifdef __cplusplus
49244
}
50245
#endif

include/circt/Dialect/RTG/IR/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ add_public_tablegen_target(CIRCTRTGAttrInterfacesIncGen)
2424
add_dependencies(circt-headers CIRCTRTGAttrInterfacesIncGen)
2525

2626
set(LLVM_TARGET_DEFINITIONS RTGISAAssemblyInterfaces.td)
27+
mlir_tablegen(RTGISAAssemblyAttrInterfaces.h.inc -gen-attr-interface-decls)
28+
mlir_tablegen(RTGISAAssemblyAttrInterfaces.cpp.inc -gen-attr-interface-defs)
29+
add_public_tablegen_target(CIRCTRTGISAAssemblyAttrInterfacesIncGen)
30+
add_dependencies(circt-headers CIRCTRTGISAAssemblyAttrInterfacesIncGen)
31+
32+
mlir_tablegen(RTGISAAssemblyTypeInterfaces.h.inc -gen-type-interface-decls)
33+
mlir_tablegen(RTGISAAssemblyTypeInterfaces.cpp.inc -gen-type-interface-defs)
34+
add_public_tablegen_target(CIRCTRTGISAAssemblyTypeInterfacesIncGen)
35+
add_dependencies(circt-headers CIRCTRTGISAAssemblyTypeInterfacesIncGen)
36+
2737
mlir_tablegen(RTGISAAssemblyOpInterfaces.h.inc -gen-op-interface-decls)
2838
mlir_tablegen(RTGISAAssemblyOpInterfaces.cpp.inc -gen-op-interface-defs)
2939
add_public_tablegen_target(CIRCTRTGISAAssemblyOpInterfacesIncGen)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===- RTGISAAssemblyAttrInterfaces.h - Interf. for ISA ASM RTG -*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file declares attr interfaces for the RTG Dialect that are specific to
10+
// ISA Assembly tests.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYATTRINTERFACES_H
15+
#define CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYATTRINTERFACES_H
16+
17+
#include "circt/Dialect/RTG/IR/RTGISAAssemblyTypeInterfaces.h"
18+
#include "mlir/IR/Attributes.h"
19+
#include "mlir/IR/BuiltinAttributeInterfaces.h"
20+
#include "llvm/ADT/APInt.h"
21+
22+
#include "circt/Dialect/RTG/IR/RTGISAAssemblyAttrInterfaces.h.inc"
23+
24+
#endif // CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYATTRINTERFACES_H

include/circt/Dialect/RTG/IR/RTGISAAssemblyInterfaces.td

Lines changed: 17 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,51 +10,38 @@
1010
#define CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYINTERFACES_TD
1111

1212
include "mlir/IR/Interfaces.td"
13-
include "mlir/IR/OpBase.td"
13+
include "mlir/IR/BuiltinAttributeInterfaces.td"
1414

15-
def RegisterOpInterface : OpInterface<"RegisterOpInterface"> {
15+
def RegisterAttrInterface : AttrInterface<"RegisterAttrInterface", [TypedAttrInterface]> {
1616
let description = [{
17-
This interface should be implemented by operations that represent
18-
ISA registers. It is used for register allocation, emission, etc.
19-
20-
Virtual registers are indicated by a register index of ~0.
17+
This interface should be implemented by attributes that represent
18+
ISA registers. It is used for elaboration, register allocation, emission,
19+
etc.
2120
}];
2221
let cppNamespace = "::circt::rtg";
2322

2423
let methods = [
25-
InterfaceMethod<[{
26-
Returns the bitvector of the Dialect's canonical register indices for
27-
which this operation allows.
28-
}],
29-
"::llvm::BitVector", "getAllowedRegs">,
30-
InterfaceMethod<[{
31-
Returns the Dialect's canonical register index of the register if it
32-
selects a specific one, or ~0 if it isn't fixed yet.
33-
}],
34-
"unsigned", "getFixedReg">,
35-
InterfaceMethod<[{
36-
Sets this operation to use a specific register given by the Dialect's
37-
canonical register index.
38-
}],
39-
"void", "setFixedReg", (ins "unsigned":$reg)>,
4024
InterfaceMethod<[{
4125
Returns the class specific index of the register. This translates from
4226
the flat internal representation to the architectural representation.
4327
}],
4428
"unsigned", "getClassIndex">,
45-
InterfaceMethod<[{
46-
Returns the class specific index of the register. This translates from
47-
the flat internal representation to the architectural representation.
48-
This returns an APInt for the common binary encoding.
49-
}],
50-
"llvm::APInt", "getClassIndexBinary">,
5129
InterfaceMethod<[{
5230
Returns a suitable string for use in assembly format.
5331
}],
54-
"std::string", "getRegisterAssembly">,
32+
"llvm::StringLiteral", "getRegisterAssembly">,
5533
];
5634
}
5735

36+
def RegisterTypeInterface : TypeInterface<"RegisterTypeInterface"> {
37+
let description = [{
38+
This interface should be implemented by types that represent
39+
ISA registers. It is used for elaboration, register allocation, emission,
40+
etc.
41+
}];
42+
let cppNamespace = "::circt::rtg";
43+
}
44+
5845
def InstructionOpInterface : OpInterface<"InstructionOpInterface"> {
5946
let description = [{
6047
This interface should be implemented by operations that represent
@@ -69,15 +56,15 @@ def InstructionOpInterface : OpInterface<"InstructionOpInterface"> {
6956
}],
7057
"void", "printInstructionBinary",
7158
(ins "llvm::raw_ostream &":$os,
72-
"llvm::ArrayRef<mlir::Attribute>":$operands)>,
59+
"llvm::ArrayRef<rtg::RegisterAttrInterface>":$operands)>,
7360
StaticInterfaceMethod<[{
7461
Emits the ISA assembly representation of the instruction to the provided
7562
stream. The format should be the one understood by common assembler
7663
tools.
7764
}],
7865
"void", "printInstructionAssembly",
7966
(ins "llvm::raw_ostream &":$os,
80-
"llvm::ArrayRef<mlir::Attribute>":$operands)>,
67+
"llvm::ArrayRef<rtg::RegisterAttrInterface>":$operands)>,
8168
];
8269
}
8370

include/circt/Dialect/RTG/IR/RTGISAAssemblyOpInterfaces.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYOPINTERFACES_H
1515
#define CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYOPINTERFACES_H
1616

17+
#include "circt/Dialect/RTG/IR/RTGISAAssemblyAttrInterfaces.h"
1718
#include "circt/Support/LLVM.h"
1819
#include "mlir/IR/OpDefinition.h"
1920

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===- RTGISAAssemblyTypeInterfaces.h - Interf. for ISA ASM RTG -*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file declares type interfaces for the RTG Dialect that are specific to
10+
// ISA Assembly tests.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYTYPEINTERFACES_H
15+
#define CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYTYPEINTERFACES_H
16+
17+
#include "circt/Support/LLVM.h"
18+
#include "mlir/IR/Types.h"
19+
20+
#include "circt/Dialect/RTG/IR/RTGISAAssemblyTypeInterfaces.h.inc"
21+
22+
#endif // CIRCT_DIALECT_RTG_IR_RTGISAASSEMBLYTYPEINTERFACES_H

include/circt/Dialect/RTG/IR/RTGOps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
#include "circt/Dialect/RTG/IR/RTGAttrInterfaces.h"
1717
#include "circt/Dialect/RTG/IR/RTGDialect.h"
18+
#include "circt/Dialect/RTG/IR/RTGISAAssemblyAttrInterfaces.h"
19+
#include "circt/Dialect/RTG/IR/RTGISAAssemblyTypeInterfaces.h"
1820
#include "circt/Dialect/RTG/IR/RTGTypeInterfaces.h"
1921
#include "circt/Dialect/RTG/IR/RTGTypes.h"
2022
#include "circt/Support/LLVM.h"

0 commit comments

Comments
 (0)