[spirv-writer] Move LiteralOperand to spirv::ir

Bug: tint:1906
Change-Id: I0f96312836e706017d24d03145ab85f963aaf41b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/154880
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/tint/lang/spirv/ir/BUILD.bazel b/src/tint/lang/spirv/ir/BUILD.bazel
index c6570fc..5e02b2f 100644
--- a/src/tint/lang/spirv/ir/BUILD.bazel
+++ b/src/tint/lang/spirv/ir/BUILD.bazel
@@ -27,9 +27,11 @@
   name = "ir",
   srcs = [
     "builtin_call.cc",
+    "literal_operand.cc",
   ],
   hdrs = [
     "builtin_call.h",
+    "literal_operand.h",
   ],
   deps = [
     "//src/tint/api/common",
diff --git a/src/tint/lang/spirv/ir/BUILD.cmake b/src/tint/lang/spirv/ir/BUILD.cmake
index e17a474..da5b68f 100644
--- a/src/tint/lang/spirv/ir/BUILD.cmake
+++ b/src/tint/lang/spirv/ir/BUILD.cmake
@@ -28,6 +28,8 @@
 tint_add_target(tint_lang_spirv_ir lib
   lang/spirv/ir/builtin_call.cc
   lang/spirv/ir/builtin_call.h
+  lang/spirv/ir/literal_operand.cc
+  lang/spirv/ir/literal_operand.h
 )
 
 tint_target_add_dependencies(tint_lang_spirv_ir lib
diff --git a/src/tint/lang/spirv/ir/BUILD.gn b/src/tint/lang/spirv/ir/BUILD.gn
index 636b868..588ee98 100644
--- a/src/tint/lang/spirv/ir/BUILD.gn
+++ b/src/tint/lang/spirv/ir/BUILD.gn
@@ -33,6 +33,8 @@
   sources = [
     "builtin_call.cc",
     "builtin_call.h",
+    "literal_operand.cc",
+    "literal_operand.h",
   ]
   deps = [
     "${tint_src_dir}/api/common",
diff --git a/src/tint/lang/spirv/ir/literal_operand.cc b/src/tint/lang/spirv/ir/literal_operand.cc
new file mode 100644
index 0000000..bc24878
--- /dev/null
+++ b/src/tint/lang/spirv/ir/literal_operand.cc
@@ -0,0 +1,25 @@
+// Copyright 2023 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/lang/spirv/ir/literal_operand.h"
+
+TINT_INSTANTIATE_TYPEINFO(tint::spirv::ir::LiteralOperand);
+
+namespace tint::spirv::ir {
+
+LiteralOperand::LiteralOperand(const core::constant::Value* value) : Base(value) {}
+
+LiteralOperand::~LiteralOperand() = default;
+
+}  // namespace tint::spirv::ir
diff --git a/src/tint/lang/spirv/ir/literal_operand.h b/src/tint/lang/spirv/ir/literal_operand.h
new file mode 100644
index 0000000..cbda1e6
--- /dev/null
+++ b/src/tint/lang/spirv/ir/literal_operand.h
@@ -0,0 +1,36 @@
+// Copyright 2023 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_LANG_SPIRV_IR_LITERAL_OPERAND_H_
+#define SRC_TINT_LANG_SPIRV_IR_LITERAL_OPERAND_H_
+
+#include "src/tint/lang/core/ir/constant.h"
+#include "src/tint/utils/rtti/castable.h"
+
+namespace tint::spirv::ir {
+
+/// LiteralOperand is a type of constant value that is intended to be emitted as a literal in
+/// the SPIR-V instruction stream.
+class LiteralOperand final : public Castable<LiteralOperand, core::ir::Constant> {
+  public:
+    /// Constructor
+    /// @param value the operand value
+    explicit LiteralOperand(const core::constant::Value* value);
+    /// Destructor
+    ~LiteralOperand() override;
+};
+
+}  // namespace tint::spirv::ir
+
+#endif  // SRC_TINT_LANG_SPIRV_IR_LITERAL_OPERAND_H_
diff --git a/src/tint/lang/spirv/writer/printer/printer.cc b/src/tint/lang/spirv/writer/printer/printer.cc
index 7d13e1c..7a34df0 100644
--- a/src/tint/lang/spirv/writer/printer/printer.cc
+++ b/src/tint/lang/spirv/writer/printer/printer.cc
@@ -73,6 +73,7 @@
 #include "src/tint/lang/core/type/u32.h"
 #include "src/tint/lang/core/type/vector.h"
 #include "src/tint/lang/core/type/void.h"
+#include "src/tint/lang/spirv/ir/literal_operand.h"
 #include "src/tint/lang/spirv/type/sampled_image.h"
 #include "src/tint/lang/spirv/writer/ast_printer/ast_printer.h"
 #include "src/tint/lang/spirv/writer/common/module.h"
@@ -231,7 +232,7 @@
 
 uint32_t Printer::Constant(core::ir::Constant* constant) {
     // If it is a literal operand, just return the value.
-    if (auto* literal = constant->As<raise::LiteralOperand>()) {
+    if (auto* literal = constant->As<spirv::ir::LiteralOperand>()) {
         return literal->Value()->ValueAs<uint32_t>();
     }
 
diff --git a/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc b/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc
index dc5ff8b..feef5fb 100644
--- a/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc
+++ b/src/tint/lang/spirv/writer/raise/builtin_polyfill.cc
@@ -29,11 +29,10 @@
 #include "src/tint/lang/core/type/storage_texture.h"
 #include "src/tint/lang/core/type/texture.h"
 #include "src/tint/lang/spirv/ir/builtin_call.h"
+#include "src/tint/lang/spirv/ir/literal_operand.h"
 #include "src/tint/lang/spirv/type/sampled_image.h"
 #include "src/tint/utils/ice/ice.h"
 
-TINT_INSTANTIATE_TYPEINFO(tint::spirv::writer::raise::LiteralOperand);
-
 using namespace tint::core::number_suffixes;  // NOLINT
 using namespace tint::core::fluent_types;     // NOLINT
 
@@ -177,8 +176,8 @@
     /// Create a literal operand.
     /// @param value the literal value
     /// @returns the literal operand
-    LiteralOperand* Literal(u32 value) {
-        return ir.values.Create<LiteralOperand>(b.ConstantValue(value));
+    spirv::ir::LiteralOperand* Literal(u32 value) {
+        return ir.values.Create<spirv::ir::LiteralOperand>(b.ConstantValue(value));
     }
 
     /// Handle an `arrayLength()` builtin.
@@ -885,8 +884,4 @@
     return Success;
 }
 
-LiteralOperand::LiteralOperand(const core::constant::Value* value) : Base(value) {}
-
-LiteralOperand::~LiteralOperand() = default;
-
 }  // namespace tint::spirv::writer::raise
diff --git a/src/tint/lang/spirv/writer/raise/builtin_polyfill.h b/src/tint/lang/spirv/writer/raise/builtin_polyfill.h
index 469d6a4..1a1fe62 100644
--- a/src/tint/lang/spirv/writer/raise/builtin_polyfill.h
+++ b/src/tint/lang/spirv/writer/raise/builtin_polyfill.h
@@ -36,18 +36,6 @@
 /// @returns success or failure
 Result<SuccessType> BuiltinPolyfill(core::ir::Module& module);
 
-/// LiteralOperand is a type of constant value that is intended to be emitted as a literal in
-/// the SPIR-V instruction stream.
-/// TODO(jrprice): Move this to lang/spirv.
-class LiteralOperand final : public Castable<LiteralOperand, core::ir::Constant> {
-  public:
-    /// Constructor
-    /// @param value the operand value
-    explicit LiteralOperand(const core::constant::Value* value);
-    /// Destructor
-    ~LiteralOperand() override;
-};
-
 }  // namespace tint::spirv::writer::raise
 
 #endif  // SRC_TINT_LANG_SPIRV_WRITER_RAISE_BUILTIN_POLYFILL_H_