summary refs log tree commit diff
path: root/parse.c
AgeCommit message (Collapse)Author
2023-08-18file,loc become dbgfile,dbglocQuentin Carbonneaux
2023-06-07parseline() tweaksQuentin Carbonneaux
2023-06-06implement line number info trackingThomas Bracht Laumann Jespersen
Support "file" and "loc" directives. "file" takes a string (a file name) assigns it a number, sets the current file to that number and records the string for later. "loc" takes a single number and outputs location information with a reference to the current file.
2023-04-02print prefix for thread-local symbolsQuentin Carbonneaux
2023-03-22rename blknew() to newblk()Quentin Carbonneaux
This is consistent with newtmp() and newcon().
2022-12-25new UNDEF RefQuentin Carbonneaux
Crashing loads of uninitialized memory proved to be a problem when implementing unions using qbe. This patch introduces a new UNDEF Ref to represent data that is known to be uninitialized. Optimization passes can make use of it to eliminate some code. In the last compilation stages, UNDEF is treated as the constant 0xdeaddead.
2022-12-14new blit instructionQuentin Carbonneaux
2022-12-12new rsval() helper for signed RefsQuentin Carbonneaux
The .val field is signed in RSlot. Add a new dedicated function to fetch it as a signed int.
2022-11-27new hlt block terminatorQuentin Carbonneaux
It is handy to express when the end of a block cannot be reached. If a hlt terminator is executed, it traps the program. We don't go the llvm way and specify execution semantics as undefined behavior.
2022-11-22use a new struct for symbolsQuentin Carbonneaux
Symbols are a useful abstraction that occurs in both Con and Alias. In this patch they get their own struct. This new struct packages a symbol name and a type; the type tells us where the symbol name must be interpreted (currently, in gobal memory or in thread-local storage). The refactor fixed a bug in addcon(), proving the value of packaging symbol names with their type.
2022-10-08"rel" fields become "reloc"Quentin Carbonneaux
2022-10-08add support for thread-local storageQuentin Carbonneaux
The apple targets are not done yet.
2022-10-03flag bad vastart usesQuentin Carbonneaux
2022-10-03fix case of Pool constantsQuentin Carbonneaux
2022-10-03parse sb,ub,sh,uh abi typesQuentin Carbonneaux
2022-09-15Fix parsing of multiple globals in datadefEmber Sawady
Eg. data $a = { w $b $c }
2022-07-01Reject multiple section definition for a symbolRoberto E. Vargas Caballero
2022-07-01Add qbe identifier in error stringsRoberto E. Vargas Caballero
When qbe is used with other tools is a bit hard to identify what is the tool that is generating the error. Adding an identifier at the beginning of the line makes much easier to identify the tool generating the error.
2022-04-11do not leak type fieldsQuentin Carbonneaux
Thanks to Daniel Xu for reporting.
2022-03-08flag types defined as unionsQuentin Carbonneaux
The risc-v abi needs to know if a type is defined as a union or not. We cannot use nunion to obtain this information because the risc-v abi made the unfortunate decision of treating union { int i; } differently from int i; So, instead, I introduce a single bit flag 'isunion'.
2022-02-24parse: allow string after first data itemPaul Ouellette
2022-02-11gas: put zero data into .bss by defaultMichael Forney
This allows frontends to use BSS generically, without knowledge of platform-dependent details.
2022-02-02shared linkage logic for func/dataQuentin Carbonneaux
2022-01-28update token hash paramsQuentin Carbonneaux
2022-01-23increase token limit to 255Bor Grošelj Simić
2022-01-23Add a negation instructionEyal Sawady
Necessary for floating-point negation, because `%result = sub 0, %operand` doesn't give the correct sign for 0/-0.
2021-11-22reuse previous address constants in fold()Michael Forney
parseref() has code to reuse address constants, but this is not done in other passes such as fold or isel. Introduce a new function newcon() which takes a Con and returns a Ref for that constant, and use this whenever creating address constants. This is necessary to fix folding of address constants when one operand is already folded. For example, in %a =l add $x, 1 %b =l add %a, 2 %c =w loadw %b %a and %b were folded to $x+1 and $x+3 respectively, but then the second add is visited again since it uses %a. This gets folded to $x+3 as well, but as a new distinct constant. This results in %b getting labeled as bottom instead of either constant, disabling the replacement of %b by a constant in subsequent instructions (such as the loadw).
2021-10-22make variadic args explicitQuentin Carbonneaux
Some abis, like the riscv one, treat arguments differently depending on whether they are variadic or not. To prepare for the upcomming riscv target, we change the variadic call syntax and give meaning to the location of the '...' marker. # new syntax %ret =w call $f(w %regular, ..., w %variadic) By nature of their abis, the change is backwards compatible for existing targets.
2021-09-20parse: fix loadw when assigned to l temporaryMichael Forney
The documentation states that loadw is syntactic sugar for loadsw, but it actually got parsed as Oload. If the result is an l temporary, Oload behaves like Oloadl, not Oloadsw. To fix this, parse Tloadw as Oloadsw explicitly.
2021-08-23parsefields: fix padding calculationDrew DeVault
This was causing issues with aggregate types. A simple reproduction is: type :type.1 = align 8 { 24 } type :type.2 = align 8 { w 1, :type.1 1 } The size of type.2 should be 32, adding only 4 bytes of padding between the first and second field. Prior to this patch, 20 bytes of padding was added instead, causing the type to have a size of 48. Signed-off-by: Drew DeVault <sir@cmpwn.com>
2021-07-28fix buffer overflow in parser (afl)Quentin Carbonneaux
Reported by Alessandro Mantovani. Overly long function names would trigger out-of-bounds accesses.
2021-03-02add data $name = section "section" ...Drew DeVault
This allows you to explicitly specify the section to emit the data directive for, allowing for sections other than .data: for example, .bss or .init_array.
2020-08-06Move NPred in parse.c and decrease itMichael Forney
This now only limits the number of arguments when parsing the input SSA, which is usually a small fixed size (depending on the frontend).
2020-08-06Use a dynamic array for phi argumentsMichael Forney
2019-05-15Allow specifying literal global namesMichael Forney
2019-03-14Rearrange the fields in Ins so the bit-fields get packed togetherMichael Forney
2019-03-08use a hash table to parse temporariesQuentin Carbonneaux
2018-04-26more compiler warnings...Quentin Carbonneaux
2018-04-26Fix compiler warnings.Emil Skoeldberg
Compiler warned about comparison between signed and unsigned values.
2017-05-17free the typ vector at the end of parse()Quentin Carbonneaux
2017-05-17intern symbol namesQuentin Carbonneaux
Symbols in the source file are still limited in length because the rest of the code assumes that strings always fit in NString bytes. Regardless, there is already a benefit because comparing/copying symbol names does not require using strcmp()/strcpy() anymore.
2017-04-16minor changes for env parameterQuentin Carbonneaux
Since the environment can only be of type `l`, do not require to write it down. I also tightened the type information of the `pare` and `arge` instructions.
2017-04-08new arm64 backend, yeepeeQuentin Carbonneaux
2017-04-08rework storage of typesQuentin Carbonneaux
The arm64 ABI needs to know precisely what floating point types are being used, so we need to store that information. I also made typ[] a dynamic array.
2017-04-08prepare for multi-targetQuentin Carbonneaux
This big diff does multiple changes to allow the addition of new targets to qbe. The changes are listed below in decreasing order of impact. 1. Add a new Target structure. To add support for a given target, one has to implement all the members of the Target structure. All the source files where changed to use this interface where needed. 2. Single out amd64-specific code. In this commit, the amd64 target T_amd64_sysv is the only target available, it is implemented in the amd64/ directory. All the non-static items in this directory are prefixed with either amd64_ or amd64_sysv (for items that are specific to the System V ABI). 3. Centralize Ops information. There is now a file 'ops.h' that must be used to store all the available operations together with their metadata. The various targets will only select what they need; but it is beneficial that there is only *one* place to change to add a new instruction. One good side effect of this change is that any operation 'xyz' in the IL now as a corresponding 'Oxyz' in the code. 4. Misc fixes. One notable change is that instruction selection now generates generic comparison operations and the lowering to the target's comparisons is done in the emitter. GAS directives for data are the same for many targets, so data emission was extracted in a file 'gas.c'. 5. Modularize the Makefile. The Makefile now has a list of C files that are target-independent (SRC), and one list of C files per target. Each target can also use its own 'all.h' header (for example to define registers).
2017-04-08fix bug in union size computationQuentin Carbonneaux
The size of a union is the size of the largest element aligned with the largest alignment. For example, the size of the following union is 16, not 13 (as returned before this patch). union { char c[13]; int i; };
2017-02-27fix int parsingQuentin Carbonneaux
The spec says that numbers can be arbitrarily big, and only the last 64 bits will be taken into consideration. Calling sscanf does not implement this, so I wrote an ad-hoc function.
2017-02-17stricter class constraints for store & vastartQuentin Carbonneaux
2017-02-15add support for closure callsQuentin Carbonneaux
Compiling languages with closures often requires passing an extra environment parameter to the called function. One solution is to use a convention, and reserve, say, the first argument for that purpose. However, that makes binding to C a little less smooth. Alternatively, QBE now provides a way to remain fully ABI compatible with C by having a "hidden" environment argument (marked with the keyword 'env'). Calling a function expecting an environment from C will make the contents of the environment undefined, but the normal arguments will be passed without alteration. Conversely, calling a C function like it is a closure by passing it an environemnt will work smoothly.
2017-02-14minor cleanup in all.hQuentin Carbonneaux