// RUN: mlir-opt %s | FileCheck %s // CHECK-LABEL: @identity_token func.func @identity_token(%arg0: !async.token) -> !async.token { // CHECK: return %arg0 : !async.token return %arg0 : !async.token } // CHECK-LABEL: @identity_value func.func @identity_value(%arg0 : !async.value) -> !async.value { // CHECK: return %arg0 : !async.value return %arg0 : !async.value } // CHECK-LABEL: @empty_async_execute func.func @empty_async_execute() -> !async.token { // CHECK: async.execute %token = async.execute { async.yield } // CHECK: return %token : !async.token return %token : !async.token } // CHECK-LABEL: @return_async_value func.func @return_async_value() -> !async.value { // CHECK: async.execute -> !async.value %token, %bodyResults = async.execute -> !async.value { %cst = arith.constant 1.000000e+00 : f32 async.yield %cst : f32 } // CHECK: return %bodyResults : !async.value return %bodyResults : !async.value } // CHECK-LABEL: @return_captured_value func.func @return_captured_value() -> !async.token { %cst = arith.constant 1.000000e+00 : f32 // CHECK: async.execute -> !async.value %token, %results = async.execute -> !async.value { async.yield %cst : f32 } // CHECK: return %token : !async.token return %token : !async.token } // CHECK-LABEL: @return_async_values func.func @return_async_values() -> (!async.value, !async.value) { %token, %bodyResults:2 = async.execute -> (!async.value, !async.value) { %cst1 = arith.constant 1.000000e+00 : f32 %cst2 = arith.constant 2.000000e+00 : f32 async.yield %cst1, %cst2 : f32, f32 } // CHECK: return %bodyResults#0, %bodyResults#1 : !async.value, !async.value return %bodyResults#0, %bodyResults#1 : !async.value, !async.value } // CHECK-LABEL: @async_token_dependencies func.func @async_token_dependencies(%arg0: !async.token) -> !async.token { // CHECK: async.execute [%arg0] %token = async.execute [%arg0] { async.yield } // CHECK: return %token : !async.token return %token : !async.token } // CHECK-LABEL: @async_value_operands func.func @async_value_operands(%arg0: !async.value) -> !async.token { // CHECK: async.execute (%arg0 as %arg1: !async.value) -> !async.value %token, %results = async.execute (%arg0 as %arg1: !async.value) -> !async.value { async.yield %arg1 : f32 } // CHECK: return %token : !async.token return %token : !async.token } // CHECK-LABEL: @async_token_and_value_operands func.func @async_token_and_value_operands(%arg0: !async.token, %arg1: !async.value) -> !async.token { // CHECK: async.execute [%arg0] (%arg1 as %arg2: !async.value) -> !async.value %token, %results = async.execute [%arg0] (%arg1 as %arg2: !async.value) -> !async.value { async.yield %arg2 : f32 } // CHECK: return %token : !async.token return %token : !async.token } // CHECK-LABEL: @empty_tokens_or_values_operands func.func @empty_tokens_or_values_operands() { // CHECK: async.execute { %token0 = async.execute [] () -> () { async.yield } // CHECK: async.execute { %token1 = async.execute () -> () { async.yield } // CHECK: async.execute { %token2 = async.execute -> () { async.yield } // CHECK: async.execute { %token3 = async.execute () { async.yield } // CHECK: async.execute { %token4 = async.execute [] { async.yield } return } // CHECK-LABEL: @await_token func.func @await_token(%arg0: !async.token) { // CHECK: async.await %arg0 async.await %arg0 : !async.token return } // CHECK-LABEL: @await_value func.func @await_value(%arg0: !async.value) -> f32 { // CHECK: async.await %arg0 %0 = async.await %arg0 : !async.value return %0 : f32 } // CHECK-LABEL: @create_group_and_await_all func.func @create_group_and_await_all(%arg0: !async.token, %arg1: !async.value) -> index { %c = arith.constant 2 : index %0 = async.create_group %c : !async.group // CHECK: async.add_to_group %arg0 // CHECK: async.add_to_group %arg1 %1 = async.add_to_group %arg0, %0 : !async.token %2 = async.add_to_group %arg1, %0 : !async.value async.await_all %0 %3 = arith.addi %1, %2 : index return %3 : index } // CHECK-LABEL: @async_func_return_token async.func @async_func_return_token() -> !async.token { // CHECK: return return } // CHECK-LABEL: @async_func_return_value async.func @async_func_return_value() -> !async.value { %0 = arith.constant 42 : i32 // CHECK: return %[[value:.*]] : i32 return %0 : i32 } // CHECK-LABEL: @async_func_return_optional_token async.func @async_func_return_optional_token() -> (!async.token, !async.value) { %0 = arith.constant 42 : i32 // CHECK: return %[[value:.*]] : i32 return %0 : i32 } // CHECK-LABEL: @async_call func.func @async_call() { // CHECK: async.call @async_func_return_token // CHECK: async.call @async_func_return_value // CHECK: async.call @async_func_return_optional_token %0 = async.call @async_func_return_token() : () -> !async.token %1 = async.call @async_func_return_value() : () -> !async.value %2, %3 = async.call @async_func_return_optional_token() : () -> (!async.token, !async.value) return }