]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - gmqcc.h
ir_block_create_{phi,call} now check self->final
[xonotic/gmqcc.git] / gmqcc.h
diff --git a/gmqcc.h b/gmqcc.h
index 34367b876be8dde29d80a94dfeb4c6f1be49d23a..b1e0cdef1709ca37e977e8f4a152f8f7ea0d6f98 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
  * I suspect it also has just __inline of some sort, but our use
  * of inline is correct (not guessed), WE WANT IT TO BE INLINE
  */
-#elseif defined(_MSC_VER)
+#elif defined(_MSC_VER)
 #    define GMQCC_INLINE __forceinline
 #else
 #    define GMQCC_INLINE
@@ -546,7 +546,12 @@ enum {
      */
     VINSTR_PHI,
     VINSTR_JUMP,
-    VINSTR_COND
+    VINSTR_COND,
+    /* A never returning CALL.
+     * Creating this causes IR blocks to be marked as 'final'.
+     * No-Return-Call
+     */
+    VINSTR_NRCALL
 };
 
 extern prog_section_statement *code_statements;
@@ -573,6 +578,7 @@ qcint    code_alloc_field (size_t qcsize);
 
 /* this function is used to keep statements and linenumbers together */
 void     code_push_statement(prog_section_statement *stmt, int linenum);
+void     code_pop_statement();
 
 /*
  * A shallow copy of a lex_file to remember where which ast node
@@ -623,8 +629,10 @@ int  con_out   (const char *, ...);
 extern size_t compile_errors;
 extern size_t compile_warnings;
 
-void /********/ compile_error  (lex_ctx ctx, /*LVL_ERROR*/ const char *msg, ...);
-bool GMQCC_WARN compile_warning(lex_ctx ctx, int warntype, const char *fmt, ...);
+void /********/ compile_error   (lex_ctx ctx, /*LVL_ERROR*/ const char *msg, ...);
+void /********/ vcompile_error  (lex_ctx ctx, /*LVL_ERROR*/ const char *msg, va_list ap);
+bool GMQCC_WARN compile_warning (lex_ctx ctx, int warntype, const char *fmt, ...);
+bool GMQCC_WARN vcompile_warning(lex_ctx ctx, int warntype, const char *fmt, va_list ap);
 
 /*===================================================================*/
 /*========================= assembler.c =============================*/
@@ -845,6 +853,7 @@ void ftepp_finish           ();
 const char *ftepp_get       ();
 void ftepp_flush            ();
 void ftepp_add_define       (const char *source, const char *name);
+void ftepp_add_macro        (const char *name,   const char *value);
 
 /*===================================================================*/
 /*======================= main.c commandline ========================*/
@@ -864,14 +873,23 @@ typedef uint32_t longbit;
 #define LONGBIT(bit) (bit)
 #endif
 
-/* Used to store the list of flags with names */
+/*===================================================================*/
+/*============================= opts.c ==============================*/
+/*===================================================================*/
 typedef struct {
     const char *name;
     longbit     bit;
 } opts_flag_def;
 
-/*===================================================================*/
-/* list of -f flags, like -fdarkplaces-string-table-bug */
+bool opts_setflag (const char *, bool);
+bool opts_setwarn (const char *, bool);
+bool opts_setoptim(const char *, bool);
+
+void opts_init         (const char *, int, size_t);
+void opts_set          (uint32_t   *, size_t, bool);
+void opts_setoptimlevel(unsigned int);
+void opts_ini_init     (const char *);
+
 enum {
 # define GMQCC_TYPE_FLAGS
 # define GMQCC_DEFINE_FLAG(X) X,
@@ -916,38 +934,41 @@ static const unsigned int opts_opt_oflag[] = {
 #  include "opts.def"
     0
 };
-extern unsigned int optimization_count[COUNT_OPTIMIZATIONS];
+extern unsigned int opts_optimizationcount[COUNT_OPTIMIZATIONS];
 
 /* other options: */
-enum {
+typedef enum {
     COMPILER_QCC,     /* circa  QuakeC */
     COMPILER_FTEQCC,  /* fteqcc QuakeC */
     COMPILER_QCCX,    /* qccx   QuakeC */
     COMPILER_GMQCC    /* this   QuakeC */
-};
+} opts_std_t;
 
-extern uint32_t    opts_O;      /* -Ox */
-extern const char *opts_output; /* -o file */
-extern int         opts_standard;
-extern bool        opts_debug;
-extern bool        opts_memchk;
-extern bool        opts_dumpfin;
-extern bool        opts_dump;
-extern bool        opts_werror;
-extern bool        opts_forcecrc;
-extern uint16_t    opts_forced_crc;
-extern bool        opts_pp_only;
-extern size_t      opts_max_array_size;
+typedef struct {
+    uint32_t    O;              /* -Ox           */
+    const char *output;         /* -o file       */
+    bool        g;              /* -g            */
+    opts_std_t  standard;       /* -std=         */
+    bool        debug;          /* -debug        */
+    bool        memchk;         /* -memchk       */
+    bool        dumpfin;        /* -dumpfin      */
+    bool        dump;           /* -dump         */
+    bool        werror;         /* -Werror       */
+    bool        forcecrc;       /* --force-crc=  */
+    uint16_t    forced_crc;     /* --force-crc=  */
+    bool        pp_only;        /* -E            */
+    size_t      max_array_size; /* --max-array=  */
+
+    uint32_t flags       [1 + (COUNT_FLAGS         / 32)];
+    uint32_t warn        [1 + (COUNT_WARNINGS      / 32)];
+    uint32_t optimization[1 + (COUNT_OPTIMIZATIONS / 32)];
+} opts_cmd_t;
+
+extern opts_cmd_t opts;
 
 /*===================================================================*/
-#define OPTS_FLAG(i)         (!! (opts_flags       [(i)/32] & (1<< ((i)%32))))
-#define OPTS_WARN(i)         (!! (opts_warn        [(i)/32] & (1<< ((i)%32))))
-#define OPTS_OPTIMIZATION(i) (!! (opts_optimization[(i)/32] & (1<< ((i)%32))))
-
-extern uint32_t opts_flags       [1 + (COUNT_FLAGS         / 32)];
-extern uint32_t opts_warn        [1 + (COUNT_WARNINGS      / 32)];
-extern uint32_t opts_optimization[1 + (COUNT_OPTIMIZATIONS / 32)];
-
-void options_set(uint32_t *flags, size_t idx, bool on);
+#define OPTS_FLAG(i)         (!! (opts.flags       [(i)/32] & (1<< ((i)%32))))
+#define OPTS_WARN(i)         (!! (opts.warn        [(i)/32] & (1<< ((i)%32))))
+#define OPTS_OPTIMIZATION(i) (!! (opts.optimization[(i)/32] & (1<< ((i)%32))))
 
 #endif