]> git.xonotic.org Git - xonotic/gmqcc.git/blob - gmqcc.ini.example
manpage/init: -fsplit-vector-parameters description
[xonotic/gmqcc.git] / gmqcc.ini.example
1 #This configuration file is similar to a regular .ini file. Comments start
2 #with hashtags or semicolons, sections are written in square brackets and
3 #in each section there can be arbitrary many key-value pairs.
4
5 #There are 3 sections currently: ‘flags’, ‘warnings’, ‘optimizations’.
6 #They contain a list of boolean values of the form ‘VARNAME = true’ or
7 #‘VARNAME = false’.  The variable names are the same as for the corre‐
8 #sponding -W, -f or -O flag written with only capital letters and dashes
9 #replaced by underscores.
10
11 [flags]
12     #Add some additional characters to the string table in order to
13     #compensate for a wrong boundcheck in some specific version of the
14     #darkplaces engine.
15
16     DARKPLACES_STRING_TABLE_BUG = true
17
18
19     #When assigning to field pointers of type .vector the common be‐
20     #haviour in compilers like fteqcc is to only assign the x-compo‐
21     #nent of the pointer. This means that you can use the vector as
22     #such, but you cannot use its y and z components directly. This
23     #flag fixes this behaviour. Before using it make sure your code
24     #does not depend on the buggy behaviour.
25
26     ADJUST_VECTOR_FIELDS = true
27
28
29     #Enable a partially fteqcc-compatible preprocessor. It supports
30     #all the features used in the Xonotic codebase. If you need more,
31     #write a ticket.
32
33     FTEPP = true
34
35
36     #Enable some predefined macros. This only works in combination
37     #with '-fftepp' and is currently not included by '-std=fteqcc'.
38     #The following macros will be added:
39     #
40     #   __LINE__
41     #   __FILE__
42     #   __COUNTER__
43     #   __COUNTER_LAST__
44     #   __RANDOM__
45     #   __RANDOM_LAST__
46     #   __DATE__
47     #   __TIME__
48     #   __FUNC__
49     #
50     #Note that __FUNC__ is not actually a preprocessor macro, but is
51     #recognized by the parser even with the preprocessor disabled.
52     #
53     #Note that fteqcc also defines __NULL__ which becomes the first
54     #global. Assigning it to a vector does not yield the same result
55     #as in gmqcc where __NULL__ is defined to nil (See -funtyped-nil
56     #), which will cause the vector to be zero in all components. With
57     #fteqcc only the first component will be 0, while the other two
58     #will become the first to of the global return value. This behav‐
59     #ior is odd and relying on it should be discouraged, and thus is
60     #not supported by gmqcc.
61
62     FTEPP_PREDEFS = false
63
64
65     #Enable math constant definitions. This only works in combination
66     #with '-fftepp' and is currently not included by '-std=fteqcc'.
67     #The following macros will be added:
68     #
69     # M_E
70     # M_LOG2E
71     # M_LOG10E
72     # M_LN2
73     # M_LN10
74     # M_PI
75     # M_PI_2
76     # M_PI_4
77     # M_1_PI
78     # M_2_PI
79     # M_2_SQRTPI
80     # M_SQRT2
81     # M_SQRT1_2
82     # M_TAU
83
84     FTEPP_MATHDEFS = false
85
86
87     #Enable indirect macro expansion. This only works in combination
88     #with '-fftepp' and is currently not included by '-std=fteqcc'.
89     #Enabling this behavior will allow the preprocessor to operate more
90     #like the standard C preprocessor in that it will allow arguments
91     #of macros which are macro-expanded to be substituted into the
92     #definition of the macro. As an example:
93     #
94     #   #define STR1(x) #x
95     #   #define STR2(x) STR1(x)
96     #   #define THE_ANSWER 42
97     #   #define THE_ANSWER_STR STR2(THE_ANSWER) /* "42" */
98     #
99     #With this enabled, an expansion of THE_ANSWER_STR will yield
100     #the string "42". With this disabled an expansion of THE_ANSWER_STR
101     #will yield "THE_ANSWER"
102
103     FTEPP_INDIRECT_EXPANSION = false
104
105
106     #Allow switch cases to use non constant variables.
107
108     RELAXED_SWITCH = true
109
110
111     #Perform early out in logical AND and OR expressions. The final
112     #result will be either a 0 or a 1, see the next flag for more pos‐
113     #sibilities.
114
115     SHORT_LOGIC = true
116
117
118     #In many languages, logical expressions perform early out in a
119     #special way: If the left operand of an AND yeilds true, or the
120     #one of an OR yields false, the complete expression evaluates to
121     #the right side.  Thus ‘true && 5’ evaluates to 5 rather than 1.
122
123     PERL_LOGIC = false
124
125
126     #Enable the underscore intrinsic: Using ‘_("A string constant")’
127     #will cause the string immediate to get a name with a "dotrans‐
128     #late_" prefix. The darkplaces engine recognizes these and trans‐
129     #lates them in a way similar to how gettext works.
130
131     TRANSLATABLE_STRINGS = true
132
133
134     #Don't implicitly convert initialized variables to constants. With
135     #this flag, the const keyword is required to make a constant.
136
137     INITIALIZED_NONCONSTANTS = false
138
139
140     #If this flag is not set, (and it is set by default in the qcc and
141     #fteqcc standards), assigning function pointers of mismatching
142     #signatures will result in an error rather than a warning.
143
144     ASSIGN_FUNCTION_TYPES = true
145
146
147     #Produce a linenumber file along with the output .dat file.
148
149     LNO = false
150
151
152     #Use C's operator precedence for ternary expressions. Unless your
153     #code depends on fteqcc-compatible behaviour, you'll want to use
154     #this option.
155
156     CORRECT_TERNARY = true
157
158
159     #Normally vectors generate 4 defs, once for the vector, and once
160     #for its components with _x, _y, _z suffixes. This option prevents
161     #components from being listed.
162
163
164     SINGLE_VECTOR_DEFS = true
165
166
167     #Most QC compilers translate ‘if(a_vector)’ directly as an IF on
168     #the vector, which means only the x-component is checked. This
169     #option causes vectors to be cast to actual booleans via a NOT_V
170     #and, if necessary, a NOT_F chained to it.
171     #
172     #   if (a_vector) // becomes
173     #   if not(!a_vector)
174     #   // likewise
175     #   a = a_vector && a_float // becomes
176     #   a = !!a_vector && a_float
177
178     CORRECT_LOGIC = true
179
180
181     #An empty string is considered to be true everywhere. The NOT_S
182     #instruction usually considers an empty string to be false, this
183     #option effectively causes the unary not in strings to use NOT_F
184     #instead.
185
186     TRUE_EMPTY_STRINGS = false
187
188
189     #An empty string is considered to be false everywhere. This means
190     #loops and if statements which depend on a string will perform a
191     #NOT_S instruction on the string before using it.
192
193     FALSE_EMPTY_STRINGS = true
194
195
196     #Enable utf8 characters. This allows utf-8 encoded character con‐
197     #stants, and escape sequence codepoints in the valid utf-8 range.
198     #Effectively enabling escape sequences like '\{x2211}'.
199
200     UTF8 = true
201
202
203     #When a warning is treated as an error, and this option is set
204     #(which it is by default), it is like any other error and will
205     #cause compilation to stop. When disabling this flag by using
206     #-fno-bail-on-werror, compilation will continue until the end, but
207     #no output is generated. Instead the first such error message's
208     #context is shown.
209
210     BAIL_ON_WERROR = false
211
212
213     #Allow loops to be labeled, and allow 'break' and 'continue' to
214     #take an optional label to decide which loop to actually jump out
215     #of or continue.
216     #
217     #   for :outer (i = 0; i < n; ++i) {
218     #       while (inner) {
219     #           ...;
220     #           if (something)
221     #               continue outer;
222     #       }
223     #   }
224
225     LOOP_LABELS = true
226
227
228     #Adds a global named 'nil' which is of no type and can be assigned
229     #to anything. No typechecking will be performed on assignments.
230     #Assigning to it is forbidden, using it in any other kind of
231     #expression is also not allowed.
232     #
233     #Note that this is different from fteqcc's __NULL__: In fteqcc,
234     #__NULL__ maps to the integer written as '0i'. It's can be
235     #assigned to function pointers and integers, but it'll error about
236     #invalid instructions when assigning it to floats without enabling
237     #the FTE instruction set. There's also a bug which allows it to be
238     #assigned to vectors, for which the source will be the global at
239     #offset 0, meaning the vector's y and z components will contain
240     #the OFS_RETURN x and y components.#
241     #
242     #In that gmqcc the nil global is an actual global filled with
243     #zeroes, and can be assigned to anything including fields, vectors
244     #or function pointers, and they end up becoming zeroed.
245
246
247     UNTYPED_NIL = true
248
249
250     #Various effects, usually to weaken some conditions.
251     #   with -funtyped-nil
252     #       Allow local variables named ‘nil’.  (This will not
253     #       allow declaring a global of that name.)
254
255     PERMISSIVE = false
256
257
258     #Allow variadic parameters to be accessed by QC code. This can be
259     #achieved via the '...' function, which takes a parameter index
260     #and a typename.
261     #
262     #Example:
263     #
264     #   void vafunc(string...count) {
265     #       float i;
266     #       for (i = 0; i < count; ++i)
267     #           print(...(i, string), "\n");
268     #   }
269
270     VARIADIC_ARGS = true
271
272
273     #Most Quake VMs, including the one from FTEQW or up till recently
274     #Darkplaces, do not cope well with vector instructions with over‐
275     #lapping input and output. This option will avoid producing such
276     #code.
277
278     LEGACY_VECTOR_MATHS = false
279
280
281     #Usually builtin-numbers are just immediate constants. With this
282     #flag expressions can be used, as long as they are compile-time
283     #constant.
284     #
285     #Example:
286     #
287     #   void printA() = #1;   // the usual way
288     #   void printB() = #2-1; // with a constant expression
289
290     EXPRESSIONS_FOR_BUILTINS = true
291
292
293     #Enabiling this option will allow assigning values or expressions
294     #to the return keyword as if it were a local variable of the same
295     #type as the function's signature's return type.
296     #
297     #Example:
298     #
299     #   float bar() { return 1024; }
300     #   float fun() {
301     #       return = bar();
302     #       return; // returns value of bar (this can be omitted)
303     #   }
304
305     RETURN_ASSIGNMENTS = true
306
307
308     #When passing on varargs to a different functions, this turns some
309     #static error cases into warnings. Like when the caller's varargs
310     #are restricted to a different type than the callee's parameter.
311     #Or a list of unrestricted varargs is passed into restricted
312     #varargs.
313
314     UNSAFE_VARARGS = false
315
316
317     #Always use STORE_F, LOAD_F, STOREP_F when accessing scalar variables.
318     #This is somewhat incorrect assembly instruction use, but in all engines
319     #they do exactly the same. This makes disassembly output harder to read,
320     #breaks decompilers, but causes the output file to be better compressible.
321
322     TYPELESS_STORES = false
323
324
325     #In commutative instructions, always put the lower-numbered operand first.
326     #This shaves off 1 byte of entropy from all these instructions, reducing
327     #compressed size of the output file.
328
329     SORT_OPERANDS = false
330
331
332     #Emulate OP_STATE operations in code rather than using the instruction.
333     #The desired fps can be set via -state-fps=NUM, defaults to 10.
334
335     EMULATE_STATE = false
336
337
338     #Turn on arithmetic exception tests in the compiler. In constant expressions
339     #which trigger exceptions like division by zero, overflow, underflow, etc,
340     #the following flag will produce diagnostics for what triggered that
341     #exception.
342     ARITHMETIC_EXCEPTIONS = false
343
344     #Split vector-literals which are only used dirctly as function parameters
345     #into 3 floats stored separately to reduce the number of globals at the
346     #expense of additional instructions.
347     SPLIT_VECTOR_PARAMETERS = false
348
349 [warnings]
350     #Generate a warning about variables which are declared but never
351     #used.  This can be avoided by adding the ‘noref’ keyword in front
352     #of the variable declaration. Additionally a complete section of
353     #unreferenced variables can be opened using ‘#pragma noref 1’ and
354     #closed via ‘#pragma noref 0’.
355
356     UNUSED_VARIABLE = false
357
358
359     #Generate a warning if it is possible that a variable can be used
360     #without prior initialization. Note that this warning is not nec‐
361     #essarily reliable if the initialization happens only under cer‐
362     #tain conditions. The other way is not possible: that the warning
363     #is not generated when uninitialized use is possible.
364
365     USED_UNINITIALIZED = false
366
367
368     #Generate an error when an unrecognized control sequence in a
369     #string is used. Meaning: when there's a character after a back‐
370     #slash in a string which has no known meaning.
371
372     UNKNOWN_CONTROL_SEQUENCE = false
373
374
375     #Warn when using special extensions which are not part of the
376     #selected standard.
377
378     EXTENSIONS = false
379
380
381     #Generally QC compilers ignore redeclaration of fields. Here you
382     #can optionally enable a warning.
383
384     FIELD_REDECLARED = false
385
386
387     #Functions which aren't of type void will warn if it possible to
388     #reach the end without returning an actual value.
389
390     MISSING_RETURN_VALUES = false
391
392
393     #Warn about a function call with an invalid number of parameters.
394
395     INVALID_PARAMETER_COUNT = false
396
397
398     #Warn when a locally declared variable shadows variable.
399
400     LOCAL_SHADOWS = false
401
402
403     #Warn when the initialization of a local variable turns the vari‐
404     #able into a constant. This is default behaviour unless
405     #-finitialized-nonconstants is used.
406
407     LOCAL_CONSTANTS = false
408
409
410     #There are only 2 known global variables of type void:
411     #‘end_sys_globals’ and ‘end_sys_fields’.  Any other void-variable
412     #will warn.
413
414     VOID_VARIABLES = false
415
416
417     #A global function which is not declared with the ‘var’ keyword is
418     #expected to have an implementing body, or be a builtin. If nei‐
419     #ther is the case, it implicitly becomes a function pointer, and a
420     #warning is generated.
421
422     IMPLICIT_FUNCTION_POINTER = false
423
424
425     #Currently there's no way for an in QC implemented function to
426     #access variadic parameters. If a function with variadic parame‐
427     #ters has an implementing body, a warning will be generated.
428
429     VARIADIC_FUNCTION = false
430
431
432     #Generate warnings about ‘$frame’ commands, for instance about
433     #duplicate frame definitions.
434
435     FRAME_MACROS = false
436
437
438     #Warn about statements which have no effect. Any expression which
439     #does not call a function or assigns a variable.
440
441     EFFECTLESS_STATEMENT = false
442
443
444     #The ‘end_sys_fields’ variable is supposed to be a global variable
445     #of type void.  It is also recognized as a field but this will
446     #generate a warning.
447
448     END_SYS_FIELDS = false
449
450
451     #Warn when assigning to a function pointer with an unmatching sig‐
452     #nature. This usually happens in cases like assigning the null
453     #function to an entity's .think function pointer.
454
455     ASSIGN_FUNCTION_TYPES = false
456
457
458     #Show warnings created using the preprocessor's '#warning' directive
459
460     CPP = true
461
462
463     #Warn if there's a preprocessor #if spanning across several files.
464
465     MULTIFILE_IF = true
466
467
468     #Warn about multiple declarations of globals. This seems pretty
469     #common in QC code so you probably do not want this unless you
470     #want to clean up your code.
471
472     DOUBLE_DECLARATION = false
473
474
475     #The combination of const and var is not illegal, however differ‐
476     #ent compilers may handle them differently. We were told, the
477     #intention is to create a function-pointer which is not assigna‐
478     #ble.  This is exactly how we interpret it. However for this
479     #interpretation the ‘var’ keyword is considered superfluous (and
480     #philosophically wrong), so it is possible to generate a warning
481     #about this.
482
483     CONST_VAR = true
484
485
486     #Warn about multibyte character constants, they do not work right
487     #now.
488
489     MULTIBYTE_CHARACTER = false
490
491
492     #Warn if a ternary expression which contains a comma operator is
493     #used without enclosing parenthesis, since this is most likely not
494     #what you actually want. We recommend the -fcorrect-ternary
495     #option.
496
497     TERNARY_PRECEDENCE = false
498
499
500     #Warn when encountering an unrecognized ‘#pragma’ line.
501
502     UNKNOWN_PRAGMAS = true
503
504
505     #Warn about unreachable code. That is: code after a return state‐
506     #ment, or code after a call to a function marked as 'noreturn'.
507
508     UNREACHABLE_CODE = true
509
510
511     #Enable some warnings added in order to help debugging in the com‐
512     #piler.  You won't need this.
513
514     DEBUG = false
515
516
517     #Warn on an unknown attribute. The warning will inlclude only the
518     #first token inside the enclosing attribute-brackets. This may
519     #change when the actual attribute syntax is better defined.
520
521     UNKNOWN_ATTRIBUTE = true
522
523
524     #Warn when using reserved names such as ‘nil’.
525
526     RESERVED_NAMES = true
527
528
529     #Warn about global constants (using the ‘const’ keyword) with no
530     #assigned value.
531
532     UNINITIALIZED_CONSTANT = true
533
534
535     #Warn about global variables with no initializing value. This is
536     #off by default, and is added mostly to help find null-values
537     #which are supposed to be replaced by the untyped 'nil' constant.
538
539     UNINITIALIZED_GLOBAL = true
540
541
542     #Warn when a variables is redeclared with a different qualifier.
543     #For example when redeclaring a variable as 'var' which was previ‐
544     #ously marked 'const'.
545
546     DIFFERENT_QUALIFIERS = true
547
548
549     #Similar to the above but for attributes like ‘[[noreturn]]’.
550
551     DIFFERENT_ATTRIBUTES = true
552
553
554     #Warn when a function is marked with the attribute "[[depre‐
555     #cated]]". This flag enables a warning on calls to functions
556     #marked as such.
557
558     DEPRECATED = true
559
560
561     #Warn about possible mistakes caused by missing or wrong parenthe‐
562     #sis, like an assignment in an 'if' condition when there's no
563     #additional set of parens around the assignment.
564
565     PARENTHESIS = true
566
567
568     #When passing variadic parameters via ...(N) it can happen that
569     #incompatible types are passed to functions. This enables several
570     #warnings when static typechecking cannot guarantee consistent
571     #behavior.
572
573     UNSAFE_TYPES = true
574
575
576     #When compiling original id1 QC there is a definition for `break`
577     #which conflicts with the 'break' keyword in GMQCC. Enabling this
578     #print a warning when the definition occurs. The definition is
579     #ignored for both cases.
580
581     BREAKDEF = true
582
583
584     #When compiling original QuakeWorld QC there are instances where
585     #code overwrites constants. This is considered an error, however
586     #for QuakeWorld to compile it needs to be treated as a warning
587     #instead, as such this warning only works when -std=qcc.
588
589     CONST_OVERWRITE = true
590
591
592     #Warn about the use of preprocessor directives inside macros.
593
594     DIRECTIVE_INMACRO = true
595
596
597     #When using a function that is not explicitly defined, the compiler
598     #will search its intrinsics table for something that matches that
599     #function name by appending "__builtin_" to it. This behaviour may
600     #be unexpected, so enabling this will produce a diagnostic when
601     #such a function is resolved to a builtin.
602
603     BUILTINS = true
604
605
606     #When comparing an inexact value such as `1.0/3.0' the result is
607     #pathologically wrong. Enabling this will trigger a compiler warning
608     #on such expressions.
609     INEXACT_COMPARES = true
610
611
612 [optimizations]
613     #Some general peephole optimizations. For instance the code `a = b
614     #+ c` typically generates 2 instructions, an ADD and a STORE. This
615     #optimization removes the STORE and lets the ADD write directly
616     #into A.
617
618     PEEPHOLE = true
619
620
621     #Tail recursive function calls will be turned into loops to avoid
622     #the overhead of the CALL and RETURN instructions.
623
624     TAIL_RECURSION = true
625
626
627     #Make all functions which use neither local arrays nor have locals
628     #which are seen as possibly uninitialized use the same local sec‐
629     #tion.  This should be pretty safe compared to other compilers
630     #which do not check for uninitialized values properly. The problem
631     #is that there's QC code out there which really doesn't initialize
632     #some values. This is fine as long as this kind of optimization
633     #isn't used, but also, only as long as the functions cannot be
634     #called in a recursive manner. Since it's hard to know whether or
635     #not an array is actually fully initialized, especially when ini‐
636     #tializing it via a loop, we assume functions with arrays to be
637     #too dangerous for this optimization.
638
639     OVERLAP_LOCALS = true
640
641
642     #This promotes locally declared variables to "temps". Meaning when
643     #a temporary result of an operation has to be stored somewhere, a
644     #local variable which is not 'alive' at that point can be used to
645     #keep the result. This can reduce the size of the global section.
646     #This will not have declared variables overlap, even if it was
647     #possible.
648
649     LOCAL_TEMPS = true
650
651
652     #Causes temporary values which do not need to be backed up on a
653     #CALL to not be stored in the function's locals-area. With this, a
654     #CALL to a function may need to back up fewer values and thus exe‐
655     #cute faster.
656
657     GLOBAL_TEMPS = true
658
659
660     #Don't generate defs for immediate values or even declared con‐
661     #stants.  Meaning variables which are implicitly constant or qual‐
662     #ified as such using the 'const' keyword.
663
664     STRIP_CONSTANT_NAMES = true
665
666
667     #Aggressively reuse strings in the string section. When a string
668     #should be added which is the trailing substring of an already
669     #existing string, the existing string's tail will be returned
670     #instead of the new string being added.
671     #
672     #For example the following code will only generate 1 string:
673     #
674     #   print("Hello you!\n");
675     #   print("you!\n"); // trailing substring of "Hello you!\n"
676     #
677     #There's however one limitation. Strings are still processed in
678     #order, so if the above print statements were reversed, this opti‐
679     #mization would not happen.
680
681     OVERLAP_STRINGS = true
682
683
684     #By default, all parameters of a CALL are copied into the parame‐
685     #ter-globals right before the CALL instructions. This is the easi‐
686     #est and safest way to translate calls, but also adds a lot of
687     #unnecessary copying and unnecessary temporary values. This opti‐
688     #mization makes operations which are used as a parameter evaluate
689     #directly into the parameter-global if that is possible, which is
690     #when there's no other CALL instruction in between.
691
692     CALL_STORES = true
693
694
695     #Usually an empty RETURN instruction is added to the end of a void
696     #typed function. However, additionally after every function a DONE
697     #instruction is added for several reasons. (For example the qcvm's
698     #disassemble switch uses it to know when the function ends.). This
699     #optimization replaces that last RETURN with DONE rather than
700     #adding the DONE additionally.
701
702     VOID_RETURN = true
703
704
705     #Because traditional QC code doesn't allow you to access individ‐
706     #ual vector components of a computed vector without storing it in
707     #a local first, sometimes people multiply it by a constant like
708     #‘'0 1 0'’ to get, in this case, the y component of a vector. This
709     #optimization will turn such a multiplication into a direct compo‐
710     #nent access. If the factor is anything other than 1, a float-mul‐
711     #tiplication will be added, which is still faster than a vector
712     #multiplication.
713
714     VECTOR_COMPONENTS = true
715
716
717     #For constant expressions that result in dead code (such as a
718     #branch whos condition can be evaluated at compile-time), this
719     #will eliminate the branch and else body (if present) to produce
720     #more optimal code.
721
722     CONST_FOLD_DCE = true
723
724
725     #For constant expressions we can fold them to immediate values.
726     #this option cannot be disabled or enabled, the compiler forces
727     #it to stay enabled by ignoring the value entierly. There are
728     #plans to enable some level of constant fold disabling, but right
729     #now the language can't function without it. This is merley here
730     #as an exercise to the reader.
731
732     CONST_FOLD = true