doc: sample: update sample ir files
This commit is contained in:
30
doc/sample/ir/dominance-test.mie
Normal file
30
doc/sample/ir/dominance-test.mie
Normal file
@@ -0,0 +1,30 @@
|
||||
~func.func() ({
|
||||
^R:
|
||||
%0 = ~arith.constant() {value = 0 : i32} : () -> i32
|
||||
~cf.br-cond(%0) [ ^A, ^B, ^C ] : (i32) -> ()
|
||||
|
||||
^A:
|
||||
~cf.br() [ ^D ] : () -> ()
|
||||
^B:
|
||||
~cf.br-cond(%0) [ ^D, ^A, ^E ] : (i32) -> ()
|
||||
^C:
|
||||
~cf.br-cond(%0) [ ^G, ^F ] : (i32) -> ()
|
||||
^D:
|
||||
~cf.br() [ ^L ] : () -> ()
|
||||
^E:
|
||||
~cf.br() [ ^H ] : () -> ()
|
||||
^F:
|
||||
~cf.br() [ ^I ] : () -> ()
|
||||
^G:
|
||||
~cf.br-cond(%0) [ ^I, ^J ] : (i32) -> ()
|
||||
^H:
|
||||
~cf.br-cond(%0) [ ^E, ^K ] : (i32) -> ()
|
||||
^I:
|
||||
~cf.br() [ ^K ] : () -> ()
|
||||
^J:
|
||||
~cf.br() [ ^I ] : () -> ()
|
||||
^K:
|
||||
~cf.br-cond(%0) [ ^R, ^I ] : (i32) -> ()
|
||||
^L:
|
||||
~cf.br() [ ^H ] : () -> ()
|
||||
}) {sym_name = "test", function_type = () -> () } : () -> ()
|
||||
@@ -1,15 +1,17 @@
|
||||
; Comment
|
||||
func.func @reduce(%buffer: memref<1024*f32>, %lb: index, %ub: index, %step: index) -> f32 {
|
||||
; Initial sum set to 0.
|
||||
%sum.0 = f32.constant 0.0
|
||||
; iter_args binds initial values to the loop's region arguments.
|
||||
%sum = scf.for %iv = %lb to %ub step %step iter-args(%sum.iter = %sum.0) -> (f32) {
|
||||
%t = memref.load %buffer[%iv] : memref<1024*f32>
|
||||
%sum.next = arith.addf %sum.iter, %t : f32
|
||||
; Yield current iteration sum to next iteration %sum.iter or to %sum
|
||||
; if final iteration.
|
||||
scf.yield %sum.next : f32
|
||||
}
|
||||
module {
|
||||
func.func @reduce(%buffer: memref<1024*f32>, %lb: index, %ub: index, %step: index) -> f32 {
|
||||
; Initial sum set to 0.
|
||||
%sum.0 = arith.constant 0.0 : f32
|
||||
; iter_args binds initial values to the loop's region arguments.
|
||||
%sum = scf.for %iv = %lb to %ub step %step iter-args(%sum.iter = %sum.0) -> f32 {
|
||||
%t = memref.load %buffer[%iv] : memref<1024*f32>
|
||||
%sum.next = arith.addf %sum.iter, %t : f32
|
||||
; Yield current iteration sum to next iteration %sum.iter or to %sum
|
||||
; if final iteration.
|
||||
scf.yield %sum.next : f32
|
||||
}
|
||||
|
||||
func.return %sum : f32
|
||||
func.return %sum : f32
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,16 @@
|
||||
~func.func() ({
|
||||
^entry(%buffer: memref<1024*f32>, %lb: index, %ub: index, %step: index):
|
||||
; Initial sum set to 0.
|
||||
%sum.0 = ~f32.constant() {value = 0.0 : f32} : () -> f32
|
||||
; iter_args binds initial values to the loop's region arguments.
|
||||
;%sum = "scf.for"(%lb, %ub, %step) -> (f32) {
|
||||
~cf.br [ ^for.entry(%lb: index, %sum.0: f32) ] : () -> ()
|
||||
|
||||
^for.entry(%iv: index, %sum.iter: f32):
|
||||
%t = ~memref.load(%buffer, %iv) : (memref<1024*f32>, index) -> f32
|
||||
%sum.next = ~arith.addf(%sum.iter, %t) : (f32, f32) -> f32
|
||||
|
||||
~cf.br [ ^for.cond:(%iv: index, %sum.next: f32) ] : () -> ()
|
||||
|
||||
^for.cond(%iv: index, %sum.next: f32):
|
||||
; Yield current iteration sum to next iteration %sum.iter or to %sum
|
||||
; if final iteration.
|
||||
%iv.next = ~arith.addi(%iv, %step) : (index, index) -> index
|
||||
%stop = ~arith.cmpi(%iv.next, %ub) {predicate = 9 : i64} : (index, index) -> i1
|
||||
~cf.br-cond(%stop) [ ^for.end, ^for.entry:(%iv.next: index, %sum.next: f32) ] : () -> ()
|
||||
|
||||
^for.end(%sum: f32):
|
||||
~func.return(%sum) : (f32) -> ()
|
||||
}) {sym_name = "reduce"} : (memref<1024*f32>, index, index, index) -> f32
|
||||
|
||||
module {
|
||||
func.func @_reduce(%buffer: memref<1024*f32>, %lb: index, %ub: index, %step: index) -> f32 {
|
||||
%sum.0 = arith.constant 0 : f32
|
||||
cf.br ^for.entry(%lb: index, %sum.0: f32)
|
||||
^for.entry(%iv: index, %sum.iter: f32):
|
||||
%t = memref.load %buffer[%iv] : memref<1024*f32>
|
||||
%sum.next = arith.addf %sum.iter, %t : f32
|
||||
cf.br ^for.cond(%iv: index, %sum.next: f32)
|
||||
^for.cond(%iv.0: index, %sum.iter.0: index):
|
||||
%iv.next = arith.addi %iv.0, %step : index
|
||||
%stop = arith.cmpi uge %iv.next, %ub : index
|
||||
cf.br-cond %stop, ^for.end(%sum.iter.0: index), ^for.entry(%iv.next: index, %sum.iter.0: index)
|
||||
^for.end(%sum: f32):
|
||||
func.return %sum : f32
|
||||
}
|
||||
}
|
||||
|
||||
26
doc/sample/ir/parse-test-2.mie
Normal file
26
doc/sample/ir/parse-test-2.mie
Normal file
@@ -0,0 +1,26 @@
|
||||
~builtin.module() ({
|
||||
~func.func() ({
|
||||
^entry(%buffer: i32, %lb: index, %ub: index, %step: index):
|
||||
; Initial sum set to 0.
|
||||
%sum.0 = ~arith.constant() {value = 0.0 : f32} : () -> f32
|
||||
; iter_args binds initial values to the loop's region arguments.
|
||||
;%sum = "scf.for"(%lb, %ub, %step) -> (f32) {
|
||||
~cf.br() [ ^for.entry:(%lb: index, %sum.0: f32) ] : () -> ()
|
||||
|
||||
^for.entry(%iv: index, %sum.iter: f32):
|
||||
%t, %x, %z = ~memref.load(%buffer, %iv) : (i32, index) -> (f32, i1, i1)
|
||||
%sum.next = ~arith.addf(%sum.iter, %t) : (f32, f32) -> f32
|
||||
|
||||
~cf.br() [ ^for.cond:(%iv: index, %sum.next: f32) ] : () -> ()
|
||||
|
||||
^for.cond(%iv2: index, %sum.next2: f32):
|
||||
; Yield current iteration sum to next iteration %sum.iter or to %sum
|
||||
; if final iteration.
|
||||
%iv.next = ~arith.addi(%iv, %step) : (index, index) -> index
|
||||
%stop = ~arith.cmpi(%iv.next, %ub) { predicate = 9 } : (index, index) -> i1
|
||||
~cf.br-cond(%stop) [ ^for.end, ^for.entry:(%iv.next: index, %sum.next: f32) ] : (i1) -> ()
|
||||
|
||||
^for.end(%sum: f32):
|
||||
~func.return(%sum) : (f32) -> ()
|
||||
}) {sym_name = "reduce", function_type = (i32, index, index, index) -> f32 } : () -> ()
|
||||
}) : () -> ()
|
||||
@@ -1,26 +1,25 @@
|
||||
~builtin.module() ({
|
||||
~func.func() ({
|
||||
^entry(%buffer: i32, %lb: index, %ub: index, %step: index):
|
||||
module {
|
||||
func.func @reduce(%buffer: memref<?*f32>, %lb: index, %ub: index, %step: index) -> f32 {
|
||||
; Initial sum set to 0.
|
||||
%sum.0 = ~arith.constant() {value = 0.0 : f32} : () -> f32
|
||||
%sum.0 = arith.constant 0.0 : f32
|
||||
; iter_args binds initial values to the loop's region arguments.
|
||||
;%sum = "scf.for"(%lb, %ub, %step) -> (f32) {
|
||||
~cf.br() [ ^for.entry:(%lb: index, %sum.0: f32) ] : () -> ()
|
||||
cf.br ^for.entry(%lb: index, %sum.0: f32)
|
||||
|
||||
^for.entry(%iv: index, %sum.iter: f32):
|
||||
%t, %x, %z = ~memref.load(%buffer, %iv) : (i32, index) -> (f32, i1, i1)
|
||||
%sum.next = ~arith.addf(%sum.iter, %t) : (f32, f32) -> f32
|
||||
%t = memref.load %buffer[%iv] : memref<?*f32>
|
||||
%sum.next = arith.addf %sum.iter, %t : f32
|
||||
|
||||
~cf.br() [ ^for.cond:(%iv: index, %sum.next: f32) ] : () -> ()
|
||||
cf.br ^for.cond(%iv: index, %sum.next: f32)
|
||||
|
||||
^for.cond(%iv2: index, %sum.next2: f32):
|
||||
; Yield current iteration sum to next iteration %sum.iter or to %sum
|
||||
; if final iteration.
|
||||
%iv.next = ~arith.addi(%iv, %step) : (index, index) -> index
|
||||
%stop = ~arith.cmpi(%iv.next, %ub) { predicate = 9 } : (index, index) -> i1
|
||||
~cf.br-cond(%stop) [ ^for.end, ^for.entry:(%iv.next: index, %sum.next: f32) ] : (i1) -> ()
|
||||
%iv.next = arith.addi %iv, %step : index
|
||||
%stop = arith.cmpi uge %iv.next, %ub : index
|
||||
cf.br-cond %stop, ^for.end, ^for.entry(%iv.next: index, %sum.next: f32)
|
||||
|
||||
^for.end(%sum: f32):
|
||||
~func.return(%sum) : (f32) -> ()
|
||||
}) {sym_name = "reduce", function_type = (i32, index, index, index) -> f32 } : () -> ()
|
||||
}) : () -> ()
|
||||
func.return %sum : f32
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user