]> git.sur5r.net Git - cc65/blobdiff - src/cc65/main.c
So far the built-in inlining of several known standard function was always (!) enable...
[cc65] / src / cc65 / main.c
index a27822ed8718fe58d700fd7125ae00987bb81b38..d3d298876796be344db58dbc29b9881034838fb6 100644 (file)
@@ -6,7 +6,7 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000-2013, Ullrich von Bassewitz                                      */
+/* (C) 2000-2015, Ullrich von Bassewitz                                      */
 /*                Roemerstrasse 52                                           */
 /*                D-70794 Filderstadt                                        */
 /* EMail:         uz@cc65.org                                                */
@@ -88,7 +88,7 @@ static void Usage (void)
             "  -O\t\t\t\tOptimize code\n"
             "  -Oi\t\t\t\tOptimize code, inline more code\n"
             "  -Or\t\t\t\tEnable register variables\n"
-            "  -Os\t\t\t\tInline some known functions\n"
+            "  -Os\t\t\t\tInline some standard functions\n"
             "  -T\t\t\t\tInclude source as comment\n"
             "  -V\t\t\t\tPrint the compiler version number\n"
             "  -W warning[,...]\t\tSuppress warnings\n"
@@ -104,6 +104,7 @@ static void Usage (void)
             "\n"
             "Long options:\n"
             "  --add-source\t\t\tInclude source as comment\n"
+            "  --all-cdecl\t\t\tMake functions default to __cdecl__\n"
             "  --bss-name seg\t\tSet the name of the BSS segment\n"
             "  --check-stack\t\t\tGenerate stack overflow checks\n"
             "  --code-name seg\t\tSet the name of the CODE segment\n"
@@ -117,9 +118,11 @@ static void Usage (void)
             "  --debug-opt name\t\tDebug optimization steps\n"
             "  --dep-target target\t\tUse this dependency target\n"
             "  --disable-opt name\t\tDisable an optimization step\n"
+            "  --eagerly-inline-funcs\t\tEagerly inline some known functions\n"
             "  --enable-opt name\t\tEnable an optimization step\n"
             "  --help\t\t\tHelp (this text)\n"
             "  --include-dir dir\t\tSet an include directory search path\n"
+            "  --inline-stdfuncs\t\tInline some standard functions\n"
             "  --list-opt-steps\t\tList all optimizer steps and exit\n"
             "  --list-warnings\t\tList available warning types for -W\n"
             "  --local-strings\t\tEmit string literals immediately\n"
@@ -160,6 +163,14 @@ static void SetSys (const char* Sys)
             AbEnd ("Cannot use `module' as a target for the compiler");
             break;
 
+        case TGT_ATARI2600:
+            DefineNumericMacro ("__ATARI2600__", 1);
+            break;
+
+        case TGT_ATARI5200:
+            DefineNumericMacro ("__ATARI5200__", 1);
+            break;
+
         case TGT_ATARI:
             DefineNumericMacro ("__ATARI__", 1);
             break;
@@ -215,12 +226,20 @@ static void SetSys (const char* Sys)
             DefineNumericMacro ("__APPLE2ENH__", 1);
             break;
 
+        case TGT_GAMATE:
+            DefineNumericMacro ("__GAMATE__", 1);
+            break;
+
         case TGT_GEOS_CBM:
             /* Do not handle as a CBM system */
             DefineNumericMacro ("__GEOS__", 1);
             DefineNumericMacro ("__GEOS_CBM__", 1);
             break;
 
+        case TGT_CREATIVISION:
+            DefineNumericMacro ("__CREATIVISION__", 1);
+            break;
+
         case TGT_GEOS_APPLE:
             DefineNumericMacro ("__GEOS__", 1);
             DefineNumericMacro ("__GEOS_APPLE__", 1);
@@ -234,6 +253,10 @@ static void SetSys (const char* Sys)
             DefineNumericMacro ("__ATMOS__", 1);
             break;
 
+        case TGT_TELESTRAT:
+            DefineNumericMacro ("__TELESTRAT__", 1);
+            break;
+                                
         case TGT_NES:
             DefineNumericMacro ("__NES__", 1);
             break;
@@ -254,6 +277,14 @@ static void SetSys (const char* Sys)
             DefineNumericMacro ("__SIM65C02__", 1);
             break;
 
