Patchwork [i386] : Introduce define_c_enum

login
register
mail settings
Submitter Uros Bizjak
Date June 11, 2010, 7 p.m.
Message ID <1276282843.2505.12.camel@localhost>
Download mbox | patch
Permalink /patch/55347/
State New
Headers show

Comments

Uros Bizjak - June 11, 2010, 7 p.m.
Hello!

Attached mechanical patch converts UNSPEC_* to unspec define_c_enum and
UNSPECV_* to unspecv define_c_enum, following example in mips/mips.md

2010-06-11  Uros Bizjak  <ubizjak@gmail.com>

	* config/i386/i386.md (unspec): New define_c_enum.
	(unspecv): Ditto.

Patch was tested on x86_64-pc-linux-gnu {,-m32}. I have also checked
that dumps now print unspec names instead of numerical constants (which
is a great improvement for anybody looking at the dumps, IMO).

Uros.

Patch

Index: i386.md
===================================================================
--- i386.md	(revision 160626)
+++ i386.md	(working copy)
@@ -62,198 +62,198 @@ 
 
 ;; UNSPEC usage:
 
-(define_constants
-  [; Relocation specifiers
-   (UNSPEC_GOT			0)
-   (UNSPEC_GOTOFF		1)
-   (UNSPEC_GOTPCREL		2)
-   (UNSPEC_GOTTPOFF		3)
-   (UNSPEC_TPOFF		4)
-   (UNSPEC_NTPOFF		5)
-   (UNSPEC_DTPOFF		6)
-   (UNSPEC_GOTNTPOFF		7)
-   (UNSPEC_INDNTPOFF		8)
-   (UNSPEC_PLTOFF		9)
-   (UNSPEC_MACHOPIC_OFFSET	10)
+(define_c_enum "unspec" [
+  ;; Relocation specifiers
+  UNSPEC_GOT
+  UNSPEC_GOTOFF
+  UNSPEC_GOTPCREL
+  UNSPEC_GOTTPOFF
+  UNSPEC_TPOFF
+  UNSPEC_NTPOFF
+  UNSPEC_DTPOFF
+  UNSPEC_GOTNTPOFF
+  UNSPEC_INDNTPOFF
+  UNSPEC_PLTOFF
+  UNSPEC_MACHOPIC_OFFSET
 
-   ; Prologue support
-   (UNSPEC_STACK_ALLOC		11)
-   (UNSPEC_SET_GOT		12)
-   (UNSPEC_SSE_PROLOGUE_SAVE	13)
-   (UNSPEC_REG_SAVE		14)
-   (UNSPEC_DEF_CFA		15)
-   (UNSPEC_SET_RIP		16)
-   (UNSPEC_SET_GOT_OFFSET	17)
-   (UNSPEC_MEMORY_BLOCKAGE	18)
-   (UNSPEC_SSE_PROLOGUE_SAVE_LOW 19)
+  ;; Prologue support
+  UNSPEC_STACK_ALLOC
+  UNSPEC_SET_GOT
+  UNSPEC_SSE_PROLOGUE_SAVE
+  UNSPEC_REG_SAVE
+  UNSPEC_DEF_CFA
+  UNSPEC_SET_RIP
+  UNSPEC_SET_GOT_OFFSET
+  UNSPEC_MEMORY_BLOCKAGE
+  UNSPEC_SSE_PROLOGUE_SAVE_LOW
 
-   ; TLS support
-   (UNSPEC_TP			20)
-   (UNSPEC_TLS_GD		21)
-   (UNSPEC_TLS_LD_BASE		22)
-   (UNSPEC_TLSDESC		23)
+  ;; TLS support
+  UNSPEC_TP
+  UNSPEC_TLS_GD
+  UNSPEC_TLS_LD_BASE
+  UNSPEC_TLSDESC
 
-   ; Other random patterns
-   (UNSPEC_SCAS			30)
-   (UNSPEC_FNSTSW		31)
-   (UNSPEC_SAHF			32)
-   (UNSPEC_FSTCW		33)
-   (UNSPEC_ADD_CARRY		34)
-   (UNSPEC_FLDCW		35)
-   (UNSPEC_REP			36)
-   (UNSPEC_LD_MPIC		38)	; load_macho_picbase
-   (UNSPEC_TRUNC_NOOP		39)
+  ;; Other random patterns
+  UNSPEC_SCAS
+  UNSPEC_FNSTSW
+  UNSPEC_SAHF
+  UNSPEC_FSTCW
+  UNSPEC_ADD_CARRY
+  UNSPEC_FLDCW
+  UNSPEC_REP
+  UNSPEC_LD_MPIC	; load_macho_picbase
+  UNSPEC_TRUNC_NOOP
 
-   ; For SSE/MMX support:
-   (UNSPEC_FIX_NOTRUNC		40)
-   (UNSPEC_MASKMOV		41)
-   (UNSPEC_MOVMSK		42)
-   (UNSPEC_MOVNT		43)
-   (UNSPEC_MOVU			44)
-   (UNSPEC_RCP			45)
-   (UNSPEC_RSQRT		46)
-   (UNSPEC_SFENCE		47)
-   (UNSPEC_PFRCP		49)
-   (UNSPEC_PFRCPIT1		40)
-   (UNSPEC_PFRCPIT2		41)
-   (UNSPEC_PFRSQRT		42)
-   (UNSPEC_PFRSQIT1		43)
-   (UNSPEC_MFENCE		44)
-   (UNSPEC_LFENCE		45)
-   (UNSPEC_PSADBW		46)
-   (UNSPEC_LDDQU		47)
-   (UNSPEC_MS_TO_SYSV_CALL	48)
+  ;; For SSE/MMX support:
+  UNSPEC_FIX_NOTRUNC
+  UNSPEC_MASKMOV
+  UNSPEC_MOVMSK
+  UNSPEC_MOVNT
+  UNSPEC_MOVU
+  UNSPEC_RCP
+  UNSPEC_RSQRT
+  UNSPEC_SFENCE
+  UNSPEC_PFRCP
+  UNSPEC_PFRCPIT1
+  UNSPEC_PFRCPIT2
+  UNSPEC_PFRSQRT
+  UNSPEC_PFRSQIT1
+  UNSPEC_MFENCE
+  UNSPEC_LFENCE
+  UNSPEC_PSADBW
+  UNSPEC_LDDQU
+  UNSPEC_MS_TO_SYSV_CALL
 
-   ; Generic math support
-   (UNSPEC_COPYSIGN		50)
-   (UNSPEC_IEEE_MIN		51)	; not commutative
-   (UNSPEC_IEEE_MAX		52)	; not commutative
+  ;; Generic math support
+  UNSPEC_COPYSIGN
+  UNSPEC_IEEE_MIN	; not commutative
+  UNSPEC_IEEE_MAX	; not commutative
 
-   ; x87 Floating point
-   (UNSPEC_SIN			60)
-   (UNSPEC_COS			61)
-   (UNSPEC_FPATAN		62)
-   (UNSPEC_FYL2X		63)
-   (UNSPEC_FYL2XP1		64)
-   (UNSPEC_FRNDINT		65)
-   (UNSPEC_FIST			66)
-   (UNSPEC_F2XM1		67)
-   (UNSPEC_TAN			68)
-   (UNSPEC_FXAM			69)
+  ;; x87 Floating point
+  UNSPEC_SIN
+  UNSPEC_COS
+  UNSPEC_FPATAN
+  UNSPEC_FYL2X
+  UNSPEC_FYL2XP1
+  UNSPEC_FRNDINT
+  UNSPEC_FIST
+  UNSPEC_F2XM1
+  UNSPEC_TAN
+  UNSPEC_FXAM
 
-   ; x87 Rounding
-   (UNSPEC_FRNDINT_FLOOR	70)
-   (UNSPEC_FRNDINT_CEIL 	71)
-   (UNSPEC_FRNDINT_TRUNC	72)
-   (UNSPEC_FRNDINT_MASK_PM	73)
-   (UNSPEC_FIST_FLOOR		74)
-   (UNSPEC_FIST_CEIL 		75)
+  ;; x87 Rounding
+  UNSPEC_FRNDINT_FLOOR
+  UNSPEC_FRNDINT_CEIL
+  UNSPEC_FRNDINT_TRUNC
+  UNSPEC_FRNDINT_MASK_PM
+  UNSPEC_FIST_FLOOR
+  UNSPEC_FIST_CEIL
 
-   ; x87 Double output FP
-   (UNSPEC_SINCOS_COS		80)
-   (UNSPEC_SINCOS_SIN		81)
-   (UNSPEC_XTRACT_FRACT		84)
-   (UNSPEC_XTRACT_EXP		85)
-   (UNSPEC_FSCALE_FRACT		86)
-   (UNSPEC_FSCALE_EXP		87)
-   (UNSPEC_FPREM_F		88)
-   (UNSPEC_FPREM_U		89)
-   (UNSPEC_FPREM1_F		90)
-   (UNSPEC_FPREM1_U		91)
+  ;; x87 Double output FP
+  UNSPEC_SINCOS_COS
+  UNSPEC_SINCOS_SIN
+  UNSPEC_XTRACT_FRACT
+  UNSPEC_XTRACT_EXP
+  UNSPEC_FSCALE_FRACT
+  UNSPEC_FSCALE_EXP
+  UNSPEC_FPREM_F
+  UNSPEC_FPREM_U
+  UNSPEC_FPREM1_F
+  UNSPEC_FPREM1_U
 
-   (UNSPEC_C2_FLAG		95)
-   (UNSPEC_FXAM_MEM		96)
+  UNSPEC_C2_FLAG
+  UNSPEC_FXAM_MEM
 
-   ; SSP patterns
-   (UNSPEC_SP_SET		100)
-   (UNSPEC_SP_TEST		101)
-   (UNSPEC_SP_TLS_SET		102)
-   (UNSPEC_SP_TLS_TEST		103)
+  ;; SSP patterns
+  UNSPEC_SP_SET
+  UNSPEC_SP_TEST
+  UNSPEC_SP_TLS_SET
+  UNSPEC_SP_TLS_TEST
 
-   ; SSSE3
-   (UNSPEC_PSHUFB		120)
-   (UNSPEC_PSIGN		121)
-   (UNSPEC_PALIGNR		122)
+  ;; SSSE3
+  UNSPEC_PSHUFB
+  UNSPEC_PSIGN
+  UNSPEC_PALIGNR
 
-   ; For SSE4A support
-   (UNSPEC_EXTRQI               130)
-   (UNSPEC_EXTRQ                131)
-   (UNSPEC_INSERTQI             132)
-   (UNSPEC_INSERTQ              133)
+  ;; For SSE4A support
+  UNSPEC_EXTRQI
+  UNSPEC_EXTRQ
+  UNSPEC_INSERTQI
+  UNSPEC_INSERTQ
 
-   ; For SSE4.1 support
-   (UNSPEC_BLENDV		134)
-   (UNSPEC_INSERTPS		135)
-   (UNSPEC_DP			136)
-   (UNSPEC_MOVNTDQA		137)
-   (UNSPEC_MPSADBW		138)
-   (UNSPEC_PHMINPOSUW		139)
-   (UNSPEC_PTEST		140)
-   (UNSPEC_ROUND		141)
+  ;; For SSE4.1 support
+  UNSPEC_BLENDV
+  UNSPEC_INSERTPS
+  UNSPEC_DP
+  UNSPEC_MOVNTDQA
+  UNSPEC_MPSADBW
+  UNSPEC_PHMINPOSUW
+  UNSPEC_PTEST
+  UNSPEC_ROUND
 
-   ; For SSE4.2 support
-   (UNSPEC_CRC32		143)
-   (UNSPEC_PCMPESTR		144)
-   (UNSPEC_PCMPISTR		145)
+  ;; For SSE4.2 support
+  UNSPEC_CRC32
+  UNSPEC_PCMPESTR
+  UNSPEC_PCMPISTR
 
-   ; For FMA4 support
-   (UNSPEC_FMA4_INTRINSIC	150)
-   (UNSPEC_FMA4_FMADDSUB	151)
-   (UNSPEC_FMA4_FMSUBADD	152)
-   (UNSPEC_XOP_UNSIGNED_CMP	151)
-   (UNSPEC_XOP_TRUEFALSE	152)
-   (UNSPEC_XOP_PERMUTE		153)
-   (UNSPEC_FRCZ			154)
+  ;; For FMA4 support
+  UNSPEC_FMA4_INTRINSIC
+  UNSPEC_FMA4_FMADDSUB
+  UNSPEC_FMA4_FMSUBADD
+  UNSPEC_XOP_UNSIGNED_CMP
+  UNSPEC_XOP_TRUEFALSE
+  UNSPEC_XOP_PERMUTE
+  UNSPEC_FRCZ
 
-   ; For AES support
-   (UNSPEC_AESENC		159)
-   (UNSPEC_AESENCLAST		160)
-   (UNSPEC_AESDEC		161)
-   (UNSPEC_AESDECLAST		162)
-   (UNSPEC_AESIMC		163)
-   (UNSPEC_AESKEYGENASSIST	164)
+  ;; For AES support
+  UNSPEC_AESENC
+  UNSPEC_AESENCLAST
+  UNSPEC_AESDEC
+  UNSPEC_AESDECLAST
+  UNSPEC_AESIMC
+  UNSPEC_AESKEYGENASSIST
 
-   ; For PCLMUL support
-   (UNSPEC_PCLMUL		165)
+  ;; For PCLMUL support
+  UNSPEC_PCLMUL
 
-   ; For AVX support
-   (UNSPEC_PCMP			166)
-   (UNSPEC_VPERMIL		167)
-   (UNSPEC_VPERMIL2		168)
-   (UNSPEC_VPERMIL2F128		169)
-   (UNSPEC_MASKLOAD		170)
-   (UNSPEC_MASKSTORE		171)
-   (UNSPEC_CAST			172)
-   (UNSPEC_VTESTP		173)
-  ])
+  ;; For AVX support
+  UNSPEC_PCMP
+  UNSPEC_VPERMIL
+  UNSPEC_VPERMIL2
+  UNSPEC_VPERMIL2F128
+  UNSPEC_MASKLOAD
+  UNSPEC_MASKSTORE
+  UNSPEC_CAST
+  UNSPEC_VTESTP
+])
 
