intel/disasm: brw_label and support functions
[mesa.git] / src / mesa / x86 / assyntax.h
index ebe9c57460d415fa08ea0e48b8a44ed19e71cdeb..f269cb45ce7a43042aa2f06f7bc83b3b505aa309 100644 (file)
 #endif
 
 #if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__))
-#define CONCAT(x, y)   x ## y
+#define CONCAT(x, y)           x ## y
+#define CONCAT3(x, y, z)       x ## y ## z
 #else
-#define CONCAT(x, y)   x/**/y
+#define CONCAT(x, y)           x/**/y
+#define CONCAT3(x, y, z)       x/**/y/**/z
 #endif
 
 #ifdef ACK_ASSEMBLER
 #endif /* ACK_ASSEMBLER */
 
 
-#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) || defined(__GNUC__) && !defined(__DJGPP__) && !defined(__MINGW32__)
+#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) || defined(__GNUC__) && !defined(__MINGW32__)
 #define GLNAME(a)      a
 #else
 #define GLNAME(a)      CONCAT(_,a)
 #define GLOBL          CHOICE(.globl, .globl, .extern)
 #define GLOBAL         GLOBL
 #define EXTERN         GLOBL
-/*
-#define ALIGNTEXT32    CHOICE(.align 32, .align ARG2(5,0x90), .align 32)
-*/
+#ifndef __AOUT__
 #define ALIGNTEXT32    CHOICE(.align 32, .balign 32, .align 32)
 #define ALIGNTEXT16    CHOICE(.align 16, .balign 16, .align 16)
 #define ALIGNTEXT8     CHOICE(.align 8, .balign 8, .align 8)
 #define ALIGNDATA8     CHOICE(.align 8, .balign ARG2(8,0x0), .align 8)
 #define ALIGNDATA4     CHOICE(.align 4, .balign ARG2(4,0x0), .align 4)
 #define ALIGNDATA2     CHOICE(.align 2, .balign ARG2(2,0x0), .align 2)
+#else
+/* 'as -aout' on FreeBSD doesn't have .balign */
+#define ALIGNTEXT32    CHOICE(.align 32, .align ARG2(5,0x90), .align 32)
+#define ALIGNTEXT16    CHOICE(.align 16, .align ARG2(4,0x90), .align 16)
+#define ALIGNTEXT8     CHOICE(.align 8, .align ARG2(3,0x90), .align 8)
+#define ALIGNTEXT4     CHOICE(.align 4, .align ARG2(2,0x90), .align 4)
+#define ALIGNTEXT2     CHOICE(.align 2, .align ARG2(1,0x90), .align 2)
+/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
+ * guaranteed to be filled with NOPs.  Otherwise it does nothing.
+ */
+#define ALIGNTEXT32ifNOP       CHOICE(.align 32, .align ARG2(5,0x90), /*can't do it*/)
+#define ALIGNTEXT16ifNOP       CHOICE(.align 16, .align ARG2(4,0x90), /*can't do it*/)
+#define ALIGNTEXT8ifNOP        CHOICE(.align 8, .align ARG2(3,0x90), /*can't do it*/)
+#define ALIGNTEXT4ifNOP        CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/)
+#define ALIGNDATA32    CHOICE(.align 32, .align ARG2(5,0x0), .align 32)
+#define ALIGNDATA16    CHOICE(.align 16, .align ARG2(4,0x0), .align 16)
+#define ALIGNDATA8     CHOICE(.align 8, .align ARG2(3,0x0), .align 8)
+#define ALIGNDATA4     CHOICE(.align 4, .align ARG2(2,0x0), .align 4)
+#define ALIGNDATA2     CHOICE(.align 2, .align ARG2(1,0x0), .align 2)
+#endif /* __AOUT__ */
 #define FILE(s)                CHOICE(.file s, .file s, .file s)
 #define STRING(s)      CHOICE(.string s, .asciz s, .asciz s)
 #define D_LONG         CHOICE(.long, .long, .data4)
 
 /* Addressing Modes */
 /* Immediate Mode */
-#define ADDR(a)                CHOICE(CONCAT($,a), CONCAT($,a), a)
-#define CONST(a)       CHOICE(CONCAT($,a), CONCAT($,a), a)
+#define ADDR(a)                CHOICE(CONCAT($,a), $a, a)
+#define CONST(a)       CHOICE(CONCAT($,a), $a, a)
 
 /* Indirect Mode */
 #define CONTENT(a)     CHOICE(a, a, (a))        /* take contents of variable */
 #define P_XMM6         xmm6
 #define P_XMM7         xmm7
 
