public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, GCC][AArch64] Use Enums for code models option selection
@ 2012-05-31  9:56 Sofiane Naci
  2012-06-13 13:43 ` Sofiane Naci
  0 siblings, 1 reply; 6+ messages in thread
From: Sofiane Naci @ 2012-05-31  9:56 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1517 bytes --]

Hi,

This patch re-factors code models option selection in the AArch64 port:

 . Renaming variables such as mem_model to cmodel, for better clarity.
 . Using the generic support for enumerated option arguments.
 . Fixing touched code layout and formatting issues.

Thanks
Sofiane

-----

ChangeLog:

2012-05-31  Sofiane Naci <sofiane.naci@arm.com>

	[AArch64] Use Enums for code models option selection.

	* config/aarch64/aarch64-elf-raw.h (AARCH64_DEFAULT_MEM_MODEL):
Delete.
	* config/aarch64/aarch64-linux.h (AARCH64_DEFAULT_MEM_MODEL):
Delete.
	* config/aarch64/aarch64-opts.h (enum aarch64_code_model): New.
	* config/aarch64/aarch64-protos.h: Update comments.
	* config/aarch64/aarch64.c: Update comments.
	(aarch64_default_mem_model): Rename to aarch64_code_model.
	(aarch64_expand_mov_immediate): Remove error message.
	(aarch64_select_rtx_section): Remove assertion and update comment.
	(aarch64_override_options): Move memory model initialization from
here.
	(struct aarch64_mem_model): Delete.
	(aarch64_memory_models[]): Delete.
	(initialize_aarch64_memory_model): Rename to
initialize_aarch64_code_model
	and update.
	(aarch64_classify_symbol): Handle AARCH64_CMODEL_TINY and
	AARCH64_CMODEL_TINY_PIC
	* config/aarch64/aarch64.h
	(enum aarch64_memory_model): Delete.
	(aarch64_default_mem_model): Rename to aarch64_cmodel.
	(HAS_LONG_COND_BRANCH): Update.
	(HAS_LONG_UNCOND_BRANCH): Update.
	* config/aarch64/aarch64.opt
	(cmodel): New.
	(mcmodel): Update.

[-- Attachment #2: aarch64-use-enums-for-cmodels.patch --]
[-- Type: application/octet-stream, Size: 10966 bytes --]

diff --git a/gcc/config/aarch64/aarch64-elf-raw.h b/gcc/config/aarch64/aarch64-elf-raw.h
index 66ac75d..d9ec53f 100644
--- a/gcc/config/aarch64/aarch64-elf-raw.h
+++ b/gcc/config/aarch64/aarch64-elf-raw.h
@@ -22,8 +22,6 @@
 #ifndef GCC_AARCH64_ELF_RAW_H
 #define GCC_AARCH64_ELF_RAW_H
 
-#define AARCH64_DEFAULT_MEM_MODEL   AARCH64_MEM_MODEL_SMALL
-
 #define STARTFILE_SPEC " crti%O%s crtbegin%O%s crt0%O%s"
 #define ENDFILE_SPEC " crtend%O%s crtn%O%s"
 
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 7b44982..7649eba 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -50,6 +50,4 @@
     }						\
   while (0)
 
-#define AARCH64_DEFAULT_MEM_MODEL   AARCH64_MEM_MODEL_SMALL
-
 #endif  /* GCC_AARCH64_LINUX_H */
diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
index 98d4519..8878829 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -35,4 +35,24 @@ enum aarch64_processor
   aarch64_none
 };
 
+/* The code model defines the address generation strategy.
+   Most have a PIC and non-PIC variant.  */
+enum aarch64_code_model {
+  /* Static code and data fit within a 1MB region.
+     Not fully implemented, mostly treated as SMALL.  */
+  AARCH64_CMODEL_TINY,
+  /* Static code, data and GOT/PLT fit within a 1MB region.
+     Not fully implemented, mostly treated as SMALL_PIC.  */
+  AARCH64_CMODEL_TINY_PIC,
+  /* Static code and data fit within a 4GB region.
+     The default non-PIC code model.  */
+  AARCH64_CMODEL_SMALL,
+  /* Static code, data and GOT/PLT fit within a 4GB region.
+     The default PIC code model.  */
+  AARCH64_CMODEL_SMALL_PIC,
+  /* No assumptions about addresses of code and data.
+     The PIC variant is not yet implemented.  */
+  AARCH64_CMODEL_LARGE,
+};
+
 #endif
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index e6f02b9..130b0dd 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -76,7 +76,7 @@ enum aarch64_symbol_context
    or
    str x1, [x0, :lo12:foo]
 
-   This corresponds to the small memory model of the compiler.
+   This corresponds to the small code model of the compiler.
 
    SYMBOL_SMALL_GOT: Similar to the one above but this
    gives us the GOT entry of the symbol being referred to :
@@ -100,7 +100,7 @@ enum aarch64_symbol_context
    SYMBOL_FORCE_TO_MEM : Global variables are addressed using
    constant pool. All variable addresses are spilled into constant
    pools. The constant pools themselves are addressed using PC
-   relative accesses. This only works for the large memory model.
+   relative accesses.  This only works for the large code model.
  */
 enum aarch64_symbol_type
 {
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 34d0475..a2dd224 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -86,9 +86,8 @@ struct aarch64_address_info {
   enum aarch64_symbol_type symbol_type;
 };
 
-/* Set up default memory model.  */
-enum aarch64_memory_model
-aarch64_default_mem_model = AARCH64_DEFAULT_MEM_MODEL;
+/* The current code model.  */
+enum aarch64_code_model aarch64_cmodel;
 
 #ifdef HAVE_AS_TLS
 #undef TARGET_HAVE_TLS
@@ -633,7 +632,6 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
 	  return;
 
 	default:
-	  error ("Unimplemented memory model in generating symbolic references.  */");
 	  gcc_unreachable ();
 	}
     }
@@ -3879,14 +3877,11 @@ aarch64_select_rtx_section (enum machine_mode mode ATTRIBUTE_UNUSED,
 			    rtx x ATTRIBUTE_UNUSED,
 			    unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
 {
-  /* Force all constant pool entries into the current function
-     section.  XXX Will need fixing for Large PIC not to push relocatable
-     constants into text section.  */
-  gcc_assert (!flag_pic || (flag_pic && (aarch64_default_mem_model != AARCH64_MEM_MODEL_LARGE)));
+  /* Force all constant pool entries into the current function section.  */
   return function_section (current_function_decl);
 }
 
-\f
+
 /* Costs.  */
 
 /* Helper function for rtx cost calculation.  Strip a shift expression
@@ -4334,7 +4329,7 @@ aarch64_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
   return aarch64_tune_params->memmov_cost;
 }
 
-static void initialize_aarch64_memory_model (void);
+static void initialize_aarch64_code_model (void);
 
 /* Tuning parameters.  */
 
@@ -4615,13 +4610,7 @@ aarch64_override_options (void)
       aarch64_parse_tune ();
     }
 
-  if (flag_pic > 0)
-    {
-      aarch64_default_mem_model = AARCH64_MEM_MODEL_SMALL_PIC;
-    }
-
-  if (aarch64_mem_model_string != NULL)
-    initialize_aarch64_memory_model ();
+  initialize_aarch64_code_model ();
 
   aarch64_build_bitmask_table ();
 
@@ -4693,46 +4682,29 @@ aarch64_init_expanders (void)
   init_machine_status = aarch64_init_machine_status;
 }
 
-/* A checking mechanism for the implementation of the various
-    memory models.  */
-struct aarch64_mem_model
-{
-  const char * mem_model;
-  enum aarch64_memory_model model;
-  enum aarch64_memory_model model_pic;
-};
-
-
-static const struct aarch64_mem_model aarch64_memory_models[] =
-{
-  {"small", AARCH64_MEM_MODEL_SMALL, AARCH64_MEM_MODEL_SMALL_PIC},
-  {"large", AARCH64_MEM_MODEL_LARGE, AARCH64_MEM_MODEL_UNIMPLEMENTED}
-};
-
-void
-initialize_aarch64_memory_model (void)
+/* A checking mechanism for the implementation of the various code models.  */
+static void
+initialize_aarch64_code_model (void)
 {
-  unsigned i;
-  aarch64_default_mem_model = AARCH64_MEM_MODEL_UNIMPLEMENTED;
-  for (i = 0;
-       i < sizeof (aarch64_memory_models) / sizeof (struct aarch64_mem_model);
-       i++)
-    {
-      if (strcmp (aarch64_mem_model_string,
-		  aarch64_memory_models[i].mem_model) == 0)
-	{
-	  if (flag_pic == 0)
-	    aarch64_default_mem_model = aarch64_memory_models[i].model;
-	  else
-	    aarch64_default_mem_model = aarch64_memory_models[i].model_pic;
-	  break;
-	}
-    }
-
-  if (aarch64_default_mem_model == AARCH64_MEM_MODEL_UNIMPLEMENTED)
-    error ("Unimplemented / Illegal memory model `%s'%s",
-	   aarch64_mem_model_string,
-	   flag_pic ? " with -fPIC" : "");
+   if (flag_pic)
+     {
+       switch (aarch64_cmodel_var)
+	 {
+	 case AARCH64_CMODEL_TINY:
+	   aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
+	   break;
+	 case AARCH64_CMODEL_SMALL:
+	   aarch64_cmodel == AARCH64_CMODEL_SMALL_PIC;
+	   break;
+	 case AARCH64_CMODEL_LARGE:
+	   sorry ("code model %qs with -f%s", "large",
+		  flag_pic > 1 ? "PIC" : "pic");
+	 default:
+	   gcc_unreachable ();
+	 }
+     }
+   else
+     aarch64_cmodel = aarch64_cmodel_var;
 }
 
 /* Return true if SYMBOL_REF X binds locally.  */
