Merge branch 'mesa_7_6_branch'
[mesa.git] / src / mesa / x86 / assyntax.h
index b9bb1f7ea08923ef7f97b9ae37b3bf88397616af..524944f73a4ef69bfc8cc39fa526fad6eafa4f7c 100644 (file)
@@ -1,4 +1,3 @@
-/* $Id: assyntax.h,v 1.16 2000/10/23 00:16:28 gareth Exp $ */
 
 #ifndef __ASSYNTAX_H__
 #define __ASSYNTAX_H__
 
 #if !(defined(NASM_ASSEMBLER) || defined(MASM_ASSEMBLER))
 
+/* Default to ATT_ASSEMBLER when SVR4 or SYSV are defined */
+#if (defined(SVR4) || defined(SYSV)) && !defined(GNU_ASSEMBLER)
+#define ATT_ASSEMBLER
+#endif
+
 #if !defined(ATT_ASSEMBLER) && !defined(GNU_ASSEMBLER) && !defined(ACK_ASSEMBLER)
 #define GNU_ASSEMBLER
 #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
 #define _STX6          %st(6)
 #define _STX7          %st(7)
 #define ST(x)          CONCAT(_STX,x)
+#ifdef GNU_ASSEMBLER
+#define ST0            %st(0)
+#else
+#define ST0            %st
+#endif
 /* MMX Registers */
 #define MM0            %mm0
 #define MM1            %mm1
 #endif /* ACK_ASSEMBLER */
 
 
-#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__)
+#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) || defined(__GNUC__) && !defined(__DJGPP__) && !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 ST(n)          st ## n
+#define ST0            st0
 
 #define TBYTE_PTR      tword
 #define QWORD_PTR      qword
@@ -953,11 +984,12 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #endif
 
 #if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \
- || (defined(linux) || defined(__OS2ELF__)) && defined(__ELF__) \
- || defined(__FreeBSD__) && __FreeBSD__ >= 3
+ || (defined(__linux__) || defined(__OS2ELF__)) && defined(__ELF__) \
+ || (defined(__FreeBSD__) && __FreeBSD__ >= 3) \
+ || (defined(__NetBSD__) && defined(__ELF__))
 #define GLNAME(a)      a
 #else
-#define GLNAME(a)      _ ## a
+#define GLNAME(a)      CONCAT(_, a)
 #endif
 
 /*
@@ -980,12 +1012,21 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define B_CONST(a)             a
 
 /* Indirect Mode */
+#ifdef NASM_ASSEMBLER
+#define P_CONTENT(a)           [a]
+#define X_CONTENT(a)           TBYTE_PTR [a]
+#define D_CONTENT(a)           QWORD_PTR [a]
+#define L_CONTENT(a)           DWORD_PTR [a]
+#define W_CONTENT(a)           WORD_PTR [a]
+#define B_CONTENT(a)           BYTE_PTR [a]
+#else
 #define P_CONTENT(a)           a
 #define X_CONTENT(a)           TBYTE_PTR a
 #define D_CONTENT(a)           QWORD_PTR a
 #define L_CONTENT(a)           DWORD_PTR a
 #define W_CONTENT(a)           WORD_PTR a
 #define B_CONTENT(a)           BYTE_PTR a
+#endif
 
 /* Register a indirect */
 #define P_REGIND(a)            [a]
@@ -1054,10 +1095,10 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define B_REGDB(d, b)          BYTE_PTR [b + d]
 
 /* Variable indirect: */
-#define VARINDIRECT(var)       var
+#define VARINDIRECT(var)       [var]
 
 /* Use register contents as jump/call target: */
