]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
Test for gmqcc in check-proj
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 2ab3a00e5cc940ff97229e47bc5f161625974c0d..d8ad37465ef0525ea2298a9eb484f7a6e9220f04 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -35,7 +35,7 @@
 #endif /*! _MSC_VER */
 
 #define GMQCC_VERSION_MAJOR 0
-#define GMQCC_VERSION_MINOR 3
+#define GMQCC_VERSION_MINOR 4
 #define GMQCC_VERSION_PATCH 0
 #define GMQCC_VERSION_BUILD(J,N,P) (((J)<<16)|((N)<<8)|(P))
 #define GMQCC_VERSION \
@@ -149,6 +149,16 @@ GMQCC_IND_STRING(GMQCC_VERSION_PATCH) \
 #    define GMQCC_NORETURN
 #endif /*! (defined(__GNUC__) && __GNUC__ >= 2) || defined (__CLANG__) */
 
+#if (defined(__GNUC__)) || defined(__CLANG__)
+#   define GMQCC_LIKELY(X)   __builtin_expect((X), 1)
+#   define GMQCC_UNLIKELY(X) __builtin_expect((X), 0)
+#else
+#   define GMQCC_LIKELY(X)   (X)
+#   define GMQCC_UNLIKELY(X) (X)
+#endif
+
+#define GMQCC_ARRAY_COUNT(X) (sizeof(X) / sizeof((X)[0]))
+
 #ifndef _MSC_VER
 #   include <stdint.h>
 #else
@@ -322,11 +332,11 @@ void *stat_mem_allocate  (size_t, size_t, const char *);
 bool  util_filexists     (const char *);
 bool  util_strupper      (const char *);
 bool  util_strdigit      (const char *);
-void  util_debug         (const char *, const char *, ...);
 void  util_endianswap    (void *,  size_t, unsigned int);
 
-size_t util_strtocmd    (const char *, char *, size_t);
-size_t util_strtononcmd (const char *, char *, size_t);
+size_t util_strtocmd         (const char *, char *, size_t);
+size_t util_strtononcmd      (const char *, char *, size_t);
+size_t util_optimizationtostr(const char *, char *, size_t);
 
 uint16_t util_crc16(uint16_t crc, const char *data, size_t len);
 
@@ -379,7 +389,6 @@ void _util_vec_grow(void **a, size_t i, size_t s);
 #define vec_shrinkto(A,N) ((void)(vec_meta(A)->used  = (N)))
 #define vec_shrinkby(A,N) ((void)(vec_meta(A)->used -= (N)))
 #define vec_append(A,N,S) ((void)(memcpy(vec_add((A), (N)), (S), (N) * sizeof(*(S)))))
-#define vec_upload(X,Y,S) ((void)(memcpy(vec_add((X), (S) * sizeof(*(Y))), (Y), (S) * sizeof(*(Y)))))
 #define vec_remove(A,I,N) ((void)(memmove((A)+(I),(A)+((I)+(N)),sizeof(*(A))*(vec_meta(A)->used-(I)-(N))),vec_meta(A)->used-=(N)))
 
 typedef struct correct_trie_s {
@@ -707,19 +716,31 @@ enum {
      * Creating this causes IR blocks to be marked as 'final'.
      * No-Return-Call
      */
-    VINSTR_NRCALL
+    VINSTR_NRCALL,
+
+    /* Emulated instructions. */
+    VINSTR_BITAND_V, /* BITAND_V must be the first emulated bitop */
+    VINSTR_BITAND_VF,
+    VINSTR_BITOR_V,
+    VINSTR_BITOR_VF,
+    VINSTR_BITXOR,
+    VINSTR_BITXOR_V,
+    VINSTR_BITXOR_VF,
+    VINSTR_CROSS
 };
 
 /* TODO: elide */
 extern const char *util_instr_str[VINSTR_END];
 
-/* TOO: _t */
-typedef float   qcfloat_t;
-typedef int32_t qcint_t;
+
+typedef float    qcfloat_t;
+typedef int32_t  qcint_t;
+typedef uint32_t qcuint_t;
 
 typedef struct {
     prog_section_statement_t *statements;
     int                      *linenums;
+    int                      *columnnums;
     prog_section_def_t       *defs;
     prog_section_field_t     *fields;
     prog_section_function_t  *functions;
@@ -728,9 +749,19 @@ typedef struct {
     uint16_t                  crc;
     uint32_t                  entfields;
     ht                        string_cache;
-    qcint_t                     string_cached_empty;
+    qcint_t                   string_cached_empty;
 } code_t;
 
+/*
+ * A shallow copy of a lex_file to remember where which ast node
+ * came from.
+ */
+typedef struct {
+    const char *file;
+    size_t      line;
+    size_t      column;
+} lex_ctx_t;
+
 /*
  * code_write          -- writes out the compiled file
  * code_init           -- prepares the code file
@@ -744,19 +775,10 @@ GMQCC_WARN
 code_t   *code_init          (void);
 void      code_cleanup       (code_t *);
 uint32_t  code_genstring     (code_t *, const char *string);
-qcint_t     code_alloc_field   (code_t *, size_t qcsize);
-void      code_push_statement(code_t *, prog_section_statement_t *stmt, int linenum);
+qcint_t   code_alloc_field   (code_t *, size_t qcsize);
+void      code_push_statement(code_t *, prog_section_statement_t *stmt, lex_ctx_t ctx);
 void      code_pop_statement (code_t *);
 
-/*
- * A shallow copy of a lex_file to remember where which ast node
- * came from.
- */
-typedef struct {
-    const char *file;
-    size_t      line;
-    size_t      column;
-} lex_ctx_t;
 
 /*===================================================================*/
 /*============================ con.c ================================*/
@@ -824,11 +846,6 @@ typedef struct {
     qcfloat_t x, y, z;
 } vec3_t;
 
-vec3_t  vec3_add  (vec3_t, vec3_t);
-vec3_t  vec3_sub  (vec3_t, vec3_t);
-qcfloat_t vec3_mulvv(vec3_t, vec3_t);
-vec3_t  vec3_mulvf(vec3_t, float);
-
 /*===================================================================*/
 /*============================= exec.c ==============================*/
 /*===================================================================*/