[transform] Move the transform folder

This CL moves the transform folder from src/ast to src/. The transforms
operate on the AST, but they aren't part of the AST so I think the top
level folder makes more sense.

This will possibly cause issues when rolling if the transform is being
used.

Change-Id: Ibd7c94474168a7a4bdf38321f4e12ad111c80323
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/28941
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
diff --git a/BUILD.gn b/BUILD.gn
index 1110d6c..a1ed133 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -315,8 +315,6 @@
     "src/ast/struct_member_offset_decoration.h",
     "src/ast/switch_statement.cc",
     "src/ast/switch_statement.h",
-    "src/ast/transform/vertex_pulling_transform.cc",
-    "src/ast/transform/vertex_pulling_transform.h",
     "src/ast/type/alias_type.cc",
     "src/ast/type/alias_type.h",
     "src/ast/type/array_type.cc",
@@ -375,6 +373,8 @@
     "src/reader/reader.h",
     "src/scope_stack.h",
     "src/source.h",
+    "src/transform/vertex_pulling_transform.cc",
+    "src/transform/vertex_pulling_transform.h",
     "src/type_determiner.cc",
     "src/type_determiner.h",
     "src/type_manager.cc",
@@ -723,7 +723,6 @@
     "src/ast/struct_member_test.cc",
     "src/ast/struct_test.cc",
     "src/ast/switch_statement_test.cc",
-    "src/ast/transform/vertex_pulling_transform_test.cc",
     "src/ast/type/alias_type_test.cc",
     "src/ast/type/array_type_test.cc",
     "src/ast/type/bool_type_test.cc",
@@ -746,6 +745,7 @@
     "src/ast/variable_test.cc",
     "src/ast/workgroup_decoration_test.cc",
     "src/scope_stack_test.cc",
+    "src/transform/vertex_pulling_transform_test.cc",
     "src/type_determiner_test.cc",
     "src/type_manager_test.cc",
     "src/validator_control_block_test.cc",
diff --git a/include/tint/tint.h b/include/tint/tint.h
index cba95f0..9a23ab2 100644
--- a/include/tint/tint.h
+++ b/include/tint/tint.h
@@ -21,13 +21,12 @@
 #include "src/ast/pipeline_stage.h"
 #include "src/context.h"
 #include "src/reader/reader.h"
+#include "src/transform/vertex_pulling_transform.h"
 #include "src/type_determiner.h"
 #include "src/type_manager.h"
 #include "src/validator.h"
 #include "src/writer/writer.h"
 
-#include "src/ast/transform/vertex_pulling_transform.h"
-
 #if TINT_BUILD_SPV_READER
 #include "src/reader/spirv/parser.h"
 #endif  // TINT_BUILD_SPV_READER
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 16409aa..7c16a03 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -136,8 +136,6 @@
   ast/struct_member_offset_decoration.h
   ast/switch_statement.cc
   ast/switch_statement.h
-  ast/transform/vertex_pulling_transform.cc
-  ast/transform/vertex_pulling_transform.h
   ast/type_constructor_expression.h
   ast/type_constructor_expression.cc
   ast/type/alias_type.cc
@@ -196,6 +194,8 @@
   reader/reader.h
   scope_stack.h
   source.h
+  transform/vertex_pulling_transform.cc
+  transform/vertex_pulling_transform.h
   type_determiner.cc
   type_determiner.h
   type_manager.cc
@@ -333,7 +333,6 @@
   ast/struct_member_offset_decoration_test.cc
   ast/struct_test.cc
   ast/switch_statement_test.cc
-  ast/transform/vertex_pulling_transform_test.cc
   ast/type/alias_type_test.cc
   ast/type/array_type_test.cc
   ast/type/bool_type_test.cc
@@ -356,6 +355,7 @@
   ast/variable_test.cc
   ast/workgroup_decoration_test.cc
   scope_stack_test.cc
+  transform/vertex_pulling_transform_test.cc
   type_determiner_test.cc
   type_manager_test.cc
   validator_control_block_test.cc
diff --git a/src/ast/transform/vertex_pulling_transform.cc b/src/transform/vertex_pulling_transform.cc
similarity index 68%
rename from src/ast/transform/vertex_pulling_transform.cc
rename to src/transform/vertex_pulling_transform.cc
index 23fd90b..be060a9 100644
--- a/src/ast/transform/vertex_pulling_transform.cc
+++ b/src/transform/vertex_pulling_transform.cc
@@ -12,16 +12,14 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "src/ast/transform/vertex_pulling_transform.h"
+#include "src/transform/vertex_pulling_transform.h"
 
 #include "src/ast/array_accessor_expression.h"
 #include "src/ast/assignment_statement.h"
 #include "src/ast/binary_expression.h"
 #include "src/ast/bitcast_expression.h"
 #include "src/ast/decorated_variable.h"
