aboutsummaryrefslogtreecommitdiff
path: root/qbe.c
AgeCommit message (Collapse)Author
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-02qbe: Error on use of long double rather than trigger assertionMichael Forney
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-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-30qbe: Move aggregate copying to separate functionMichael Forney
2021-06-30qbe: Remove before unnecessary adds during copyMichael Forney
2021-05-02qbe: Use fixed precision of 17 when printing floating point constantsMichael Forney
It appears that some operating systems don't yet support the C11 DBL_DECIMAL_DIG. In order to ensure consistent output no matter the precision of long double (which varies from arch to arch), just use a fixed 17, which is sufficient for IEEE 754 binary64.
2021-04-23Make some static data constMichael Forney
2021-04-21qbe: Print floating point with DBL_DECIMAL_DIG precisionMichael Forney
DECIMAL_DIG may vary from system to system depending on the width of long double, causing one of the tests to fail.
2021-04-08qbe: Remove unnecessary value copy for struct/union typesMichael Forney
Previously, this was needed so that an aggregate type value was updated to be an 'l' type value. However, since 5ff1d2fa the aggregate type name is stored in a separate parameter in IARG/ICALL instructions, so we can just re-use the same pointer value.
2021-04-08qbe: Remove unnecessary extension for relational operandsMichael Forney
The operands are already promoted, so never need to be extended. These extend()s were added in 7d746860 in an attempt to fix a bug related to the comparison of values with type smaller than int. However, the real bug was that the operands should have been promoted to int by usual arithmetic conversions, which was fixed later in a8131372.
2021-04-07qbe: Remove __PRETTY_FUNCTION__ declarationMichael Forney
We no longer define __GNUC__ so we don't have to work around glibc's assert definition anymore.
2021-04-06qbe: Shorten a few overly long linesMichael Forney
2021-03-31qbe: Slight simplificationMichael Forney
2021-03-31qbe: Use second argument of call/arg to store type nameMichael Forney
2021-03-31qbe: Use separate type for block/labelMichael Forney
Labels are no longer used as instruction arguments.
2021-03-31qbe: Switch to fixed-size instruction structMichael Forney
Move jump and phi instructions to struct block, and function arguments to their own instruction. This will facilitate allocating instructions as an array.
2021-03-27qbe: Change value kind naming schemeMichael Forney
2020-05-24qbe: Omit unnecessary add to help QBE's memopt passMichael Forney
2020-01-31qbe: Make non-constant initializer expression a proper errorMichael Forney
2020-01-30Fix links to issue trackerMichael Forney
2019-07-10Remove comment for completed TODOMichael Forney
2019-07-05Specify function name in error messageMichael Forney
2019-07-05qbe: Handle K&R function definition argument promotionMichael Forney
Parameters for K&R function definitions that are affected by default argument promotion are passed as their promoted type, so need to be converted back before storing into memory allocated for the parameter.
2019-07-05qbe: Separate out value conversion from funcexprMichael Forney
2019-07-05Move some functions aroundMichael Forney
2019-06-27qbe: Fix switch statements with 64-bit controlling expressionMichael Forney
2019-05-29Temporarily avoid %a when printing floating constantsMichael Forney
This is C99, but is not supported by fscanf in OpenBSD, so floating constants can't be read back in by QBE.
2019-05-16qbe: Fix error check for invalid objectMichael Forney
The result of funcexpr might be NULL if we are in a dead branch, but this doesn't mean that we had an invalid object.
2019-05-15Implement asm labelsMichael Forney
2019-05-12eval: Keep track of kind of constant expression we are evaluatingMichael Forney
When we are evaluating an arithmetic constant expression, we don't want to indroduce static data definitions for string or compound literals. Fixes #59.
2019-05-10qbe: Fix QBE types for structs containing bit-fieldsMichael Forney
2019-04-27Sign-extend result of bit-field assignmentsMichael Forney
Fixes #51. Thanks to Andrew Chambers for the bug report and test case.
2019-04-25qbe: Error out when va_arg is called with non-scalar typeMichael Forney
2019-04-24Use a common member for expression baseMichael Forney
2019-04-24Use a common member for expression opMichael Forney
2019-04-24Free function call argument listsMichael Forney
2019-04-24Free functions when we're done with themMichael Forney
2019-04-24qbe: Make sure generated code doesn't depend on argument evaluation orderMichael Forney
It would be correct in any order, but this is a bit simpler and guarantees the same output.
2019-04-23Fix integer promotion on bit-fieldsMichael Forney
Fixes #47.
2019-04-21Keep track of type properties in typeMichael Forney
2019-04-20Make basic types have their own kindMichael Forney
2019-04-18Fix potential overflow of bit-field initializers into following memberMichael Forney
Fixes #46. Thanks to Andrew Chambers for the bug report.
2019-04-17Merge map.h and tree.h into util.hMichael Forney
2019-04-17Just use a single mapkey functionMichael Forney