[PATCH, rs6000] Predefine __PPU__ to indicate -mcpu=cell

Ulrich Weigand uweigand@de.ibm.com
Mon Aug 11 16:21:00 GMT 2008


David Edelsohn wrote:
> >>>>> Ulrich Weigand writes:
> 
> Ulrich> I see, it seems I have misinterpreted existing code like
> Ulrich> if (rs6000_cpu == PROCESSOR_PPC405)
> Ulrich> builtin_define ("__PPC405__");
> 
> Ulrich> David, do you have any suggestions how to properly check for -mcpu=cell?
> Ulrich> It seems this information is not actually available anywhere ...
> 
> 	No, it's not available, which is why we use rs6000_cpu as the best
> available option.  The other option would be a new instruction that is
> specific to Cell PPU, but that does not exist.

Well, I guess we could simply make that information available by
adding a second variable (rs6000_arch ?), like in the patch below ...

If you think this is the right way to go, I can prepare and test a
proper patch along those lines.   Otherwise, I guess I'd be OK with
just my original patch.

Bye,
Ulrich


Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 137229)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -135,6 +135,7 @@
 /* Target cpu type */
 
 enum processor_type rs6000_cpu;
+enum processor_type rs6000_arch;
 struct rs6000_cpu_select rs6000_select[3] =
 {
   /* switch		name,			tune	arch */
@@ -1553,6 +1554,7 @@
   /* Identify the processor type.  */
   rs6000_select[0].string = default_cpu;
   rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
+  rs6000_arch = rs6000_cpu;
 
   for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
     {
@@ -1567,6 +1569,8 @@
 
 		if (ptr->set_arch_p)
 		  {
+		    rs6000_arch = processor_target_table[j].processor;
+
 		    target_flags &= ~set_masks;
 		    target_flags |= (processor_target_table[j].target_enable
 				     & set_masks);
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	(revision 137229)
+++ gcc/config/rs6000/rs6000.h	(working copy)
@@ -291,6 +291,7 @@
 };
 
 extern enum processor_type rs6000_cpu;
+extern enum processor_type rs6000_arch;
 
 /* Recast the processor type to the cpu attribute.  */
 #define rs6000_cpu_attr ((enum attr_cpu)rs6000_cpu)



-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com



More information about the Gcc-patches mailing list