Define specialized PoolTypeConverter constants in the header

This avoids having the IceTargetLoweringX86.cpp file defining the
X86NAMESPACE as X8632, despite being bitness agnostic.

Note this makes use of C++17 constexpr being implicitly inline, which
means we no longer have to provide an out-of-class declaration of these
static values.

Bug: b/192890685
Change-Id: I174a0d9a7f2a9c74e4692215be330e45580797a8
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/55530
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Sean Risser <srisser@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn
index e0d624c..bba64dd 100644
--- a/src/Reactor/BUILD.gn
+++ b/src/Reactor/BUILD.gn
@@ -209,7 +209,6 @@
       "$subzero_dir/src/IceRevision.cpp",
       "$subzero_dir/src/IceSwitchLowering.cpp",
       "$subzero_dir/src/IceTargetLowering.cpp",
-      "$subzero_dir/src/IceTargetLoweringX86.cpp",
       "$subzero_dir/src/IceThreading.cpp",
       "$subzero_dir/src/IceTimerTree.cpp",
       "$subzero_dir/src/IceTypes.cpp",
diff --git a/third_party/subzero/CMakeLists.txt b/third_party/subzero/CMakeLists.txt
index 0460010..995ac6d 100644
--- a/third_party/subzero/CMakeLists.txt
+++ b/third_party/subzero/CMakeLists.txt
@@ -48,14 +48,12 @@
 
 if(ARCH STREQUAL "x86_64")
     list(APPEND SUBZERO_SRC_FILES
-        src/IceTargetLoweringX86.cpp
         src/IceInstX8664.cpp
         src/IceTargetLoweringX8664.cpp
     )
     set(SUBZERO_TARGET_CPU X8664)
 elseif(ARCH STREQUAL "x86")
     list(APPEND SUBZERO_SRC_FILES
-        src/IceTargetLoweringX86.cpp
         src/IceInstX8632.cpp
         src/IceTargetLoweringX8632.cpp
     )
diff --git a/third_party/subzero/src/IceTargetLoweringX86.cpp b/third_party/subzero/src/IceTargetLoweringX86.cpp
deleted file mode 100644
index 8fbd075..0000000
--- a/third_party/subzero/src/IceTargetLoweringX86.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===---- subzero/src/IceTargetLoweringX86.cpp - x86 lowering -*- C++ -*---===//
-//
-//                        The Subzero Code Generator
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-///
-/// \file
-/// \brief Implements portions of the TargetLoweringX86Base class, and related
-/// classes.
-///
-//===----------------------------------------------------------------------===//
-
-// Choose one namespace, since including this file should not cause the
-// templates to be instantiated.  This avoids duplicating the PoolTypeConverter
-// data items, but is ugly as code common to all of x86 is including code
-// specific to one of 32 or 64.
-// TODO(jpp): replace this ugliness with the beauty of extern template.
-
-#define X86NAMESPACE X8632
-#include "IceTargetLoweringX86Base.h"
-#undef X86NAMESPACE
-
-namespace Ice {
-namespace X86 {
-
-const char *PoolTypeConverter<float>::TypeName = "float";
-const char *PoolTypeConverter<float>::AsmTag = ".long";
-const char *PoolTypeConverter<float>::PrintfString = "0x%x";
-
-const char *PoolTypeConverter<double>::TypeName = "double";
-const char *PoolTypeConverter<double>::AsmTag = ".quad";
-const char *PoolTypeConverter<double>::PrintfString = "0x%llx";
-
-const char *PoolTypeConverter<uint32_t>::TypeName = "i32";
-const char *PoolTypeConverter<uint32_t>::AsmTag = ".long";
-const char *PoolTypeConverter<uint32_t>::PrintfString = "0x%x";
-
-const char *PoolTypeConverter<uint16_t>::TypeName = "i16";
-const char *PoolTypeConverter<uint16_t>::AsmTag = ".short";
-const char *PoolTypeConverter<uint16_t>::PrintfString = "0x%x";
-
-const char *PoolTypeConverter<uint8_t>::TypeName = "i8";
-const char *PoolTypeConverter<uint8_t>::AsmTag = ".byte";
-const char *PoolTypeConverter<uint8_t>::PrintfString = "0x%x";
-
-} // end of namespace X86
-} // end of namespace Ice
diff --git a/third_party/subzero/src/IceTargetLoweringX86.h b/third_party/subzero/src/IceTargetLoweringX86.h
new file mode 100644
index 0000000..4521f2e
--- /dev/null
+++ b/third_party/subzero/src/IceTargetLoweringX86.h
@@ -0,0 +1,72 @@
+//===---- subzero/src/IceTargetLoweringX86.h - x86 lowering -*- C++ -*---===//
+//
+//                        The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief Declares common functionlity for lowering to the X86 architecture
+/// (32-bit and 64-bit).
+///
+//===----------------------------------------------------------------------===//
+
+#include <inttypes.h>
+
+namespace Ice {
+namespace X86 {
+
+template <typename T> struct PoolTypeConverter {};
+
+template <> struct PoolTypeConverter<float> {
+  using PrimitiveIntType = uint32_t;
+  using IceType = ConstantFloat;
+  static constexpr Type Ty = IceType_f32;
+  static constexpr const char *TypeName = "float";
+  static constexpr const char *AsmTag = ".long";
+  static constexpr const char *PrintfString = "0x%x";
+};
+
+template <> struct PoolTypeConverter<double> {
+  using PrimitiveIntType = uint64_t;
+  using IceType = ConstantDouble;
+  static constexpr Type Ty = IceType_f64;
+  static constexpr const char *TypeName = "double";
+  static constexpr const char *AsmTag = ".quad";
+  static constexpr const char *PrintfString = "%" PRIu64;
+};
+
+// Add converter for int type constant pooling
+template <> struct PoolTypeConverter<uint32_t> {
+  using PrimitiveIntType = uint32_t;
+  using IceType = ConstantInteger32;
+  static constexpr Type Ty = IceType_i32;
+  static constexpr const char *TypeName = "i32";
+  static constexpr const char *AsmTag = ".long";
+  static constexpr const char *PrintfString = "0x%x";
+};
+
+// Add converter for int type constant pooling
+template <> struct PoolTypeConverter<uint16_t> {
+  using PrimitiveIntType = uint32_t;
+  using IceType = ConstantInteger32;
+  static constexpr Type Ty = IceType_i16;
+  static constexpr const char *TypeName = "i16";
+  static constexpr const char *AsmTag = ".short";
+  static constexpr const char *PrintfString = "0x%x";
+};
+
+// Add converter for int type constant pooling
+template <> struct PoolTypeConverter<uint8_t> {
+  using PrimitiveIntType = uint32_t;
+  using IceType = ConstantInteger32;
+  static constexpr Type Ty = IceType_i8;
+  static constexpr const char *TypeName = "i8";
+  static constexpr const char *AsmTag = ".byte";
+  static constexpr const char *PrintfString = "0x%x";
+};
+
+} // end of namespace X86
+} // end of namespace Ice
diff --git a/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h b/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h
index 1206220..5711cb9 100644
--- a/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h
+++ b/third_party/subzero/src/IceTargetLoweringX86BaseImpl.h
@@ -27,6 +27,7 @@
 #include "IceLiveness.h"
 #include "IceOperand.h"
 #include "IcePhiLoweringImpl.h"
