Skip to content

Instantly share code, notes, and snippets.

@stellaraccident
Created September 22, 2021 02:41
Show Gist options
  • Save stellaraccident/2727cfa955c61e1704408a27f93e626b to your computer and use it in GitHub Desktop.
Save stellaraccident/2727cfa955c61e1704408a27f93e626b to your computer and use it in GitHub Desktop.
module @module attributes {hal.device.targets = [#device_target_cpu]} {
vm.module public @module attributes {ordinal_counts = #vm.ordinal_counts<import_funcs = 0, export_funcs = 1, internal_funcs = 1, global_bytes = 0, global_refs = 0, rodatas = 0, rwdatas = 0>} {
vm.func private @return_arg(%arg0: i32) -> (i32, i32) attributes {ordinal = 0 : i32} {
%zero = vm.const.i32.zero : i32
%c2 = vm.const.i32 2 : i32
%c9 = vm.const.i32 9 : i32
%c1 = vm.const.i32 1 : i32
%c256 = vm.const.i32 256 : i32
%c-4 = vm.const.i32 -4 : i32
%list = vm.list.alloc %zero : (i32) -> !vm.list<?>
%list_0 = vm.list.alloc %zero : (i32) -> !vm.list<?>
vm.list.resize %list_0, %c2 : (!vm.list<?>, i32)
vm.list.set.i32 %list_0, %zero, %c9 : (!vm.list<?>, i32, i32)
vm.list.set.i32 %list_0, %c1, %arg0 : (!vm.list<?>, i32, i32)
vm.list.resize %list, %c2 : (!vm.list<?>, i32)
vm.list.set.i32 %list, %zero, %c256 : (!vm.list<?>, i32, i32)
vm.list.set.ref %list, %c1, %list_0 : (!vm.list<?>, i32, !vm.list<?>)
%list_1 = vm.list.get.ref %list, %c1 : (!vm.list<?>, i32) -> !vm.list<?>
%0 = vm.list.get.i32 %list_1, %zero : (!vm.list<?>, i32) -> i32
%eq = vm.cmp.eq.i32 %0, %c9 : i32
vm.cond_br %eq, ^bb1, ^bb2(%c-4, %zero : i32, i32)
^bb1: // pred: ^bb0
%1 = vm.list.get.i32 %list_1, %c1 : (!vm.list<?>, i32) -> i32
vm.br ^bb2(%zero, %1 : i32, i32)
^bb2(%2: i32, %3: i32): // 2 preds: ^bb0, ^bb1
%eq_2 = vm.cmp.eq.i32 %2, %zero : i32
%4 = vm.select.i32 %eq_2, %3, %zero : i32
vm.return %2, %4 : i32, i32
}
vm.export @return_arg attributes {ordinal = 0 : i32}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment