aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/backend/rust-compile-context.h
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-12-16 10:23:26 +0000
committerGitHub <noreply@github.com>2021-12-16 10:23:26 +0000
commit768f926074a27a7b1a2179613eeeb8291648b8a7 (patch)
treea696b3458140310c223e519b0b53d4481dc2c1de /gcc/rust/backend/rust-compile-context.h
parent3629645386ad503606f29f95c2e16d0600df6e20 (diff)
parente0588300adc00872b0e818477dba614348d2cb02 (diff)
downloadgcc-768f926074a27a7b1a2179613eeeb8291648b8a7.zip
gcc-768f926074a27a7b1a2179613eeeb8291648b8a7.tar.gz
gcc-768f926074a27a7b1a2179613eeeb8291648b8a7.tar.bz2
Merge #834
834: Add enum code generation r=philberty a=philberty This adds a naieve first pass approach to enum type code generation. The original idea was to use GCC's QUAL_UNION_TYPE but I have ran into issues with the DECL_QUALIFIER as my understanding of how this works is incorrect. This takes an enum such as: ```rust enum AnEnum { A, B, C (char), D (x: i64, y: i64), } ``` And turns this into one big union consisting of all fields as RECORD_TYPES. ```c union AnEnum { record A { RUST$ENUM$DISR }; record B { RUST$ENUM$DISR }; record C { RUST$ENUM$DISR, char }; record D { RUST$ENUM$DISR, i64, i64}; } ``` see: https://github.com/bminor/binutils-gdb/blob/527b8861cd472385fa9160a91dd6d65a25c41987/gdb/dwarf2/read.c#L9010-L9241 With the RUST$ENUM$DISR being the first field in all of the records this means the alignment allows for indirect memory access of the struct to use it as a qualifier field to figure out which variant is currently in use. The data-less varients use their generated discriminat value during type-checking the data variants use their HIR ID for their discriminant. This will likely get redone to get improved GDB integration/updated to use the QUAL_UNION_TYPE when we learn how to do this properly. Fixes #79 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/backend/rust-compile-context.h')
0 files changed, 0 insertions, 0 deletions