+#include "IceTargetLoweringX86.h"
 #include "IceUtils.h"
 #include "IceVariableSplitting.h"
 
@@ -35,58 +36,6 @@
 #include <stack>
 
 namespace Ice {
-namespace X86 {
-template <typename T> struct PoolTypeConverter {};
-
-template <> struct PoolTypeConverter<float> {
-  using PrimitiveIntType = uint32_t;
-  using IceType = ConstantFloat;
-  static const Type Ty = IceType_f32;
-  static const char *TypeName;
-  static const char *AsmTag;
-  static const char *PrintfString;
-};
-
-template <> struct PoolTypeConverter<double> {
-  using PrimitiveIntType = uint64_t;
-  using IceType = ConstantDouble;
-  static const Type Ty = IceType_f64;
-  static const char *TypeName;
-  static const char *AsmTag;
-  static const char *PrintfString;
-};
-
-// Add converter for int type constant pooling
-template <> struct PoolTypeConverter<uint32_t> {
-  using PrimitiveIntType = uint32_t;
-  using IceType = ConstantInteger32;
-  static const Type Ty = IceType_i32;
-  static const char *TypeName;
-  static const char *AsmTag;
-  static const char *PrintfString;
-};
-
-// Add converter for int type constant pooling
-template <> struct PoolTypeConverter<uint16_t> {
-  using PrimitiveIntType = uint32_t;
-  using IceType = ConstantInteger32;
-  static const Type Ty = IceType_i16;
-  static const char *TypeName;
-  static const char *AsmTag;
-  static const char *PrintfString;
-};
-
-// Add converter for int type constant pooling
-template <> struct PoolTypeConverter<uint8_t> {
-  using PrimitiveIntType = uint32_t;
-  using IceType = ConstantInteger32;
-  static const Type Ty = IceType_i8;
-  static const char *TypeName;
-  static const char *AsmTag;
-  static const char *PrintfString;
-};
-} // end of namespace X86
-
 namespace X86NAMESPACE {
 
 // The Microsoft x64 ABI requires the caller to allocate a 32 byte