diff --git a/frontends/PyCDE/src/pycde/module.py b/frontends/PyCDE/src/pycde/module.py index d32cf47fe7..c5791a257b 100644 --- a/frontends/PyCDE/src/pycde/module.py +++ b/frontends/PyCDE/src/pycde/module.py @@ -133,7 +133,7 @@ class module: if self.extern_mod is None: # Find the top MLIR module. mod = op - while mod.name != "module": + while mod.parent is not None: mod = mod.parent input_ports = [(n.value, o.type) for (n, o) in zip(op_names, op.operands)] @@ -363,7 +363,7 @@ class _Generate: # Find the top MLIR module. mod = op - while mod.name != "module": + while mod.parent is not None: mod = mod.parent # Assemble the parameters. diff --git a/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp b/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp index 7ec41e7fcb..4bb31f1ce4 100644 --- a/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp +++ b/lib/Conversion/LLHDToLLVM/LLHDToLLVM.cpp @@ -1077,7 +1077,7 @@ struct WaitOpConversion : public ConvertToLLVMPattern { op->getLoc(), i64Ty, transformed.time(), rewriter.getI32ArrayAttr(2)); std::array args({statePtr, procStateBC, realTime, delta, eps}); - rewriter.create(op->getLoc(), voidTy, + rewriter.create(op->getLoc(), llvm::None, rewriter.getSymbolRefAttr(llhdSuspendFunc), args); } @@ -1232,7 +1232,7 @@ struct InstOpConversion : public ConvertToLLVMPattern { // Add reg state pointer to global state. initBuilder.create( - op->getLoc(), voidTy, rewriter.getSymbolRefAttr(allocEntityFunc), + op->getLoc(), llvm::None, rewriter.getSymbolRefAttr(allocEntityFunc), ArrayRef({initStatePtr, owner, regMall})); // Index of the signal in the entity's signal table. @@ -1442,7 +1442,7 @@ struct InstOpConversion : public ConvertToLLVMPattern { procStateSensesPtr); std::array allocProcArgs({initStatePtr, owner, procStateMall}); - initBuilder.create(op->getLoc(), voidTy, + initBuilder.create(op->getLoc(), llvm::None, rewriter.getSymbolRefAttr(allocProcFunc), allocProcArgs); } @@ -1660,7 +1660,7 @@ struct DrvOpConversion : public ConvertToLLVMPattern { std::array args( {statePtr, transformed.signal(), bc, sigWidth, realTime, delta, eps}); // Create the library call. - rewriter.create(op->getLoc(), voidTy, + rewriter.create(op->getLoc(), llvm::None, rewriter.getSymbolRefAttr(drvFunc), args); rewriter.eraseOp(op); diff --git a/lib/Dialect/SV/Transforms/HWCleanup.cpp b/lib/Dialect/SV/Transforms/HWCleanup.cpp index ec4c3d2e28..90f87b4014 100644 --- a/lib/Dialect/SV/Transforms/HWCleanup.cpp +++ b/lib/Dialect/SV/Transforms/HWCleanup.cpp @@ -28,20 +28,38 @@ namespace { /// Check the equivalence of operations by doing a deep comparison of operands /// and attributes, but does not compare the content of any regions attached to /// each op. -struct SimpleOperationInfo : public llvm::DenseMapInfo { +struct AlwaysLikeOpInfo : public llvm::DenseMapInfo { static unsigned getHashValue(const Operation *opC) { return mlir::OperationEquivalence::computeHash( - const_cast(opC)); + const_cast(opC), + /*hashOperands=*/mlir::OperationEquivalence::directHashValue, + /*hashResults=*/mlir::OperationEquivalence::ignoreHashValue, + mlir::OperationEquivalence::IgnoreLocations); } static bool isEqual(const Operation *lhsC, const Operation *rhsC) { auto *lhs = const_cast(lhsC); auto *rhs = const_cast(rhsC); + // Trivially the same. if (lhs == rhs) return true; + // Filter out tombstones and empty ops. if (lhs == getTombstoneKey() || lhs == getEmptyKey() || rhs == getTombstoneKey() || rhs == getEmptyKey()) return false; - return mlir::OperationEquivalence::isEquivalentTo(lhs, rhs); + // Compare attributes. + if (lhs->getName() != rhs->getName() || + lhs->getAttrDictionary() != rhs->getAttrDictionary() || + lhs->getNumOperands() != rhs->getNumOperands()) + return false; + // Compare operands. + for (auto operandPair : llvm::zip(lhs->getOperands(), rhs->getOperands())) { + Value lhsOperand = std::get<0>(operandPair); + Value rhsOperand = std::get<1>(operandPair); + if (lhsOperand != rhsOperand) + return false; + } + // The two AlwaysOps are similar enough to be combined. + return true; } }; @@ -135,7 +153,7 @@ void HWCleanupPass::runOnGraphRegion(Region ®ion, bool shallow) { // A set of operations in the current block which are mergable. Any // operation in this set is a candidate for another similar operation to // merge in to. - DenseSet alwaysFFOpsSeen; + DenseSet alwaysFFOpsSeen; llvm::SmallDenseMap ifdefOps; sv::InitialOp initialOpSeen; sv::AlwaysCombOp alwaysCombOpSeen; diff --git a/llvm b/llvm index 310c9496d8..1689dade42 160000 --- a/llvm +++ b/llvm @@ -1 +1 @@ -Subproject commit 310c9496d80961188e8d8f8ad306cdf44bd7541f +Subproject commit 1689dade4218945db175f7916c2261667f9bf371 diff --git a/test/CAPI/ir.c b/test/CAPI/ir.c index e3bddb82e3..7f38f6700d 100644 --- a/test/CAPI/ir.c +++ b/test/CAPI/ir.c @@ -40,7 +40,7 @@ int registerOnlyHW() { return 2; mlirDialectHandleRegisterDialect(hwHandle, ctx); - if (mlirContextGetNumRegisteredDialects(ctx) != 1) + if (mlirContextGetNumRegisteredDialects(ctx) != 2) return 3; if (mlirContextGetNumLoadedDialects(ctx) != 1) return 4; diff --git a/test/Conversion/FIRRTLToHW/lower-to-hw-errors.mlir b/test/Conversion/FIRRTLToHW/lower-to-hw-errors.mlir index f92e3de0c8..fbfe2adc9e 100644 --- a/test/Conversion/FIRRTLToHW/lower-to-hw-errors.mlir +++ b/test/Conversion/FIRRTLToHW/lower-to-hw-errors.mlir @@ -15,7 +15,7 @@ firrtl.circuit "InvalidBundle" { %0 = firrtl.invalidvalue : !firrtl.bundle> } - // expected-error @+1 {{unexpected operation 'func' in a firrtl.circuit}} + // expected-error @+1 {{unexpected operation 'builtin.func' in a firrtl.circuit}} func private @UnknownFunction() { return } diff --git a/test/Conversion/FIRRTLToHW/lower-to-hw-module.mlir b/test/Conversion/FIRRTLToHW/lower-to-hw-module.mlir index 1ad9149b97..271669bf4a 100644 --- a/test/Conversion/FIRRTLToHW/lower-to-hw-module.mlir +++ b/test/Conversion/FIRRTLToHW/lower-to-hw-module.mlir @@ -2,7 +2,7 @@ // The firrtl.circuit should be removed, the main module name moved to an // attribute on the module. -// CHECK-LABEL: {{^}}module attributes {firrtl.mainModule = "Simple"} { +// CHECK-LABEL: {{^}}builtin.module attributes {firrtl.mainModule = "Simple"} { // CHECK-NOT: firrtl.circuit // We should get a large header boilerplate. diff --git a/test/Conversion/LLHDToLLVM/convert_signals.mlir b/test/Conversion/LLHDToLLVM/convert_signals.mlir index fffac95941..3f52abe4cc 100644 --- a/test/Conversion/LLHDToLLVM/convert_signals.mlir +++ b/test/Conversion/LLHDToLLVM/convert_signals.mlir @@ -83,7 +83,7 @@ llhd.entity @convert_prb (%sI1 : !llhd.sig, %sArr : !llhd.sig // CHECK: %[[VAL_19:.*]] = llvm.extractvalue %[[VAL_13]][1 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_20:.*]] = llvm.extractvalue %[[VAL_13]][2 : i32] : !llvm.array<3 x i64> -// CHECK: %[[VAL_21:.*]] = llvm.call @driveSignal(%[[VAL_0]], %[[VAL_4]], %[[VAL_17]], %[[VAL_14]], %[[VAL_18]], %[[VAL_19]], %[[VAL_20]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> !llvm.void +// CHECK: llvm.call @driveSignal(%[[VAL_0]], %[[VAL_4]], %[[VAL_17]], %[[VAL_14]], %[[VAL_18]], %[[VAL_19]], %[[VAL_20]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> () // CHECK: %[[VAL_22:.*]] = llvm.mlir.constant(1 : i32) : i32 // CHECK: %[[VAL_23:.*]] = llvm.mlir.constant(8 : i64) : i64 // CHECK: %[[VAL_24:.*]] = llvm.mlir.null : !llvm.ptr> @@ -97,7 +97,7 @@ llhd.entity @convert_prb (%sI1 : !llhd.sig, %sArr : !llhd.sig // CHECK: %[[VAL_32:.*]] = llvm.extractvalue %[[VAL_13]][1 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_33:.*]] = llvm.extractvalue %[[VAL_13]][2 : i32] : !llvm.array<3 x i64> -// CHECK: %[[VAL_34:.*]] = llvm.call @driveSignal(%[[VAL_0]], %[[VAL_6]], %[[VAL_30]], %[[VAL_27]], %[[VAL_31]], %[[VAL_32]], %[[VAL_33]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> !llvm.void +// CHECK: llvm.call @driveSignal(%[[VAL_0]], %[[VAL_6]], %[[VAL_30]], %[[VAL_27]], %[[VAL_31]], %[[VAL_32]], %[[VAL_33]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> () // CHECK: llvm.return // CHECK: } llhd.entity @convert_drv (%sI1 : !llhd.sig, %sArr : !llhd.sig>) -> () { @@ -116,7 +116,7 @@ llhd.entity @convert_drv (%sI1 : !llhd.sig, %sArr : !llhd.sig) -> () { // CHECK: %[[VAL_49:.*]] = llvm.extractvalue %[[VAL_41]][0 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_50:.*]] = llvm.extractvalue %[[VAL_41]][1 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_51:.*]] = llvm.extractvalue %[[VAL_41]][2 : i32] : !llvm.array<3 x i64> -// CHECK: %[[VAL_52:.*]] = llvm.call @driveSignal(%[[VAL_0]], %[[VAL_6]], %[[VAL_48]], %[[VAL_43]], %[[VAL_49]], %[[VAL_50]], %[[VAL_51]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> !llvm.void +// CHECK: llvm.call @driveSignal(%[[VAL_0]], %[[VAL_6]], %[[VAL_48]], %[[VAL_43]], %[[VAL_49]], %[[VAL_50]], %[[VAL_51]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> () // CHECK: llvm.br ^bb8 // CHECK: ^bb8: // CHECK: llvm.br ^bb9 diff --git a/test/Conversion/LLHDToLLVM/convert_simple.mlir b/test/Conversion/LLHDToLLVM/convert_simple.mlir index 84c74417be..627f266a06 100644 --- a/test/Conversion/LLHDToLLVM/convert_simple.mlir +++ b/test/Conversion/LLHDToLLVM/convert_simple.mlir @@ -32,7 +32,7 @@ // CHECK: %[[VAL_24:.*]] = llvm.extractvalue %[[VAL_19]][0 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_25:.*]] = llvm.extractvalue %[[VAL_19]][1 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_26:.*]] = llvm.extractvalue %[[VAL_19]][2 : i32] : !llvm.array<3 x i64> -// CHECK: %[[VAL_27:.*]] = llvm.call @driveSignal(%[[VAL_0]], %[[VAL_5]], %[[VAL_23]], %[[VAL_20]], %[[VAL_24]], %[[VAL_25]], %[[VAL_26]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> !llvm.void +// CHECK: llvm.call @driveSignal(%[[VAL_0]], %[[VAL_5]], %[[VAL_23]], %[[VAL_20]], %[[VAL_24]], %[[VAL_25]], %[[VAL_26]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64)>>, !llvm.ptr, i64, i64, i64, i64) -> () // CHECK: llvm.return // CHECK: } diff --git a/test/Conversion/LLHDToLLVM/convert_wait.mlir b/test/Conversion/LLHDToLLVM/convert_wait.mlir index 3f0867b368..2af6fbb1ea 100644 --- a/test/Conversion/LLHDToLLVM/convert_wait.mlir +++ b/test/Conversion/LLHDToLLVM/convert_wait.mlir @@ -33,7 +33,7 @@ // CHECK: %[[VAL_19:.*]] = llvm.extractvalue %[[VAL_11]][0 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_20:.*]] = llvm.extractvalue %[[VAL_11]][1 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_21:.*]] = llvm.extractvalue %[[VAL_11]][2 : i32] : !llvm.array<3 x i64> -// CHECK: %[[VAL_22:.*]] = llvm.call @llhdSuspend(%[[VAL_0]], %[[VAL_18]], %[[VAL_19]], %[[VAL_20]], %[[VAL_21]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64) -> !llvm.void +// CHECK: llvm.call @llhdSuspend(%[[VAL_0]], %[[VAL_18]], %[[VAL_19]], %[[VAL_20]], %[[VAL_21]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64) -> () // CHECK: llvm.return // CHECK: ^bb4: // CHECK: %[[VAL_23:.*]] = llvm.mlir.constant(0 : i32) : i32 @@ -168,7 +168,7 @@ llhd.proc @convert_resume_observe_partial (%in0 : !llhd.sig, %in1 : !llhd.si // CHECK: %[[VAL_25:.*]] = llvm.extractvalue %[[VAL_13]][0 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_26:.*]] = llvm.extractvalue %[[VAL_13]][1 : i32] : !llvm.array<3 x i64> // CHECK: %[[VAL_27:.*]] = llvm.extractvalue %[[VAL_13]][2 : i32] : !llvm.array<3 x i64> -// CHECK: %[[VAL_28:.*]] = llvm.call @llhdSuspend(%[[VAL_0]], %[[VAL_24]], %[[VAL_25]], %[[VAL_26]], %[[VAL_27]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64) -> !llvm.void +// CHECK: llvm.call @llhdSuspend(%[[VAL_0]], %[[VAL_24]], %[[VAL_25]], %[[VAL_26]], %[[VAL_27]]) : (!llvm.ptr, !llvm.ptr, i64, i64, i64) -> () // CHECK: llvm.return // CHECK: ^bb4: // CHECK: %[[VAL_29:.*]] = llvm.mlir.constant(0 : i32) : i32 diff --git a/test/circt-opt/commandline.mlir b/test/circt-opt/commandline.mlir index b044be5286..014e493f7e 100644 --- a/test/circt-opt/commandline.mlir +++ b/test/circt-opt/commandline.mlir @@ -5,6 +5,7 @@ // DIALECT: Available Dialects: // DIALECT-NEXT: affine +// DIALECT-NEXT: builtin // DIALECT-NEXT: calyx // DIALECT-NEXT: comb // DIALECT-NEXT: esi diff --git a/tools/firtool/firtool.cpp b/tools/firtool/firtool.cpp index c35ede3e38..27bd427514 100644 --- a/tools/firtool/firtool.cpp +++ b/tools/firtool/firtool.cpp @@ -35,6 +35,7 @@ #include "mlir/Transforms/GreedyPatternRewriteDriver.h" #include "mlir/Transforms/Passes.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/Path.h" #include "llvm/Support/SourceMgr.h" diff --git a/tools/llhd-sim/llhd-sim.cpp b/tools/llhd-sim/llhd-sim.cpp index a1d29ff2fd..1957a9db10 100644 --- a/tools/llhd-sim/llhd-sim.cpp +++ b/tools/llhd-sim/llhd-sim.cpp @@ -24,6 +24,7 @@ #include "mlir/Target/LLVMIR/Export.h" #include "mlir/Transforms/Passes.h" +#include "llvm/Support/Error.h" #include "llvm/Support/InitLLVM.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/ToolOutputFile.h"