Revert "[libc] Add more robust compile time architecture detection"

This reverts commit a72e2499865b55cb007b63673100c06cc85faf97.

GitOrigin-RevId: fe953b15cf08a4d25a16bdbda23dfefb3568540b
diff --git a/src/__support/CMakeLists.txt b/src/__support/CMakeLists.txt
index 5d2667d..871c3a4 100644
--- a/src/__support/CMakeLists.txt
+++ b/src/__support/CMakeLists.txt
@@ -3,7 +3,6 @@
 add_header_library(
   common
   HDRS
-    architectures.h
     common.h
     endian.h
     sanitizer.h
diff --git a/src/__support/FPUtil/FEnvUtils.h b/src/__support/FPUtil/FEnvUtils.h
index 2cb62e5..a9d11ce 100644
--- a/src/__support/FPUtil/FEnvUtils.h
+++ b/src/__support/FPUtil/FEnvUtils.h
@@ -9,11 +9,9 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_FENVUTILS_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_FENVUTILS_H
 
-#include "src/__support/architectures.h"
-
-#if defined(LLVM_LIBC_ARCH_X86_64)
+#ifdef __x86_64__
 #include "x86_64/FEnvImpl.h"
-#elif defined(LLVM_LIBC_ARCH_AARCH64)
+#elif defined(__aarch64__)
 #include "aarch64/FEnvImpl.h"
 #else
 #include "DummyFEnvImpl.h"
diff --git a/src/__support/FPUtil/FMA.h b/src/__support/FPUtil/FMA.h
index 5f35bec..c109b34 100644
--- a/src/__support/FPUtil/FMA.h
+++ b/src/__support/FPUtil/FMA.h
@@ -10,11 +10,10 @@
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_FMA_H
 
 #include "src/__support/CPP/TypeTraits.h"
-#include "src/__support/architectures.h"
 
-#if defined(LLVM_LIBC_ARCH_X86_64)
+#ifdef __x86_64__
 #include "x86_64/FMA.h"
-#elif defined(LLVM_LIBC_ARCH_AARCH64)
+#elif defined(__aarch64__)
 #include "aarch64/FMA.h"
 #else
 #include "generic/FMA.h"
diff --git a/src/__support/FPUtil/PlatformDefs.h b/src/__support/FPUtil/PlatformDefs.h
index 61af0da..d9964d1 100644
--- a/src/__support/FPUtil/PlatformDefs.h
+++ b/src/__support/FPUtil/PlatformDefs.h
@@ -9,9 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_FPUTIL_PLATFORM_DEFS_H
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_PLATFORM_DEFS_H
 
-#include "src/__support/architectures.h"
-
-#if defined(LLVM_LIBC_ARCH_X86)
+#if defined(__x86_64__) || defined(__i386__)
 #define X87_FPU
 #endif
 
diff --git a/src/__support/FPUtil/PolyEval.h b/src/__support/FPUtil/PolyEval.h
index 10d406d..ccf4d60 100644
--- a/src/__support/FPUtil/PolyEval.h
+++ b/src/__support/FPUtil/PolyEval.h
@@ -10,7 +10,6 @@
 #define LLVM_LIBC_SRC_SUPPORT_FPUTIL_POLYEVAL_H
 
 #include "src/__support/CPP/TypeTraits.h"
-#include "src/__support/architectures.h"
 
 // Evaluate polynomial using Horner's Scheme:
 // With polyeval(x, a_0, a_1, ..., a_n) = a_n * x^n + ... + a_1 * x + a_0, we
@@ -19,7 +18,7 @@
 // Example: to evaluate x^3 + 2*x^2 + 3*x + 4, call
 //   polyeval( x, 4.0, 3.0, 2.0, 1.0 )
 
-#if defined(LLVM_LIBC_ARCH_X86_64) || defined(LLVM_LIBC_ARCH_AARCH64)
+#if defined(__x86_64__) || defined(__aarch64__)
 #include "FMA.h"
 
 namespace __llvm_libc {
diff --git a/src/__support/architectures.h b/src/__support/architectures.h
deleted file mode 100644
index 485faae..0000000
--- a/src/__support/architectures.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//===-- Compile time architecture detection -------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#if defined(__pnacl__) || defined(__CLR_VER)
-#define LLVM_LIBC_ARCH_VM
-#endif
-
-#if (defined(_M_IX86) || defined(__i386__)) && !defined(LLVM_LIBC_ARCH_VM)
-#define LLVM_LIBC_ARCH_X86_32
-#endif
-
-#if (defined(_M_X64) || defined(__x86_64__)) && !defined(LLVM_LIBC_ARCH_VM)
-#define LLVM_LIBC_ARCH_X86_64
-#endif
-
-#if defined(LLVM_LIBC_ARCH_X86_32) || defined(LLVM_LIBC_ARCH_X86_64)
-#define LLVM_LIBC_ARCH_X86
-#endif
-
-#if (defined(__arm__) || defined(_M_ARM))
-#define LLVM_LIBC_ARCH_ARM
-#endif
-
-#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
-#define LLVM_LIBC_ARCH_AARCH64
-#endif
-
-#if (defined(LLVM_LIBC_ARCH_AARCH64) || defined(LLVM_LIBC_ARCH_ARM))
-#define LLVM_LIBC_ARCH_ANY_ARM
-#endif
diff --git a/src/string/memcmp.cpp b/src/string/memcmp.cpp
index 0f2dae2..bb2b5e2 100644
--- a/src/string/memcmp.cpp
+++ b/src/string/memcmp.cpp
@@ -7,7 +7,6 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/string/memcmp.h"
-#include "src/__support/architectures.h"
 #include "src/__support/common.h"
 #include "src/string/memory_utils/elements.h"
 
@@ -16,7 +15,7 @@
 namespace __llvm_libc {
 
 static int memcmp_impl(const char *lhs, const char *rhs, size_t count) {
-#if defined(LLVM_LIBC_ARCH_X86)
+#if defined(__i386__) || defined(__x86_64__)
   using namespace ::__llvm_libc::x86;
 #else
   using namespace ::__llvm_libc::scalar;
diff --git a/src/string/memory_utils/elements_aarch64.h b/src/string/memory_utils/elements_aarch64.h
index 0c8990c..36d3074 100644
--- a/src/string/memory_utils/elements_aarch64.h
+++ b/src/string/memory_utils/elements_aarch64.h
@@ -9,9 +9,7 @@
 #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ELEMENTS_AARCH64_H
 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ELEMENTS_AARCH64_H
 
-#include "src/__support/architectures.h"
-
-#if defined(LLVM_LIBC_ARCH_AARCH64)
+#if defined(__arm__) || defined(__aarch64__)
 
 #include <src/string/memory_utils/elements.h>
 #include <stddef.h> // size_t
@@ -117,6 +115,6 @@
 } // namespace aarch64
 } // namespace __llvm_libc
 
-#endif // defined(LLVM_LIBC_ARCH_AARCH64)
+#endif // defined(__arm__) || defined(__aarch64__)
 
 #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ELEMENTS_AARCH64_H
diff --git a/src/string/memory_utils/elements_x86.h b/src/string/memory_utils/elements_x86.h
index e8be55b..9b32b42 100644
--- a/src/string/memory_utils/elements_x86.h
+++ b/src/string/memory_utils/elements_x86.h
@@ -9,9 +9,8 @@
 #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ELEMENTS_X86_H
 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ELEMENTS_X86_H
 
-#include "src/__support/architectures.h"
-
-#if defined(LLVM_LIBC_ARCH_X86)
+#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) ||            \
+    defined(_M_X64)
 
 #include <stddef.h> // size_t
 #include <stdint.h> // uint8_t, uint16_t, uint32_t, uint64_t
@@ -173,6 +172,7 @@
 } // namespace x86
 } // namespace __llvm_libc
 
