From b0ca189452f5d12f013f7163570ccf4c97c374b0 Mon Sep 17 00:00:00 2001
From: Marcus Shawcroft <marcus.shawcroft@arm.com>
Date: Thu, 20 Sep 2012 14:04:54 +0100
Subject: [PATCH 01/11] Use define_c_enum

---
 gcc/ChangeLog.aarch64           |   7 +++
 gcc/config/aarch64/aarch64.md   | 123 +++++++---------------------------------
 gcc/config/aarch64/iterators.md |  81 ++++++++++++++++++++++++++
 gcc/config/aarch64/sync.md      |  12 +++-
 4 files changed, 120 insertions(+), 103 deletions(-)

diff --git a/gcc/ChangeLog.aarch64 b/gcc/ChangeLog.aarch64
index 4bab7ae..6baf152 100644
--- a/gcc/ChangeLog.aarch64
+++ b/gcc/ChangeLog.aarch64
@@ -1,3 +1,10 @@
+2012-09-20  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
+
+	* config/aarch64/aarch64.md: Make unspec and unspecv constants
+	c_enums and split out to iterators.md and sync.md.
+	* config/aarch64/iterators.md: Add SIMD unspec c_enums.
+	* config/aarch64/sync.md: Add sync unspecv c_enums.
+
 2012-09-18  Ian Bolton  <ian.bolton@arm.com>
 
 	* config/aarch64/aarch64.h: Define CTZ_DEFINED_VALUE_AT_ZERO.
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index eeaaf63..e6086a9 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -65,108 +65,27 @@
   ]
 )
 
