aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-09-28expr: Skip codegen for unused expression in conditional with constant expressionMichael Forney
This compiles `0 ? e1 : e2` as `e2`, and `1 ? e1 : e2` as `e1` (while still adjusting the type as necessary).
2021-09-28mkexpr: Add a base parameter to mkexprMichael Forney
2021-09-28runtests: Print better result summaryMichael Forney
2021-09-28Skip unnecessary conversion to bool for logical and conditional expressionsMichael Forney
As in ede6a5c9, if an expression is used only to control a jnz, we don't need to convert it to a 0 or 1 value. QBE ignores the upper 32-bits of the argument to jnz, so the conversion is still needed for pointer, long, and floating point types (including float since -0 has non-zero bit representation).
2021-09-14configure: Undefine __PIC__Michael Forney
QBE doesn't emit position-independent code, so we don't want __PIC__ defined if the preprocessor does by default.
2021-09-14driver: Pass -nostdinc on to preprocessorMichael Forney
2021-09-14qbe: Support more aligned types in funccopyMichael Forney
We don't have any of these currently, but it's easier to support than to error out.
2021-09-14qbe: Fix temporary type for < 8 byte aligned struct copiesMichael Forney
2021-09-13Add test for string concatenation corner caseMichael Forney
2021-09-13Revert "Add stringconcat function to concatenate adjacent string literals"Michael Forney
This reverts commit c16f07acf655b9f4fb006d8256b4027fb5a13aa8. This incorrectly allows octal escapes to span between adjacent string literals (e.g. "\0" "1" is not the same as "\01").
2021-09-13qbe, init: Handle prefixed string literalsNihal Jere
2021-09-13Make string literal data unsigned charMichael Forney
2021-09-09CI: Switch to debian/stableMichael Forney
2021-09-07decl: Include location for _Complex/_Atomic error messagesMichael Forney
2021-09-07expr: Fix varargs again and add more testsMichael Forney
2021-09-07qbe: Add default cases to avoid uninitialized warningMichael Forney
2021-09-06Add config.mk to .gitignoreMichael Forney
2021-09-06configure: Drop -E from preprocesscmdMichael Forney
We are already using cpp here, so -E is redundant.
2021-09-06driver: Pass -P through to the pre-processorMichael Forney
Since we no longer pass -P to cpp ourselves, we need to pass it through when it appears on the command-line instead of ignoring it.
2021-09-06decl: Relax restrictions for 0-length array memberMichael Forney
Zero-length array members are quite common in linux UAPI headers, where they don't follow the restrictions of flexible array members. Since they are non-standard, relax the error checking for them, rather than considering them the same as a flexible array member.
2021-09-06Fix type-checking of va_list arguments to varargs built-insMichael Forney
If the argument was a function parameter, its type has already been adjusted. So on x86_64, we can't just ignore the automatic array-to-pointer conversion, since it was never a pointer to begin with. Instead, keep track of the adjusted va_list type, and check that the arguments to varargs built-ins match that type.
2021-09-06Add tests for char/wchar_t signednessMichael Forney
2021-09-04Use architecture-specific va_list typeMichael Forney
Previously, cproc effectively used used typedef struct { /* 32 bytes, 8-byte aligned */ } __builtin_va_list[1]; However, this is not quite correct for x86_64 nor aarch64, though it was close enough for both to work in most cases. In actuality, for x86_64 we want typedef struct { /* 24 bytes, 8-byte aligned */ } __builtin_va_list[1]; and for aarch64 we want typedef struct { /* 32 bytes, 8-byte aligned */ } __builtin_va_list; The difference only appears when the size of va_list matters, or when va_list is passed as a parameter. However, the former is not often the case, and the aarch64 ABI replaces aggregate arguments with pointers to caller-allocated memory, which is quite similar to arrays decaying to pointers in C except that the struct is not copied. Additionally, riscv64 simply uses typedef void *__builtin_va_list; which again has a different size and calling convention. To fix this, make the __builtin_va_list type architecture-specific and use architecture-specific tests for varargs-related functionality.
2021-09-04Prepare for supporting architecture-specific va_list typeMichael Forney
2021-09-04test: Add the ability to have architecture-specific testsMichael Forney
2021-09-03main: Add specialized error message for stray ';' at toplevelMichael Forney
2021-09-03pp: Set location column to 1 after line directiveMichael Forney
2021-09-03scan: Improve accuracy of token locationsMichael Forney
The location should not include preceding whitespace and was off by one.
2021-09-02qbe: Error on use of long double rather than trigger assertionMichael Forney
2021-09-02pp: Implement #line directives and gcc line markersMichael Forney
Fixes #66.
2021-08-30Update qbe submoduleMichael Forney
2021-08-20utf: Add missing return for invalid UTF-8Michael Forney
2021-08-15utf: Use C99 types for UTF-16/32 character instead of C11 char16_t/char32_tMichael Forney
Some operating systems do not support uchar.h, and glibc only defines char16_t/char32_t for GNU C compilers.
2021-08-15decl: Don't accept abstract function declarator when disallowedMichael Forney
When declarator() is called with allowabstract == false, the caller can assume that it will always return the identifier being declared. However, abstract function declarators were incorrectly accepted in this case with name set to NULL instead of erroring out due to invalid syntax. To fix this, only skip forward to function declarator parsing for abstract declarators, since this is the only case where we can't immediately tell whether we have a parenthesized declarator or a function declarator. Fixes #74.
2021-07-06Add functions for encoding/decoding UTF-8/16Michael Forney
These will be needed to implement wide string literals.
2021-07-05qbe: StyleMichael Forney
2021-07-05qbe: Fix bitfield sign extension with types shorter than intMichael Forney
2021-07-02qbe: Mark static const data as suchMichael Forney
2021-07-02qbe: Remove more unnecessary copy instructionsMichael Forney
Now that we don't track QBE types within values, we don't have to worry about generating incorrect SSA when passing an 'l' value to a function taking a 'w'. So we can just return the source value instead of emitting a dummy copy instruction.
2021-07-02qbe: Remove repr from struct value and use per-instruction class insteadMichael Forney
This way we avoid leaking backend-specific details of type representation outside qbe.c. It also facilitates some future simplifications.
2021-07-01qbe: Remove unnecessary distinction between loaduw and loadswMichael Forney
We always store the result to a w temporary, so there is no difference. In fact, QBE provides loadw as an alias for loadsw precisely for this reason.
2021-07-01decl: Check that the flexible array member (if present) is lastMichael Forney
2021-07-01decl: Disallow members with incomplete typesMichael Forney
Make an exception for flexible array members, though we should also check that the flexible array member, if any, is last.
2021-07-01decl: Check that struct/union has at least one memberMichael Forney
2021-07-01qbe: Reorganize struct value to reduce size to 8 bytesMichael Forney
Make the ID an unsigned int. This will make it small enough to efficiently pass struct value by value. It also simplifies things slightly.
2021-06-30stmt: Check that controlling expression is a scalar, and drop unneeded ↵Michael Forney
conversion The conversion is only needed for floating types. QBE isn't able to optimize it away for integer types yet, so removing this unnecessary conversion has a substantial performance benefit.
2021-06-30qbe: Move aggregate copying to separate functionMichael Forney
2021-06-30qbe: Remove before unnecessary adds during copyMichael Forney
2021-06-28Add stringconcat function to concatenate adjacent string literalsMichael Forney
This function also ensures that the string prefixes (if any) are compatible. It should make it easier to implement wide string support.
2021-06-16Add initial NetBSD supportMichael Forney