Commit graph

274 commits

Author SHA1 Message Date
Wolfgang (Blub) Bumiller
b2315777d1 cache the IMMEDIATE string in the builder directly 2012-08-24 19:52:06 +02:00
Wolfgang (Blub) Bumiller
74cb075665 cache filenames as such instead of using code_cachedstring 2012-08-24 19:44:29 +02:00
Wolfgang (Blub) Bumiller
bdffa662b6 not using cachedstring on generated string values anymore, it's not the IR's job 2012-08-24 19:08:33 +02:00
Wolfgang (Blub) Bumiller
04dca17cff ir_value now checks if a name was specified 2012-08-24 18:14:39 +02:00
Wolfgang (Blub) Bumiller
2524d9c31b ir: don't require a label on a block 2012-08-24 18:03:57 +02:00
Wolfgang (Blub) Bumiller
f042068aab ir_value_life_merge_into: fix a possible underflow 2012-08-24 15:06:30 +02:00
Wolfgang (Blub) Bumiller
5e4b8846d1 slight change to ir_value_dump_life; fixing ir_value_life_merge_into: TODO test this seperately, all cases 2012-08-23 22:07:32 +02:00
Wolfgang (Blub) Bumiller
76b0eb0cb7 Don't add DEF_SAVEGLOBAL for locals actually... 2012-08-23 18:32:11 +02:00
Wolfgang (Blub) Bumiller
b2cb612c70 Adding DEF_SAVEGLOBAL, marking globals as to-be-saved now, for real support of quicksaving 2012-08-23 18:28:05 +02:00
Wolfgang (Blub) Bumiller
f9746a59ae it's not the IR's job to fail when a local of the same name is created twice... 2012-08-23 17:22:13 +02:00
Wolfgang (Blub) Bumiller
7e3ccf4626 MUL_VF and MUL_FV get their special life-range handling 2012-08-22 18:51:32 +02:00
Wolfgang (Blub) Bumiller
9296257c71 fix the functiondef's .locals... 2012-08-22 16:29:27 +02:00
Wolfgang (Blub) Bumiller
5d884bcb45 for liferange calc: the block we start from must tart with an empty set of living values 2012-08-22 16:20:26 +02:00
Wolfgang (Blub) Bumiller
eb86a3d7a3 fixing some debug output 2012-08-22 16:19:56 +02:00
Wolfgang (Blub) Bumiller
b2efef9be2 more info with -dump 2012-08-22 16:04:06 +02:00
Wolfgang (Blub) Bumiller
f6e5396f9f First generate the globals, then the fields, so the defs have the correct layout for quake 2012-08-22 14:15:49 +02:00
Wolfgang (Blub) Bumiller
5f2fc64498 -Wimplicit-function-pointer, functions without bodies still have a global function variable and thus are function pointers, though this shouldn't really be used, thus -Wimplicit-function-pointer is on by default 2012-08-22 12:37:06 +02:00
Wolfgang (Blub) Bumiller
5390782d9b Don't try to generate function code for functions without bodies 2012-08-22 12:33:24 +02:00
Wolfgang (Blub) Bumiller
1f32fe1d8a Since we currently append AINSTR_END to the end of all functions for debugging purposes, and darkplaces complains when the very last statement isn't INSTR_DONE or INSTR_RETURN, we append an INSTR_DONE at the very end 2012-08-21 18:12:01 +02:00
Wolfgang (Blub) Bumiller
9eb9c99e72 Do not generate an OFS_RETURN variable, the IR doesn't need to know it as such 2012-08-21 16:08:23 +02:00
Wolfgang (Blub) Bumiller
19b66800ae TYPE_FUNCTION values which are not constant are now allowed to be generated, they are function pointers. 2012-08-21 16:01:28 +02:00
Wolfgang (Blub) Bumiller
8f4333df30 right... instead of checking for end_sys_globals twice, maybe ACTUALLY check for end_sys_fields too... 2012-08-21 15:50:53 +02:00
Wolfgang (Blub) Bumiller
93856bf151 -Wvoid-variables, QC uses 2 special void-typed variables: end_sys_globals and .end_sys_fields. However if for some reason someone wants more, we still allow them to be code-generated, but by default warn about them by default 2012-08-21 15:49:53 +02:00
Wolfgang (Blub) Bumiller
fe3b1b2e8d ir_values which are members of a vector should know that, so that liferange calc can use the vector rather than the member 2012-08-19 21:37:29 +02:00
Wolfgang (Blub) Bumiller
9420c01538 added -Wused-uninitialized and warning about variables which may be used without being initialized 2012-08-19 21:26:14 +02:00
Wolfgang (Blub) Bumiller
ede98f5521 Removing the old LIFE_RANGE_WITHOUT_LAST_READ support 2012-08-19 21:00:42 +02:00
Wolfgang (Blub) Bumiller
211b11f154 strip the newlines out of ir error messages, they're added by the msgprint routine 2012-08-19 20:45:26 +02:00
Wolfgang (Blub) Bumiller
c2925b61f2 add the type for the invalid-type-for-global message 2012-08-19 20:37:10 +02:00
Wolfgang (Blub) Bumiller
af3d9e0bdf ir_value_set_string needs to use a strdup which doesn't return NULL for an emptystring 2012-08-19 20:35:51 +02:00
Wolfgang (Blub) Bumiller
14210a62ef functions which have no living values but store_return values may cause the allocator to be run with no allocations being made - in this case we shouldn't try accessing the empty array and simply exit the allocator 2012-08-19 19:54:15 +02:00
Wolfgang (Blub) Bumiller
9aa86bee16 Removing old commented-out code 2012-08-19 19:01:31 +02:00
Wolfgang (Blub) Bumiller
ece880d5e3 missing initializer 2012-08-19 18:03:56 +02:00
Wolfgang (Blub) Bumiller
e606913187 IR generation: for functions: first generate all defs, then the code, so access to prototyped functions doesn't result in NULL code 2012-08-19 18:00:53 +02:00
Wolfgang (Blub) Bumiller
387335bb4d STOREP instructions' first operand has to be considered a read-operand, not a write operand, otherwise the life ranges will be wrong, and the value itself IS only read, not written to 2012-08-19 17:46:10 +02:00
Wolfgang (Blub) Bumiller
332d306723 for void returning functions we can use store_return to avoid a useless store after it 2012-08-19 17:42:22 +02:00
Wolfgang (Blub) Bumiller
e1ffa04bc2 calls for now use store_value since we don't properly deal with its liferange yet; fixing some local-alloation things; taking call parameters into account in ir_block_life_propagate 2012-08-19 17:29:36 +02:00
Wolfgang (Blub) Bumiller
611973bc59 Fixing a misleading error message in ir.c 2012-08-19 16:59:59 +02:00
Wolfgang (Blub) Bumiller
4d335c8704 ir: fix bug that functions without declared locals would put temps at position zero ... 2012-08-19 16:49:24 +02:00
Wolfgang (Blub) Bumiller
6d84010dc4 ast_return should accept NULL as value to create a simple 'return' without a value 2012-08-18 17:58:38 +02:00
Wolfgang (Blub) Bumiller
9eede6d303 fix a MEM_VECTOR_CLEAR to be done AFTER clearing the contents... 2012-08-18 15:53:35 +02:00
Wolfgang (Blub) Bumiller
39f37262db add LOAD for TYPE_FUNCTION as LOAD_FNC so we can actually access function fields 2012-08-18 12:44:17 +02:00
Wolfgang (Blub) Bumiller
32c095b622 Fix a possible endless loop in ir_values_overlap 2012-08-16 16:38:36 +02:00
Wolfgang (Blub) Bumiller
d9da4d11b1 Shutup visual studio... 2012-08-16 12:32:01 +02:00
Wolfgang (Blub) Bumiller
9430332ae5 ir.c: strcmp->memcpy 2012-08-15 17:02:48 +02:00
Wolfgang (Blub) Bumiller
abc574289f fix wrong count on IF/IFNOT jumps 2012-08-14 16:48:20 +02:00
Wolfgang (Blub) Bumiller
722be55fa9 removing all direct 'printfs' from ast and ir, replaced by the error interface 2012-08-14 13:14:32 +02:00
Wolfgang (Blub) Bumiller
e3b3c2efe3 Merge branch 'master' into blub/parser 2012-08-13 15:25:40 +02:00
Wolfgang (Blub) Bumiller
633561a730 type_eq_instr[], type_ne_instr[] 2012-08-13 15:25:14 +02:00
Wolfgang (Blub) Bumiller
5680c661a6 adding missing initializer for ir_value's member array 2012-08-12 21:56:53 +02:00
Wolfgang (Blub) Bumiller
0c06f9f650 Merge branch 'master' into blub/parser 2012-08-12 18:45:22 +02:00
Wolfgang (Blub) Bumiller
60a5d8ab4f print error and return NULL when trying to create an invalid member access 2012-08-12 18:44:58 +02:00
Wolfgang (Blub) Bumiller
7e3edea621 fixing the messup of MUL_FV and _VF being swapped - getting rid of additions that really have no place here (YET) (matrix/quaternion types) 2012-08-12 11:34:55 +02:00
Wolfgang (Blub) Bumiller
647582aeb4 merging master 2012-08-12 11:28:52 +02:00
Wolfgang (Blub) Bumiller
b968927074 default case for ir_value_dump's type switch 2012-08-12 11:28:18 +02:00
Wolfgang (Blub) Bumiller
c3cbda8b2b ir_instr_dump to print CALL+paramcountfor calls rather than CALL0 always 2012-08-12 10:19:33 +02:00
Wolfgang (Blub) Bumiller
93d372f222 TYPE_FUNCTION in ir_value_dump to show '(function)' rather than '(void)' 2012-08-12 10:15:27 +02:00
Wolfgang (Blub) Bumiller
2cba6f08fe indentation of ir debug dump functions 2012-08-12 10:14:22 +02:00
Wolfgang (Blub) Bumiller
d68d19dbfd Merging master to handle vector members, fields, and members of vector fields 2012-08-12 10:08:41 +02:00
Wolfgang (Blub) Bumiller
8b168077c7 IR generation of vector-fields put the 'main' vector offset at the wrong position - fixed that 2012-08-11 22:14:45 +02:00
Wolfgang (Blub) Bumiller
c31c59312b ir_block_create_store/p will now honor -fadjust-vector-fields by using STORE_V/STOREP_V instead of _FLD on vector-fields 2012-08-11 19:38:02 +02:00
Wolfgang (Blub) Bumiller
bb1f38de5d also generate _y and _z data for fieldpointers 2012-08-11 19:34:58 +02:00
Wolfgang (Blub) Bumiller
228b3cca41 to support .vector's _y and _z we need to add the global-data pointing to _y and _z... 2012-08-11 19:08:23 +02:00
Wolfgang (Blub) Bumiller
fda4687ece STOREP also has the destination in OPB rather than OPC 2012-08-11 18:06:10 +02:00
Wolfgang (Blub) Bumiller
5f2a775d41 generate address of store_return values created with ir_value_out properly 2012-08-11 17:53:41 +02:00
Wolfgang (Blub) Bumiller
062449ecd6 ir_block_create_store_op checks whether or not the storetype is an SSA value - do not do that for storeP instructions 2012-08-11 16:38:17 +02:00
Wolfgang (Blub) Bumiller
04db054466 -std=gmqcc should add a dot prefix to the globals for fields, the field itself doesn't use the dot prefix for its name though 2012-08-11 16:08:38 +02:00
Wolfgang (Blub) Bumiller
1559dedfd9 ir_value_set_field 2012-08-11 15:41:10 +02:00
Wolfgang (Blub) Bumiller
c1e305088e Merge branch 'master' into blub/bc3 2012-08-11 11:46:59 +02:00
Wolfgang (Blub) Bumiller
9b2e26a189 don't set globaladdr directly, use a setter, the setter will update the member values used for vector access too 2012-08-11 11:45:26 +02:00
Wolfgang (Blub) Bumiller
55743936d9 Merge branch 'master' into blub/bc3 2012-08-10 20:48:42 +02:00
Wolfgang (Blub) Bumiller
9c2e6a2334 Experimental ast_member to access vector members 2012-08-08 14:49:37 +02:00
Wolfgang (Blub) Bumiller
ae251d3914 Merge branch 'master' into blub/bc3 2012-08-08 12:05:08 +02:00
Wolfgang Bumiller
03307a0903 ir_block_create_fieldaddress to pass on fieldtype from its input field 2012-07-28 21:59:34 +02:00
Wolfgang Bumiller
d05bee94d1 code_alloc_field to allocate entityfield data, ir now has ir_builder_create_field - so that globals and fields can be created separately - properly 2012-07-28 21:55:01 +02:00
Wolfgang Bumiller
22e6b8558b Merge branch 'master' into blub/bc3 2012-07-26 23:22:53 +02:00
Wolfgang Bumiller
b4225ea98a INSTR_NOT_* output to opC not opB... 2012-07-26 22:11:46 +02:00
Wolfgang Bumiller
e22d340e23 ast/ir support for unary instructions 2012-07-26 20:45:18 +02:00
Wolfgang Bumiller
aef49d9667 Merge branch 'master' into blub/bc3 2012-07-22 12:21:43 +02:00
Wolfgang Bumiller
9c2c62e82b use type_sizeof in another place where it wasn't 2012-07-22 12:20:06 +02:00
Wolfgang Bumiller
a4617d0e61 ast_function generates parameter locals, ir_function_create_local now allows adding parameters as long as no local variables have been added yet 2012-07-22 12:15:48 +02:00
Wolfgang Bumiller
43897f6e8f store_param storetype, parameter value list added to ast_function 2012-07-22 12:07:30 +02:00
Wolfgang Bumiller
45933d2ce9 ast_binary_new should determine the return type... 2012-07-20 21:42:36 +02:00
Wolfgang Bumiller
7756cb9205 the IR won't create globals of the same name - make names starting with # an exception 2012-07-20 21:36:37 +02:00
Wolfgang Bumiller
071fd32040 Handling some operands, added type_name array 2012-07-20 21:19:30 +02:00
Wolfgang Bumiller
09fa41318d Merge branch 'master' into blub/bc3 2012-07-19 18:06:56 +02:00
Wolfgang Bumiller
fe8457f9ba ir_function_dump to print builtins as such 2012-07-19 18:06:37 +02:00
Wolfgang Bumiller
858854a83e fixing matrix/quaternion constval setters 2012-07-16 12:29:44 +02:00
Wolfgang Bumiller
abdda3ee1b Merge branch 'master' into blub/bc3 2012-07-16 12:28:06 +02:00
Wolfgang Bumiller
d4b2790deb Correct variable name for type_storep_instr 2012-07-16 12:27:58 +02:00
Wolfgang Bumiller
49f3980360 Merging master 2012-07-16 11:40:30 +02:00
Wolfgang Bumiller
478d5ef5ad type_storep_instr: in theory we could use type_store_instr + INSTR_STOREP_F - INSTR_STORE_F, however, this won't work later when TYPE_INTEGER comes in since the _I instructions are at a seperate place 2012-07-16 10:24:35 +02:00
Wolfgang Bumiller
db62b7b3bc Replacing 2 switches to use type_store_instr instead 2012-07-16 10:19:04 +02:00
Wolfgang Bumiller
bef1bdee9e type_sizeof is an array, not a function 2012-07-10 19:29:38 +02:00
Wolfgang Bumiller
8270f37d3c use type_sizeof in some places where previously manual size checking has been done 2012-07-10 19:29:01 +02:00
Wolfgang Bumiller
e9ac1c9e21 First thing: we want quaternions and 4x4 matrices 2012-07-10 19:26:07 +02:00
Wolfgang Bumiller
3987509493 Do not actually return after generating a call, there are other isntructions following 2012-07-04 15:16:02 +02:00
Wolfgang Bumiller
904196e9bb Store the codeaddr of function's ir_values upon generation... 2012-07-04 15:05:09 +02:00
Wolfgang Bumiller
88f2238699 Return that the call was actually generated successfully if it was... 2012-07-04 15:02:55 +02:00
Wolfgang Bumiller
29091971d2 add AINSTR_END to the end of functions so the debug-printing knows when to end... 2012-07-04 13:29:26 +02:00
Wolfgang Bumiller
7245b675b2 Don't die on functions with no variables 2012-07-04 13:16:15 +02:00
Wolfgang Bumiller
ed24ea0cef creating and generating builtin functions, ast-macros for builtins, todo: params 2012-07-03 23:38:38 +02:00
Wolfgang Bumiller
e965ffb9df basic CALL translation: to be refined 2012-07-03 22:47:01 +02:00
Wolfgang Bumiller
e8cc27df5b type_store_instr[] to get an INSTR_STORE_x by type 2012-07-03 22:46:38 +02:00
Wolfgang (Blub) Bumiller
9e094ddeb5 create_call should use store_return as output type for now 2012-06-29 15:40:21 +02:00
Wolfgang (Blub) Bumiller
67b75055b2 adding another storage type: store_return; when generating a CALL, the generator can check the output value's storetype, and if it is NOT store_return, it needs to STORE_x the return value into the output value. 2012-06-29 14:37:12 +02:00
Wolfgang (Blub) Bumiller
856c9d16a5 generating an ir_value for an ir_function at creation now 2012-06-29 13:25:31 +02:00
Wolfgang (Blub) Bumiller
c1ea9cc409 function in the ast now MUST have an output type in their 'next' ast_expression pointer, the IR's outtype of functions is now filled 2012-06-29 13:07:19 +02:00
Wolfgang (Blub) Bumiller
67fa4ce07b ir_builder_create_call to take return type from the ir_value 2012-06-29 12:55:35 +02:00
Wolfgang (Blub) Bumiller
5348708da4 Fix a possibly uninitialized variable 2012-06-28 17:27:02 +02:00
Wolfgang (Blub) Bumiller
9e7143d934 Fixing GMQCC_SUPPRESS_EMPTY_BODY typo 2012-06-28 17:23:01 +02:00
Wolfgang (Blub) Bumiller
01b3f5ef58 ast_call_codegen, ir_block_create_call plus call-related functions, ir_value->outtype TODO: fill outtype in ir_value 2012-06-28 17:21:26 +02:00
Wolfgang (Blub) Bumiller
7363e88cd7 Added a comment about an idea on how to translate calls better. Gotta check some papers for better solutions later 2012-06-28 16:20:31 +02:00
Wolfgang (Blub) Bumiller
2073834b9a ir_instr can now store a list of parameters, will be used for CALLs 2012-06-28 15:50:51 +02:00
Wolfgang (Blub) Bumiller
60542f7df0 generation of COND and JUMP now works 2012-06-25 19:27:50 +02:00
Wolfgang (Blub) Bumiller
21b7005541 ir_function.allocated_locals now contains the number of locals a function requires, renamed code.slot to code.local, makes more sense 2012-06-25 17:43:10 +02:00
Wolfgang (Blub) Bumiller
d69fda7fa1 removing debug output 2012-06-25 17:37:50 +02:00
Wolfgang (Blub) Bumiller
214c063b3f value position allocation, fixing a possible endless loop in ir_values_overlap 2012-06-25 16:06:01 +02:00
Wolfgang (Blub) Bumiller
db7b9a4f96 ir_value_life_merge_into, to merge the liferange of one value into the range of another, testing in test_ir 2012-06-25 14:51:31 +02:00
Wolfgang (Blub) Bumiller
01af44f3c8 ir_function_allocate_locals prototype 2012-06-25 14:14:34 +02:00
Wolfgang (Blub) Bumiller
ebfc73e48a u1 here instead of s1 2012-06-25 13:30:14 +02:00
Wolfgang (Blub) Bumiller
249ecd60db Generate function global, take 2-op instruction operand ordering into account 2012-06-25 11:52:18 +02:00
Wolfgang Bumiller
dc74573fae Print the name, not the struct pointer :S 2012-05-13 14:06:50 +02:00
Wolfgang (Blub) Bumiller
5673267c01 Adding a few error message. 2012-05-09 17:39:17 +02:00
Wolfgang (Blub) Bumiller
dfc0f6fab3 TYPE_VARIANT in codegen, writing code from ast-test 2012-05-09 17:30:08 +02:00
Wolfgang (Blub) Bumiller
61d3a9d1a0 generating block code in a simple naive order for now - the ast / parser should help improving order 2012-05-09 15:03:19 +02:00
Wolfgang (Blub) Bumiller
9d72fa9a03 Checking if mem_a returns NULL in ir_..._new functions 2012-05-09 15:03:19 +02:00
Wolfgang (Blub) Bumiller
f5cbd73768 It's the same TYPE enum... 2012-05-09 15:03:19 +02:00
Wolfgang Bumiller
5ca6f4abca More work on generating code - still not instantiating function-statements, 2 kinds of FIXME comments: relocation and creation of ir_values for ir_functions 2012-05-09 15:03:19 +02:00
Wolfgang Bumiller
c252c7e62b Starting ir_builder_generate - TYPE_FUNCTION still TODO 2012-05-09 15:03:19 +02:00
Wolfgang Bumiller
8bfbe4d619 Preparing to generate code from the IR - code_write should return a bool, and take a filename rather than use program.dat hardcoded 2012-05-09 15:03:19 +02:00
Wolfgang (Blub) Bumiller
e0331ef15f Changing life-range calculation to include the last read because then it doesn't need another vector to keep elements in. In order for this to make sense, the life-range overlap test now returns false if the end of one range _equals_ the beginning of the other, since that's not truly overlapping anymore 2012-05-04 10:20:04 +02:00
Wolfgang (Blub) Bumiller
b5aed08c93 Dump should print a warning if lifepasses don't match... 2012-05-03 14:17:00 +02:00
Wolfgang (Blub) Bumiller
5c385a3c78 naive_phi now recognizes both store_local and store_value as non-global, create_store prints the operand names on an invalid store to a value of store-type store_value 2012-05-03 14:01:56 +02:00
Wolfgang Bumiller
bb7c59c648 Remove 2 unused variables in create_binop - unused since create_general_instruction 2012-05-01 16:45:15 +02:00
Wolfgang Bumiller
22cf7e0a4d Fix missing 'int op;' in load_from_end, accidently removed it together with the other vars whil making it use general_instruction 2012-05-01 16:44:36 +02:00
Wolfgang Bumiller
cde5444f24 create_phi -> store_value, not store_local... phi output cannot be overwritten 2012-05-01 16:27:36 +02:00
Wolfgang Bumiller
0337320054 Reuse general_instr to shorten create_binop 2012-05-01 16:26:25 +02:00
Wolfgang Bumiller
282edea8de Get rid of duplicate code by adding an ir_block_create_general_instr 2012-05-01 16:23:45 +02:00
Wolfgang Bumiller
6ae8a69ab0 ir_block_create_fieldaddress - and fixing operand-numbering in load_from_ent 2012-05-01 16:20:44 +02:00
Wolfgang Bumiller
45651cea8d Implementation of liferange overlap test 2012-05-01 12:40:37 +02:00
Wolfgang Bumiller
ddbd460331 Check for TYPE_FIELD in load_from_ent 2012-05-01 12:14:07 +02:00
Wolfgang Bumiller
18969b1713 style fix 2012-05-01 12:13:04 +02:00
Wolfgang Bumiller
4c38566877 ir_block_create_load_from_ent - long name, I know, but we need to be able to load from pointers too at some point... 2012-05-01 12:12:53 +02:00
Wolfgang Bumiller
5f0800bef6 support TYPE_FIELD in stores; storeP to do a different kind of type checking 2012-05-01 12:05:47 +02:00
Wolfgang Bumiller
340daeabc4 ir_block_create_storep for storing through pointers, the IR does not implicitly create conversions for now when using pointers, but it could 2012-05-01 11:58:52 +02:00
Dale Weiler
c3df4edebd Remove trailing whitespace 2012-04-28 19:03:16 -04:00
Dale Weiler
3e7a8c0e78 All code is now C89/C90 compat 2012-04-28 18:56:09 -04:00
Dale Weiler
05966ee009 Remove trailing whitespace from everything 2012-04-28 16:43:39 -04:00
Dale Weiler
df9a685f61 surpress empty bodies 2012-04-28 15:13:41 -04:00
Wolfgang Bumiller
50f00fb0a7 Adding debug dump functions 2012-04-28 11:50:09 +02:00