dan sinclair | 63716c5 | 2023-05-04 18:01:26 +0000 | [diff] [blame] | 1 | // Copyright 2023 The Tint Authors. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | #include "src/tint/ir/test_helper.h" |
| 16 | |
| 17 | #include "gmock/gmock.h" |
| 18 | #include "src/tint/ast/case_selector.h" |
| 19 | #include "src/tint/ast/int_literal_expression.h" |
| 20 | #include "src/tint/constant/scalar.h" |
| 21 | |
| 22 | namespace tint::ir { |
| 23 | namespace { |
| 24 | |
| 25 | using namespace tint::number_suffixes; // NOLINT |
| 26 | |
| 27 | using IR_BuilderImplTest = TestHelper; |
| 28 | |
| 29 | TEST_F(IR_BuilderImplTest, EmitExpression_Builtin) { |
| 30 | auto i = GlobalVar("i", builtin::AddressSpace::kPrivate, Expr(1_f)); |
| 31 | auto* expr = Call("asin", i); |
| 32 | WrapInFunction(expr); |
| 33 | |
| 34 | auto r = Build(); |
| 35 | ASSERT_TRUE(r) << Error(); |
| 36 | auto m = r.Move(); |
| 37 | |
| 38 | EXPECT_EQ(Disassemble(m), R"(%fn0 = block |
| 39 | %1:ref<private, f32, read_write> = var private read_write |
| 40 | store %1:ref<private, f32, read_write>, 1.0f |
| 41 | |
| 42 | |
| 43 | |
| 44 | %fn1 = func test_function():void [@compute @workgroup_size(1, 1, 1)] |
| 45 | %fn2 = block |
| 46 | %2:f32 = asin %1:ref<private, f32, read_write> |
| 47 | ret |
| 48 | func_end |
| 49 | |
| 50 | )"); |
| 51 | } |
| 52 | |
| 53 | } // namespace |
| 54 | } // namespace tint::ir |