+        case TGT_OSIC1P:
+            DefineNumericMacro ("__OSIC1P__", 1);
+            break;
+
+        case TGT_PCENGINE:
+            DefineNumericMacro ("__PCE__", 1);
+            break;
+
         default:
             AbEnd ("Unknown target system type %d", Target);
     }
@@ -302,9 +333,9 @@ static void DefineSym (const char* Def)
         DefineNumericMacro (Def, 1);
     } else {
         /* We have a value, P points to the '=' character. Since the argument
-         * is const, create a copy and replace the '=' in the copy by a zero
-         * terminator.
-         */
+        ** is const, create a copy and replace the '=' in the copy by a zero
+        ** terminator.
+        */
         char* Q;
         unsigned Len = strlen (Def)+1;
         char* S = (char*) xmalloc (Len);
@@ -342,6 +373,15 @@ static void OptAddSource (const char* Opt attribute ((unused)),
 
 
 
+static void OptAllCDecl (const char* Opt attribute ((unused)),
+                         const char* Arg attribute ((unused)))
+/* Make functions default to cdecl instead of fastcall. */
+{
+    AutoCDecl = 1;
+}
+
+
+
 static void OptBssName (const char* Opt attribute ((unused)), const char* Arg)
 /* Handle the --bss-name option */
 {
@@ -464,13 +504,13 @@ static void OptDebugOpt (const char* Opt attribute ((unused)), const char* Arg)
     }
 
     /* Read line by line, ignore empty lines and switch optimization
-     * steps on/off.
-     */
+    ** steps on/off.
+    */
     while (fgets (Buf, sizeof (Buf), F) != 0) {
 
         /* Remove trailing control chars. This will also remove the
-         * trailing newline.
-         */
+        ** trailing newline.
+        */
         unsigned Len = strlen (Buf);
         while (Len > 0 && IsControl (Buf[Len-1])) {
             --Len;
@@ -484,8 +524,8 @@ static void OptDebugOpt (const char* Opt attribute ((unused)), const char* Arg)
         }
 
         /* Check the first character and enable/disable the step or
-         * ignore the line
-         */
+        ** ignore the line
+        */
         switch (*Line) {
 
             case '\0':
@@ -511,8 +551,8 @@ static void OptDebugOpt (const char* Opt attribute ((unused)), const char* Arg)
     }
 
     /* Close the file, no error check here since we were just reading and
-     * this is only a debug function.
-     */
+    ** this is only a debug function.
+    */
     (void) fclose (F);
 }
 
@@ -543,6 +583,16 @@ static void OptDisableOpt (const char* Opt attribute ((unused)), const char* Arg
 
 
 
+static void OptEagerlyInlineFuncs (const char* Opt attribute((unused)),
+                                   const char* Arg attribute((unused)))
+/* Eagerly inline some known functions */
+{
+    IS_Set (&InlineStdFuncs, 1);
+    IS_Set (&EagerlyInlineFuncs, 1);
+}
+
+
+
 static void OptEnableOpt (const char* Opt attribute ((unused)), const char* Arg)
 /* Enable an optimization step */
 {
@@ -570,6 +620,15 @@ static void OptIncludeDir (const char* Opt attribute ((unused)), const char* Arg
 
 
 
+static void OptInlineStdFuncs (const char* Opt attribute((unused)),
+                               const char* Arg attribute((unused)))
+/* Inline some standard functions */
+{
+    IS_Set (&InlineStdFuncs, 1);
+}
+
+
+
 static void OptListOptSteps (const char* Opt attribute ((unused)),
                              const char* Arg attribute ((unused)))
 /* List all optimizer steps */
@@ -716,7 +775,7 @@ static void OptVersion (const char* Opt attribute ((unused)),
                         const char* Arg attribute ((unused)))
 /* Print the compiler version */
 {
-    fprintf (stderr, "cc65 V%s\n", GetVersionAsString ());
+    fprintf (stderr, "%s V%s\n", ProgName, GetVersionAsString ());
     exit (EXIT_SUCCESS);
 }
 
@@ -781,38 +840,41 @@ int main (int argc, char* argv[])
 {
     /* Program long options */
     static const LongOpt OptTab[] = {
-        { "--add-source",       0,      OptAddSource            },
-        { "--bss-name",         1,      OptBssName              },
-        { "--check-stack",      0,      OptCheckStack           },
-        { "--code-name",        1,      OptCodeName             },
-        { "--codesize",         1,      OptCodeSize             },
-        { "--cpu",              1,      OptCPU                  },
-        { "--create-dep",       1,      OptCreateDep            },
-        { "--create-full-dep",  1,      OptCreateFullDep        },
-        { "--data-name",        1,      OptDataName             },
-        { "--debug",            0,      OptDebug                },
-        { "--debug-info",       0,      OptDebugInfo            },
-        { "--debug-opt",        1,      OptDebugOpt             },
-        { "--debug-opt-output", 0,      OptDebugOptOutput       },
-        { "--dep-target",       1,      OptDepTarget            },
-        { "--disable-opt",      1,      OptDisableOpt           },
-        { "--enable-opt",       1,      OptEnableOpt            },
-        { "--help",             0,      OptHelp                 },
-        { "--include-dir",      1,      OptIncludeDir           },
-        { "--list-opt-steps",   0,      OptListOptSteps         },
-        { "--list-warnings",    0,      OptListWarnings         },
-        { "--local-strings",    0,      OptLocalStrings         },
-        { "--memory-model",     1,      OptMemoryModel          },
-        { "--register-space",   1,      OptRegisterSpace        },
-        { "--register-vars",    0,      OptRegisterVars         },
-        { "--rodata-name",      1,      OptRodataName           },
-        { "--signed-chars",     0,      OptSignedChars          },
-        { "--standard",         1,      OptStandard             },
-        { "--static-locals",    0,      OptStaticLocals         },
-        { "--target",           1,      OptTarget               },
-        { "--verbose",          0,      OptVerbose              },
-        { "--version",          0,      OptVersion              },
-        { "--writable-strings", 0,      OptWritableStrings      },
+        { "--add-source",           0,      OptAddSource            },
+        { "--all-cdecl",            0,      OptAllCDecl             },
+        { "--bss-name",             1,      OptBssName              },
+        { "--check-stack",          0,      OptCheckStack           },
+        { "--code-name",            1,      OptCodeName             },
+        { "--codesize",             1,      OptCodeSize             },
+        { "--cpu",                  1,      OptCPU                  },
+        { "--create-dep",           1,      OptCreateDep            },
+        { "--create-full-dep",      1,      OptCreateFullDep        },
+        { "--data-name",            1,      OptDataName             },
+        { "--debug",                0,      OptDebug                },
+        { "--debug-info",           0,      OptDebugInfo            },
+        { "--debug-opt",            1,      OptDebugOpt             },
+        { "--debug-opt-output",     0,      OptDebugOptOutput       },
+        { "--dep-target",           1,      OptDepTarget            },
+        { "--disable-opt",          1,      OptDisableOpt           },
+        { "--eagerly-inline-funcs", 0,      OptEagerlyInlineFuncs   },
+        { "--enable-opt",           1,      OptEnableOpt            },
+        { "--help",                 0,      OptHelp                 },
+        { "--include-dir",          1,      OptIncludeDir           },
+        { "--inline-stdfuncs",      0,      OptInlineStdFuncs       },
+        { "--list-opt-steps",       0,      OptListOptSteps         },
+        { "--list-warnings",        0,      OptListWarnings         },
+        { "--local-strings",        0,      OptLocalStrings         },
+        { "--memory-model",         1,      OptMemoryModel          },
+        { "--register-space",       1,      OptRegisterSpace        },
+        { "--register-vars",        0,      OptRegisterVars         },
+        { "--rodata-name",          1,      OptRodataName           },
+        { "--signed-chars",         0,      OptSignedChars          },
+        { "--standard",             1,      OptStandard             },
+        { "--static-locals",        0,      OptStaticLocals         },
+        { "--target",               1,      OptTarget               },
+        { "--verbose",              0,      OptVerbose              },
+        { "--version",              0,      OptVersion              },
+        { "--writable-strings",     0,      OptWritableStrings      },
     };
 
     unsigned I;
@@ -1012,6 +1074,3 @@ int main (int argc, char* argv[])
     /* Return an apropriate exit code */
     return (ErrorCount > 0)? EXIT_FAILURE : EXIT_SUCCESS;
 }
-
-
-