Import Tint changes from Dawn

Changes:
  - 54bcbdbbf34be86f006c7e4cadc60798942a99b5 tint/resolver: Fix intrinsic table matching of AInt as AF... by Ben Clayton <bclayton@google.com>
  - 7b332abc828e056db1fc13b4dc3ea23566465f41 Remove cmake visibility flags. by dan sinclair <dsinclair@chromium.org>
GitOrigin-RevId: 54bcbdbbf34be86f006c7e4cadc60798942a99b5
Change-Id: I3d0b8ee52ebc669be1a966e48d38d4bcbbc19315
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/100821
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index 5d77470..4ffaf94 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -648,9 +648,6 @@
 add_library(libtint ${TINT_LIB_SRCS})
 tint_default_compile_options(libtint)
 target_link_libraries(libtint tint_diagnostic_utils)
-if (${COMPILER_IS_LIKE_GNU})
-  target_compile_options(libtint PRIVATE -fvisibility=hidden)
-endif()
 if (${TINT_SYMBOL_STORE_DEBUG_NAME})
     target_compile_definitions(libtint PUBLIC "TINT_SYMBOL_STORE_DEBUG_NAME=1")
 endif()
diff --git a/src/tint/intrinsics.def b/src/tint/intrinsics.def
index 2b84d45..ae89f5c 100644
--- a/src/tint/intrinsics.def
+++ b/src/tint/intrinsics.def
@@ -105,8 +105,8 @@
 
 // https://gpuweb.github.io/gpuweb/wgsl/#plain-types-section
 type bool
-@precedence(5) @display("abstract-float") type fa
-@precedence(4) @display("abstract-int")   type ia
+@precedence(5) @display("abstract-int")   type ia
+@precedence(4) @display("abstract-float") type fa
 @precedence(3) type i32
 @precedence(2) type u32
 @precedence(1) type f32
@@ -757,40 +757,40 @@
 // Matrix constructors (scalar)
 @const("MatCtorS")
 ctor mat2x2<T: fa_f32_f16>(T, T,
-                          T, T) -> mat2x2<T>
+                           T, T) -> mat2x2<T>
 @const("MatCtorS")
 ctor mat2x3<T: fa_f32_f16>(T, T, T,
-                          T, T, T) -> mat2x3<T>
+                           T, T, T) -> mat2x3<T>
 @const("MatCtorS")
 ctor mat2x4<T: fa_f32_f16>(T, T, T, T,
-                          T, T, T, T) -> mat2x4<T>
+                           T, T, T, T) -> mat2x4<T>
 @const("MatCtorS")
 ctor mat3x2<T: fa_f32_f16>(T, T,
-                          T, T,
-                          T, T) -> mat3x2<T>
+                           T, T,
+                           T, T) -> mat3x2<T>
 @const("MatCtorS")
 ctor mat3x3<T: fa_f32_f16>(T, T, T,
-                          T, T, T,
-                          T, T, T) -> mat3x3<T>
+                           T, T, T,
+                           T, T, T) -> mat3x3<T>
 @const("MatCtorS")
 ctor mat3x4<T: fa_f32_f16>(T, T, T, T,
-                          T, T, T, T,
-                          T, T, T, T) -> mat3x4<T>
+                           T, T, T, T,
+                           T, T, T, T) -> mat3x4<T>
 @const("MatCtorS")
 ctor mat4x2<T: fa_f32_f16>(T, T,
-                          T, T,
-                          T, T,
-                          T, T) -> mat4x2<T>
+                           T, T,
+                           T, T,
+                           T, T) -> mat4x2<T>
 @const("MatCtorS")
 ctor mat4x3<T: fa_f32_f16>(T, T, T,
-                          T, T, T,
-                          T, T, T,
-                          T, T, T) -> mat4x3<T>
+                           T, T, T,
+                           T, T, T,
+                           T, T, T) -> mat4x3<T>
 @const("MatCtorS")
 ctor mat4x4<T: fa_f32_f16>(T, T, T, T,
-                          T, T, T, T,
-                          T, T, T, T,
-                          T, T, T, T) -> mat4x4<T>
+                           T, T, T, T,
+                           T, T, T, T,
+                           T, T, T, T) -> mat4x4<T>
 
 // Matrix constructors (column vectors)
 @const("MatCtorV")
