-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix LUT input pin orderings to be MSB to LSB in comb truth table…
… operations Previously, Yosys Optimizer's RTLIL importer collected alphabetical pins A, B, C, (...) for truth table operations when importing the optimized RTLIL. A is the LSB and C is the MSB top bit. When converting to comb truth table ops, we place A, B, C as the inputs, while comb's truth table op expects inputs ordered from MSB to LSB. This resulted in correctness issues later in lowerings to CGGI (whose LUT op also expects MSB to LSB) and then tfhe_rust. PiperOrigin-RevId: 603044828
- Loading branch information
1 parent
6293a83
commit 0df1895
Showing
19 changed files
with
207 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Built-in common HEIR definitions | ||
|
||
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library") | ||
|
||
package( | ||
default_applicable_licenses = ["@heir//:license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
exports_files( | ||
[ | ||
"HEIRInterfaces.h", | ||
], | ||
) | ||
|
||
td_library( | ||
name = "td_files", | ||
srcs = [ | ||
"HEIRInterfaces.td", | ||
], | ||
# include from the heir-root to enable fully-qualified include-paths | ||
includes = ["../.."], | ||
deps = [ | ||
"@llvm-project//mlir:OpBaseTdFiles", | ||
], | ||
) | ||
|
||
gentbl_cc_library( | ||
name = "interfaces_inc_gen", | ||
tbl_outs = [ | ||
( | ||
["-gen-op-interface-decls"], | ||
"HEIRInterfaces.h.inc", | ||
), | ||
( | ||
["-gen-op-interface-defs"], | ||
"HEIRInterfaces.cpp.inc", | ||
), | ||
], | ||
tblgen = "@llvm-project//mlir:mlir-tblgen", | ||
td_file = "HEIRInterfaces.td", | ||
deps = [ | ||
":td_files", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef HEIR_INCLUDE_DIALECT_HEIRINTERFACES_H_ | ||
#define HEIR_INCLUDE_DIALECT_HEIRINTERFACES_H_ | ||
|
||
#include "mlir/include/mlir/IR/Builders.h" // from @llvm-project | ||
#include "mlir/include/mlir/IR/BuiltinTypes.h" // from @llvm-project | ||
#include "mlir/include/mlir/IR/Dialect.h" // from @llvm-project | ||
#include "mlir/include/mlir/IR/DialectImplementation.h" // from @llvm-project | ||
|
||
// Pull in HEIR interfaces | ||
#include "include/Dialect/HEIRInterfaces.h.inc" | ||
|
||
#endif // HEIR_INCLUDE_DIALECT_HEIRINTERFACES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
include "mlir/IR/OpBase.td" | ||
|
||
def LUTOpInterface : OpInterface<"LUTOpInterface"> { | ||
let description = [{ | ||
This is an example interface definition. | ||
}]; | ||
|
||
let methods = [ | ||
InterfaceMethod< | ||
"Gets lookup table inputs from most significant bit to least.", | ||
"mlir::ValueRange", "getLookupTableInputs" | ||
>, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Built in HEIR declarations | ||
|
||
package( | ||
default_applicable_licenses = ["@heir//:license"], | ||
default_visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "HEIRInterfaces", | ||
srcs = [ | ||
"HEIRInterfaces.cpp", | ||
], | ||
hdrs = [ | ||
"@heir//include/Dialect:HEIRInterfaces.h", | ||
], | ||
deps = [ | ||
"@heir//include/Dialect:interfaces_inc_gen", | ||
"@llvm-project//mlir:IR", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "include/Dialect/CGGI/IR/CGGIOps.h" | ||
|
||
#include "mlir/include/mlir/IR/ValueRange.h" // from @llvm-project | ||
|
||
namespace mlir { | ||
namespace heir { | ||
namespace cggi { | ||
|
||
mlir::ValueRange Lut2Op::getLookupTableInputs() { | ||
return mlir::ValueRange{getB(), getA()}; | ||
} | ||
|
||
mlir::ValueRange Lut3Op::getLookupTableInputs() { | ||
return mlir::ValueRange{getC(), getB(), getA()}; | ||
} | ||
|
||
} // namespace cggi | ||
} // namespace heir | ||
} // namespace mlir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Block clang-format from thinking the header is unused | ||
// IWYU pragma: begin_keep | ||
#include "include/Dialect/HEIRInterfaces.h" | ||
// IWYU pragma: end_keep | ||
|
||
#include "include/Dialect/HEIRInterfaces.cpp.inc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.