Skip to content

Commit

Permalink
[RTL] Fix RTL test pattern matching (llvm#61)
Browse files Browse the repository at this point in the history
Fix pattern matching for RTL tests.
  • Loading branch information
amaleewilson authored Jul 30, 2020
1 parent 6f53880 commit 5fd07b2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
26 changes: 13 additions & 13 deletions test/rtl/basic.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@
// CHECK-LABEL: func @test1(%arg0: i3) -> i50 {
func @test1(%arg0: i3) -> i50 {
// CHECK-NEXT: %c42_i12 = rtl.constant(42 : i12) : i12
// CHECK-NEXT: %[[RES0:.*]] = rtl.add %c42_i12, %c42_i12 : i12
// CHECK-NEXT: %[[RES1:.*]] = rtl.mul %c42_i12, %[[RES0:.*]] : i12
// CHECK-NEXT: [[RES0:%[0-9]+]] = rtl.add %c42_i12, %c42_i12 : i12
// CHECK-NEXT: [[RES1:%[0-9]+]] = rtl.mul %c42_i12, [[RES0]] : i12
%a = rtl.constant(42 : i12) : i12
%b = rtl.add %a, %a : i12
%c = rtl.mul %a, %b : i12

// CHECK-NEXT: %[[RES2:.*]] = rtl.sext %arg0 : (i3) -> i7
// CHECK-NEXT: %[[RES3:.*]] = rtl.zext %arg0 : (i3) -> i7
// CHECK-NEXT: [[RES2:%[0-9]+]] = rtl.sext %arg0 : (i3) -> i7
// CHECK-NEXT: [[RES3:%[0-9]+]] = rtl.zext %arg0 : (i3) -> i7
%d = rtl.sext %arg0 : (i3) -> i7
%e = rtl.zext %arg0 : (i3) -> i7

// CHECK-NEXT: %[[RES4:.*]] = rtl.concat %[[C42_i12:.*]] : (i12) -> i12
// CHECK-NEXT: [[RES4:%[0-9]+]] = rtl.concat %c42_i12 : (i12) -> i12
%conc1 = rtl.concat %a : (i12) -> i12

// CHECK-NEXT: %[[RES5:.*]] = rtl.andr %[[RES4:.*]] : i12
// CHECK-NEXT: %[[RES6:.*]] = rtl.orr %[[RES4:.*]] : i12
// CHECK-NEXT: %[[RES7:.*]] = rtl.xorr %[[RES4:.*]] : i12
// CHECK-NEXT: [[RES5:%[0-9]+]] = rtl.andr [[RES4]] : i12
// CHECK-NEXT: [[RES6:%[0-9]+]] = rtl.orr [[RES4]] : i12
// CHECK-NEXT: [[RES7:%[0-9]+]] = rtl.xorr [[RES4]] : i12
%andr1 = rtl.andr %conc1 : i12
%orr1 = rtl.orr %conc1 : i12
%xorr1 = rtl.xorr %conc1 : i12

// CHECK-NEXT: %[[RES8:.*]] = rtl.concat %[[RES4:.*]], %[[RES0:.*]], %[[RES1:.*]], %[[RES2:.*]], %[[RES3:.*]] : (i12, i12, i12, i7, i7) -> i50
// CHECK-NEXT: [[RES8:%[0-9]+]] = rtl.concat [[RES4]], [[RES0]], [[RES1]], [[RES2]], [[RES3]] : (i12, i12, i12, i7, i7) -> i50
%result = rtl.concat %conc1, %b, %c, %d, %e : (i12, i12, i12, i7, i7) -> i50

// CHECK-NEXT: %[[RES9:.*]] = rtl.extract [[RES8:.*]] from 4 : (i50) -> i19
// CHECK-NEXT: [[RES9:%[0-9]+]] = rtl.extract [[RES8]] from 4 : (i50) -> i19
%small1 = rtl.extract %result from 4 : (i50) -> i19

// CHECK-NEXT: %[[RES10:.*]] = rtl.extract [[RES8:.*]] from 31 : (i50) -> i19
// CHECK-NEXT: [[RES10:%[0-9]+]] = rtl.extract [[RES8]] from 31 : (i50) -> i19
%small2 = rtl.extract %result from 31 : (i50) -> i19

// CHECK-NEXT: rtl.add %[[RES9:.*]], %[[RES10:.*]] : i19
// CHECK-NEXT: rtl.add [[RES9]], [[RES10]] : i19
%add = rtl.add %small1, %small2 : i19

// CHECK-NEXT: = rtl.wire : i4
%w = rtl.wire : i4

// CHECK-NEXT: return [[RES8:.*]] : i50
// CHECK-NEXT: return [[RES8]] : i50
return %result : i50
}
// CHECK-NEXT: }
10 changes: 5 additions & 5 deletions test/rtl/bitwise.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

// CHECK-LABEL: func @bitwise(%arg0: i7, %arg1: i7) -> i21 {
func @bitwise(%a: i7, %b: i7) -> i21 {
// CHECK-NEXT: %[[RES0:.*]] = rtl.xor %arg0 : i7
// CHECK-NEXT: %[[RES1:.*]] = rtl.or %arg0, %arg1 : i7
// CHECK-NEXT: %[[RES2:.*]] = rtl.and %arg0, %arg1, %arg0 : i7
// CHECK-NEXT: [[RES0:%[0-9]+]] = rtl.xor %arg0 : i7
// CHECK-NEXT: [[RES1:%[0-9]+]] = rtl.or %arg0, %arg1 : i7
// CHECK-NEXT: [[RES2:%[0-9]+]] = rtl.and %arg0, %arg1, %arg0 : i7
%and1 = rtl.xor %a : i7
%or1 = rtl.or %a, %b : i7
%xor1 = rtl.and %a, %b, %a : i7

// CHECK-NEXT: %[[RESULT:.*]] = rtl.concat %[[RES0:.*]], %[[RES1:.*]], %[[RES2:.*]] : (i7, i7, i7) -> i21
// CHECK-NEXT: return %[[RESULT]] : i21
// CHECK-NEXT: [[RESULT:%[0-9]+]] = rtl.concat [[RES0]], [[RES1]], [[RES2]] : (i7, i7, i7) -> i21
// CHECK-NEXT: return [[RESULT]] : i21
%result = rtl.concat %and1, %or1, %xor1 : (i7, i7, i7) -> i21
return %result : i21
}
20 changes: 10 additions & 10 deletions test/rtl/canonicalization.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func @mul_annulment(%arg0: i11, %arg1: i11, %arg2: i11) -> i11 {
// Identities

// CHECK-LABEL: func @and_identity(%arg0: i11, %arg1: i11) -> i11 {
// CHECK-NEXT: %[[RES:.*]] = rtl.and %arg0, %arg1
// CHECK-NEXT: return %[[RES:.*]]
// CHECK-NEXT: [[RES:%[0-9]+]] = rtl.and %arg0, %arg1
// CHECK-NEXT: return [[RES]]

func @and_identity(%arg0: i11, %arg1: i11) -> i11 {
%c-1_i11 = rtl.constant(-1 : i11) : i11
Expand All @@ -73,8 +73,8 @@ func @and_identity(%arg0: i11, %arg1: i11) -> i11 {
}

// CHECK-LABEL: func @or_identity(%arg0: i11, %arg1: i11) -> i11 {
// CHECK-NEXT: %[[RES:.*]] = rtl.or %arg0, %arg1
// CHECK-NEXT: return %[[RES:.*]]
// CHECK-NEXT: [[RES:%[0-9]+]] = rtl.or %arg0, %arg1
// CHECK-NEXT: return [[RES]]

func @or_identity(%arg0: i11, %arg1: i11) -> i11 {
%c0_i11 = rtl.constant(0 : i11) : i11
Expand All @@ -83,8 +83,8 @@ func @or_identity(%arg0: i11, %arg1: i11) -> i11 {
}

// CHECK-LABEL: func @xor_identity(%arg0: i11, %arg1: i11) -> i11 {
// CHECK-NEXT: %[[RES:.*]] = rtl.xor %arg1, %arg0
// CHECK-NEXT: return %[[RES:.*]]
// CHECK-NEXT: [[RES:%[0-9]+]] = rtl.xor %arg1, %arg0
// CHECK-NEXT: return [[RES]]

func @xor_identity(%arg0: i11, %arg1: i11) -> i11 {
%c0_i11 = rtl.constant(0 : i11) : i11
Expand All @@ -93,8 +93,8 @@ func @xor_identity(%arg0: i11, %arg1: i11) -> i11 {
}

// CHECK-LABEL: func @add_identity(%arg0: i11, %arg1: i11) -> i11 {
// CHECK-NEXT: %[[RES:.*]] = rtl.add %arg0, %arg1
// CHECK-NEXT: return %[[RES:.*]]
// CHECK-NEXT: [[RES:%[0-9]+]] = rtl.add %arg0, %arg1
// CHECK-NEXT: return [[RES]]

func @add_identity(%arg0: i11, %arg1: i11) -> i11 {
%c0_i11 = rtl.constant(0 : i11) : i11
Expand All @@ -103,8 +103,8 @@ func @add_identity(%arg0: i11, %arg1: i11) -> i11 {
}

// CHECK-LABEL: func @mul_identity(%arg0: i11, %arg1: i11) -> i11 {
// CHECK-NEXT: %[[RES:.*]] = rtl.mul %arg0, %arg1
// CHECK-NEXT: return %[[RES:.*]]
// CHECK-NEXT: [[RES:%[0-9]+]] = rtl.mul %arg0, %arg1
// CHECK-NEXT: return [[RES]]

func @mul_identity(%arg0: i11, %arg1: i11) -> i11 {
%c1_i11 = rtl.constant(1 : i11) : i11
Expand Down

0 comments on commit 5fd07b2

Please sign in to comment.