diff --git a/src/tint/resolver/intrinsic_table.cc b/src/tint/resolver/intrinsic_table.cc
index 0cd0abe..86b44a4 100644
--- a/src/tint/resolver/intrinsic_table.cc
+++ b/src/tint/resolver/intrinsic_table.cc
@@ -349,7 +349,7 @@
 }
 
 bool match_fa(const sem::Type* ty) {
-    return ty->IsAnyOf<Any, sem::AbstractFloat>();
+    return ty->IsAnyOf<Any, sem::AbstractNumeric>();
 }
 
 const sem::AbstractInt* build_ia(MatchState& state) {
diff --git a/src/tint/resolver/intrinsic_table.inl b/src/tint/resolver/intrinsic_table.inl
index c589b2f..ff5878a 100644
--- a/src/tint/resolver/intrinsic_table.inl
+++ b/src/tint/resolver/intrinsic_table.inl
@@ -48,34 +48,6 @@
   return "bool";
 }
 
-/// TypeMatcher for 'type fa'
-class Fa : public TypeMatcher {
- public:
-  /// Checks whether the given type matches the matcher rules.
-  /// Match may define and refine the template types and numbers in state.
-  /// @param state the MatchState
-  /// @param type the type to match
-  /// @returns the canonicalized type on match, otherwise nullptr
-  const sem::Type* Match(MatchState& state,
-                         const sem::Type* type) const override;
-  /// @param state the MatchState
-  /// @return a string representation of the matcher.
-  std::string String(MatchState* state) const override;
-};
-
-const sem::Type* Fa::Match(MatchState& state, const sem::Type* ty) const {
-  if (!match_fa(ty)) {
-    return nullptr;
-  }
-  return build_fa(state);
-}
-
-std::string Fa::String(MatchState*) const {
-  std::stringstream ss;
-  ss << "abstract-float";
-  return ss.str();
-}
-
 /// TypeMatcher for 'type ia'
 class Ia : public TypeMatcher {
  public:
@@ -104,6 +76,34 @@
   return ss.str();
 }
 
