tint: Add sem::Load node

This change adds the node, but this is (currently) not generated or used.

Bug: tint:1654
Change-Id: Id38e531bf811833cf576085805cb00f444ea5451
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99581
Commit-Queue: James Price <jrprice@google.com>
Kokoro: James Price <jrprice@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
diff --git a/src/tint/BUILD.gn b/src/tint/BUILD.gn
index d74eaac..45a965d 100644
--- a/src/tint/BUILD.gn
+++ b/src/tint/BUILD.gn
@@ -429,6 +429,7 @@
     "sem/if_statement.h",
     "sem/index_accessor_expression.h",
     "sem/info.h",
+    "sem/load.h",
     "sem/loop_statement.h",
     "sem/materialize.h",
     "sem/module.h",
@@ -662,6 +663,8 @@
     "sem/index_accessor_expression.h",
     "sem/info.cc",
     "sem/info.h",
+    "sem/load.cc",
+    "sem/load.h",
     "sem/loop_statement.cc",
     "sem/loop_statement.h",
     "sem/materialize.cc",
diff --git a/src/tint/CMakeLists.txt b/src/tint/CMakeLists.txt
index d32da21..630f998 100644
--- a/src/tint/CMakeLists.txt
+++ b/src/tint/CMakeLists.txt
@@ -322,6 +322,8 @@
   sem/index_accessor_expression.h
   sem/info.cc
   sem/info.h
+  sem/load.cc
+  sem/load.h
   sem/loop_statement.cc
   sem/loop_statement.h
   sem/materialize.cc
diff --git a/src/tint/sem/load.cc b/src/tint/sem/load.cc
new file mode 100644
index 0000000..58f7068
--- /dev/null
+++ b/src/tint/sem/load.cc
@@ -0,0 +1,37 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0(the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "src/tint/sem/load.h"
+
+#include "src/tint/debug.h"
+#include "src/tint/type/reference.h"
+
+TINT_INSTANTIATE_TYPEINFO(tint::sem::Load);
+
+namespace tint::sem {
+Load::Load(const Expression* ref, const Statement* statement)
+    : Base(/* declaration */ ref->Declaration(),
+           /* type */ ref->Type()->UnwrapRef(),
+           /* stage */ EvaluationStage::kRuntime,  // Loads can only be runtime
+           /* statement */ statement,
+           /* constant */ nullptr,
+           /* has_side_effects */ ref->HasSideEffects(),
+           /* root_ident */ ref->RootIdentifier()),
+      reference_(ref) {
+    TINT_ASSERT(Semantic, ref->Type()->Is<type::Reference>());
+}
+
+Load::~Load() = default;
+
+}  // namespace tint::sem
diff --git a/src/tint/sem/load.h b/src/tint/sem/load.h
new file mode 100644
index 0000000..1a63266
--- /dev/null
+++ b/src/tint/sem/load.h
@@ -0,0 +1,50 @@
+// Copyright 2022 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0(the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef SRC_TINT_SEM_LOAD_H_
+#define SRC_TINT_SEM_LOAD_H_
+
+#include "src/tint/sem/expression.h"
+#include "src/tint/type/reference.h"
+
+namespace tint::sem {
+
+/// Load is a semantic expression which represents the load of a reference to a non-reference value.
+/// Loads from reference types are implicit in WGSL, so the Load semantic node shares the same AST
+/// node as the inner semantic node.
+class Load final : public Castable<Load, Expression> {
+  public:
+    /// Constructor
+    /// @param reference the reference expression being loaded
+    /// @param statement the statement that owns this expression
+    Load(const Expression* reference, const Statement* statement);
+
+    /// Destructor
+    ~Load() override;
+
+    /// @return the reference being loaded
+    const Expression* Reference() const { return reference_; }
+
+    /// @returns the type of the loaded reference.
+    const type::Reference* ReferenceType() const {
+        return static_cast<const type::Reference*>(reference_->Type());
+    }
+
+  private:
+    Expression const* const reference_;
+};
+
+}  // namespace tint::sem
+
+#endif  // SRC_TINT_SEM_LOAD_H_
diff --git a/src/tint/sem/materialize.h b/src/tint/sem/materialize.h
index 6fa77a4..8a65a03 100644
--- a/src/tint/sem/materialize.h
+++ b/src/tint/sem/materialize.h
@@ -40,7 +40,7 @@
     /// Destructor
     ~Materialize() override;
 
-    /// @return the target of the call
+    /// @return the expression being materialized
     const Expression* Expr() const { return expr_; }
 
   private: