Previously, ast transformations were performed informally as ad-hoc modifications to the generated C source code. In this commit, the same transformations are performed by rewriting the ast prior to code generation time. The most significant new transformer is transform_assignment_list. This transforms assignments such as: a, b, c = f(b, c, d) To: a = f(&b, &c, d) The former syntax is used frequently in the manual's description of FPU-related instructions.
97 lines
2.2 KiB
C
97 lines
2.2 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
struct sr_bits {
|
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
uint32_t t : 1;
|
|
uint32_t s : 1;
|
|
uint32_t _res0 : 2;
|
|
uint32_t imask : 4;
|
|
uint32_t _res1 : 3;
|
|
uint32_t q : 1;
|
|
uint32_t m : 1;
|
|
uint32_t _res2 : 5;
|
|
uint32_t fd : 1;
|
|
uint32_t _res3 : 12;
|
|
uint32_t bl : 1;
|
|
uint32_t rb : 1;
|
|
uint32_t md : 1;
|
|
uint32_t _res4 : 1;
|
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
uint32_t _res4 : 1;
|
|
uint32_t md : 1;
|
|
uint32_t rb : 1;
|
|
uint32_t bl : 1;
|
|
uint32_t _res3 : 12;
|
|
uint32_t fd : 1;
|
|
uint32_t _res2 : 5;
|
|
uint32_t m : 1;
|
|
uint32_t q : 1;
|
|
uint32_t _res1 : 3;
|
|
uint32_t imask : 4;
|
|
uint32_t _res0 : 2;
|
|
uint32_t s : 1;
|
|
uint32_t t : 1;
|
|
#else
|
|
# error "unsupported endianness"
|
|
#endif
|
|
};
|
|
|
|
|
|
struct fpscr_bits {
|
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
uint32_t rm : 1;
|
|
uint32_t _res0 : 1;
|
|
uint32_t flag_inexact : 1;
|
|
uint32_t flag_underflow : 1;
|
|
uint32_t flag_overflow : 1;
|
|
uint32_t flag_division_by_zero : 1;
|
|
uint32_t flag_invalid_operation : 1;
|
|
uint32_t enable_inexact : 1;
|
|
uint32_t enable_underflow : 1;
|
|
uint32_t enable_overflow : 1;
|
|
uint32_t enable_division_by_zero : 1;
|
|
uint32_t enable_invalid : 1;
|
|
uint32_t cause_inexact : 1;
|
|
uint32_t cause_underflow : 1;
|
|
uint32_t cause_overflow : 1;
|
|
uint32_t cause_division_by_zero : 1;
|
|
uint32_t cause_invalid : 1;
|
|
uint32_t cause_fpu_error : 1;
|
|
uint32_t dn : 1;
|
|
uint32_t pr : 1;
|
|
uint32_t sz : 1;
|
|
uint32_t fr : 1;
|
|
uint32_t _res1 : 10;
|
|
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
|
uint32_t _res1 : 10;
|
|
uint32_t fr : 1;
|
|
uint32_t sz : 1;
|
|
uint32_t pr : 1;
|
|
uint32_t dn : 1;
|
|
uint32_t cause_fpu_error : 1;
|
|
uint32_t cause_invalid : 1;
|
|
uint32_t cause_division_by_zero : 1;
|
|
uint32_t cause_overflow : 1;
|
|
uint32_t cause_underflow : 1;
|
|
uint32_t cause_inexact : 1;
|
|
uint32_t enable_invalid : 1;
|
|
uint32_t enable_division_by_zero : 1;
|
|
uint32_t enable_overflow : 1;
|
|
uint32_t enable_underflow : 1;
|
|
uint32_t enable_inexact : 1;
|
|
uint32_t flag_invalid_operation : 1;
|
|
uint32_t flag_division_by_zero : 1;
|
|
uint32_t flag_overflow : 1;
|
|
uint32_t flag_underflow : 1;
|
|
uint32_t flag_inexact : 1;
|
|
uint32_t _res0 : 1;
|
|
uint32_t rm : 1;
|
|
#else
|
|
# error "unsupported endianness"
|
|
#endif
|
|
};
|
|
|