-#define CODEPTR(reg)           reg
+#define CODEPTR(reg)           P_(reg)
 
 /*
  * Redefine assembler commands
@@ -1066,6 +1107,7 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define P_(a)                  P_ ## a
 #define X_(a)                  X_ ## a
 #define D_(a)                  D_ ## a
+#define SR_(a)                 W_ ## a
 #define S_(a)                  L_ ## a
 #define L_(a)                  L_ ## a
 #define W_(a)                  W_ ## a
@@ -1181,7 +1223,7 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define JS(a)                  js NEAR a
 #define JZ(a)                  jz NEAR a
 #define JMP(a)                 jmp a
-#define JMPF(s,a)              jmpf
+#define JMPF(s,a)              jmp far s:a
 #define LAHF                   lahf
 #define LAR(a, b)              lar b, a
 #define LEA_L(a, b)            lea P_(b), P_(a)
@@ -1189,11 +1231,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
@@ -1207,7 +1249,7 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define LOOPNZ(a)              loopnz a
 #define LSL(a, b)              lsl b, a
 #define LTR(a)                 ltr a
-#define MOV_SR(a, b)           mov S_(b), S_(a)
+#define MOV_SR(a, b)           mov SR_(b), SR_(a)
 #define MOV_L(a, b)            mov L_(b), L_(a)
 #define MOV_W(a, b)            mov W_(b), W_(a)
 #define MOV_B(a, b)            mov B_(b), B_(a)
@@ -1242,14 +1284,14 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define OUTS_L                 outsd
 #define OUTS_W                 outsw
 #define OUTS_B                 outsb
-#define POP_SR(a)              pop S_(a)
+#define POP_SR(a)              pop SR_(a)
 #define POP_L(a)               pop L_(a)
 #define POP_W(a)               pop W_(a)
 #define POPA_L                 popad
 #define POPA_W                 popa
 #define POPF_L                 popfd
 #define POPF_W                 popf
-#define PUSH_SR(a)             push S_(a)
+#define PUSH_SR(a)             push SR_(a)
 #define PUSH_L(a)              push L_(a)
 #define PUSH_W(a)              push W_(a)
 #define PUSH_B(a)              push B_(a)
@@ -1277,11 +1319,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)
@@ -1321,15 +1363,15 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define SETZ(a)                        setz a
 #define SGDT(a)                        sgdt a
 #define SIDT(a)                        sidt a
-#define SHL_L(a, b)            shl L_(b), L_(a)
-#define SHL_W(a, b)            shl W_(b), W_(a)
+#define SHL_L(a, b)            shl L_(b), B_(a)
+#define SHL_W(a, b)            shl W_(b), B_(a)
 #define SHL_B(a, b)            shl B_(b), B_(a)
 #define SHLD_L(a,b,c)          shld
 #define SHLD2_L(a,b)           shld L_(b), L_(a)
 #define SHLD_W(a,b,c)          shld
 #define SHLD2_W(a,b)           shld W_(b), W_(a)
-#define SHR_L(a, b)            shr L_(b), L_(a)
-#define SHR_W(a, b)            shr W_(b), W_(a)
+#define SHR_L(a, b)            shr L_(b), B_(a)
+#define SHR_W(a, b)            shr W_(b), B_(a)
 #define SHR_B(a, b)            shr B_(b), B_(a)
 #define SHRD_L(a,b,c)          shrd
 #define SHRD2_L(a,b)           shrd L_(b), L_(a)
@@ -1340,9 +1382,9 @@ SECTION _DATA public align=16 class=DATA use32 flat
 #define STC                    stc
 #define STD                    std
 #define STI                    sti
-#define STOS_L                 stos
-#define STOS_W                 stos
-#define STOS_B                 stos
+#define STOS_L                 stosd
+#define STOS_W                 stosw
+#define STOS_B                 stosb
 #define STR(a)                 str a
 #define SUB_L(a, b)            sub L_(b), L_(a)
 #define SUB_W(a, b)            sub W_(b), W_(a)
@@ -1669,9 +1711,37 @@ 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 */
+#define SEGCS          D_BYTE  46
+#define SEGDS          D_BYTE  62
+#define SEGES          D_BYTE  38
+#define SEGFS          D_BYTE  100
+#define SEGGS          D_BYTE  101
+
+/* Temporary labels: valid until next non-local label */
+#ifdef NASM_ASSEMBLER
+#define TLBL(a)                CONCAT(.,a)
+#else
+#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(__DJGPP__) && !defined(__MINGW32__)
+#  define HIDDEN(x) .hidden x
+#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 && !defined(__DJGPP__) && !defined(__MINGW32__)
+#  pragma GCC visibility push(default)
+#  define HIDDEN(x) .hidden x
+#else
+#  define HIDDEN(x)
+#endif
 
 #endif /* __ASSYNTAX_H__ */