summary refs log tree commit diff stats
path: root/tinyc/il-gen.c
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-11-02 10:46:30 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-11-02 10:46:30 +0100
commit1eaeccc15d15d15d2f62ea1648f7dd64722dbd37 (patch)
treeb922cdabc780fa3a8837a6804d2df31793d9e2ca /tinyc/il-gen.c
parente9243a16167b24899d4fcf051f3252b3a5804811 (diff)
parentbd19b5f4d36bb40b4af93d7e15fdfa582e9fe3b7 (diff)
downloadNim-1eaeccc15d15d15d2f62ea1648f7dd64722dbd37.tar.gz
Merge branch 'devel' into araq
Diffstat (limited to 'tinyc/il-gen.c')
-rw-r--r--tinyc/il-gen.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/tinyc/il-gen.c b/tinyc/il-gen.c
index 29f052655..bb670ccb0 100644
--- a/tinyc/il-gen.c
+++ b/tinyc/il-gen.c
@@ -18,6 +18,8 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#error this code has bit-rotted since 2003
+
 /* number of available registers */
 #define NB_REGS             3
 
@@ -41,7 +43,7 @@ enum {
     REG_ST2,
 };
 
-int reg_classes[NB_REGS] = {
+const int reg_classes[NB_REGS] = {
     /* ST0 */ RC_ST | RC_ST0,
     /* ST1 */ RC_ST | RC_ST1,
     /* ST2 */ RC_ST,
@@ -53,11 +55,11 @@ int reg_classes[NB_REGS] = {
 #define REG_FRET REG_ST0 /* float return register */
 
 /* defined if function parameters must be evaluated in reverse order */
-//#define INVERT_FUNC_PARAMS
+/* #define INVERT_FUNC_PARAMS */
 
 /* defined if structures are passed as pointers. Otherwise structures
    are directly pushed on stack. */
-//#define FUNC_STRUCT_PARAM_AS_PTR
+/* #define FUNC_STRUCT_PARAM_AS_PTR */
 
 /* pointer size, in bytes */
 #define PTR_SIZE 4
@@ -193,7 +195,7 @@ static void il_type_to_str(char *buf, int buf_size,
         pstrcat(buf, buf_size, tstr);
         break;
     case VT_STRUCT:
-        error("structures not handled yet");
+        tcc_error("structures not handled yet");
         break;
     case VT_FUNC:
         s = sym_find((unsigned)t >> VT_STRUCT_SHIFT);
@@ -387,7 +389,7 @@ void gfunc_start(GFuncContext *c, int func_call)
 void gfunc_param(GFuncContext *c)
 {
     if ((vtop->t & VT_BTYPE) == VT_STRUCT) {
-        error("structures passed as value not handled yet");
+        tcc_error("structures passed as value not handled yet");
     } else {
         /* simply push on stack */
         gv(RC_ST0);
@@ -441,6 +443,7 @@ void gfunc_prolog(int t)
     /* if the function returns a structure, then add an
        implicit pointer parameter */
     func_vt = sym->t;
+    func_var = (sym->c == FUNC_ELLIPSIS);
     if ((func_vt & VT_BTYPE) == VT_STRUCT) {
         func_vc = addr;
         addr++;
@@ -528,19 +531,6 @@ int gtst(int inv, int t)
             t = gjmp(t);
             gsym(vtop->c.i);
         }
-    } else {
-        if (is_float(vtop->t)) {
-            vpushi(0);
-            gen_op(TOK_NE);
-        }
-        if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_FORWARD)) == VT_CONST) {
-            /* constant jmp optimization */
-            if ((vtop->c.i != 0) != inv) 
-                t = gjmp(t);
-        } else {
-            v = gv(RC_INT);
-            t = out_opj(IL_OP_BRTRUE - inv, t);
-        }
     }
     vtop--;
     return t;
@@ -612,7 +602,7 @@ void gen_opi(int op)
 }
 
 /* generate a floating point operation 'v = t1 op t2' instruction. The
-   two operands are guaranted to have the same floating point type */
+   two operands are guaranteed to have the same floating point type */
 void gen_opf(int op)
 {
     /* same as integer */