-#include "src/ast/expression.h"
 #include "src/ast/member_accessor_expression.h"
-#include "src/ast/module.h"
 #include "src/ast/scalar_constructor_expression.h"
 #include "src/ast/struct.h"
 #include "src/ast/struct_decoration.h"
@@ -36,22 +34,21 @@
 #include "src/ast/type_constructor_expression.h"
 #include "src/ast/uint_literal.h"
 #include "src/ast/variable_decl_statement.h"
-#include "src/context.h"
 
 namespace tint {
-namespace ast {
 namespace transform {
 
 namespace {
-// TODO(idanr): What to do if these names are already used?
+
 static const char kVertexBufferNamePrefix[] = "tint_pulling_vertex_buffer_";
 static const char kStructBufferName[] = "data";
 static const char kPullingPosVarName[] = "tint_pulling_pos";
 static const char kDefaultVertexIndexName[] = "tint_pulling_vertex_index";
 static const char kDefaultInstanceIndexName[] = "tint_pulling_instance_index";
+
 }  // namespace
 
-VertexPullingTransform::VertexPullingTransform(Context* ctx, Module* mod)
+VertexPullingTransform::VertexPullingTransform(Context* ctx, ast::Module* mod)
     : ctx_(ctx), mod_(mod) {}
 
 VertexPullingTransform::~VertexPullingTransform() = default;
@@ -78,7 +75,7 @@
 
   // Find entry point
   auto* func = mod_->FindFunctionByNameAndStage(entry_point_name_,
-                                                PipelineStage::kVertex);
+                                                ast::PipelineStage::kVertex);
   if (func == nullptr) {
     SetError("Vertex stage entry point not found");
     return false;
@@ -125,12 +122,13 @@
 
   // Look for an existing vertex index builtin
   for (auto& v : mod_->global_variables()) {
-    if (!v->IsDecorated() || v->storage_class() != StorageClass::kInput) {
+    if (!v->IsDecorated() || v->storage_class() != ast::StorageClass::kInput) {
       continue;
     }
 
     for (auto& d : v->AsDecorated()->decorations()) {
-      if (d->IsBuiltin() && d->AsBuiltin()->value() == Builtin::kVertexIdx) {
+      if (d->IsBuiltin() &&
+          d->AsBuiltin()->value() == ast::Builtin::kVertexIdx) {
         vertex_index_name_ = v->name();
         return;
       }
@@ -140,12 +138,13 @@
   // We didn't find a vertex index builtin, so create one
   vertex_index_name_ = kDefaultVertexIndexName;
 
-  auto var = std::make_unique<DecoratedVariable>(std::make_unique<Variable>(
-      vertex_index_name_, StorageClass::kInput, GetI32Type()));
+  auto var =
+      std::make_unique<ast::DecoratedVariable>(std::make_unique<ast::Variable>(
+          vertex_index_name_, ast::StorageClass::kInput, GetI32Type()));
 
-  VariableDecorationList decorations;
+  ast::VariableDecorationList decorations;
   decorations.push_back(
-      std::make_unique<BuiltinDecoration>(Builtin::kVertexIdx));
+      std::make_unique<ast::BuiltinDecoration>(ast::Builtin::kVertexIdx));
 
   var->set_decorations(std::move(decorations));
   mod_->AddGlobalVariable(std::move(var));
@@ -166,12 +165,13 @@
 
   // Look for an existing instance index builtin
   for (auto& v : mod_->global_variables()) {
-    if (!v->IsDecorated() || v->storage_class() != StorageClass::kInput) {
+    if (!v->IsDecorated() || v->storage_class() != ast::StorageClass::kInput) {
       continue;
     }
 
     for (auto& d : v->AsDecorated()->decorations()) {
-      if (d->IsBuiltin() && d->AsBuiltin()->value() == Builtin::kInstanceIdx) {
+      if (d->IsBuiltin() &&
+          d->AsBuiltin()->value() == ast::Builtin::kInstanceIdx) {
         instance_index_name_ = v->name();
         return;
       }
@@ -181,12 +181,13 @@
   // We didn't find an instance index builtin, so create one
   instance_index_name_ = kDefaultInstanceIndexName;
 
-  auto var = std::make_unique<DecoratedVariable>(std::make_unique<Variable>(
-      instance_index_name_, StorageClass::kInput, GetI32Type()));
+  auto var =
+      std::make_unique<ast::DecoratedVariable>(std::make_unique<ast::Variable>(
+          instance_index_name_, ast::StorageClass::kInput, GetI32Type()));
 
-  VariableDecorationList decorations;
+  ast::VariableDecorationList decorations;
   decorations.push_back(
-      std::make_unique<BuiltinDecoration>(Builtin::kInstanceIdx));
+      std::make_unique<ast::BuiltinDecoration>(ast::Builtin::kInstanceIdx));
 
   var->set_decorations(std::move(decorations));
   mod_->AddGlobalVariable(std::move(var));
@@ -194,7 +195,7 @@
 
 void VertexPullingTransform::ConvertVertexInputVariablesToPrivate() {
   for (auto& v : mod_->global_variables()) {
-    if (!v->IsDecorated() || v->storage_class() != StorageClass::kInput) {
+    if (!v->IsDecorated() || v->storage_class() != ast::StorageClass::kInput) {
       continue;
     }
 
@@ -207,8 +208,8 @@
       // This is where the replacement happens. Expressions use identifier
       // strings instead of pointers, so we don't need to update any other place
       // in the AST.
-      v = std::make_unique<Variable>(v->name(), StorageClass::kPrivate,
-                                     v->type());
+      v = std::make_unique<ast::Variable>(
+          v->name(), ast::StorageClass::kPrivate, v->type());
       location_to_var_[location] = v.get();
       break;
     }
@@ -218,45 +219,51 @@
 void VertexPullingTransform::AddVertexStorageBuffers() {
   // TODO(idanr): Make this readonly https://github.com/gpuweb/gpuweb/issues/935
   // The array inside the struct definition
-  auto internal_array = std::make_unique<type::ArrayType>(GetU32Type());
+  auto internal_array = std::make_unique<ast::type::ArrayType>(GetU32Type());
   internal_array->set_array_stride(4u);
   auto* internal_array_type = ctx_->type_mgr().Get(std::move(internal_array));
 
   // Creating the struct type
-  StructMemberList members;
-  StructMemberDecorationList member_dec;
-  member_dec.push_back(std::make_unique<StructMemberOffsetDecoration>(0u));
-  members.push_back(std::make_unique<StructMember>(
+  ast::StructMemberList members;
+  ast::StructMemberDecorationList member_dec;
+  member_dec.push_back(std::make_unique<ast::StructMemberOffsetDecoration>(0u));
+
+  members.push_back(std::make_unique<ast::StructMember>(
       kStructBufferName, internal_array_type, std::move(member_dec)));
-  auto* struct_type = ctx_->type_mgr().Get(std::make_unique<type::StructType>(
-      std::make_unique<Struct>(StructDecoration::kBlock, std::move(members))));
+
+  auto* struct_type = ctx_->type_mgr().Get(
+      std::make_unique<ast::type::StructType>(std::make_unique<ast::Struct>(
+          ast::StructDecoration::kBlock, std::move(members))));
 
   for (uint32_t i = 0; i < vertex_state_->vertex_buffers.size(); ++i) {
     // The decorated variable with struct type
-    auto var = std::make_unique<DecoratedVariable>(std::make_unique<Variable>(
-        GetVertexBufferName(i), StorageClass::kStorageBuffer, struct_type));
+    auto var = std::make_unique<ast::DecoratedVariable>(
+        std::make_unique<ast::Variable>(GetVertexBufferName(i),
+                                        ast::StorageClass::kStorageBuffer,
+                                        struct_type));
 
     // Add decorations
-    VariableDecorationList decorations;
-    decorations.push_back(std::make_unique<BindingDecoration>(i));
-    decorations.push_back(std::make_unique<SetDecoration>(pulling_set_));
+    ast::VariableDecorationList decorations;
+    decorations.push_back(std::make_unique<ast::BindingDecoration>(i));
+    decorations.push_back(std::make_unique<ast::SetDecoration>(pulling_set_));
     var->set_decorations(std::move(decorations));
 
     mod_->AddGlobalVariable(std::move(var));
   }
 }
 
-void VertexPullingTransform::AddVertexPullingPreamble(Function* vertex_func) {
+void VertexPullingTransform::AddVertexPullingPreamble(
+    ast::Function* vertex_func) {
   // Assign by looking at the vertex descriptor to find attributes with matching
   // location.
 
   // A block statement allowing us to use append instead of insert
-  auto block = std::make_unique<BlockStatement>();
+  auto block = std::make_unique<ast::BlockStatement>();
 
   // Declare the |kPullingPosVarName| variable in the shader
-  auto pos_declaration =
-      std::make_unique<VariableDeclStatement>(std::make_unique<Variable>(
-          kPullingPosVarName, StorageClass::kFunction, GetI32Type()));
+  auto pos_declaration = std::make_unique<ast::VariableDeclStatement>(
+      std::make_unique<ast::Variable>(
+          kPullingPosVarName, ast::StorageClass::kFunction, GetI32Type()));
 
   // |kPullingPosVarName| refers to the byte location of the current read. We
   // declare a variable in the shader to avoid having to reuse Expression
@@ -276,26 +283,26 @@
       auto* v = it->second;
 
       // Identifier to index by
-      auto index_identifier = std::make_unique<IdentifierExpression>(
+      auto index_identifier = std::make_unique<ast::IdentifierExpression>(
           buffer_layout.step_mode == InputStepMode::kVertex
               ? vertex_index_name_
               : instance_index_name_);
 
       // An expression for the start of the read in the buffer in bytes
-      auto pos_value = std::make_unique<BinaryExpression>(
-          BinaryOp::kAdd,
-          std::make_unique<BinaryExpression>(
-              BinaryOp::kMultiply, std::move(index_identifier),
+      auto pos_value = std::make_unique<ast::BinaryExpression>(
+          ast::BinaryOp::kAdd,
+          std::make_unique<ast::BinaryExpression>(
+              ast::BinaryOp::kMultiply, std::move(index_identifier),
               GenUint(static_cast<uint32_t>(buffer_layout.array_stride))),
           GenUint(static_cast<uint32_t>(attribute_desc.offset)));
 
       // Update position of the read
-      auto set_pos_expr = std::make_unique<AssignmentStatement>(
+      auto set_pos_expr = std::make_unique<ast::AssignmentStatement>(
           CreatePullingPositionIdent(), std::move(pos_value));
       block->append(std::move(set_pos_expr));
 
-      block->append(std::make_unique<AssignmentStatement>(
-          std::make_unique<IdentifierExpression>(v->name()),
+      block->append(std::make_unique<ast::AssignmentStatement>(
+          std::make_unique<ast::IdentifierExpression>(v->name()),
           AccessByFormat(i, attribute_desc.format)));
     }
   }
@@ -303,17 +310,18 @@
   vertex_func->body()->insert(0, std::move(block));
 }
 
-std::unique_ptr<Expression> VertexPullingTransform::GenUint(uint32_t value) {
-  return std::make_unique<ScalarConstructorExpression>(
-      std::make_unique<UintLiteral>(GetU32Type(), value));
+std::unique_ptr<ast::Expression> VertexPullingTransform::GenUint(
+    uint32_t value) {
+  return std::make_unique<ast::ScalarConstructorExpression>(
+      std::make_unique<ast::UintLiteral>(GetU32Type(), value));
 }
 
-std::unique_ptr<Expression>
+std::unique_ptr<ast::Expression>
 VertexPullingTransform::CreatePullingPositionIdent() {
-  return std::make_unique<IdentifierExpression>(kPullingPosVarName);
+  return std::make_unique<ast::IdentifierExpression>(kPullingPosVarName);
 }
 
-std::unique_ptr<Expression> VertexPullingTransform::AccessByFormat(
+std::unique_ptr<ast::Expression> VertexPullingTransform::AccessByFormat(
     uint32_t buffer,
     VertexFormat format) {
   // TODO(idanr): this doesn't account for the format of the attribute in the
@@ -341,41 +349,42 @@
   }
 }
 
-std::unique_ptr<Expression> VertexPullingTransform::AccessU32(
+std::unique_ptr<ast::Expression> VertexPullingTransform::AccessU32(
     uint32_t buffer,
-    std::unique_ptr<Expression> pos) {
+    std::unique_ptr<ast::Expression> pos) {
   // Here we divide by 4, since the buffer is uint32 not uint8. The input buffer
   // has byte offsets for each attribute, and we will convert it to u32 indexes
   // by dividing. Then, that element is going to be read, and if needed,
   // unpacked into an appropriate variable. All reads should end up here as a
   // base case.
-  return std::make_unique<ArrayAccessorExpression>(
-      std::make_unique<MemberAccessorExpression>(
-          std::make_unique<IdentifierExpression>(GetVertexBufferName(buffer)),
-          std::make_unique<IdentifierExpression>(kStructBufferName)),
-      std::make_unique<BinaryExpression>(BinaryOp::kDivide, std::move(pos),
-                                         GenUint(4)));
+  return std::make_unique<ast::ArrayAccessorExpression>(
+      std::make_unique<ast::MemberAccessorExpression>(
+          std::make_unique<ast::IdentifierExpression>(
+              GetVertexBufferName(buffer)),
+          std::make_unique<ast::IdentifierExpression>(kStructBufferName)),
+      std::make_unique<ast::BinaryExpression>(ast::BinaryOp::kDivide,
+                                              std::move(pos), GenUint(4)));
 }
 
-std::unique_ptr<Expression> VertexPullingTransform::AccessI32(
+std::unique_ptr<ast::Expression> VertexPullingTransform::AccessI32(
     uint32_t buffer,
-    std::unique_ptr<Expression> pos) {
+    std::unique_ptr<ast::Expression> pos) {
   // as<T> reinterprets bits
-  return std::make_unique<BitcastExpression>(GetI32Type(),
-                                             AccessU32(buffer, std::move(pos)));
+  return std::make_unique<ast::BitcastExpression>(
+      GetI32Type(), AccessU32(buffer, std::move(pos)));
 }
 
-std::unique_ptr<Expression> VertexPullingTransform::AccessF32(
+std::unique_ptr<ast::Expression> VertexPullingTransform::AccessF32(
     uint32_t buffer,
-    std::unique_ptr<Expression> pos) {
+    std::unique_ptr<ast::Expression> pos) {
   // as<T> reinterprets bits
-  return std::make_unique<BitcastExpression>(GetF32Type(),
-                                             AccessU32(buffer, std::move(pos)));
+  return std::make_unique<ast::BitcastExpression>(
+      GetF32Type(), AccessU32(buffer, std::move(pos)));
 }
 
-std::unique_ptr<Expression> VertexPullingTransform::AccessPrimitive(
+std::unique_ptr<ast::Expression> VertexPullingTransform::AccessPrimitive(
     uint32_t buffer,
-    std::unique_ptr<Expression> pos,
+    std::unique_ptr<ast::Expression> pos,
     VertexFormat format) {
   // This function uses a position expression to read, rather than using the
   // position variable. This allows us to read from offset positions relative to
@@ -393,41 +402,42 @@
   }
 }
 
-std::unique_ptr<Expression> VertexPullingTransform::AccessVec(
+std::unique_ptr<ast::Expression> VertexPullingTransform::AccessVec(
     uint32_t buffer,
     uint32_t element_stride,
-    type::Type* base_type,
+    ast::type::Type* base_type,
     VertexFormat base_format,
     uint32_t count) {
-  ExpressionList expr_list;
+  ast::ExpressionList expr_list;
   for (uint32_t i = 0; i < count; ++i) {
     // Offset read position by element_stride for each component
-    auto cur_pos = std::make_unique<BinaryExpression>(
-        BinaryOp::kAdd, CreatePullingPositionIdent(),
+    auto cur_pos = std::make_unique<ast::BinaryExpression>(
+        ast::BinaryOp::kAdd, CreatePullingPositionIdent(),
         GenUint(element_stride * i));
     expr_list.push_back(
         AccessPrimitive(buffer, std::move(cur_pos), base_format));
   }
 
-  return std::make_unique<TypeConstructorExpression>(
+  return std::make_unique<ast::TypeConstructorExpression>(
       ctx_->type_mgr().Get(
-          std::make_unique<type::VectorType>(base_type, count)),
+          std::make_unique<ast::type::VectorType>(base_type, count)),
       std::move(expr_list));
 }
 
-type::Type* VertexPullingTransform::GetU32Type() {
-  return ctx_->type_mgr().Get(std::make_unique<type::U32Type>());
+ast::type::Type* VertexPullingTransform::GetU32Type() {
+  return ctx_->type_mgr().Get(std::make_unique<ast::type::U32Type>());
 }
 
-type::Type* VertexPullingTransform::GetI32Type() {
-  return ctx_->type_mgr().Get(std::make_unique<type::I32Type>());
+ast::type::Type* VertexPullingTransform::GetI32Type() {
+  return ctx_->type_mgr().Get(std::make_unique<ast::type::I32Type>());
 }
 
-type::Type* VertexPullingTransform::GetF32Type() {
-  return ctx_->type_mgr().Get(std::make_unique<type::F32Type>());
+ast::type::Type* VertexPullingTransform::GetF32Type() {
+  return ctx_->type_mgr().Get(std::make_unique<ast::type::F32Type>());
 }
 
 VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor() = default;
+
 VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor(
     uint64_t in_array_stride,
     InputStepMode in_step_mode,
@@ -435,21 +445,25 @@
     : array_stride(std::move(in_array_stride)),
       step_mode(std::move(in_step_mode)),
       attributes(std::move(in_attributes)) {}
+
 VertexBufferLayoutDescriptor::VertexBufferLayoutDescriptor(
     const VertexBufferLayoutDescriptor& other)
     : array_stride(other.array_stride),
       step_mode(other.step_mode),
       attributes(other.attributes) {}
+
 VertexBufferLayoutDescriptor::~VertexBufferLayoutDescriptor() = default;
 
 VertexStateDescriptor::VertexStateDescriptor() = default;
+
 VertexStateDescriptor::VertexStateDescriptor(
     std::vector<VertexBufferLayoutDescriptor> in_vertex_buffers)
     : vertex_buffers(std::move(in_vertex_buffers)) {}
+
 VertexStateDescriptor::VertexStateDescriptor(const VertexStateDescriptor& other)
     : vertex_buffers(other.vertex_buffers) {}
+
 VertexStateDescriptor::~VertexStateDescriptor() = default;
 
 }  // namespace transform
-}  // namespace ast
 }  // namespace tint
diff --git a/src/ast/transform/vertex_pulling_transform.h b/src/transform/vertex_pulling_transform.h
similarity index 81%
rename from src/ast/transform/vertex_pulling_transform.h
rename to src/transform/vertex_pulling_transform.h
index 030c517..c1d9195 100644
--- a/src/ast/transform/vertex_pulling_transform.h
+++ b/src/transform/vertex_pulling_transform.h
@@ -12,8 +12,15 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#ifndef SRC_AST_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
-#define SRC_AST_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
+#ifndef SRC_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
+#define SRC_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
+
+#include "src/ast/expression.h"
+#include "src/ast/function.h"
+#include "src/ast/module.h"
+#include "src/ast/statement.h"
+#include "src/ast/variable.h"
+#include "src/context.h"
 
 #include <memory>
 #include <string>
@@ -21,22 +28,6 @@
 #include <vector>
 
 namespace tint {
-
-class Context;
-
-namespace ast {
-
-class EntryPoint;
-class Expression;
-class Function;
-class Module;
-class Statement;
-class Variable;
-
-namespace type {
-class Type;
-}  // namespace type
-
 namespace transform {
 
 /// Describes the format of data in a vertex buffer
@@ -102,6 +93,7 @@
   /// Copy constructor
   /// @param other the struct to copy
   VertexBufferLayoutDescriptor(const VertexBufferLayoutDescriptor& other);
+
   ~VertexBufferLayoutDescriptor();
 
   /// The array stride used in the in buffer
@@ -124,6 +116,7 @@
   /// Copy constructor
   /// @param other the struct to copy
   VertexStateDescriptor(const VertexStateDescriptor& other);
+
   ~VertexStateDescriptor();
 
   /// The vertex buffers
@@ -154,7 +147,7 @@
   /// Constructor
   /// @param ctx the tint context
   /// @param mod the module to convert to vertex pulling
-  VertexPullingTransform(Context* ctx, Module* mod);
+  VertexPullingTransform(Context* ctx, ast::Module* mod);
   ~VertexPullingTransform();
 
   /// Sets the vertex state descriptor, containing info about attributes
@@ -196,49 +189,53 @@
   void AddVertexStorageBuffers();
 
   /// Adds assignment to the variables from the buffers
-  void AddVertexPullingPreamble(Function* vertex_func);
+  void AddVertexPullingPreamble(ast::Function* vertex_func);
 
   /// Generates an expression holding a constant uint
   /// @param value uint value
-  std::unique_ptr<Expression> GenUint(uint32_t value);
+  std::unique_ptr<ast::Expression> GenUint(uint32_t value);
 
   /// Generates an expression to read the shader value |kPullingPosVarName|
-  std::unique_ptr<Expression> CreatePullingPositionIdent();
+  std::unique_ptr<ast::Expression> CreatePullingPositionIdent();
 
   /// Generates an expression reading from a buffer a specific format.
   /// This reads the value wherever |kPullingPosVarName| points to at the time
   /// of the read.
   /// @param buffer the index of the vertex buffer
   /// @param format the format to read
-  std::unique_ptr<Expression> AccessByFormat(uint32_t buffer,
-                                             VertexFormat format);
+  std::unique_ptr<ast::Expression> AccessByFormat(uint32_t buffer,
+                                                  VertexFormat format);
 
   /// Generates an expression reading a uint32 from a vertex buffer
   /// @param buffer the index of the vertex buffer
   /// @param pos an expression for the position of the access, in bytes
-  std::unique_ptr<Expression> AccessU32(uint32_t buffer,
-                                        std::unique_ptr<Expression> pos);
+  std::unique_ptr<ast::Expression> AccessU32(
+      uint32_t buffer,
+      std::unique_ptr<ast::Expression> pos);
 
   /// Generates an expression reading an int32 from a vertex buffer
   /// @param buffer the index of the vertex buffer
   /// @param pos an expression for the position of the access, in bytes
-  std::unique_ptr<Expression> AccessI32(uint32_t buffer,
-                                        std::unique_ptr<Expression> pos);
+  std::unique_ptr<ast::Expression> AccessI32(
+      uint32_t buffer,
+      std::unique_ptr<ast::Expression> pos);
 
   /// Generates an expression reading a float from a vertex buffer
   /// @param buffer the index of the vertex buffer
   /// @param pos an expression for the position of the access, in bytes
-  std::unique_ptr<Expression> AccessF32(uint32_t buffer,
-                                        std::unique_ptr<Expression> pos);
+  std::unique_ptr<ast::Expression> AccessF32(
+      uint32_t buffer,
+      std::unique_ptr<ast::Expression> pos);
 
   /// Generates an expression reading a basic type (u32, i32, f32) from a vertex
   /// buffer
   /// @param buffer the index of the vertex buffer
   /// @param pos an expression for the position of the access, in bytes
   /// @param format the underlying vertex format
-  std::unique_ptr<Expression> AccessPrimitive(uint32_t buffer,
-                                              std::unique_ptr<Expression> pos,
-                                              VertexFormat format);
+  std::unique_ptr<ast::Expression> AccessPrimitive(
+      uint32_t buffer,
+      std::unique_ptr<ast::Expression> pos,
+      VertexFormat format);
 
   /// Generates an expression reading a vec2/3/4 from a vertex buffer.
   /// This reads the value wherever |kPullingPosVarName| points to at the time
@@ -248,19 +245,19 @@
   /// @param base_type underlying AST type
   /// @param base_format underlying vertex format
   /// @param count how many elements the vector has
-  std::unique_ptr<Expression> AccessVec(uint32_t buffer,
-                                        uint32_t element_stride,
-                                        type::Type* base_type,
-                                        VertexFormat base_format,
-                                        uint32_t count);
+  std::unique_ptr<ast::Expression> AccessVec(uint32_t buffer,
+                                             uint32_t element_stride,
+                                             ast::type::Type* base_type,
+                                             VertexFormat base_format,
+                                             uint32_t count);
 
   // Used to grab corresponding types from the type manager
-  type::Type* GetU32Type();
-  type::Type* GetI32Type();
-  type::Type* GetF32Type();
+  ast::type::Type* GetU32Type();
+  ast::type::Type* GetI32Type();
+  ast::type::Type* GetF32Type();
 
   Context* ctx_ = nullptr;
-  Module* mod_ = nullptr;
+  ast::Module* mod_ = nullptr;
   std::string entry_point_name_;
   std::string error_;
 
@@ -270,12 +267,11 @@
   // Default to 4 as it is past the limits of user-accessible sets
   uint32_t pulling_set_ = 4u;
 
-  std::unordered_map<uint32_t, Variable*> location_to_var_;
+  std::unordered_map<uint32_t, ast::Variable*> location_to_var_;
   std::unique_ptr<VertexStateDescriptor> vertex_state_;
 };
 
 }  // namespace transform
-}  // namespace ast
 }  // namespace tint
 
-#endif  // SRC_AST_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
+#endif  // SRC_TRANSFORM_VERTEX_PULLING_TRANSFORM_H_
diff --git a/src/ast/transform/vertex_pulling_transform_test.cc b/src/transform/vertex_pulling_transform_test.cc
similarity index 92%
rename from src/ast/transform/vertex_pulling_transform_test.cc
rename to src/transform/vertex_pulling_transform_test.cc
index e2569b2..59599ed 100644
--- a/src/ast/transform/vertex_pulling_transform_test.cc
+++ b/src/transform/vertex_pulling_transform_test.cc
@@ -12,7 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "src/ast/transform/vertex_pulling_transform.h"
+#include "src/transform/vertex_pulling_transform.h"
 
 #include "gtest/gtest.h"
 #include "src/ast/decorated_variable.h"
@@ -27,7 +27,6 @@
 #include "src/validator.h"
 
 namespace tint {
-namespace ast {
 namespace transform {
 namespace {
 
@@ -40,9 +39,9 @@
 
   // Create basic module with an entry point and vertex function
   void InitBasicModule() {
-    auto func = std::make_unique<Function>(
-        "main", VariableList{},
-        ctx_.type_mgr().Get(std::make_unique<type::VoidType>()));
+    auto func = std::make_unique<ast::Function>(
+        "main", ast::VariableList{},
+        ctx_.type_mgr().Get(std::make_unique<ast::type::VoidType>()));
     func->add_decoration(
         std::make_unique<ast::StageDecoration>(ast::PipelineStage ::kVertex));
     mod()->AddFunction(std::move(func));
@@ -52,7 +51,7 @@
   void InitTransform(VertexStateDescriptor vertex_state) {
     EXPECT_TRUE(mod_->IsValid());
 
-    tint::TypeDeterminer td(&ctx_, mod_.get());
+    TypeDeterminer td(&ctx_, mod_.get());
     EXPECT_TRUE(td.Determine());
 
     transform_->SetVertexState(
@@ -63,12 +62,12 @@
   // Inserts a variable which will be converted to vertex pulling
   void AddVertexInputVariable(uint32_t location,
                               std::string name,
-                              type::Type* type) {
-    auto var = std::make_unique<DecoratedVariable>(
-        std::make_unique<Variable>(name, StorageClass::kInput, type));
+                              ast::type::Type* type) {
+    auto var = std::make_unique<ast::DecoratedVariable>(
+        std::make_unique<ast::Variable>(name, ast::StorageClass::kInput, type));
 
-    VariableDecorationList decorations;
-    decorations.push_back(std::make_unique<LocationDecoration>(location));
+    ast::VariableDecorationList decorations;
+    decorations.push_back(std::make_unique<ast::LocationDecoration>(location));
 
     var->set_decorations(std::move(decorations));
     mod_->AddGlobalVariable(std::move(var));
@@ -108,9 +107,9 @@
 }
 
 TEST_F(VertexPullingTransformTest, Error_EntryPointWrongStage) {
-  auto func = std::make_unique<Function>(
-      "main", VariableList{},
-      ctx()->type_mgr().Get(std::make_unique<type::VoidType>()));
+  auto func = std::make_unique<ast::Function>(
+      "main", ast::VariableList{},
+      ctx()->type_mgr().Get(std::make_unique<ast::type::VoidType>()));
   func->add_decoration(
       std::make_unique<ast::StageDecoration>(ast::PipelineStage::kFragment));
   mod()->AddFunction(std::move(func));
@@ -129,7 +128,7 @@
 TEST_F(VertexPullingTransformTest, OneAttribute) {
   InitBasicModule();
 
-  type::F32Type f32;
+  ast::type::F32Type f32;
   AddVertexInputVariable(0, "var_a", &f32);
 
   InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}});
@@ -209,7 +208,7 @@
 TEST_F(VertexPullingTransformTest, OneInstancedAttribute) {
   InitBasicModule();
 
-  type::F32Type f32;
+  ast::type::F32Type f32;
   AddVertexInputVariable(0, "var_a", &f32);
 
   InitTransform(
@@ -290,7 +289,7 @@
 TEST_F(VertexPullingTransformTest, OneAttributeDifferentOutputSet) {
   InitBasicModule();
 
-  type::F32Type f32;
+  ast::type::F32Type f32;
   AddVertexInputVariable(0, "var_a", &f32);
 
   InitTransform({{{4, InputStepMode::kVertex, {{VertexFormat::kF32, 0, 0}}}}});
@@ -372,32 +371,32 @@
 TEST_F(VertexPullingTransformTest, ExistingVertexIndexAndInstanceIndex) {
   InitBasicModule();
 
-  type::F32Type f32;
+  ast::type::F32Type f32;
   AddVertexInputVariable(0, "var_a", &f32);
   AddVertexInputVariable(1, "var_b", &f32);
 
-  type::I32Type i32;
+  ast::type::I32Type i32;
   {
-    auto vertex_index_var =
-        std::make_unique<DecoratedVariable>(std::make_unique<Variable>(
-            "custom_vertex_index", StorageClass::kInput, &i32));
+    auto vertex_index_var = std::make_unique<ast::DecoratedVariable>(
+        std::make_unique<ast::Variable>("custom_vertex_index",
+                                        ast::StorageClass::kInput, &i32));
 
-    VariableDecorationList decorations;
+    ast::VariableDecorationList decorations;
     decorations.push_back(
-        std::make_unique<BuiltinDecoration>(Builtin::kVertexIdx));
+        std::make_unique<ast::BuiltinDecoration>(ast::Builtin::kVertexIdx));
 
     vertex_index_var->set_decorations(std::move(decorations));
     mod()->AddGlobalVariable(std::move(vertex_index_var));
   }
 
   {
-    auto instance_index_var =
-        std::make_unique<DecoratedVariable>(std::make_unique<Variable>(
-            "custom_instance_index", StorageClass::kInput, &i32));
+    auto instance_index_var = std::make_unique<ast::DecoratedVariable>(
+        std::make_unique<ast::Variable>("custom_instance_index",
+                                        ast::StorageClass::kInput, &i32));
 
-    VariableDecorationList decorations;
+    ast::VariableDecorationList decorations;
     decorations.push_back(
-        std::make_unique<BuiltinDecoration>(Builtin::kInstanceIdx));
+        std::make_unique<ast::BuiltinDecoration>(ast::Builtin::kInstanceIdx));
 
     instance_index_var->set_decorations(std::move(decorations));
     mod()->AddGlobalVariable(std::move(instance_index_var));
@@ -532,10 +531,10 @@
 TEST_F(VertexPullingTransformTest, TwoAttributesSameBuffer) {
   InitBasicModule();
 
-  type::F32Type f32;
+  ast::type::F32Type f32;
   AddVertexInputVariable(0, "var_a", &f32);
 
-  type::ArrayType vec4_f32{&f32, 4u};
+  ast::type::ArrayType vec4_f32{&f32, 4u};
   AddVertexInputVariable(1, "var_b", &vec4_f32);
 
   InitTransform(
@@ -709,14 +708,14 @@
 TEST_F(VertexPullingTransformTest, FloatVectorAttributes) {
   InitBasicModule();
 
-  type::F32Type f32;
-  type::ArrayType vec2_f32{&f32, 2u};
+  ast::type::F32Type f32;
+  ast::type::ArrayType vec2_f32{&f32, 2u};
   AddVertexInputVariable(0, "var_a", &vec2_f32);
 
-  type::ArrayType vec3_f32{&f32, 3u};
+  ast::type::ArrayType vec3_f32{&f32, 3u};
   AddVertexInputVariable(1, "var_b", &vec3_f32);
 
-  type::ArrayType vec4_f32{&f32, 4u};
+  ast::type::ArrayType vec4_f32{&f32, 4u};
   AddVertexInputVariable(2, "var_c", &vec4_f32);
 
   InitTransform(
@@ -1005,5 +1004,4 @@
 
 }  // namespace
 }  // namespace transform
-}  // namespace ast
 }  // namespace tint