Giter Site home page Giter Site logo

cobalt's People

Contributors

c272 avatar

Watchers

 avatar

cobalt's Issues

Basic conditional optimisations

We can perform incredibly basic boolean expression optimisations on conditional expressions (e.g. removing things like NOT NOT). This should improve code size and performance for evaluating branch conditions.

There are also code generation time optimisations that can be made here, as Cranelift has support for combined operations such as bor_not which can represent a NOT X OR Y and band_not which can represent a NOT X AND Y.

Add appropriate span context to code generator errors

Currently, compile-time errors raised from the code generator do not provide any context as to the location or line number of the error. We're already passing the span relevant for each statement into the code generator, we might as well make use of it!
It might also be worth adding additional spans for specific variables, etc. for richer context than just "this line".

Generate `u64` when integer PICs do not contain a sign segment

Currently, if a PIC signifies an integer, Cobalt will always generate an i64, which is inefficient when there is no sign bit specified in the PIC. Perhaps we could generate these as u64 instead.

This may require a rework of some code generation functions, and how Pic signifies its typing (e.g. removal of is_str and is_float and implementation of some enum).

Stop duplicating global values/loaded variable values per-function

Currently, every time a variable is loaded, the GV is imported into the function with declare_data_in_func and then that GV is turned into a pointer (for strings) or loaded (for ints, floats).

This creates a bucket-load of duplicate GVs and values which we don't need if they're already defined in this function. Perhaps create a ValueManager (similar to the existing DataManager) and cache these GV/Value references throughout the function?

Cull & warn for unreferenced paragraphs

Related to the static analysis from #5, it would be nice to cull any unreferenced paragraphs from the code generation output from the results of a prior analysis pass, and warn the user that they have an unused function.

Verify that the AST contains at least 1 terminating paragraph

Currently, with the introduction of paragraphs, the user can forgo entering a "STOP RUN" clause since the compiler currently has no ability to perform a walk of the call graph to determine whether the program will at some point (theoretically) enter a terminating block.

Perhaps a verify_ast function or something similar should be introduced to perform a static analysis pass before the code generation stage. Does not impact functionality, returns still work as expected, this is just not ideal from the user or compliance perspective.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.