From 558e9ac588405f623997fffb94aebf12edca8e7c Mon Sep 17 00:00:00 2001 From: "huanghuang.zhou" Date: Wed, 20 Apr 2022 17:36:10 +0800 Subject: [PATCH 1/2] Update llhd-conv output mlir with cf dialect. --- src/mlir/writer.rs | 6 +++--- tests/mlir/from_moore.llhd | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/mlir/from_moore.llhd diff --git a/src/mlir/writer.rs b/src/mlir/writer.rs index 56845573d..7c1b985a1 100644 --- a/src/mlir/writer.rs +++ b/src/mlir/writer.rs @@ -137,8 +137,8 @@ impl std::fmt::Display for MLIROpcode { Opcode::Halt => "llhd.halt", Opcode::Ret => "return", Opcode::RetValue => "return", - Opcode::Br => "br", - Opcode::BrCond => "cond_br", + Opcode::Br => "cf.br", + Opcode::BrCond => "cf.cond_br", Opcode::Wait => "llhd.wait", Opcode::WaitTime => "llhd.wait", _ => panic!("No single corresponding op in CIRCT!"), @@ -273,7 +273,7 @@ impl Writer { if data.kind() != UnitKind::Entity { if let Some(block) = data.first_block() { write!(uw.writer.sink, " ")?; - write!(uw.writer.sink, "br ")?; + write!(uw.writer.sink, "cf.br ")?; uw.write_block_name(block, block_args.get(&block).unwrap_or(&Vec::new()))?; write!(uw.writer.sink, "\n")?; } diff --git a/tests/mlir/from_moore.llhd b/tests/mlir/from_moore.llhd new file mode 100644 index 000000000..a55ebfe0e --- /dev/null +++ b/tests/mlir/from_moore.llhd @@ -0,0 +1,13 @@ +; RUN: llhd-conv %s -i %s --output-format mlir + +proc %foo.initial.15.0 () -> (i32$ %x) { +0: + %1 = const i32 42 + %2 = const time 0s 1e + drv i32$ %x, %1, %2 + halt +} + +entity @foo () -> (i32$ %x) { + inst %foo.initial.15.0 () -> (i32$ %x) +} From 14990a333522ea7df78af83294ef2e267863da18 Mon Sep 17 00:00:00 2001 From: "huanghuang.zhou" Date: Wed, 20 Apr 2022 17:57:03 +0800 Subject: [PATCH 2/2] small fix --- tests/mlir/from_moore.llhd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mlir/from_moore.llhd b/tests/mlir/from_moore.llhd index a55ebfe0e..46a583c34 100644 --- a/tests/mlir/from_moore.llhd +++ b/tests/mlir/from_moore.llhd @@ -1,4 +1,4 @@ -; RUN: llhd-conv %s -i %s --output-format mlir +; RUN: llhd-conv -i %s --output-format mlir proc %foo.initial.15.0 () -> (i32$ %x) { 0: