Skip to content

Latest commit

 

History

History
94 lines (73 loc) · 3.67 KB

TODO.org

File metadata and controls

94 lines (73 loc) · 3.67 KB

LCC TODO

lcc, Driver

[Feature Request] Build System Integration

[2024-07-05 Fri 14:43]

While the half-baked support we have with the basic compiler templates defined in ./cmake/ is fine and dandy, it’d be cool if the compiler could generate CMake for a given executable file, imports, etc. i.e. invoke the compiler once to figure out how to invoke the compiler to build everything required and in what order. Maybe even generate the CMake and optionally invoke it to generate a build tree, lol. Kind of weirdly mutually recursive but I think it would ease use of the language when creating a new project. i.e. start writing, ask the compiler to generate a basic CMake build system that you can then handle yourself.

lcc, Codegen

Cleanup and Consolidate Calling Convention Code

[2024-07-19 Fri 21:18]

We are calculating register classes, making argument register lists, etc. all over the place when we should probably just have a sysv header and a msx64 header that we have everything in. This should also clean up the call sites quite a bit (hopefully). Example arg_regs within lib/lcc/ir/module_mir.cc.

opt

BUG

[2024-07-08 Mon 13:28]

Instruction combine (icmb) and ssa passes cause the following to change the signature of fopen and pass a struct instead of the ptr that it is supposed to. There is some issue with not updating the type of a replaced/altered instruction, or something. It could also be the IR we are generating is just wrong for this particular case but it works unoptimised so it’d be an edge case, if it were.

lcc examples/glint/SimpleFile.g --passes icmb,ssa
NO OPTIMISATIONS:
read : glintcc @__struct_0(@__struct_0 %0):
  bb0:
    %1 = alloca @__struct_0
    store @__struct_0 %0 into %1
    %2 = alloca ptr
    %3 = gmp @__struct_0 from %1 at i64 0
    %4 = load ptr from %3
    %5 = gep i8 from @.str.0 at i64 0
    %6 = call @fopen (ptr %4, ptr %5) -> ptr
    ...

SSA CONSTRUCTION:
read : glintcc @__struct_0(@__struct_0 %0):
  bb0:
    %1 = alloca @__struct_0
    store @__struct_0 %0 into %1
    %2 = gmp @__struct_0 from %1 at i64 0
    %3 = load ptr from %2
    %4 = gep i8 from @.str.0 at i64 0
    %5 = call @fopen (ptr %3, ptr %4) -> ptr
    ...

INSTRUCTION COMBINE:
read : glintcc @__struct_0(@__struct_0 %0):
  bb0:
    %1 = alloca @__struct_0
    store @__struct_0 %0 into %1
    %2 = alloca ptr
    %3 = load ptr from %1
    %4 = call @fopen (ptr %3, ptr @.str.0) -> ptr
    ...

ICMB, SSA:
read : glintcc @__struct_0(@__struct_0 %0):
  bb0:
    %1 = call @fopen (@__struct_0 %0, ptr @.str.0) -> ptr
    ...

Probably from this portion of code from the SSA Construction pass running on the simplified “alloca -> store -> load”, in which it is replacing the load instruction with it’s reaching definition, past the optimised-out alloca.

/// If this instruction uses a load of an optimisable
/// alloca, replace the load with the reaching definition
/// of that alloca.
i->replace_children<LoadInst>([&](LoadInst* l) -> Value* {
    auto a = rgs::find(optimisable, l->ptr());
    if (a == optimisable.end()) return nullptr;
    return ReachingDef(*a, l);
 });

NOTE: Running icmb pass after ssa pass works, but I don’t think that’s reliable since multiple runs of all passes are possible. It also has the same affect as just removing the ssa pass.

Get rid of clown colors in IR

[2024-07-03 Wed 10:22]

Just ughh.

[ISel] Add Where type to template of Pattern

[2023-12-14 Thu 17:06]

We want this to contain a list of types that begin with Require*. For example, RequireOperandSizeLessThan<operand_index, declared_size>.