Skip to content

Latest commit

 

History

History
136 lines (105 loc) · 4.54 KB

TODO.org

File metadata and controls

136 lines (105 loc) · 4.54 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

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.

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>.

Intercept, Language

Packed Structs called “Cereals”

[2023-12-09 Sat 17:39]

Basically, a packed struct is going to be an entirely separate type kind, like struct, enum, etc.

foo : cereal {
  x :u8;
  y :u16;
}

The size of foo above would be 24 bits, and the layout is guaranteed.

The use of cereals would be for serialisation and deserialisation, where you sometimes need exact bit or byte types that don’t necessarily follow all padding rules and such.

Error on non-hygienic declarations when defining a macro

[2023-12-09 Sat 18:22]

Whoever wrote the lexer and parser absolutely butchered macros. I already fixed defines, I’m pretty sure, but it wasn’t even erroring when it should, so we aren’t checking for hygienic expansions :(.

An assignment is an explicit typing of the rhs as much as a declaration is of the left

[2023-12-13 Wed 16:24]

This means we should treat the right hand side of an assignment, in code like the following,

x : u32 = 69
x := -1

as an explicit cast of the expression’s result type to the left hand side type, should it be convertible.

An explicit cast means the programmer specified they want it to happen. I WANT an assignment to happen if I write it, and I shouldn’t be forced to write `as typeof x` or similar just to make it work.

usz and isz

[2023-12-21 Thu 11:32]