Get compiling with Borland C++ for Windows
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 27 Feb 2000 06:03:18 +0000 (06:03 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 27 Feb 2000 06:03:18 +0000 (06:03 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@131 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/Makefile.bcc [new file with mode: 0644]
src/SDCCcse.c
src/SDCCicode.c
src/SDCCmain.c
src/mcs51/Makefile.bcc [new file with mode: 0644]
src/mcs51/gen.c
src/mcs51/ralloc.c
src/z80/Makefile.bcc [new file with mode: 0644]

diff --git a/src/Makefile.bcc b/src/Makefile.bcc
new file mode 100644 (file)
index 0000000..d788d39
--- /dev/null
@@ -0,0 +1,69 @@
+# Generated automatically from Makefile.in by configure.
+#
+#
+#
+
+PRJDIR         = ..
+
+# !include $(PRJDIR)/Makefile.common
+
+PORTS          = mcs51 z80
+PORT_LIBS       = mcs51/port.lib z80/port.lib
+
+LIBS           = -lgc 
+LIBDIRS                = -L$(PRJDIR)/support/gc
+LIBGC           = $(PRJDIR)/support/gc/gc.lib
+
+OBJECTS         = SDCCy.obj SDCClex.obj SDCCerr.obj SDCChasht.obj SDCCmain.obj \
+                  SDCCsymt.obj SDCCopt.obj SDCCast.obj SDCCmem.obj SDCCval.obj \
+                  SDCCicode.obj SDCCbitv.obj SDCCset.obj SDCClabel.obj \
+                  SDCCBBlock.obj SDCCloop.obj SDCCcse.obj SDCCcflow.obj SDCCdflow.obj \
+                  SDCClrange.obj SDCCptropt.obj SDCCpeeph.obj SDCCglue.obj
+
+TARGET          = $(PRJDIR)/bin/sdcc.exe
+
+# Compiling entire program or any subproject
+# ------------------------------------------
+all: $(LIBGC) $(TARGET)
+
+ports:
+#        for i in $(PORTS); do $(MAKE) -C $$i; done
+
+#$(PRJDIR)/support/gc/libgc.a:
+#        cd $(PRJDIR)/support/gc && $(MAKE)
+
+
+!include Makefile.dep
+#!include clean.mk
+
+
+# My rules
+# --------
+$(TARGET): $(OBJECTS) $(PORT_LIBS)
+        bcc32 -e$(TARGET) $(OBJECTS) $(PORT_LIBS) $(LIBGC)
+
+CFLAGS  = -6 -O -g0 -I. -I.. -I..\support
+
+.c.obj:
+        BCC32 -c $(CFLAGS) $(CPPFLAGS) $<
+
+SDCCy.h: SDCCy.c
+
+SDCCy.c: SDCC.y
+       $(YACC) -d -v -o $@ $<
+
+SDCClex.c: SDCC.lex SDCCy.h
+       $(LEX) -t $< >$@
+
+.y.c:
+       rm -f $*.cc $*.h
+       $(YACC) -d $<
+       mv y.tab.c $*.cc
+       mv y.tab.h $*.h
+
+.l.c:
+       rm -f $*.cc
+       $(LEX) -t $< >$*.cc
+
+
+
index 04e6337f071d2010121341b95dfb65ba9a04be64..00cda0b8521905d298220c27e98f27810eaa43c9 100644 (file)
@@ -67,6 +67,8 @@ int pcseDef (void *item, va_list ap)
     cseDef *cdp = item;
     iCodeTable *icTab ;
 
+    (void)ap;
+    
     if (!cdp->sym)
        fprintf(stdout,"**null op**");
     printOperand(cdp->sym,stdout);
@@ -854,7 +856,7 @@ void ifxOptimize (iCode *ic, set *cseSet,
     /* if the conditional is a literal then */
     if (IS_OP_LITERAL(IC_COND(ic))) {         
 
-       if ( operandLitValue(IC_COND(ic)) && IC_TRUE(ic)) {
+       if ( (operandLitValue(IC_COND(ic)) != 0.0) && IC_TRUE(ic)) {
            
            /* change to a goto */
            ic->op = GOTO ;
index 3a2799d41b734829d123cec6ba3cc212360a37f7..7213568f9a70f759c5ae9af15f74b842f230bbff 100644 (file)
@@ -2140,6 +2140,12 @@ operand *geniCodeRightShift (operand *left, operand *right)
     return IC_RESULT(ic) ;  
 }
 
+#ifdef __BORLANDC__
+#define LONG_LONG __int64
+#else
+#define LONG_LONG long long
+#endif
+
 /*-----------------------------------------------------------------*/
 /* geniCodeLogic- logic code                                       */
 /*-----------------------------------------------------------------*/
@@ -2156,7 +2162,7 @@ operand *geniCodeLogic (operand *left, operand *right, int op )
        int nbits = bitsForType(ltype);
        long v = operandLitValue(right);
 
-       if (v > ((long long) 1 << nbits) && v > 0)
+       if (v > ((LONG_LONG) 1 << nbits) && v > 0)
            werror(W_CONST_RANGE," compare operation ");
     }
 
@@ -2249,7 +2255,7 @@ operand *geniCodeAssign (operand *left, operand *right, int nosupdate)
        int nbits = bitsForType(ltype);
        long v = operandLitValue(right);
 
-       if (v > ((long long)1 << nbits) && v > 0)
+       if (v > ((LONG_LONG)1 << nbits) && v > 0)
            werror(W_CONST_RANGE," = operation");
     }
     /* if the left & right type don't exactly match */
index 6a9126d4f6e010a4dceee06e507aeb1509b6c847..2a5064a42ee86d8b3714808236d50f17748af81a 100644 (file)
 
 #include "common.h"
 #include <ctype.h>
+
+#ifdef __BORLANDC__
+#include <process.h>
+#else
 #include "spawn.h"
+#endif
 
 /* This is a bit messy.  We cant include unistd.h as it defines
    'link' which we also use.
@@ -979,15 +984,40 @@ int   parseCmdLine ( int argc, char **argv )
 char *try_dir[]= {SRCDIR "/bin",PREFIX "/bin", NULL};
 int my_system (const char *cmd, char **cmd_argv)
 {    
-
     char *dir, *got= NULL; int i= 0;
-    while (!got && try_dir[i]) {
-       dir= (char*)malloc(strlen(try_dir[i])+strlen(cmd)+10);
-       strcpy(dir, try_dir[i]); strcat(dir, "/"); strcat(dir, cmd);
-       if (access(dir, X_OK) == 0)
-           got= strdup(dir);
-       free(dir);
-       i++;
+    #ifdef __BORLANDC__
+    char *r;
+    #endif
+
+    while (!got && try_dir[i])
+    {
+        dir= (char*)malloc(strlen(try_dir[i])+strlen(cmd)+10);
+        strcpy(dir, try_dir[i]);
+        strcat(dir, "/");
+        strcat(dir, cmd);
+
+        #ifdef __BORLANDC__
+        strcat(dir, ".exe");
+
+        /* Mung slashes into backslashes to keep WIndoze happy. */
+       r = dir;
+
+        while (*r)
+        {
+            if (*r == '/')
+            {
+                *r = '\\';
+            }
+            r++;
+        }
+        #endif
+
+        if (access(dir, X_OK) == 0)
+        {
+            got= strdup(dir);
+        }
+        free(dir);
+        i++;
     }
 #if FEATURE_VERBOSE_EXEC
     if (verboseExec) {
@@ -1288,8 +1318,8 @@ int main ( int argc, char **argv , char **envp)
        fclose(yyin);
 
     if (preOutName && !options.c1mode) {
-       unlink(preOutName);
-       free(preOutName);
+        unlink(preOutName);
+        free(preOutName);
     }
     return 0;
     
diff --git a/src/mcs51/Makefile.bcc b/src/mcs51/Makefile.bcc
new file mode 100644 (file)
index 0000000..bc0ae89
--- /dev/null
@@ -0,0 +1,24 @@
+PRJDIR = ../..
+
+# !include $(PRJDIR)/Makefile.common
+
+OBJ = gen.obj ralloc.obj main.obj
+LIB = port.lib
+
+CFLAGS  = -6 -O -g0 -I.. -I. -I..\.. -I..\..\support
+
+.c.obj:
+        BCC32 -c $(CFLAGS) $(CPPFLAGS) $<
+
+all: $(LIB)
+
+main.obj: main.c peeph.rul
+
+$(LIB): peeph.rul $(OBJ)
+       del $(LIB)
+       tlib /a $(LIB) +gen.obj +ralloc.obj +main.obj
+       
+peeph.rul: peeph.def
+        gawk -f ../SDCCpeeph.awk peeph.def > peeph.rul
+
+# include clean.mk
index 416fa2bc9bb3af2679614e7b11c4fb9c310391e6..a182bc99d1116d70c054b039614990ad105c52f8 100644 (file)
 #ifdef HAVE_ENDIAN_H
 #include <endian.h>
 #else
+#ifndef __BORLANDC__
 #warning "Cannot determine ENDIANESS of this machine assuming LITTLE_ENDIAN"
 #warning "If you running sdcc on an INTEL 80x86 Platform you are okay"
 #endif
 #endif
+#endif
 
 #include "common.h"
 #include "SDCCpeeph.h"
@@ -1872,6 +1874,12 @@ static int resultRemat (iCode *ic)
     return 0;
 }
 
+#ifdef __BORLANDC__
+#define STRCASECMP stricmp
+#else
+#define STRCASECMP strcasecmp
+#endif
+
 /*-----------------------------------------------------------------*/
 /* inExcludeList - return 1 if the string is in exclude Reg list   */
 /*-----------------------------------------------------------------*/
@@ -1880,12 +1888,12 @@ static bool inExcludeList(char *s)
     int i =0;
     
     if (options.excludeRegs[i] &&
-       strcasecmp(options.excludeRegs[i],"none") == 0)
+    STRCASECMP(options.excludeRegs[i],"none") == 0)
        return FALSE ;
 
     for ( i = 0 ; options.excludeRegs[i]; i++) {
        if (options.excludeRegs[i] &&
-           strcasecmp(s,options.excludeRegs[i]) == 0)
+        STRCASECMP(s,options.excludeRegs[i]) == 0)
            return TRUE;
     }
     return FALSE ;