-(define_constants
-  [(UNSPECV_BLOCKAGE		0)
-   (UNSPECV_STACK_PROBE		1)
-   (UNSPECV_EMMS		2)
-   (UNSPECV_LDMXCSR		3)
-   (UNSPECV_STMXCSR		4)
-   (UNSPECV_FEMMS		5)
-   (UNSPECV_CLFLUSH		6)
-   (UNSPECV_ALIGN		7)
-   (UNSPECV_MONITOR		8)
-   (UNSPECV_MWAIT		9)
-   (UNSPECV_CMPXCHG		10)
-   (UNSPECV_XCHG		12)
-   (UNSPECV_LOCK		13)
-   (UNSPECV_PROLOGUE_USE	14)
-   (UNSPECV_CLD			15)
-   (UNSPECV_VZEROALL		16)
-   (UNSPECV_VZEROUPPER		17)
-   (UNSPECV_RDTSC		18)
-   (UNSPECV_RDTSCP		19)
-   (UNSPECV_RDPMC		20)
-   (UNSPECV_VSWAPMOV		21)
-   (UNSPECV_LLWP_INTRINSIC	22)
-   (UNSPECV_SLWP_INTRINSIC	23)
-   (UNSPECV_LWPVAL_INTRINSIC	24)
-   (UNSPECV_LWPINS_INTRINSIC	25)
-  ])
+(define_c_enum "unspecv" [
+  UNSPECV_BLOCKAGE
+  UNSPECV_STACK_PROBE
+  UNSPECV_EMMS
+  UNSPECV_LDMXCSR
+  UNSPECV_STMXCSR
+  UNSPECV_FEMMS
+  UNSPECV_CLFLUSH
+  UNSPECV_ALIGN
+  UNSPECV_MONITOR
+  UNSPECV_MWAIT
+  UNSPECV_CMPXCHG
+  UNSPECV_XCHG
+  UNSPECV_LOCK
+  UNSPECV_PROLOGUE_USE
+  UNSPECV_CLD
+  UNSPECV_VZEROALL
+  UNSPECV_VZEROUPPER
+  UNSPECV_RDTSC
+  UNSPECV_RDTSCP
+  UNSPECV_RDPMC
+  UNSPECV_VSWAPMOV
+  UNSPECV_LLWP_INTRINSIC
+  UNSPECV_SLWP_INTRINSIC
+  UNSPECV_LWPVAL_INTRINSIC
+  UNSPECV_LWPINS_INTRINSIC
+])
 
 ;; Constants to represent pcomtrue/pcomfalse variants
 (define_constants