-#define CONCAT(x, y)   x ## y
+#define CONCAT(x, y)           x ## y
+#define CONCAT3(x, y, z)       x ## y ## z
 
 #if defined(NASM_ASSEMBLER)
 
 #define D_BYTE         db
 /* #define SPACE */
 /* #define COMM */
-#if defined(__WATCOMC__)
-SECTION _TEXT public align=16 class=CODE use32 flat
-SECTION _DATA public align=16 class=DATA use32 flat
-#define SEG_TEXT       SECTION _TEXT
-#define SEG_DATA       SECTION _DATA
-#define SEG_BSS                SECTION .bss
-#else
 #define SEG_DATA       SECTION .data
 #define SEG_TEXT       SECTION .text
 #define SEG_BSS                SECTION .bss
-#endif
 
 #define D_SPACE(n)     db n REP 0
 
@@ -964,7 +977,8 @@ SECTION _DATA public align=16 class=DATA use32 flat
 
 #if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \
  || (defined(__linux__) || defined(__OS2ELF__)) && defined(__ELF__) \
- || defined(__FreeBSD__) && __FreeBSD__ >= 3
+ || (defined(__FreeBSD__) && __FreeBSD__ >= 3) \
+ || (defined(__NetBSD__) && defined(__ELF__))
 #define GLNAME(a)      a
 #else
 #define GLNAME(a)      CONCAT(_, a)
@@ -1209,11 +1223,11 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define LEAVE                  leave
 #define LGDT(a)                        lgdt a
 #define LIDT(a)                        lidt a
-#define LDS(a, b)              lds b, a
-#define LES(a, b)              les b, a
-#define LFS(a, b)              lfs b, a
-#define LGS(a, b)              lgs b, a
-#define LSS(a, b)              lss b, a
+#define LDS(a, b)              lds b, P_(a)
+#define LES(a, b)              les b, P_(a)
+#define LFS(a, b)              lfs b, P_(a)
+#define LGS(a, b)              lgs b, P_(a)
+#define LSS(a, b)              lss b, P_(a)
 #define LLDT(a)                        lldt a
 #define LMSW(a)                        lmsw a
 #define LOCK                   lock
@@ -1297,11 +1311,11 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define REPZ                   REPE
 #define RET                    ret
 #define SAHF                   sahf
-#define SAL_L(a, b)            sal L_(b), L_(a)
-#define SAL_W(a, b)            sal W_(b), W_(a)
+#define SAL_L(a, b)            sal L_(b), B_(a)
+#define SAL_W(a, b)            sal W_(b), B_(a)
 #define SAL_B(a, b)            sal B_(b), B_(a)
-#define SAR_L(a, b)            sar L_(b), L_(a)
-#define SAR_W(a, b)            sar W_(b), W_(a)
+#define SAR_L(a, b)            sar L_(b), B_(a)
+#define SAR_W(a, b)            sar W_(b), B_(a)
 #define SAR_B(a, b)            sar B_(b), B_(a)
 #define SBB_L(a, b)            sbb L_(b), L_(a)
 #define SBB_W(a, b)            sbb W_(b), W_(a)
@@ -1689,8 +1703,10 @@ SECTION _DATA public align=16 class=DATA use32 flat
 /* Added by BrianP for FreeBSD (per David Dawes) */
 #if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER) && !defined(__bsdi__)
 #define LLBL(a)                CONCAT(.L,a)
+#define LLBL2(a,b)     CONCAT3(.L,a,b)
 #else
 #define LLBL(a)                a
+#define LLBL2(a,b)     CONCAT(a,b)
 #endif
 
 /* Segment overrides */
@@ -1707,4 +1723,24 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define TLBL(a)                CONCAT(a,$)
 #endif
 
+/* Hidden symbol visibility support.
+ * If we build with gcc's -fvisibility=hidden flag, we'll need to change
+ * the symbol visibility mode to 'default'.
+ */
+#if defined(GNU_ASSEMBLER) && !defined(__MINGW32__) && !defined(__APPLE__)
+#  define HIDDEN(x) .hidden x
+#elif defined(__GNUC__) && !defined(__MINGW32__) && !defined(__APPLE__)
+#  pragma GCC visibility push(default)
+#  define HIDDEN(x) .hidden x
+#else
+#  define HIDDEN(x)
+#endif
+
+/* Control flow enforcement support */
+#ifdef HAVE_CET_H
+#include <cet.h>
+#else
+#define _CET_ENDBR
+#endif
+
 #endif /* __ASSYNTAX_H__ */