+ GMQCC_DEFINE_FLAG (
+ PEEPHOLE, 1,
+
+ "Some general peephole optimizations. For instance the code `a = b\n"
+ "+ c` typically generates 2 instructions, an ADD and a STORE. This\n"
+ "optimization removes the STORE and lets the ADD write directly\n"
+ "into A."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ TAIL_RECURSION, 1,
+
+ "Tail recursive function calls will be turned into loops to avoid\n"
+ "the overhead of the CALL and RETURN instructions."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ OVERLAP_LOCALS, 3,
+
+ "Make all functions which use neither local arrays nor have locals\n"
+ "which are seen as possibly uninitialized use the same local sec‐\n"
+ "tion. This should be pretty safe compared to other compilers\n"
+ "which do not check for uninitialized values properly. The problem\n"
+ "is that there's QC code out there which really doesn't initialize\n"
+ "some values. This is fine as long as this kind of optimization\n"
+ "isn't used, but also, only as long as the functions cannot be\n"
+ "called in a recursive manner. Since it's hard to know whether or\n"
+ "not an array is actually fully initialized, especially when ini‐\n"
+ "tializing it via a loop, we assume functions with arrays to be\n"
+ "too dangerous for this optimization."
+ )
+
+
+ GMQCC_DEFINE_FLAG (
+ LOCAL_TEMPS, 3,
+
+ "This promotes locally declared variables to \"temps\". Meaning when\n"
+ "a temporary result of an operation has to be stored somewhere, a\n"
+ "local variable which is not 'alive' at that point can be used to\n"
+ "keep the result. This can reduce the size of the global section.\n"
+ "This will not have declared variables overlap, even if it was\n"
+ "possible."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ GLOBAL_TEMPS, 3,
+
+ "Causes temporary values which do not need to be backed up on a\n"
+ "CALL to not be stored in the function's locals-area. With this, a\n"
+ "CALL to a function may need to back up fewer values and thus exe‐\n"
+ "cute faster."
+ )
+
+
+ GMQCC_DEFINE_FLAG (
+ STRIP_CONSTANT_NAMES, 1,
+
+ "Don't generate defs for immediate values or even declared con‐\n"
+ "stants. Meaning variables which are implicitly constant or qual‐\n"
+ "ified as such using the 'const' keyword."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ OVERLAP_STRINGS, 2,
+
+ "Aggressively reuse strings in the string section. When a string\n"
+ "should be added which is the trailing substring of an already\n"
+ "existing string, the existing string's tail will be returned\n"
+ "instead of the new string being added.\n\n"
+ "For example the following code will only generate 1 string:\n\n"
+ " print(\"Hell you!\\n\");\n"
+ " print(\"you!\n\"); // trailing substring of \"Hello you!\\n\"\n\n"
+ "There's however one limitation. Strings are still processed in\n"
+ "order, so if the above print statements were reversed, this opti‐\n"
+ "mization would not happen."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ CALL_STORES, 3,
+
+ "By default, all parameters of a CALL are copied into the parame‐\n"
+ "ter-globals right before the CALL instructions. This is the easi‐\n"
+ "est and safest way to translate calls, but also adds a lot of\n"
+ "unnecessary copying and unnecessary temporary values. This opti‐\n"
+ "mization makes operations which are used as a parameter evaluate\n"
+ "directly into the parameter-global if that is possible, which is\n"
+ "when there's no other CALL instruction in between."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ VOID_RETURN, 1,
+
+ "Usually an empty RETURN instruction is added to the end of a void\n"
+ "typed function. However, additionally after every function a DONE\n"
+ "instruction is added for several reasons. (For example the qcvm's\n"
+ "disassemble switch uses it to know when the function ends.). This\n"
+ "optimization replaces that last RETURN with DONE rather than\n"
+ "adding the DONE additionally."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ VECTOR_COMPONENTS, 1,
+
+ "Because traditional QC code doesn't allow you to access individ‐\n"
+ "ual vector components of a computed vector without storing it in\n"
+ "a local first, sometimes people multiply it by a constant like\n"
+ "‘'0 1 0'’ to get, in this case, the y component of a vector. This\n"
+ "optimization will turn such a multiplication into a direct compo‐\n"
+ "nent access. If the factor is anything other than 1, a float-mul‐\n"
+ "tiplication will be added, which is still faster than a vector"
+ "multiplication."
+ )
+#endif
+
+#ifdef GMQCC_TYPE_OPTIONS
+ GMQCC_DEFINE_FLAG (
+ O,
+
+ "Specify the optimization level\n"
+ "3 Highest optimization level\n"
+ "2 Default optimization level\n"
+ "1 Minimal optimization level\n"
+ "0 Disable optimization entirely"
+ )
+ GMQCC_DEFINE_FLAG (
+ OUTPUT,
+
+ "Specify the output file name. Defaults to progs.dat. This will\n"
+ "overwrite the output file listed in a progs.src file in case such\n"
+ "a file is used."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ QUIET,
+
+ "Be less verbose. In particular removes the messages about which\n"
+ "files are being processed, and which compilation mode is being\n"
+ "used, and some others. Warnings and errors will of course still\n"
+ "be displayed."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ G,
+
+ ""
+ )
+
+ GMQCC_DEFINE_FLAG (
+ STANDARD,
+
+ "Use the specified standard for parsing QC code. The following\n"
+ "standards are available: gmqcc, qcc, fteqcc Selecting a standard\n"
+ "also implies some -f options and behaves as if those options have\n"
+ "been written right after the -std option, meaning if you changed\n"
+ "them before the --std option, you're now overwriting them.\n\n"
+ "-std=gmqcc includes:\n"
+ " -fadjust-vector-fields\n"
+ " -fcorrect-logic\n"
+ " -ftrue-empty-strings\n"
+ " -floop-labels\n"
+ " -finitialized-nonconstants\n"
+ " -ftranslatable-strings\n"
+ " -fno-false-empty-strings\n"
+ " -Winvalid-parameter-count\n"
+ " -Wmissing-returnvalues\n"
+ " -fcorrect-ternary (cannot be turned off)\n\n"
+ "-std=qcc includes:\n"
+ " -fassign-function-types\n"
+ " -fIno-adjust-vector-fields\n\n"
+ "-std=fteqcc includes:\n"
+ " -fftepp\n"
+ " -ftranslatable-strings\n"
+ " -fassign-function-types\n"
+ " -Wternary-precedence\n"
+ " -fno-adjust-vector-fields\n"
+ " -fno-correct-ternary"
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DEBUG,
+
+ "Turn on some compiler debuggin mechanisms"
+ )
+
+ GMQCC_DEFINE_FLAG (
+ MEMCHK,
+
+ "Turn on compiler mem-chk. (Shows allocations and checks for\n"
+ "leaks.)"
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DUMPFIN,
+
+ "DEBUG OPTION. Print the code's intermediate representation after\n"
+ "the optimization and finalization passes to stdout before gener‐\n"
+ "ating the binary. The instructions will be enumerated, and values\n"
+ "will contain a list of liferanges."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ DUMP,
+
+ "DEBUG OPTION. Print the code's intermediate representation before\n"
+ "the optimization and finalization passes to stdout before gener‐\n"
+ "ating the binary."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ FORCECRC,
+
+ "When enabled allows forcing a specific CRC16 for the generated\n"
+ "progs.dat"
+ )
+
+ GMQCC_DEFINE_FLAG (
+ FORCED_CRC,
+
+ "Value which represents the CRC to force into the progs.dat"
+ )
+
+ GMQCC_DEFINE_FLAG (
+ PP_ONLY,
+
+ "Run only the preprocessor as if -fftepp was used and print the\n"
+ "preprocessed code to stdout."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ MAX_ARRAY_SIZE,
+
+ "Maximum allowed one-dimensional array size. Arrays are expensive\n"
+ "since binary search trees are generated for each set/get of an array\n"
+ "the more elements in an array (the larger it is), the longer it will\n"
+ "take to set/get elements."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ ADD_INFO,
+
+ "Adds compiler information to the generated binary file. Currently\n"
+ "this includes the following globals:\n"
+ " reserved:version\n"
+ " String containing the compiler version as printed by the\n"
+ " --version parameter."
+ )
+
+ GMQCC_DEFINE_FLAG (
+ CORRECTION,
+
+ "When enabled, errors about undefined values try to suggest an\n"
+ "existing value via spell checking."
+ )