index 45c9e18ddfa1c629a466cba034f20149b03cbc80..80573d3a1debb0070b37f3c1b11ee2f2fb91dca7 100644 (file)
@@ -443,6 +443,8 @@ static symbol *createStackSpil (symbol *sym)
     int useXstack, model, noOverlay;
     int stackAuto;
 
+    char slocBuffer[30];
+
     /* first go try and find a free one that is already 
        existing on the stack */
     if (applyToSet(_G.stackSpil,isFree,&sloc, sym)) {
@@ -458,8 +460,14 @@ static symbol *createStackSpil (symbol *sym)
        we need to allocate this on the stack : this is really a
        hack!! but cannot think of anything better at this time */
        
-    sprintf(buffer,"sloc%d",_G.slocNum++);
-    sloc = newiTemp(buffer);
+    if (sprintf(slocBuffer,"sloc%d",_G.slocNum++) >= sizeof(slocBuffer))
+    {
+       fprintf(stderr, "***Internal error: slocBuffer overflowed: %s:%d\n",
+               __FILE__, __LINE__);
+       exit(1);        
+    }
+
+    sloc = newiTemp(slocBuffer);
 
     /* set the type to the spilling symbol */
     sloc->type = copyLinkChain(sym->type);
diff --git a/src/z80/Makefile.bcc b/src/z80/Makefile.bcc
new file mode 100644 (file)
index 0000000..1b2c468
--- /dev/null
@@ -0,0 +1,28 @@
+PRJDIR = ../..
+
+# !include $(PRJDIR)/Makefile.common
+
+OBJ = gen.obj ralloc.obj main.obj gbz80.obj
+LIB = port.lib
+
+CFLAGS  = -6 -O -g0 -I.. -I. -I..\.. -I..\..\support
+
+.c.obj:
+        BCC32 -c $(CFLAGS) $(CPPFLAGS) $<
+
+all: $(LIB)
+
+main.obj: main.c peeph.rul
+gbz80.obj: gbz80.c peeph-gbz80.rul
+
+$(LIB): peeph.rul $(OBJ)
+       del $(LIB)
+        tlib /a $(LIB) +gen.obj +ralloc.obj +main.obj +gbz80.obj
+       
+peeph.rul: peeph.def
+        gawk -f ../SDCCpeeph.awk peeph.def > peeph.rul
+
+peeph-gbz80.rul: peeph-gbz80.def
+        gawk -f ../SDCCpeeph.awk peeph-gbz80.def > peeph-gbz80.rul
+
+# include clean.mk