[AArch64] Re-organize aarch64_classify_symbol.
authorChris Schlumberger-Socha <chris.schlumberger-socha@arm.com>
Wed, 29 May 2013 12:57:33 +0000 (12:57 +0000)
committerMarcus Shawcroft <mshawcroft@gcc.gnu.org>
Wed, 29 May 2013 12:57:33 +0000 (12:57 +0000)
This patch re-orgnaizes the implementation of aarch64_classify_symbol
in preparation for tiny absolute memory model support.

Co-Authored-By: Marcus Shawcroft <marcus.shawcroft@arm.com>
From-SVN: r199407

gcc/ChangeLog
gcc/config/aarch64/aarch64.c

index 4b9e846058195f39b8dcf376fd32234d3e92607a..6c4997351f0b2a8403cf934d7a1b5ae8ae045126 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-29  Chris Schlumberger-Socha <chris.schlumberger-socha@arm.com>
+           Marcus Shawcroft  <marcus.shawcroft@arm.com>
+
+       * config/aarch64/aarch64.c (aarch64_classify_symbol): Remove comment.
+       Refactor if/switch.  Replace gcc_assert with if.
+
 2013-05-29  Ganesh Gopalasubramanian  <Ganesh.Gopalasubramanian@amd.com>
 
        * config/i386/i386.c (initial_ix86_tune_features): Enable
index e580a1bcafc144d390182b1cf102c3324b090db9..59e6234291b47630e0ea1202228585d2bc974bfe 100644 (file)
@@ -5016,6 +5016,7 @@ aarch64_classify_tls_symbol (rtx x)
 
 /* Return the method that should be used to access SYMBOL_REF or
    LABEL_REF X in context CONTEXT.  */
+
 enum aarch64_symbol_type
 aarch64_classify_symbol (rtx x,
                         enum aarch64_symbol_context context ATTRIBUTE_UNUSED)
@@ -5038,48 +5039,34 @@ aarch64_classify_symbol (rtx x,
        }
     }
 
-  gcc_assert (GET_CODE (x) == SYMBOL_REF);
-
-  switch (aarch64_cmodel)
+  if (GET_CODE (x) == SYMBOL_REF)
     {
-    case AARCH64_CMODEL_LARGE:
-      return SYMBOL_FORCE_TO_MEM;
-
-    case AARCH64_CMODEL_TINY:
-    case AARCH64_CMODEL_SMALL:
-
-      /* This is needed to get DFmode, TImode constants to be loaded off
-         the constant pool.  Is it necessary to dump TImode values into
-         the constant pool.  We don't handle TImode constant loads properly
-         yet and hence need to use the constant pool.  */
-      if (CONSTANT_POOL_ADDRESS_P (x))
-       return SYMBOL_FORCE_TO_MEM;
-
-      if (aarch64_tls_symbol_p (x))
-       return aarch64_classify_tls_symbol (x);
-
-      if (SYMBOL_REF_WEAK (x))
-       return SYMBOL_FORCE_TO_MEM;
-
-      return SYMBOL_SMALL_ABSOLUTE;
-
-    case AARCH64_CMODEL_TINY_PIC:
-    case AARCH64_CMODEL_SMALL_PIC:
-
-      if (CONSTANT_POOL_ADDRESS_P (x))
+      if (aarch64_cmodel == AARCH64_CMODEL_LARGE
+         || CONSTANT_POOL_ADDRESS_P (x))
        return SYMBOL_FORCE_TO_MEM;
 
       if (aarch64_tls_symbol_p (x))
        return aarch64_classify_tls_symbol (x);
 
-      if (!aarch64_symbol_binds_local_p (x))
-       return SYMBOL_SMALL_GOT;
+      switch (aarch64_cmodel)
+       {
+       case AARCH64_CMODEL_TINY:
+       case AARCH64_CMODEL_SMALL:
+         if (SYMBOL_REF_WEAK (x))
+           return SYMBOL_FORCE_TO_MEM;
+         return SYMBOL_SMALL_ABSOLUTE;
 
-      return SYMBOL_SMALL_ABSOLUTE;
+       case AARCH64_CMODEL_TINY_PIC:
+       case AARCH64_CMODEL_SMALL_PIC:
+         if (!aarch64_symbol_binds_local_p (x))
+           return SYMBOL_SMALL_GOT;
+         return SYMBOL_SMALL_ABSOLUTE;
 
-    default:
-      gcc_unreachable ();
+       default:
+         gcc_unreachable ();
+       }
     }
+
   /* By default push everything into the constant pool.  */
   return SYMBOL_FORCE_TO_MEM;
 }