Skip to content

Commit 2fbd69e

Browse files
committed
[Heavy] Add context class generator to NbdlWriter
1 parent 31a40c1 commit 2fbd69e

File tree

4 files changed

+235
-156
lines changed

4 files changed

+235
-156
lines changed

heavy/include/nbdl_gen/Nbdl.td

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def Nbdl_Store : TypeDef<Nbdl_Dialect, "Store", []> {
7070
}];
7171
}
7272

73-
/* FIXME Should this have member information?
73+
/* FIXME Types should only be based on corresponding concepts in nbdl.
7474
def Nbdl_Struct : Nbdl_TypeBase<"Struct", "struct"> {
7575
let summary = "C++ semiregular aggregate type";
7676
let description = [{
@@ -179,7 +179,7 @@ def Nbdl_MatchOp : Nbdl_Op<"match", [Terminator, NoTerminator]> {
179179
def Nbdl_OverloadOp : Nbdl_Op<"overload", []> {
180180
let description = [{
181181
In the region of a MatchOp we specify a function overload of the
182-
given Nbdl_TypenameAttr using OverloadOp.
182+
given typename using OverloadOp.
183183
The body of the overload takes an argument that is the matched
184184
object and the rest of the arguments are the captures.
185185
}];
@@ -226,7 +226,7 @@ def Nbdl_MemberNameOp : Nbdl_Op<"member_name", []> {
226226

227227
def Nbdl_StoreComposeOp : Nbdl_Op<"store_compose", []> {
228228
let description = [{
229-
Add a store $lhs as a member to another store $rhs using a key $key
229+
Add a value $lhs as a member to another store $rhs using a key $key
230230
to access the member. The type $key will shadow any key of the same
231231
type in $rhs (ie values are not considered.)
232232

@@ -263,14 +263,22 @@ def Nbdl_ContextOp : Nbdl_Op<"context", [Symbol, IsolatedFromAbove]> {
263263
created type is a Tag.
264264
}];
265265

266-
// Copying the approach used for scheme globals
267-
let extraClassDeclaration = [{
268-
bool isExternal() { return getBody().empty(); }
269-
}];
270-
271266
let regions = (region AnyRegion:$body);
272267
let arguments = (ins StrAttr:$sym_name);
273268
let results = (outs);
269+
let extraClassDeclaration = [{
270+
bool isExternal() { return getBody().empty(); }
271+
272+
// Get the fully qualified name.
273+
// This is needed for defining template specializations.
274+
llvm::StringRef getFullName() { return getSymName(); }
275+
276+
// Get the unqualified name.
277+
llvm::StringRef getName() {
278+
llvm::StringRef SymName = getSymName();
279+
return SymName.take_back(SymName.rfind(':'));
280+
}
281+
}];
274282
}
275283

276284
def Nbdl_ContOp : Nbdl_Op<"cont", [Terminator]> {

heavy/lib/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ add_heavy_library(heavy
1717
SourceFileStorage.cpp
1818
SourceManager.cpp
1919
Nbdl.cpp
20-
NbdlDialect.cpp
21-
NbdlWriter.cpp
20+
Nbdl/NbdlDialect.cpp
21+
Nbdl/NbdlWriter.cpp
2222
# TODO Do not use Clangs CharInfo.
2323
${CLANG_LIB_DIR}/Basic/CharInfo.cpp
2424

File renamed without changes.

0 commit comments

Comments
 (0)