]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - intrin.h
more fixes
[xonotic/gmqcc.git] / intrin.h
old mode 100755 (executable)
new mode 100644 (file)
index 4f672dd..1503d60
--- a/intrin.h
+++ b/intrin.h
@@ -36,7 +36,7 @@ typedef struct {
     const char       *alias;
 } intrin_t;
 
-ht intrin_intrinsics() {
+static ht intrin_intrinsics(void) {
     static ht intrinsics = NULL;
     if (!intrinsics)
         intrinsics = util_htnew(PARSER_HT_SIZE);
@@ -69,12 +69,10 @@ ht intrin_intrinsics() {
         vec_push(parser->globals,   (ast_expression*)(VALUE));        \
     } while (0)
 
-
-ast_expression *intrin_func (parser_t *parser, const char *name);
-
 #define QC_M_E 2.71828182845905
 
-ast_expression *intrin_pow(parser_t *parser) {
+static ast_expression *intrin_func(parser_t *parser, const char *name);
+static ast_expression *intrin_pow (parser_t *parser) {
     /*
      * float pow(float x, float y) {
      *   float local = 1.0f;
@@ -117,7 +115,7 @@ ast_expression *intrin_pow(parser_t *parser) {
                 parser_ctx(parser),
                 INSTR_STORE_F,
                 (ast_expression*)local,
-                (ast_expression*)parser_const_float_1(parser)
+                (ast_expression*)parser->fold->imm_float[1] /* 1 == 1.0f */
             )
         );
 
@@ -128,7 +126,7 @@ ast_expression *intrin_pow(parser_t *parser) {
                 INSTR_STORE_F,
                 INSTR_MUL_F,
                 (ast_expression*)arg2,
-                (ast_expression*)parser_const_float(parser, 0.25f)
+                (ast_expression*)fold_constgen_float(parser->fold, 0.25f)
             )
         );
 
@@ -151,7 +149,7 @@ ast_expression *intrin_pow(parser_t *parser) {
                 parser_ctx(parser),
                 INSTR_AND,
                 (ast_expression*)arg2,
-                (ast_expression*)parser_const_float_1(parser)
+                (ast_expression*)parser->fold->imm_float[1] /* 1 == 1.0f */
             ),
             true, /* ! not */
             NULL,
@@ -170,7 +168,7 @@ ast_expression *intrin_pow(parser_t *parser) {
                 INSTR_STORE_F,
                 INSTR_SUB_F,
                 (ast_expression*)arg2,
-                (ast_expression*)parser_const_float_1(parser)
+                (ast_expression*)parser->fold->imm_float[1] /* 1 == 1.0f */
             )
         );
         /* local *= x */
@@ -192,7 +190,7 @@ ast_expression *intrin_pow(parser_t *parser) {
                 parser_ctx(parser),
                 INSTR_GT,
                 (ast_expression*)arg2,
-                (ast_expression*)parser_const_float_0(parser)
+                (ast_expression*)parser->fold->imm_float[0] /* 0 == 0.0f */
             ),
             false,
             NULL,
@@ -221,7 +219,7 @@ ast_expression *intrin_pow(parser_t *parser) {
     return (ast_expression*)value;
 }
 
-ast_expression *intrin_mod(parser_t *parser) {
+static ast_expression *intrin_mod(parser_t *parser) {
     /*
      * float mod(float x, float y) {
      *   return x - y * floor(x / y);
@@ -276,7 +274,7 @@ ast_expression *intrin_mod(parser_t *parser) {
     return (ast_expression*)value;
 }
 
-ast_expression *intrin_exp(parser_t *parser) {
+static ast_expression *intrin_exp(parser_t *parser) {
     /*
      * float exp(float x) {
      *     return pow(QC_M_E, x);
@@ -293,7 +291,7 @@ ast_expression *intrin_exp(parser_t *parser) {
         INTRIN_VAL(value, "exp", func, "<float>", TYPE_FLOAT);
 
         /* push arguments for params to call */
-        vec_push(call->params, (ast_expression*)parser_const_float(parser, QC_M_E));
+        vec_push(call->params, (ast_expression*)fold_constgen_float(parser->fold, QC_M_E));
         vec_push(call->params, (ast_expression*)arg1);
 
         /* return pow(QC_M_E, x) */
@@ -314,7 +312,7 @@ ast_expression *intrin_exp(parser_t *parser) {
     return (ast_expression*)value;
 }
 
-ast_expression *intrin_isnan(parser_t *parser) {
+static ast_expression *intrin_isnan(parser_t *parser) {
     /*
      * float isnan(float x) {
      *   float local;
@@ -383,7 +381,7 @@ void intrin_intrinsics_destroy(parser_t *parser) {
 }
 
 
-ast_expression *intrin_func(parser_t *parser, const char *name) {
+static ast_expression *intrin_func(parser_t *parser, const char *name) {
     static bool  init = false;
     size_t       i    = 0;
     void        *find;