Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3edd3ff
Made GetSetOpInterface accept types other than integer
PetrifiedPanda Jun 24, 2026
3149a06
Made elementType also accept types other than IntegerTypes
PetrifiedPanda Jun 24, 2026
625d7d8
Made Get and Set ops accept any type rather than only integer types
PetrifiedPanda Jun 24, 2026
f240659
Updated getElementType to fit new GetSetOpInterface definition and ad…
PetrifiedPanda Jun 24, 2026
4873560
Docs changes
PetrifiedPanda Jun 24, 2026
ab32640
WIP: Exploding struct typed registers into multiple. Not working. Cur…
PetrifiedPanda Jul 15, 2026
0a39b9d
Fixed get and set functions (still only works for single registers, n…
PetrifiedPanda Jul 17, 2026
9986c89
Added simple test
PetrifiedPanda Jul 17, 2026
cc258b2
Formatting and removed unused variable
PetrifiedPanda Jul 17, 2026
aa55490
Added triple nested register and added CHECK statements for the explo…
PetrifiedPanda Jul 17, 2026
f5130e1
Added docs
PetrifiedPanda Jul 17, 2026
63a6196
Removed code that was not relevant from test
PetrifiedPanda Jul 27, 2026
d00289b
Added another test with non-struct registers to test both non-struct …
PetrifiedPanda Jul 27, 2026
db9c398
Removed TODO comments
PetrifiedPanda Jul 27, 2026
7739929
Added triple nested load and store to test
PetrifiedPanda Jul 27, 2026
93fecd7
Fixed issues that happen when structs are nested deeper than 2
PetrifiedPanda Jul 27, 2026
419a0ce
Ran generate-test-checks.py on test
PetrifiedPanda Jul 27, 2026
6f3aeb4
Added numElements to RegisterOp::create (still need to properly handl…
PetrifiedPanda Jul 27, 2026
89976e5
Added struct typed register file to test
PetrifiedPanda Jul 27, 2026
b9b939c
Implemented register file access
PetrifiedPanda Jul 27, 2026
daaa10f
Formatting
PetrifiedPanda Jul 27, 2026
e2ebd76
Removed outdated TODO
PetrifiedPanda Jul 28, 2026
7376f8a
Added a canonicalization pattern that legalizes hw.constant operation…
PetrifiedPanda Aug 10, 2026
fd93737
Removed unused link libraries
PetrifiedPanda Aug 11, 2026
4e57875
Removed unused variable
PetrifiedPanda Aug 11, 2026
1e6019b
Formatting
PetrifiedPanda Aug 11, 2026
4562b0e
Removed unused hash maps
PetrifiedPanda Aug 17, 2026
9ae0103
Added a map to store the types of the removed registers (needed for r…
PetrifiedPanda Aug 17, 2026
a38bda3
Support ranged access for structs
PetrifiedPanda Aug 18, 2026
ce3ed2c
Implemented ranged access handling for get
PetrifiedPanda Aug 18, 2026
c817d5f
Made explodeRegs modify an std::string inplace instead of creating a …
PetrifiedPanda Aug 24, 2026
9ebb260
Implemented coredsl.set for ranged access (still needs to be tested)
PetrifiedPanda Aug 24, 2026
3937606
Added comment explaining what the ranged access operators do
PetrifiedPanda Aug 24, 2026
6687afa
Formatting
PetrifiedPanda Aug 24, 2026
f3b2f7b
Moved adding offset to index and truncating to maxIndexWidth into sep…
PetrifiedPanda Aug 25, 2026
3913170
Formatting
PetrifiedPanda Aug 25, 2026
e3210ae
Added comment to emitTruncatedOffset
PetrifiedPanda Aug 25, 2026
1368637
Made emitTruncatedOffset properly handle a zero offset on an index th…
PetrifiedPanda Aug 25, 2026
e687f51
Changed emitTruncatedOffset to not add a cast when i == 0, as that ca…
PetrifiedPanda Aug 25, 2026
ba0d9f9
Added assertion that from < to for ranged struct accesses
PetrifiedPanda Aug 25, 2026
6c6a34f
Corrected code that emits a constant with the exact needed size for t…
PetrifiedPanda Aug 25, 2026
3878784
Added test cases for ranged access with structs
PetrifiedPanda Aug 25, 2026
031482c
Remove TODO
PetrifiedPanda Aug 25, 2026
504678a
Renamed symToTypeMap to align with its name in the pattern structs an…
PetrifiedPanda Aug 31, 2026
379b119
Renamed explodeRegs to traverseStructReg, because it does not do the …
PetrifiedPanda Aug 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/ConversionPasses.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The YAML is consumed by the Python patch generator (gen_patches.py).
-output : Output path for the YAML analysis file
```

### `-coredsl-explode-struct-registers`

_Divide struct registers into multiple scalar registers_

### `-coredsl-legalize-cf`

_Legalize cf operations by converting them to scf_
Expand Down
4 changes: 2 additions & 2 deletions docs/CoreDSLDialect.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ Examples:

| Result | Description |
| :----: | ----------- |
| `result` | an arbitrary precision integer with signedness semantics |
| `result` | any type |



Expand Down Expand Up @@ -728,7 +728,7 @@ coredsl.set @MEM[%addr : ui32, 0:3] = %3 : ui32 // big-endian
| Operand | Description |
| :-----: | ----------- |
| `base` | an arbitrary precision integer with signedness semantics and unsigned integer |
| `value` | an arbitrary precision integer with signedness semantics |
| `value` | any type |



Expand Down
8 changes: 8 additions & 0 deletions include/shortnail/Conversion/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ def CoreDSLLegalizeCF : Pass<"coredsl-legalize-cf", "::mlir::coredsl::ISAXOp"> {
];
}

def CoreDSLExplodeStructRegisters : Pass<"coredsl-explode-struct-registers", "::mlir::coredsl::ISAXOp"> {
let summary = "Divide struct registers into multiple scalar registers";
let dependentDialects = [
"::mlir::coredsl::CoreDSLDialect",
"::circt::hw::HWDialect",
];
}

def AnalyzeISAX : Pass<"analyze-isax", "mlir::ModuleOp"> {
let summary = "Analyze CoreDSL ISAX MLIR and output structured YAML";
let description = [{
Expand Down
1 change: 1 addition & 0 deletions include/shortnail/Dialect/CoreDSL/CoreDSL.td
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def CoreDSL_Dialect : Dialect {
"comb::CombDialect",
];
let cppNamespace = "::mlir::coredsl";
let hasCanonicalizer = 1;
}

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion include/shortnail/Dialect/CoreDSL/CoreDSLInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def GetSetOpInterface : OpInterface<"GetSetOpInterface"> {
InterfaceMethod<
"Get the minimal required index width.", "unsigned", "getMinIndexWidth">,
InterfaceMethod<
"Get the underlying element type of the memory.", "::mlir::IntegerType",
"Get the underlying element type of the memory.", "::mlir::Type",
"getElementType">
];
}
Expand Down
2 changes: 1 addition & 1 deletion include/shortnail/Dialect/CoreDSL/CoreDSLOps.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct MemInfo {
uint64_t size;
unsigned maxIdxWidth;
unsigned minIdxWidth;
IntegerType elementType;
Type elementType;
bool isConst;
bool isVolatile;
};
Expand Down
4 changes: 2 additions & 2 deletions include/shortnail/Dialect/CoreDSL/CoreDSLOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class CoreDSL_AccessOp<string mnemonic, string lhsAssemblyFormat, string rhsAsse

def CoreDSL_GetOp : CoreDSL_AccessOp<"get", "$sym", "`:` type($result) attr-dict",
(ins FlatSymbolRefAttr:$sym),
(outs HWArithIntegerType:$result),
(outs AnyType:$result),
/*extraClassDecls=*/"Operation* resolveSymbol(); std::optional<MemInfo> getMemInfo();",
/*isRangeAccessOptional=*/"true"> {
let summary = "Reads from architectural state.";
Expand All @@ -358,7 +358,7 @@ def CoreDSL_GetOp : CoreDSL_AccessOp<"get", "$sym", "`:` type($result) attr-dict
}

def CoreDSL_SetOp : CoreDSL_AccessOp<"set", "$sym", "`=` $value `:` type($value) attr-dict",
(ins FlatSymbolRefAttr:$sym, HWArithIntegerType:$value),
(ins FlatSymbolRefAttr:$sym, AnyType:$value),
(outs), /*extraClassDecls=*/"Operation* resolveSymbol(); std::optional<MemInfo> getMemInfo();",
/*isRangeAccessOptional=*/"true", [],
/*folderPrototype=*/"LogicalResult $cppClass::fold(FoldAdaptor adaptor, SmallVectorImpl<OpFoldResult> &results)",
Expand Down
1 change: 1 addition & 0 deletions lib/Conversion/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_subdirectory(AnalyzeISAX)
add_subdirectory(CoreDSLExplodeStructRegisters)
add_subdirectory(CoreDSLLegalizeCF)
add_subdirectory(CoreDSLToPy)
add_subdirectory(MergeISAX)
14 changes: 14 additions & 0 deletions lib/Conversion/CoreDSLExplodeStructRegisters/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
add_shortnail_library(ShortnailCoreDSLExplodeStructRegisters
CoreDSLExplodeStructRegisters.cpp

DEPENDS
MLIRConversionPassIncGen

LINK_LIBS PUBLIC
MLIRIR
MLIRPass

CIRCTHW

ShortnailCoreDSL
)
Loading
Loading