-#endif // defined(LLVM_LIBC_ARCH_X86)
+#endif // defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) ||
+       // defined(_M_X64)
 
 #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_ELEMENTS_X86_H
diff --git a/src/string/memory_utils/memset_utils.h b/src/string/memory_utils/memset_utils.h
index 666d649..5b955a3 100644
--- a/src/string/memory_utils/memset_utils.h
+++ b/src/string/memory_utils/memset_utils.h
@@ -9,7 +9,6 @@
 #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_MEMSET_UTILS_H
 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_MEMSET_UTILS_H
 
-#include "src/__support/architectures.h"
 #include "src/string/memory_utils/elements.h"
 #include "src/string/memory_utils/utils.h"
 
@@ -50,7 +49,7 @@
 // superior for sizes that mattered.
 inline static void GeneralPurposeMemset(char *dst, unsigned char value,
                                         size_t count) {
-#if defined(LLVM_LIBC_ARCH_X86)
+#if defined(__i386__) || defined(__x86_64__)
   using namespace ::__llvm_libc::x86;
 #else
   using namespace ::__llvm_libc::scalar;
diff --git a/src/string/memory_utils/utils.h b/src/string/memory_utils/utils.h
index f23a324..d6047e1 100644
--- a/src/string/memory_utils/utils.h
+++ b/src/string/memory_utils/utils.h
@@ -9,13 +9,19 @@
 #ifndef LLVM_LIBC_SRC_MEMORY_UTILS_UTILS_H
 #define LLVM_LIBC_SRC_MEMORY_UTILS_UTILS_H
 
-#include "src/__support/architectures.h"
-
 // Cache line sizes for ARM: These values are not strictly correct since
 // cache line sizes depend on implementations, not architectures.  There
 // are even implementations with cache line sizes configurable at boot
 // time.
-#if defined(LLVM_LIBC_ARCH_AARCH64) || defined(LLVM_LIBC_ARCH_X86)
+#if defined(__aarch64__)
+#define LLVM_LIBC_CACHELINE_SIZE 64
+#elif defined(__ARM_ARCH_5T__)
+#define LLVM_LIBC_CACHELINE_SIZE 32
+#elif defined(__ARM_ARCH_7A__)
+#define LLVM_LIBC_CACHELINE_SIZE 64
+#elif defined(__PPC64__)
+#define LLVM_LIBC_CACHELINE_SIZE 128
+#elif defined(__i386__) || defined(__x86_64__)
 #define LLVM_LIBC_CACHELINE_SIZE 64
 #else
 #error "Unsupported platform for memory functions."
diff --git a/test/src/fenv/enabled_exceptions_test.cpp b/test/src/fenv/enabled_exceptions_test.cpp
index bf04b64..7b91e98 100644
--- a/test/src/fenv/enabled_exceptions_test.cpp
+++ b/test/src/fenv/enabled_exceptions_test.cpp
@@ -11,7 +11,6 @@
 #include "src/fenv/fetestexcept.h"
 
 #include "src/__support/FPUtil/FEnvUtils.h"
-#include "src/__support/architectures.h"
 #include "utils/UnitTest/FPExceptMatcher.h"
 #include "utils/UnitTest/Test.h"
 
@@ -21,7 +20,7 @@
 // This test enables an exception and verifies that raising that exception
 // triggers SIGFPE.
 TEST(LlvmLibcExceptionStatusTest, RaiseAndCrash) {
-#if defined(LLVM_LIBC_ARCH_AARCH64)
+#ifdef __aarch64__
   // Few aarch64 HW implementations do not trap exceptions. We skip this test
   // completely on such HW.
   //
@@ -33,7 +32,7 @@
   __llvm_libc::fputil::enableExcept(FE_DIVBYZERO);
   if (__llvm_libc::fputil::getExcept() == 0)
     return;
-#endif // defined(LLVM_LIBC_ARCH_AARCH64)
+#endif
 
   // TODO: Install a floating point exception handler and verify that the
   // the expected exception was raised. One will have to longjmp back from
diff --git a/test/src/fenv/feenableexcept_test.cpp b/test/src/fenv/feenableexcept_test.cpp
index 173401d..2158f95 100644
--- a/test/src/fenv/feenableexcept_test.cpp
+++ b/test/src/fenv/feenableexcept_test.cpp
@@ -6,10 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/fenv/feenableexcept.h"
-
-#include "src/__support/architectures.h"
 #include "src/fenv/fedisableexcept.h"
+#include "src/fenv/feenableexcept.h"
 #include "src/fenv/fegetexcept.h"
 
 #include "utils/UnitTest/Test.h"
@@ -17,7 +15,7 @@
 #include <fenv.h>
 
 TEST(LlvmLibcFEnvTest, EnableTest) {
-#if defined(LLVM_LIBC_ARCH_AARCH64)
+#ifdef __aarch64__
   // Few aarch64 HW implementations do not trap exceptions. We skip this test
   // completely on such HW.
   //
@@ -29,7 +27,7 @@
   __llvm_libc::feenableexcept(FE_DIVBYZERO);
   if (__llvm_libc::fegetexcept() == 0)
     return;
-#endif // defined(LLVM_LIBC_ARCH_AARCH64)
+#endif
 
   int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
                    FE_UNDERFLOW};
diff --git a/test/src/fenv/feholdexcept_test.cpp b/test/src/fenv/feholdexcept_test.cpp
index 6bdea80..be836a4 100644
--- a/test/src/fenv/feholdexcept_test.cpp
+++ b/test/src/fenv/feholdexcept_test.cpp
@@ -9,14 +9,13 @@
 #include "src/fenv/feholdexcept.h"
 
 #include "src/__support/FPUtil/FEnvUtils.h"
-#include "src/__support/architectures.h"
 #include "utils/UnitTest/FPExceptMatcher.h"
 #include "utils/UnitTest/Test.h"
 
 #include <fenv.h>
 
 TEST(LlvmLibcFEnvTest, RaiseAndCrash) {
-#if defined(LLVM_LIBC_ARCH_AARCH64)
+#ifdef __aarch64__
   // Few aarch64 HW implementations do not trap exceptions. We skip this test
   // completely on such HW.
   //
@@ -28,7 +27,7 @@
   __llvm_libc::fputil::enableExcept(FE_DIVBYZERO);
   if (__llvm_libc::fputil::getExcept() == 0)
     return;
-#endif // defined(LLVM_LIBC_ARCH_AARCH64)
+#endif
 
   int excepts[] = {FE_DIVBYZERO, FE_INVALID, FE_INEXACT, FE_OVERFLOW,
                    FE_UNDERFLOW};
diff --git a/utils/MPFRWrapper/MPFRUtils.cpp b/utils/MPFRWrapper/MPFRUtils.cpp
index 331f018..9a2a125 100644
--- a/utils/MPFRWrapper/MPFRUtils.cpp
+++ b/utils/MPFRWrapper/MPFRUtils.cpp
@@ -10,8 +10,7 @@
 
 #include "src/__support/CPP/StringView.h"
 #include "src/__support/FPUtil/FPBits.h"
-#include "src/__support/FPUtil/TestHelpers.h"
-#include "src/__support/architectures.h"
+#include "utils/UnitTest/FPMatcher.h"
 
 #include <cmath>
 #include <memory>
@@ -45,7 +44,7 @@
   static constexpr unsigned int value = 53;
 };
 
-#if !(defined(LLVM_LIBC_ARCH_X86))
+#if !(defined(__x86_64__) || defined(__i386__))
 template <> struct Precision<long double> {
   static constexpr unsigned int value = 64;
 };
@@ -101,7 +100,9 @@
     mpfr_set(value, other.value, MPFR_RNDN);
   }
 
-  ~MPFRNumber() { mpfr_clear(value); }
+  ~MPFRNumber() {
+    mpfr_clear(value);
+  }
 
   MPFRNumber &operator=(const MPFRNumber &rhs) {
     mpfrPrecision = rhs.mpfrPrecision;