-(define_constants
-  [
-    (UNSPEC_NOP		0)
-    (UNSPEC_TLS		1)
-    (UNSPEC_CASESI	2)
-    (UNSPEC_GOTSMALLPIC    3)
-    (UNSPEC_GOTSMALLTLS    4)
-    (UNSPEC_PRLG_STK    5)
-    (UNSPEC_MB          6)
-    (UNSPEC_ASHIFT_SIGNED	7) ; Used in aarch64-simd.md.
-    (UNSPEC_ASHIFT_UNSIGNED	8) ; Used in aarch64-simd.md.
-    (UNSPEC_FRINTZ        9)
-    (UNSPEC_FRINTP       10)
-    (UNSPEC_FRINTM       11)
-    (UNSPEC_FRINTA       12)
-    (UNSPEC_FRINTI       13)
-    (UNSPEC_TLSDESC      14)
-    (UNSPEC_FRINTX       15)
-    (UNSPEC_FMAXV	 16) ; Used in aarch64-simd.md.
-    (UNSPEC_FMINV	 17) ; Used in aarch64-simd.md.
-    (UNSPEC_FADDV	 18) ; Used in aarch64-simd.md.
-    (UNSPEC_ADDV	 19) ; Used in aarch64-simd.md.
-    (UNSPEC_SMAXV	 20) ; Used in aarch64-simd.md.
-    (UNSPEC_SMINV	 21) ; Used in aarch64-simd.md.
-    (UNSPEC_UMAXV        22) ; Used in aarch64-simd.md.
-    (UNSPEC_UMINV	 23) ; Used in aarch64-simd.md.
-    (UNSPEC_SHADD	 24) ; Used in aarch64-simd.md.
-    (UNSPEC_UHADD	 25) ; Used in aarch64-simd.md.
-    (UNSPEC_SRHADD	 26) ; Used in aarch64-simd.md.
-    (UNSPEC_URHADD	 27) ; Used in aarch64-simd.md.
-    (UNSPEC_SHSUB	 28) ; Used in aarch64-simd.md.
-    (UNSPEC_UHSUB	 29) ; Used in aarch64-simd.md.
-    (UNSPEC_SRHSUB	 30) ; Used in aarch64-simd.md.
-    (UNSPEC_URHSUB	 31) ; Used in aarch64-simd.md.
-    (UNSPEC_ADDHN	 32) ; Used in aarch64-simd.md.
-    (UNSPEC_RADDHN	 33) ; Used in aarch64-simd.md.
-    (UNSPEC_SUBHN	 34) ; Used in aarch64-simd.md.
-    (UNSPEC_RSUBHN	 35) ; Used in aarch64-simd.md.
-    (UNSPEC_ADDHN2	 36) ; Used in aarch64-simd.md.
-    (UNSPEC_RADDHN2	 37) ; Used in aarch64-simd.md.
-    (UNSPEC_SUBHN2	 38) ; Used in aarch64-simd.md.
-    (UNSPEC_RSUBHN2	 39) ; Used in aarch64-simd.md.
-    (UNSPEC_SQDMULH	 40) ; Used in aarch64-simd.md.
-    (UNSPEC_SQRDMULH	 41) ; Used in aarch64-simd.md.
-    (UNSPEC_PMUL	 42) ; Used in aarch64-simd.md.
-    (UNSPEC_USQADD	 43) ; Used in aarch64-simd.md.
-    (UNSPEC_SUQADD	 44) ; Used in aarch64-simd.md.
-    (UNSPEC_SQXTUN	 45) ; Used in aarch64-simd.md.
-    (UNSPEC_SQXTN	 46) ; Used in aarch64-simd.md.
-    (UNSPEC_UQXTN	 47) ; Used in aarch64-simd.md.
-    (UNSPEC_SSRA	 48) ; Used in aarch64-simd.md.
-    (UNSPEC_USRA	 49) ; Used in aarch64-simd.md.
-    (UNSPEC_SRSRA	 50) ; Used in aarch64-simd.md.
-    (UNSPEC_URSRA	 51) ; Used in aarch64-simd.md.
-    (UNSPEC_SRSHR	 52) ; Used in aarch64-simd.md.
-    (UNSPEC_URSHR	 53) ; Used in aarch64-simd.md.
-    (UNSPEC_SQSHLU	 54) ; Used in aarch64-simd.md.
-    (UNSPEC_SQSHL	 55) ; Used in aarch64-simd.md.
-    (UNSPEC_UQSHL	 56) ; Used in aarch64-simd.md.
-    (UNSPEC_SQSHRUN	 57) ; Used in aarch64-simd.md.
-    (UNSPEC_SQRSHRUN	 58) ; Used in aarch64-simd.md.
-    (UNSPEC_SQSHRN	 59) ; Used in aarch64-simd.md.
-    (UNSPEC_UQSHRN	 60) ; Used in aarch64-simd.md.
-    (UNSPEC_SQRSHRN	 61) ; Used in aarch64-simd.md.
-    (UNSPEC_UQRSHRN	 62) ; Used in aarch64-simd.md.
-    (UNSPEC_SSHL	 63) ; Used in aarch64-simd.md.
-    (UNSPEC_USHL	 64) ; Used in aarch64-simd.md.
-    (UNSPEC_SRSHL	 65) ; Used in aarch64-simd.md.
-    (UNSPEC_URSHL	 66) ; Used in aarch64-simd.md.
-    (UNSPEC_SQRSHL	 67) ; Used in aarch64-simd.md.
-    (UNSPEC_UQRSHL	 68) ; Used in aarch64-simd.md.
-    (UNSPEC_CMEQ	 69) ; Used in aarch64-simd.md.
-    (UNSPEC_CMLE	 70) ; Used in aarch64-simd.md.
-    (UNSPEC_CMLT	 71) ; Used in aarch64-simd.md.
-    (UNSPEC_CMGE	 72) ; Used in aarch64-simd.md.
-    (UNSPEC_CMGT	 73) ; Used in aarch64-simd.md.
-    (UNSPEC_CMHS	 74) ; Used in aarch64-simd.md.
-    (UNSPEC_CMHI	 75) ; Used in aarch64-simd.md.
-    (UNSPEC_SSLI	 76) ; Used in aarch64-simd.md.
-    (UNSPEC_USLI	 77) ; Used in aarch64-simd.md.
-    (UNSPEC_SSRI	 78) ; Used in aarch64-simd.md.
-    (UNSPEC_USRI	 79) ; Used in aarch64-simd.md.
-    (UNSPEC_SSHLL	 80) ; Used in aarch64-simd.md.
-    (UNSPEC_USHLL	 81) ; Used in aarch64-simd.md.
-    (UNSPEC_ADDP	 82) ; Used in aarch64-simd.md.
-    (UNSPEC_CMTST	 83) ; Used in aarch64-simd.md.
-    (UNSPEC_FMAX	 83) ; Used in aarch64-simd.md.
-    (UNSPEC_FMIN	 84) ; Used in aarch64-simd.md.
-    (UNSPEC_CLS 	 85) ; Used in aarch64.md.
-    (UNSPEC_RBIT	 86) ; Used in aarch64.md.
-  ]
-)
-
-(define_constants
-  [
-    (UNSPECV_EH_RETURN  0)
-    (UNSPECV_SYNC_COMPARE_AND_SWAP 1)   ; Represent a sync_compare_and_swap.
-    (UNSPECV_SYNC_LOCK             2)	; Represent a sync_lock_test_and_set.
-    (UNSPECV_SYNC_LOCK_RELEASE     3)	; Represent a sync_lock_release.
-    (UNSPECV_SYNC_OP               4)	; Represent a sync_<op>
-    (UNSPECV_SYNC_NEW_OP           5)	; Represent a sync_new_<op>
-    (UNSPECV_SYNC_OLD_OP           6)	; Represent a sync_old_<op>
+(define_c_enum "unspec" [
+    UNSPEC_CASESI
+    UNSPEC_CLS
+    UNSPEC_FRINTA
+    UNSPEC_FRINTI
+    UNSPEC_FRINTM
+    UNSPEC_FRINTP
+    UNSPEC_FRINTX
+    UNSPEC_FRINTZ
+    UNSPEC_GOTSMALLPIC
+    UNSPEC_GOTSMALLTLS
+    UNSPEC_MB
+    UNSPEC_NOP
+    UNSPEC_PRLG_STK
+    UNSPEC_RBIT
+    UNSPEC_TLS
+    UNSPEC_TLSDESC
+])
+
+(define_c_enum "unspecv" [
+    UNSPECV_EH_RETURN		; Represent EH_RETURN
   ]
 )
 
diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index fc7fc50..9cecfca 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -139,6 +139,87 @@
 
 (define_mode_iterator TX [TI TF])
 
+;; ------------------------------------------------------------------
+;; Unspec enumerations for Advance SIMD. These could well go into
+;; aarch64.md but for their use in int_iterators here.
+;; ------------------------------------------------------------------
+
+(define_c_enum "unspec"
+ [
+    UNSPEC_ASHIFT_SIGNED	; Used in aarch-simd.md.
+    UNSPEC_ASHIFT_UNSIGNED	; Used in aarch64-simd.md.
+    UNSPEC_FMAXV	; Used in aarch64-simd.md.
+    UNSPEC_FMINV	; Used in aarch64-simd.md.
+    UNSPEC_FADDV	; Used in aarch64-simd.md.
+    UNSPEC_ADDV		; Used in aarch64-simd.md.
+    UNSPEC_SMAXV	; Used in aarch64-simd.md.
+    UNSPEC_SMINV	; Used in aarch64-simd.md.
+    UNSPEC_UMAXV	; Used in aarch64-simd.md.
+    UNSPEC_UMINV	; Used in aarch64-simd.md.
+    UNSPEC_SHADD	; Used in aarch64-simd.md.
+    UNSPEC_UHADD	; Used in aarch64-simd.md.
+    UNSPEC_SRHADD	; Used in aarch64-simd.md.
+    UNSPEC_URHADD	; Used in aarch64-simd.md.
+    UNSPEC_SHSUB	; Used in aarch64-simd.md.
+    UNSPEC_UHSUB	; Used in aarch64-simd.md.
+    UNSPEC_SRHSUB	; Used in aarch64-simd.md.
+    UNSPEC_URHSUB	; Used in aarch64-simd.md.
+    UNSPEC_ADDHN	; Used in aarch64-simd.md.
+    UNSPEC_RADDHN	; Used in aarch64-simd.md.
+    UNSPEC_SUBHN	; Used in aarch64-simd.md.
+    UNSPEC_RSUBHN	; Used in aarch64-simd.md.
+    UNSPEC_ADDHN2	; Used in aarch64-simd.md.
+    UNSPEC_RADDHN2	; Used in aarch64-simd.md.
+    UNSPEC_SUBHN2	; Used in aarch64-simd.md.
+    UNSPEC_RSUBHN2	; Used in aarch64-simd.md.
+    UNSPEC_SQDMULH	; Used in aarch64-simd.md.
+    UNSPEC_SQRDMULH	; Used in aarch64-simd.md.
+    UNSPEC_PMUL		; Used in aarch64-simd.md.
+    UNSPEC_USQADD	; Used in aarch64-simd.md.
+    UNSPEC_SUQADD	; Used in aarch64-simd.md.
+    UNSPEC_SQXTUN	; Used in aarch64-simd.md.
+    UNSPEC_SQXTN	; Used in aarch64-simd.md.
+    UNSPEC_UQXTN	; Used in aarch64-simd.md.
+    UNSPEC_SSRA		; Used in aarch64-simd.md.
+    UNSPEC_USRA		; Used in aarch64-simd.md.
+    UNSPEC_SRSRA	; Used in aarch64-simd.md.
+    UNSPEC_URSRA	; Used in aarch64-simd.md.
+    UNSPEC_SRSHR	; Used in aarch64-simd.md.
+    UNSPEC_URSHR	; Used in aarch64-simd.md.
+    UNSPEC_SQSHLU	; Used in aarch64-simd.md.
+    UNSPEC_SQSHL	; Used in aarch64-simd.md.
+    UNSPEC_UQSHL	; Used in aarch64-simd.md.
+    UNSPEC_SQSHRUN	; Used in aarch64-simd.md.
+    UNSPEC_SQRSHRUN	; Used in aarch64-simd.md.
+    UNSPEC_SQSHRN	; Used in aarch64-simd.md.
+    UNSPEC_UQSHRN	; Used in aarch64-simd.md.
+    UNSPEC_SQRSHRN	; Used in aarch64-simd.md.
+    UNSPEC_UQRSHRN	; Used in aarch64-simd.md.
+    UNSPEC_SSHL		; Used in aarch64-simd.md.
+    UNSPEC_USHL		; Used in aarch64-simd.md.
+    UNSPEC_SRSHL	; Used in aarch64-simd.md.
+    UNSPEC_URSHL	; Used in aarch64-simd.md.
+    UNSPEC_SQRSHL	; Used in aarch64-simd.md.
+    UNSPEC_UQRSHL	; Used in aarch64-simd.md.
+    UNSPEC_CMEQ		; Used in aarch64-simd.md.
+    UNSPEC_CMLE		; Used in aarch64-simd.md.
+    UNSPEC_CMLT		; Used in aarch64-simd.md.
+    UNSPEC_CMGE		; Used in aarch64-simd.md.
+    UNSPEC_CMGT		; Used in aarch64-simd.md.
+    UNSPEC_CMHS		; Used in aarch64-simd.md.
+    UNSPEC_CMHI		; Used in aarch64-simd.md.
+    UNSPEC_SSLI		; Used in aarch64-simd.md.
+    UNSPEC_USLI		; Used in aarch64-simd.md.
+    UNSPEC_SSRI		; Used in aarch64-simd.md.
+    UNSPEC_USRI		; Used in aarch64-simd.md.
+    UNSPEC_SSHLL	; Used in aarch64-simd.md.
+    UNSPEC_USHLL	; Used in aarch64-simd.md.
+    UNSPEC_ADDP		; Used in aarch64-simd.md.
+    UNSPEC_CMTST	; Used in aarch64-simd.md.
+    UNSPEC_FMAX		; Used in aarch64-simd.md.
+    UNSPEC_FMIN		; Used in aarch64-simd.md.
+])
+
 ;; -------------------------------------------------------------------
 ;; Mode attributes
 ;; -------------------------------------------------------------------
diff --git a/gcc/config/aarch64/sync.md b/gcc/config/aarch64/sync.md
index 94064b2..61f1f1b 100644
--- a/gcc/config/aarch64/sync.md
+++ b/gcc/config/aarch64/sync.md
@@ -18,10 +18,20 @@
 ;; along with GCC; see the file COPYING3.  If not see
 ;; <http://www.gnu.org/licenses/>.
 
+(define_c_enum "unspecv"
+ [
+    UNSPECV_SYNC_COMPARE_AND_SWAP       ; Represent a sync_compare_and_swap.
+    UNSPECV_SYNC_LOCK			; Represent a sync_lock_test_and_set.
+    UNSPECV_SYNC_LOCK_RELEASE		; Represent a sync_lock_release.
+    UNSPECV_SYNC_OP			; Represent a sync_<op>
+    UNSPECV_SYNC_NEW_OP			; Represent a sync_new_<op>
+    UNSPECV_SYNC_OLD_OP			; Represent a sync_old_<op>
+])
+
 (define_expand "sync_compare_and_swap<mode>"
   [(set (match_operand:ALLI 0 "register_operand")
         (unspec_volatile:ALLI [(match_operand:ALLI 1 "memory_operand")
-  			       (match_operand:ALLI 2 "register_operand")
+			       (match_operand:ALLI 2 "register_operand")
 			       (match_operand:ALLI 3 "register_operand")]
 			       UNSPECV_SYNC_COMPARE_AND_SWAP))]
   ""
-- 
1.7.12.rc0.22.gcdd159b