@@ -4791,13 +4763,15 @@ aarch64_classify_symbol (rtx x,
 {
   if (GET_CODE (x) == LABEL_REF)
     {
-      switch (aarch64_default_mem_model)
+      switch (aarch64_cmodel)
 	{
-	case AARCH64_MEM_MODEL_LARGE:
+	case AARCH64_CMODEL_LARGE:
 	  return SYMBOL_FORCE_TO_MEM;
 
-	case AARCH64_MEM_MODEL_SMALL_PIC:
-	case AARCH64_MEM_MODEL_SMALL:
+	case AARCH64_CMODEL_TINY_PIC:
+	case AARCH64_CMODEL_TINY:
+	case AARCH64_CMODEL_SMALL_PIC:
+	case AARCH64_CMODEL_SMALL:
 	  return SYMBOL_SMALL_ABSOLUTE;
 
 	default:
@@ -4807,12 +4781,13 @@ aarch64_classify_symbol (rtx x,
 
   gcc_assert (GET_CODE (x) == SYMBOL_REF);
 
-  switch (aarch64_default_mem_model)
+  switch (aarch64_cmodel)
     {
-    case AARCH64_MEM_MODEL_LARGE:
+    case AARCH64_CMODEL_LARGE:
       return SYMBOL_FORCE_TO_MEM;
 
-    case AARCH64_MEM_MODEL_SMALL:
+    case AARCH64_CMODEL_TINY:
+    case AARCH64_CMODEL_SMALL:
 
       /* This is needed to get DFmode, TImode constants
 	 to be loaded off the constant pool. Is
@@ -4832,7 +4807,8 @@ aarch64_classify_symbol (rtx x,
 
       return SYMBOL_SMALL_ABSOLUTE;
 
-    case AARCH64_MEM_MODEL_SMALL_PIC:
+    case AARCH64_CMODEL_TINY_PIC:
+    case AARCH64_CMODEL_SMALL_PIC:
 
       if (CONSTANT_POOL_ADDRESS_P (x))
 	return SYMBOL_FORCE_TO_MEM;
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 4a39d0b..fc1f36d 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -801,48 +801,18 @@ enum tls_dialect
   TLS_DIALECT_DESC
 };
 
-/* Used for the code generation strategy dependent on the
-   memory model being used.
-
-   There are multiple memory models available.
-   Each one has a PIC and a non-PIC variant.
-
-   Tiny.
-   AARCH64_MEM_MODEL_TINY.
-   Unimplemented as of now.
-
-   Small.
-   AARCH64_MEM_MODEL_SMALL
-   Generate in sequences of adrh , ldrb and or
-   strb.
-
-   Large.
-   AARCH64_MEM_MODEL_LARGE
-   Default model as of now.
-*/
-enum aarch64_memory_model
-{
-  AARCH64_MEM_MODEL_UNIMPLEMENTED,
-  AARCH64_MEM_MODEL_TINY,
-  AARCH64_MEM_MODEL_SMALL,
-  AARCH64_MEM_MODEL_LARGE,
-  AARCH64_MEM_MODEL_TINY_PIC,
-  AARCH64_MEM_MODEL_SMALL_PIC,
-  AARCH64_MEM_MODEL_LARGE_PIC
-};
-
 extern enum tls_dialect aarch64_tls_dialect;
 
-extern enum aarch64_memory_model aarch64_default_mem_model;
+extern enum aarch64_code_model aarch64_cmodel;
 
 /* When using the tiny addressing model conditional and unconditional branches
    can span the whole of the available address space (1MB).  */
-#define HAS_LONG_COND_BRANCH					\
-  (aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY		\
-   || aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY_PIC)
+#define HAS_LONG_COND_BRANCH				\
+  (aarch64_cmodel == AARCH64_CMODEL_TINY		\
+   || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
 
-#define HAS_LONG_UNCOND_BRANCH					\
-  (aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY		\
-   || aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY_PIC)
+#define HAS_LONG_UNCOND_BRANCH				\
+  (aarch64_cmodel == AARCH64_CMODEL_TINY		\
+   || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
 
 #endif /* GCC_AARCH64_H */
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 3cdd335..0879507 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -21,6 +21,21 @@
 HeaderInclude
 config/aarch64/aarch64-opts.h
 
+; The code model option names for -mcmodel.
+
+Enum
+Name(cmodel) Type(enum aarch64_code_model)
+The code model option names for -mcmodel:
+
+EnumValue
+Enum(cmodel) String(tiny) Value(AARCH64_CMODEL_TINY)
+
+EnumValue
+Enum(cmodel) String(small) Value(AARCH64_CMODEL_SMALL)
+
+EnumValue
+Enum(cmodel) String(large) Value(AARCH64_CMODEL_LARGE)
+
 ; The cpu/arch option names to use in cpu/arch selection.
 
 Variable
@@ -45,8 +60,8 @@ Target Report RejectNegative InverseMask(BIG_END)
 Assume target CPU is configured as little endian
 
 mcmodel=
-Target RejectNegative Joined Var(aarch64_mem_model_string)
-Specify the PIC memory model - tiny, small, compact, medium, large
+Target RejectNegative Joined Enum(cmodel) Var(aarch64_cmodel_var) Init(AARCH64_CMODEL_SMALL)
+Specify the code model
 
 mstrict-align
 Target Report RejectNegative Mask(STRICT_ALIGN)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH, GCC][AArch64] Use Enums for code models option selection
  2012-05-31  9:56 [PATCH, GCC][AArch64] Use Enums for code models option selection Sofiane Naci
@ 2012-06-13 13:43 ` Sofiane Naci
  2012-06-13 13:58   ` Marcus Shawcroft
  0 siblings, 1 reply; 6+ messages in thread
From: Sofiane Naci @ 2012-06-13 13:43 UTC (permalink / raw)
  To: Sofiane Naci, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2023 bytes --]

Hi,

I discovered a bug in my previous patch, so I attach a new one.
The ChangeLog hasn't changed.
OK to commit?

Thanks
Sofiane

> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org]
On
> Behalf Of Sofiane Naci
> Sent: 31 May 2012 10:55
> To: gcc-patches@gcc.gnu.org
> Subject: [PATCH, GCC][AArch64] Use Enums for code models option selection
> 
> Hi,
> 
> This patch re-factors code models option selection in the AArch64 port:
> 
>  . Renaming variables such as mem_model to cmodel, for better clarity.
>  . Using the generic support for enumerated option arguments.
>  . Fixing touched code layout and formatting issues.
> 
> Thanks
> Sofiane
> 
> -----
> 
> ChangeLog:
> 
> 2012-05-31  Sofiane Naci <sofiane.naci@arm.com>
> 
> 	[AArch64] Use Enums for code models option selection.
> 
> 	* config/aarch64/aarch64-elf-raw.h (AARCH64_DEFAULT_MEM_MODEL):
> Delete.
> 	* config/aarch64/aarch64-linux.h (AARCH64_DEFAULT_MEM_MODEL):
> Delete.
> 	* config/aarch64/aarch64-opts.h (enum aarch64_code_model): New.
> 	* config/aarch64/aarch64-protos.h: Update comments.
> 	* config/aarch64/aarch64.c: Update comments.
> 	(aarch64_default_mem_model): Rename to aarch64_code_model.
> 	(aarch64_expand_mov_immediate): Remove error message.
> 	(aarch64_select_rtx_section): Remove assertion and update comment.
> 	(aarch64_override_options): Move memory model initialization from
> here.
> 	(struct aarch64_mem_model): Delete.
> 	(aarch64_memory_models[]): Delete.
> 	(initialize_aarch64_memory_model): Rename to
> initialize_aarch64_code_model
> 	and update.
> 	(aarch64_classify_symbol): Handle AARCH64_CMODEL_TINY and
> 	AARCH64_CMODEL_TINY_PIC
> 	* config/aarch64/aarch64.h
> 	(enum aarch64_memory_model): Delete.
> 	(aarch64_default_mem_model): Rename to aarch64_cmodel.
> 	(HAS_LONG_COND_BRANCH): Update.
> 	(HAS_LONG_UNCOND_BRANCH): Update.
> 	* config/aarch64/aarch64.opt
> 	(cmodel): New.
> 	(mcmodel): Update.

[-- Attachment #2: aarch64-use-enums-for-cmodels.patch --]
[-- Type: application/octet-stream, Size: 10964 bytes --]

diff --git a/gcc/config/aarch64/aarch64-elf-raw.h b/gcc/config/aarch64/aarch64-elf-raw.h
index 66ac75d..d9ec53f 100644
--- a/gcc/config/aarch64/aarch64-elf-raw.h
+++ b/gcc/config/aarch64/aarch64-elf-raw.h
@@ -22,8 +22,6 @@
 #ifndef GCC_AARCH64_ELF_RAW_H
 #define GCC_AARCH64_ELF_RAW_H
 
-#define AARCH64_DEFAULT_MEM_MODEL   AARCH64_MEM_MODEL_SMALL
-
 #define STARTFILE_SPEC " crti%O%s crtbegin%O%s crt0%O%s"
 #define ENDFILE_SPEC " crtend%O%s crtn%O%s"
 
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index 7b44982..7649eba 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -50,6 +50,4 @@
     }						\
   while (0)
 
-#define AARCH64_DEFAULT_MEM_MODEL   AARCH64_MEM_MODEL_SMALL
-
 #endif  /* GCC_AARCH64_LINUX_H */
diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h
index 98d4519..8878829 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -35,4 +35,24 @@ enum aarch64_processor
   aarch64_none
 };
 
+/* The code model defines the address generation strategy.
+   Most have a PIC and non-PIC variant.  */
+enum aarch64_code_model {
+  /* Static code and data fit within a 1MB region.
+     Not fully implemented, mostly treated as SMALL.  */
+  AARCH64_CMODEL_TINY,
+  /* Static code, data and GOT/PLT fit within a 1MB region.
+     Not fully implemented, mostly treated as SMALL_PIC.  */
+  AARCH64_CMODEL_TINY_PIC,
+  /* Static code and data fit within a 4GB region.
+     The default non-PIC code model.  */
+  AARCH64_CMODEL_SMALL,
+  /* Static code, data and GOT/PLT fit within a 4GB region.
+     The default PIC code model.  */
+  AARCH64_CMODEL_SMALL_PIC,
+  /* No assumptions about addresses of code and data.
+     The PIC variant is not yet implemented.  */
+  AARCH64_CMODEL_LARGE
+};
+
 #endif
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index e6f02b9..130b0dd 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -76,7 +76,7 @@ enum aarch64_symbol_context
    or
    str x1, [x0, :lo12:foo]
 
-   This corresponds to the small memory model of the compiler.
+   This corresponds to the small code model of the compiler.
 
    SYMBOL_SMALL_GOT: Similar to the one above but this
    gives us the GOT entry of the symbol being referred to :
@@ -100,7 +100,7 @@ enum aarch64_symbol_context
    SYMBOL_FORCE_TO_MEM : Global variables are addressed using
    constant pool. All variable addresses are spilled into constant
    pools. The constant pools themselves are addressed using PC
-   relative accesses. This only works for the large memory model.
+   relative accesses.  This only works for the large code model.
  */
 enum aarch64_symbol_type
 {
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 34d0475..a2dd224 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -86,9 +86,8 @@ struct aarch64_address_info {
   enum aarch64_symbol_type symbol_type;
 };
 
-/* Set up default memory model.  */
-enum aarch64_memory_model
-aarch64_default_mem_model = AARCH64_DEFAULT_MEM_MODEL;
+/* The current code model.  */
+enum aarch64_code_model aarch64_cmodel;
 
 #ifdef HAVE_AS_TLS
 #undef TARGET_HAVE_TLS
@@ -633,7 +632,6 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
 	  return;
 
 	default:
-	  error ("Unimplemented memory model in generating symbolic references.  */");
 	  gcc_unreachable ();
 	}
     }
@@ -3879,14 +3877,11 @@ aarch64_select_rtx_section (enum machine_mode mode ATTRIBUTE_UNUSED,
 			    rtx x ATTRIBUTE_UNUSED,
 			    unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
 {
-  /* Force all constant pool entries into the current function
-     section.  XXX Will need fixing for Large PIC not to push relocatable
-     constants into text section.  */
-  gcc_assert (!flag_pic || (flag_pic && (aarch64_default_mem_model != AARCH64_MEM_MODEL_LARGE)));
+  /* Force all constant pool entries into the current function section.  */
   return function_section (current_function_decl);
 }
 
-\f
+
 /* Costs.  */
 
 /* Helper function for rtx cost calculation.  Strip a shift expression
@@ -4334,7 +4329,7 @@ aarch64_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
   return aarch64_tune_params->memmov_cost;
 }
 
-static void initialize_aarch64_memory_model (void);
+static void initialize_aarch64_code_model (void);
 
 /* Tuning parameters.  */
 
@@ -4615,13 +4610,7 @@ aarch64_override_options (void)
       aarch64_parse_tune ();
     }
 
-  if (flag_pic > 0)
-    {
-      aarch64_default_mem_model = AARCH64_MEM_MODEL_SMALL_PIC;
-    }
-
-  if (aarch64_mem_model_string != NULL)
-    initialize_aarch64_memory_model ();
+  initialize_aarch64_code_model ();
 
   aarch64_build_bitmask_table ();
 
@@ -4693,46 +4682,29 @@ aarch64_init_expanders (void)
   init_machine_status = aarch64_init_machine_status;
 }
 
-/* A checking mechanism for the implementation of the various
-    memory models.  */
-struct aarch64_mem_model
-{
-  const char * mem_model;
-  enum aarch64_memory_model model;
-  enum aarch64_memory_model model_pic;
-};
-
-
-static const struct aarch64_mem_model aarch64_memory_models[] =
-{
-  {"small", AARCH64_MEM_MODEL_SMALL, AARCH64_MEM_MODEL_SMALL_PIC},
-  {"large", AARCH64_MEM_MODEL_LARGE, AARCH64_MEM_MODEL_UNIMPLEMENTED}
-};
-
-void
-initialize_aarch64_memory_model (void)
+/* A checking mechanism for the implementation of the various code models.  */
+static void
+initialize_aarch64_code_model (void)
 {
-  unsigned i;
-  aarch64_default_mem_model = AARCH64_MEM_MODEL_UNIMPLEMENTED;
-  for (i = 0;
-       i < sizeof (aarch64_memory_models) / sizeof (struct aarch64_mem_model);
-       i++)
-    {
-      if (strcmp (aarch64_mem_model_string,
-		  aarch64_memory_models[i].mem_model) == 0)
-	{
-	  if (flag_pic == 0)
-	    aarch64_default_mem_model = aarch64_memory_models[i].model;
-	  else
-	    aarch64_default_mem_model = aarch64_memory_models[i].model_pic;
-	  break;
-	}
-    }
-
-  if (aarch64_default_mem_model == AARCH64_MEM_MODEL_UNIMPLEMENTED)
-    error ("Unimplemented / Illegal memory model `%s'%s",
-	   aarch64_mem_model_string,
-	   flag_pic ? " with -fPIC" : "");
+   if (flag_pic)
+     {
+       switch (aarch64_cmodel_var)
+	 {
+	 case AARCH64_CMODEL_TINY:
+	   aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
+	   break;
+	 case AARCH64_CMODEL_SMALL:
+	   aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
+	   break;
+	 case AARCH64_CMODEL_LARGE:
+	   sorry ("code model %qs with -f%s", "large",
+		  flag_pic > 1 ? "PIC" : "pic");
+	 default:
+	   gcc_unreachable ();
+	 }
+     }
+   else
+     aarch64_cmodel = aarch64_cmodel_var;
 }
 
 /* Return true if SYMBOL_REF X binds locally.  */
@@ -4791,13 +4763,15 @@ aarch64_classify_symbol (rtx x,
 {
   if (GET_CODE (x) == LABEL_REF)
     {
-      switch (aarch64_default_mem_model)
+      switch (aarch64_cmodel)
 	{
-	case AARCH64_MEM_MODEL_LARGE:
+	case AARCH64_CMODEL_LARGE:
 	  return SYMBOL_FORCE_TO_MEM;
 
-	case AARCH64_MEM_MODEL_SMALL_PIC:
-	case AARCH64_MEM_MODEL_SMALL:
+	case AARCH64_CMODEL_TINY_PIC:
+	case AARCH64_CMODEL_TINY:
+	case AARCH64_CMODEL_SMALL_PIC:
+	case AARCH64_CMODEL_SMALL:
 	  return SYMBOL_SMALL_ABSOLUTE;
 
 	default:
@@ -4807,12 +4781,13 @@ aarch64_classify_symbol (rtx x,
 
   gcc_assert (GET_CODE (x) == SYMBOL_REF);
 
-  switch (aarch64_default_mem_model)
+  switch (aarch64_cmodel)
     {
-    case AARCH64_MEM_MODEL_LARGE:
+    case AARCH64_CMODEL_LARGE:
       return SYMBOL_FORCE_TO_MEM;
 
-    case AARCH64_MEM_MODEL_SMALL:
+    case AARCH64_CMODEL_TINY:
+    case AARCH64_CMODEL_SMALL:
 
       /* This is needed to get DFmode, TImode constants
 	 to be loaded off the constant pool. Is
@@ -4832,7 +4807,8 @@ aarch64_classify_symbol (rtx x,
 
       return SYMBOL_SMALL_ABSOLUTE;
 
-    case AARCH64_MEM_MODEL_SMALL_PIC:
+    case AARCH64_CMODEL_TINY_PIC:
+    case AARCH64_CMODEL_SMALL_PIC:
 
       if (CONSTANT_POOL_ADDRESS_P (x))
 	return SYMBOL_FORCE_TO_MEM;
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 4a39d0b..fc1f36d 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -801,48 +801,18 @@ enum tls_dialect
   TLS_DIALECT_DESC
 };
 
-/* Used for the code generation strategy dependent on the
-   memory model being used.
-
-   There are multiple memory models available.
-   Each one has a PIC and a non-PIC variant.
-
-   Tiny.
-   AARCH64_MEM_MODEL_TINY.
-   Unimplemented as of now.
-
-   Small.
-   AARCH64_MEM_MODEL_SMALL
-   Generate in sequences of adrh , ldrb and or
-   strb.
-
-   Large.
-   AARCH64_MEM_MODEL_LARGE
-   Default model as of now.
-*/
-enum aarch64_memory_model
-{
-  AARCH64_MEM_MODEL_UNIMPLEMENTED,
-  AARCH64_MEM_MODEL_TINY,
-  AARCH64_MEM_MODEL_SMALL,
-  AARCH64_MEM_MODEL_LARGE,
-  AARCH64_MEM_MODEL_TINY_PIC,
-  AARCH64_MEM_MODEL_SMALL_PIC,
-  AARCH64_MEM_MODEL_LARGE_PIC
-};
-
 extern enum tls_dialect aarch64_tls_dialect;
 
-extern enum aarch64_memory_model aarch64_default_mem_model;
+extern enum aarch64_code_model aarch64_cmodel;
 
 /* When using the tiny addressing model conditional and unconditional branches
    can span the whole of the available address space (1MB).  */
-#define HAS_LONG_COND_BRANCH					\
-  (aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY		\
-   || aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY_PIC)
+#define HAS_LONG_COND_BRANCH				\
+  (aarch64_cmodel == AARCH64_CMODEL_TINY		\
+   || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
 
-#define HAS_LONG_UNCOND_BRANCH					\
-  (aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY		\
-   || aarch64_default_mem_model == AARCH64_MEM_MODEL_TINY_PIC)
+#define HAS_LONG_UNCOND_BRANCH				\
+  (aarch64_cmodel == AARCH64_CMODEL_TINY		\
+   || aarch64_cmodel == AARCH64_CMODEL_TINY_PIC)
 
 #endif /* GCC_AARCH64_H */
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 3cdd335..0879507 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -21,6 +21,21 @@
 HeaderInclude
 config/aarch64/aarch64-opts.h
 
+; The code model option names for -mcmodel.
+
+Enum
+Name(cmodel) Type(enum aarch64_code_model)
+The code model option names for -mcmodel:
+
+EnumValue
+Enum(cmodel) String(tiny) Value(AARCH64_CMODEL_TINY)
+
+EnumValue
+Enum(cmodel) String(small) Value(AARCH64_CMODEL_SMALL)
+
+EnumValue
+Enum(cmodel) String(large) Value(AARCH64_CMODEL_LARGE)
+
 ; The cpu/arch option names to use in cpu/arch selection.
 
 Variable
@@ -45,8 +60,8 @@ Target Report RejectNegative InverseMask(BIG_END)
 Assume target CPU is configured as little endian
 
 mcmodel=
-Target RejectNegative Joined Var(aarch64_mem_model_string)
-Specify the PIC memory model - tiny, small, compact, medium, large
+Target RejectNegative Joined Enum(cmodel) Var(aarch64_cmodel_var) Init(AARCH64_CMODEL_SMALL)
+Specify the code model
 
 mstrict-align
 Target Report RejectNegative Mask(STRICT_ALIGN)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, GCC][AArch64] Use Enums for code models option selection
  2012-06-13 13:43 ` Sofiane Naci
@ 2012-06-13 13:58   ` Marcus Shawcroft
  2012-06-22 17:27     ` Tejas Belagod
  0 siblings, 1 reply; 6+ messages in thread
From: Marcus Shawcroft @ 2012-06-13 13:58 UTC (permalink / raw)
  To: gcc-patches

On 13/06/12 14:38, Sofiane Naci wrote:
> Hi,
>
> I discovered a bug in my previous patch, so I attach a new one.
> The ChangeLog hasn't changed.
> OK to commit?
>
> Thanks
> Sofiane
>
>> -----Original Message-----
>> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org]
> On
>> Behalf Of Sofiane Naci
>> Sent: 31 May 2012 10:55
>> To: gcc-patches@gcc.gnu.org
>> Subject: [PATCH, GCC][AArch64] Use Enums for code models option selection
>>
>> Hi,
>>
>> This patch re-factors code models option selection in the AArch64 port:
>>
>>   . Renaming variables such as mem_model to cmodel, for better clarity.
>>   . Using the generic support for enumerated option arguments.
>>   . Fixing touched code layout and formatting issues.
>>
>> Thanks
>> Sofiane
>>
>> -----
>>
>> ChangeLog:
>>
>> 2012-05-31  Sofiane Naci<sofiane.naci@arm.com>
>>
>> 	[AArch64] Use Enums for code models option selection.
>>
>> 	* config/aarch64/aarch64-elf-raw.h (AARCH64_DEFAULT_MEM_MODEL):
>> Delete.
>> 	* config/aarch64/aarch64-linux.h (AARCH64_DEFAULT_MEM_MODEL):
>> Delete.
>> 	* config/aarch64/aarch64-opts.h (enum aarch64_code_model): New.
>> 	* config/aarch64/aarch64-protos.h: Update comments.
>> 	* config/aarch64/aarch64.c: Update comments.
>> 	(aarch64_default_mem_model): Rename to aarch64_code_model.
>> 	(aarch64_expand_mov_immediate): Remove error message.
>> 	(aarch64_select_rtx_section): Remove assertion and update comment.
>> 	(aarch64_override_options): Move memory model initialization from
>> here.
>> 	(struct aarch64_mem_model): Delete.
>> 	(aarch64_memory_models[]): Delete.
>> 	(initialize_aarch64_memory_model): Rename to
>> initialize_aarch64_code_model
>> 	and update.
>> 	(aarch64_classify_symbol): Handle AARCH64_CMODEL_TINY and
>> 	AARCH64_CMODEL_TINY_PIC
>> 	* config/aarch64/aarch64.h
>> 	(enum aarch64_memory_model): Delete.
>> 	(aarch64_default_mem_model): Rename to aarch64_cmodel.
>> 	(HAS_LONG_COND_BRANCH): Update.
>> 	(HAS_LONG_UNCOND_BRANCH): Update.
>> 	* config/aarch64/aarch64.opt
>> 	(cmodel): New.
>> 	(mcmodel): Update.

OK

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, GCC][AArch64] Use Enums for code models option selection
  2012-06-13 13:58   ` Marcus Shawcroft
@ 2012-06-22 17:27     ` Tejas Belagod
  2012-06-28 16:44       ` Tejas Belagod
  0 siblings, 1 reply; 6+ messages in thread
From: Tejas Belagod @ 2012-06-22 17:27 UTC (permalink / raw)
  To: gcc-patches; +Cc: Marcus Shawcroft

Marcus Shawcroft wrote:
> On 13/06/12 14:38, Sofiane Naci wrote:
>> Hi,
>>
>> I discovered a bug in my previous patch, so I attach a new one.
>> The ChangeLog hasn't changed.
>> OK to commit?
>>
>> Thanks
>> Sofiane
>>
>>> -----Original Message-----
>>> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org]
>> On
>>> Behalf Of Sofiane Naci
>>> Sent: 31 May 2012 10:55
>>> To: gcc-patches@gcc.gnu.org
>>> Subject: [PATCH, GCC][AArch64] Use Enums for code models option selection
>>>
>>> Hi,
>>>
>>> This patch re-factors code models option selection in the AArch64 port:
>>>
>>>   . Renaming variables such as mem_model to cmodel, for better clarity.
>>>   . Using the generic support for enumerated option arguments.
>>>   . Fixing touched code layout and formatting issues.
>>>
>>> Thanks
>>> Sofiane
>>>
>>> -----
>>>
>>> ChangeLog:
>>>
>>> 2012-05-31  Sofiane Naci<sofiane.naci@arm.com>
>>>
>>> 	[AArch64] Use Enums for code models option selection.
>>>
>>> 	* config/aarch64/aarch64-elf-raw.h (AARCH64_DEFAULT_MEM_MODEL):
>>> Delete.
>>> 	* config/aarch64/aarch64-linux.h (AARCH64_DEFAULT_MEM_MODEL):
>>> Delete.
>>> 	* config/aarch64/aarch64-opts.h (enum aarch64_code_model): New.
>>> 	* config/aarch64/aarch64-protos.h: Update comments.
>>> 	* config/aarch64/aarch64.c: Update comments.
>>> 	(aarch64_default_mem_model): Rename to aarch64_code_model.
>>> 	(aarch64_expand_mov_immediate): Remove error message.
>>> 	(aarch64_select_rtx_section): Remove assertion and update comment.
>>> 	(aarch64_override_options): Move memory model initialization from
>>> here.
>>> 	(struct aarch64_mem_model): Delete.
>>> 	(aarch64_memory_models[]): Delete.
>>> 	(initialize_aarch64_memory_model): Rename to
>>> initialize_aarch64_code_model
>>> 	and update.
>>> 	(aarch64_classify_symbol): Handle AARCH64_CMODEL_TINY and
>>> 	AARCH64_CMODEL_TINY_PIC
>>> 	* config/aarch64/aarch64.h
>>> 	(enum aarch64_memory_model): Delete.
>>> 	(aarch64_default_mem_model): Rename to aarch64_cmodel.
>>> 	(HAS_LONG_COND_BRANCH): Update.
>>> 	(HAS_LONG_UNCOND_BRANCH): Update.
>>> 	* config/aarch64/aarch64.opt
>>> 	(cmodel): New.
>>> 	(mcmodel): Update.
> 
> OK
> 
> 

I've checked this in on aarch64-branch upstream for Sofiane.

Tejas.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, GCC][AArch64] Use Enums for code models option selection
  2012-06-22 17:27     ` Tejas Belagod
@ 2012-06-28 16:44       ` Tejas Belagod
  2012-06-28 17:44         ` Richard Earnshaw
  0 siblings, 1 reply; 6+ messages in thread
From: Tejas Belagod @ 2012-06-28 16:44 UTC (permalink / raw)
  To: gcc-patches; +Cc: Marcus Shawcroft

[-- Attachment #1: Type: text/plain, Size: 2712 bytes --]

Tejas Belagod wrote:
> Marcus Shawcroft wrote:
>> On 13/06/12 14:38, Sofiane Naci wrote:
>>> Hi,
>>>
>>> I discovered a bug in my previous patch, so I attach a new one.
>>> The ChangeLog hasn't changed.
>>> OK to commit?
>>>
>>> Thanks
>>> Sofiane
>>>
>>>> -----Original Message-----
>>>> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-owner@gcc.gnu.org]
>>> On
>>>> Behalf Of Sofiane Naci
>>>> Sent: 31 May 2012 10:55
>>>> To: gcc-patches@gcc.gnu.org
>>>> Subject: [PATCH, GCC][AArch64] Use Enums for code models option selection
>>>>
>>>> Hi,
>>>>
>>>> This patch re-factors code models option selection in the AArch64 port:
>>>>
>>>>   . Renaming variables such as mem_model to cmodel, for better clarity.
>>>>   . Using the generic support for enumerated option arguments.
>>>>   . Fixing touched code layout and formatting issues.
>>>>
>>>> Thanks
>>>> Sofiane
>>>>
>>>> -----
>>>>
>>>> ChangeLog:
>>>>
>>>> 2012-05-31  Sofiane Naci<sofiane.naci@arm.com>
>>>>
>>>> 	[AArch64] Use Enums for code models option selection.
>>>>
>>>> 	* config/aarch64/aarch64-elf-raw.h (AARCH64_DEFAULT_MEM_MODEL):
>>>> Delete.
>>>> 	* config/aarch64/aarch64-linux.h (AARCH64_DEFAULT_MEM_MODEL):
>>>> Delete.
>>>> 	* config/aarch64/aarch64-opts.h (enum aarch64_code_model): New.
>>>> 	* config/aarch64/aarch64-protos.h: Update comments.
>>>> 	* config/aarch64/aarch64.c: Update comments.
>>>> 	(aarch64_default_mem_model): Rename to aarch64_code_model.
>>>> 	(aarch64_expand_mov_immediate): Remove error message.
>>>> 	(aarch64_select_rtx_section): Remove assertion and update comment.
>>>> 	(aarch64_override_options): Move memory model initialization from
>>>> here.
>>>> 	(struct aarch64_mem_model): Delete.
>>>> 	(aarch64_memory_models[]): Delete.
>>>> 	(initialize_aarch64_memory_model): Rename to
>>>> initialize_aarch64_code_model
>>>> 	and update.
>>>> 	(aarch64_classify_symbol): Handle AARCH64_CMODEL_TINY and
>>>> 	AARCH64_CMODEL_TINY_PIC
>>>> 	* config/aarch64/aarch64.h
>>>> 	(enum aarch64_memory_model): Delete.
>>>> 	(aarch64_default_mem_model): Rename to aarch64_cmodel.
>>>> 	(HAS_LONG_COND_BRANCH): Update.
>>>> 	(HAS_LONG_UNCOND_BRANCH): Update.
>>>> 	* config/aarch64/aarch64.opt
>>>> 	(cmodel): New.
>>>> 	(mcmodel): Update.
>> OK
>>
>>
> 
> I've checked this in on aarch64-branch upstream for Sofiane.
> 
> Tejas.

Sorry, I broke the build when I applied this patch. Attached is a patch that 
fixes this. Build and regressions are happy. OK to commit?

Thanks,
Tejas Belagod.
ARM.

Changelog

2012-06-28  Tejas Belagod  <tejas.belagod@arm.com>

gcc/
	* config/aarch64/aarch64.h (aarch64_cmodel): Fix enum name.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: aarch64-use-enums-for-cmodels.fix.patch --]
[-- Type: text/x-patch; name=aarch64-use-enums-for-cmodels.fix.patch, Size: 592 bytes --]

diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index ce2f899..5e24cd7 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -802,7 +802,7 @@ enum aarch64_builtins
 /* Check TLS Descriptors mechanism is selected.  */
 #define TARGET_TLS_DESC (aarch64_tls_dialect == TLS_DESCRIPTORS)
 
-extern enum aarch64_memory_model aarch64_cmodel;
+extern enum aarch64_code_model aarch64_cmodel;
 
 /* When using the tiny addressing model conditional and unconditional branches
    can span the whole of the available address space (1MB).  */

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH, GCC][AArch64] Use Enums for code models option selection
  2012-06-28 16:44       ` Tejas Belagod
@ 2012-06-28 17:44         ` Richard Earnshaw
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Earnshaw @ 2012-06-28 17:44 UTC (permalink / raw)
  To: Tejas Belagod; +Cc: gcc-patches, Marcus Shawcroft

On 28/06/12 16:58, Tejas Belagod wrote:
> 
> Sorry, I broke the build when I applied this patch. Attached is a patch that 
> fixes this. Build and regressions are happy. OK to commit?
> 
> Thanks,
> Tejas Belagod.
> ARM.
> 
> Changelog
> 
> 2012-06-28  Tejas Belagod  <tejas.belagod@arm.com>
> 
> gcc/
> 	* config/aarch64/aarch64.h (aarch64_cmodel): Fix enum name.
> 
> 

OK.

R.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-06-28 17:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-31  9:56 [PATCH, GCC][AArch64] Use Enums for code models option selection Sofiane Naci
2012-06-13 13:43 ` Sofiane Naci
2012-06-13 13:58   ` Marcus Shawcroft
2012-06-22 17:27     ` Tejas Belagod
2012-06-28 16:44       ` Tejas Belagod
2012-06-28 17:44         ` Richard Earnshaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).