+/// TypeMatcher for 'type fa'
+class Fa : public TypeMatcher {
+ public:
+  /// Checks whether the given type matches the matcher rules.
+  /// Match may define and refine the template types and numbers in state.
+  /// @param state the MatchState
+  /// @param type the type to match
+  /// @returns the canonicalized type on match, otherwise nullptr
+  const sem::Type* Match(MatchState& state,
+                         const sem::Type* type) const override;
+  /// @param state the MatchState
+  /// @return a string representation of the matcher.
+  std::string String(MatchState* state) const override;
+};
+
+const sem::Type* Fa::Match(MatchState& state, const sem::Type* ty) const {
+  if (!match_fa(ty)) {
+    return nullptr;
+  }
+  return build_fa(state);
+}
+
+std::string Fa::String(MatchState*) const {
+  std::stringstream ss;
+  ss << "abstract-float";
+  return ss.str();
+}
+
 /// TypeMatcher for 'type i32'
 class I32 : public TypeMatcher {
  public:
@@ -1567,12 +1567,12 @@
 };
 
 const sem::Type* AbstractOrScalar::Match(MatchState& state, const sem::Type* ty) const {
-  if (match_fa(ty)) {
-    return build_fa(state);
-  }
   if (match_ia(ty)) {
     return build_ia(state);
   }
+  if (match_fa(ty)) {
+    return build_fa(state);
+  }
   if (match_i32(ty)) {
     return build_i32(state);
   }
@@ -1859,12 +1859,12 @@
 };
 
 const sem::Type* FiaFiu32F16::Match(MatchState& state, const sem::Type* ty) const {
-  if (match_fa(ty)) {
-    return build_fa(state);
-  }
   if (match_ia(ty)) {
     return build_ia(state);
   }
+  if (match_fa(ty)) {
+    return build_fa(state);
+  }
   if (match_i32(ty)) {
     return build_i32(state);
   }
@@ -1905,12 +1905,12 @@
 };
 
 const sem::Type* FiaFi32F16::Match(MatchState& state, const sem::Type* ty) const {
-  if (match_fa(ty)) {
-    return build_fa(state);
-  }
   if (match_ia(ty)) {
     return build_ia(state);
   }
+  if (match_fa(ty)) {
+    return build_fa(state);
+  }
   if (match_i32(ty)) {
     return build_i32(state);
   }
@@ -1948,12 +1948,12 @@
 };
 
 const sem::Type* FiaFiu32::Match(MatchState& state, const sem::Type* ty) const {
-  if (match_fa(ty)) {
-    return build_fa(state);
-  }
   if (match_ia(ty)) {
     return build_ia(state);
   }
+  if (match_fa(ty)) {
+    return build_fa(state);
+  }
   if (match_i32(ty)) {
     return build_i32(state);
   }
@@ -2533,8 +2533,8 @@
   TemplateNumberMatcher template_number_1_{1};
   TemplateNumberMatcher template_number_2_{2};
   Bool Bool_;
-  Fa Fa_;
   Ia Ia_;
+  Fa Fa_;
   I32 I32_;
   U32 U32_;
   F32 F32_;
@@ -2619,8 +2619,8 @@
     /* [0] */ &template_type_0_,
     /* [1] */ &template_type_1_,
     /* [2] */ &Bool_,
-    /* [3] */ &Fa_,
-    /* [4] */ &Ia_,
+    /* [3] */ &Ia_,
+    /* [4] */ &Fa_,
     /* [5] */ &I32_,
     /* [6] */ &U32_,
     /* [7] */ &F32_,
diff --git a/src/tint/resolver/intrinsic_table_test.cc b/src/tint/resolver/intrinsic_table_test.cc
index 02c97f7..b9f9d53 100644
--- a/src/tint/resolver/intrinsic_table_test.cc
+++ b/src/tint/resolver/intrinsic_table_test.cc
@@ -767,6 +767,22 @@
 )");
 }
 
+TEST_F(IntrinsicTableTest, MatchTypeConstructorImplicitMatFromVec) {
+    auto* af = create<sem::AbstractFloat>();
+    auto* vec2_ai = create<sem::Vector>(create<sem::AbstractInt>(), 2u);
+    auto* vec2_af = create<sem::Vector>(af, 2u);
+    auto* mat2x2_af = create<sem::Matrix>(vec2_af, 2u);
+    auto result = table->Lookup(CtorConvIntrinsic::kMat2x2, nullptr,
+                                utils::Vector{vec2_ai, vec2_ai}, Source{{12, 34}});
+    ASSERT_NE(result.target, nullptr);
+    EXPECT_TYPE(result.target->ReturnType(), mat2x2_af);
+    EXPECT_TRUE(result.target->Is<sem::TypeConstructor>());
+    ASSERT_EQ(result.target->Parameters().Length(), 2u);
+    EXPECT_TYPE(result.target->Parameters()[0]->Type(), vec2_af);
+    EXPECT_TYPE(result.target->Parameters()[1]->Type(), vec2_af);
+    EXPECT_NE(result.const_eval_fn, nullptr);
+}
+
 TEST_F(IntrinsicTableTest, MatchTypeConversion) {
     auto* i32 = create<sem::I32>();
     auto* vec3_i32 = create<sem::Vector>(i32, 3u);