Skip to content

Commit 42f1c0a

Browse files
committed
tweak
1 parent 7c98eb5 commit 42f1c0a

File tree

3 files changed

+21
-57
lines changed

3 files changed

+21
-57
lines changed

lib/Dialect/LLHD/Transforms/Deseq.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ TruthTable Deseq::computeBoolean(OpResult value) {
505505
return result;
506506
}
507507

508+
if (auto instanceOp = dyn_cast<hw::InstanceOp>(op)) {
509+
// TODO: Should we delve into hw.module itself?
510+
return getUnknownBoolean();
511+
}
512+
508513
// Otherwise check if the operation depends on any of the triggers. If it
509514
// does, create a poison value since we don't really know how the trigger
510515
// affects this boolean. If it doesn't, create an unknown value.

lib/Dialect/LLHD/Transforms/LowerProcesses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ static void simplifyProcess(ProcessOp &processOp) {
401401
void LowerProcessesPass::runOnOperation() {
402402
SmallVector<ProcessOp> processOps(getOperation().getOps<ProcessOp>());
403403
for (auto processOp : processOps) {
404-
simplifyProcess(processOp);
404+
// simplifyProcess(processOp);
405405
Lowering(processOp).lower();
406406
}
407407
}

test/Dialect/LLHD/Transforms/lower-processes.mlir

Lines changed: 15 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -158,57 +158,50 @@ hw.module @SkipIfNoWaits() {
158158
}
159159

160160
// CHECK-LABEL: @SkipIfWaitHasDestinationOperands(
161-
hw.module @SkipIfWaitHasDestinationOperands(in %a: i42, in %b: i42) {
161+
hw.module @SkipIfWaitHasDestinationOperands(in %a: i42) {
162162
// CHECK: llhd.process
163-
// CHECK: llhd.wait yield ({{.*}} : i42), ^bb2({{.*}} : i42)
164-
%0 = llhd.process -> i42 {
165-
cf.br ^bb1(%a : i42)
166-
^bb1(%1: i42):
167-
%false = hw.constant false
168-
%c100 = hw.constant 100 : i42
169-
cf.cond_br %false, ^bb2(%1 : i42), ^bb3(%c100 : i42)
170-
^bb2(%2: i42):
171-
llhd.wait yield (%2 : i42), ^bb2(%2 : i42)
172-
^bb3(%3: i42):
173-
%4 = comb.add %3, %b : i42
174-
cf.br ^bb1(%4 : i42)
163+
llhd.process {
164+
cf.br ^bb1
165+
^bb1:
166+
llhd.wait ^bb2(%a : i42)
167+
^bb2(%0: i42):
168+
cf.br ^bb1
175169
}
176170
}
177171

178172
// CHECK-LABEL: @SkipIfEntryAndWaitConvergeInWrongSpot(
179173
hw.module @SkipIfEntryAndWaitConvergeInWrongSpot(in %a: i42) {
180174
// CHECK: llhd.process
181-
%c100 = hw.constant 100 : i42
182175
llhd.process {
183-
cf.br ^bb2(%c100 : i42)
176+
cf.br ^bb2 // skip logic after wait
184177
^bb1:
185178
%0 = comb.add %a, %a : i42
186-
cf.br ^bb2(%0 : i42)
187-
^bb2(%1 : i42):
188-
llhd.wait (%1 : i42), ^bb1
179+
cf.br ^bb2
180+
^bb2:
181+
llhd.wait ^bb1
189182
}
190183
}
191184

192185
// CHECK-LABEL: @SkipIfEntryAndWaitConvergeWithDifferentBlockArgs(
193186
hw.module @SkipIfEntryAndWaitConvergeWithDifferentBlockArgs(in %a: i42, in %b: i42) {
194187
// CHECK: llhd.process
195-
%0 = llhd.process -> i42 {
188+
llhd.process {
196189
cf.br ^bb2(%a : i42)
197190
^bb1:
198191
cf.br ^bb2(%b : i42)
199192
^bb2(%0: i42):
200-
llhd.wait yield (%0 : i42), ^bb1
193+
llhd.wait ^bb1
201194
}
202195
}
203196

204197
// CHECK-LABEL: @SkipIfValueUnobserved(
205198
hw.module @SkipIfValueUnobserved(in %a: i42) {
206199
// CHECK: llhd.process
207-
%0 = llhd.process -> i42 {
200+
llhd.process {
208201
cf.br ^bb1
209202
^bb1:
210203
%0 = comb.add %a, %a : i42
211-
llhd.wait yield (%0 : i42), ^bb1
204+
llhd.wait ^bb1
212205
}
213206
}
214207

@@ -244,37 +237,3 @@ hw.module @SkipIfEntryAndWaitConvergeWithSideEffectingOps(in %a : i42) {
244237
llhd.wait yield (%a : i42), (%a : i42), ^bb1
245238
}
246239
}
247-
248-
// CHECK-LABEL: @PruneWaitOperands
249-
hw.module @PruneWaitOperands(in %clock : i1, in %f1 : i2, in %f2 : i3) {
250-
%false = hw.constant false
251-
%c10_i8 = hw.constant 10 : i8
252-
%c20_i8 = hw.constant 20 : i8
253-
%c100_i10 = hw.constant 100 : i10
254-
%c110_i10 = hw.constant 110 : i10
255-
%true = hw.constant true
256-
// CHECK: llhd.process -> i1, i8, i2, i10, i3 {
257-
// CHECK-NEXT: cf.br ^bb1(%c10_i8, %c100_i10 : i8, i10)
258-
// CHECK-NEXT: ^bb1(%1: i8, %2: i10):
259-
// CHECK-NEXT: llhd.wait yield (%clock, %1, %f1, %2, %f2 : i1, i8, i2, i10, i3), (%clock : i1), ^bb2
260-
// CHECK-NEXT: ^bb2:
261-
// CHECK: cf.cond_br {{.*}}, ^bb3, ^bb1(%c20_i8, %c110_i10 : i8, i10)
262-
// CHECK-NEXT: ^bb3:
263-
// CHECK: cf.cond_br {{.*}}, ^bb1(%c10_i8, %c100_i10 : i8, i10), ^bb1(%c20_i8, %c110_i10 : i8, i10)
264-
// CHECK-NEXT: }
265-
%0:5 = llhd.process -> i1, i8, i2, i10, i3 {
266-
cf.br ^bb1(%clock, %c10_i8, %f1, %c100_i10, %f2 : i1, i8, i2, i10, i3)
267-
^bb1(%1: i1, %2: i8, %3: i2, %4: i10, %5: i3):
268-
llhd.wait yield (%1, %2, %3, %4, %5 : i1, i8, i2, i10, i3), (%clock : i1), ^bb2(%2, %1, %3, %5, %4 : i8, i1, i2, i3, i10)
269-
^bb2(%6: i8, %7: i1, %8: i2, %9: i3, %10: i10):
270-
%15 = comb.xor bin %7, %true : i1
271-
%16 = comb.and bin %15, %clock : i1
272-
cf.cond_br %16, ^bb3, ^bb1(%clock, %c20_i8, %f1, %c110_i10, %f2 : i1, i8, i2, i10, i3)
273-
^bb3:
274-
%25 = comb.and %true, %clock : i1
275-
cf.cond_br %25,
276-
^bb1(%clock, %c10_i8, %f1, %c100_i10, %f2 : i1, i8, i2, i10, i3),
277-
^bb1(%clock, %c20_i8, %f1, %c110_i10, %f2 : i1, i8, i2, i10, i3)
278-
}
279-
hw.output
280-
}

0 commit comments

Comments
 (0)