Skip to content

Commit

Permalink
Notes - Ideas on improving generated C
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed Jan 1, 2025
1 parent 0dbd3a7 commit dc1b6c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions Notes/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ TODO:
- Optimise typecheck runtime
- Mostly done with trait resolve optimisations
- De-duplicate `static.cpp`/`helpers.cpp` (lots of common logic)
- minicargo job system (for nicer reporting of progress)
- Codegen units (speed up librustc build by shattering the codegen into multipule objects)
- Proper monomorphisation of closures
- Add PathParams to the closure type, that translate the source node into the current context
- Add variance to lifetime inference.

MIR match generation
Expand All @@ -19,6 +16,16 @@ MIR match generation
> Rule codegen should store the next block for each rule
> Store both the source block and the next block (can store multiple pairs)
Codegen:
- Completely eliminate ZSTs (remove from args, remove from locals)
- ZSTs are borrowed in some cases, so still need to exist
- Could replace borrow with a borrow of an equivalent location (e.g. next argument, or just `rv`)
- NOTE: Failed? ICE in rustc (when implemented using borrows of `rv`)
- Treat `repr(transparent)` types as the inner type (i.e. don't even emit `struct`s)
- Tweak `const_eval_select` to be less verbose (or expand/delete after monomorph?)
- A chunk of the verbosity is from ZSTs
- And some from laziness
- Transparent `Option<NonZero>` (same inner type?)

## Big change TODOs
- Support MIR-only RLibs
Expand Down Expand Up @@ -63,7 +70,6 @@ MIR match generation
- Reduces typing
- No memory gains though.
- Full SMIRI support in `minicargo` (running `standalone_miri` on build scripts)
- Rupport `rustc` in `minicargo` (for doing the pre-cargo build of libstd)
- Restructure to treat `if { ... } else if` chains as a list instead of recursive structures
- Pre-cache inherent methods for faster lookup

Expand Down
2 changes: 1 addition & 1 deletion src/trans/codegen_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2139,7 +2139,7 @@ namespace {
unsigned idx = 1 - ve->zero_variant;
emit_ctype(repr->fields.at(idx).ty, FMT_CB(os, os << "var_" << idx));
m_of << ";\n";
m_of << "\t} DATA;";
m_of << "\t} DATA;\n";
}
// If there's only one field - it's either a single variant, or a value enum
else if( repr->fields.size() == 1 )
Expand Down

0 comments on commit dc1b6c2

Please sign in to comment.