Skip to main content

December 2022

Week of 2022-12-26​

  • πŸ“’ You can now call functions in a parameter context! Calling a function in a parameter context will evaluate the function at compile time. The result can then be used as parameter values. For example,

    fn fma(x: Int, y: Int, z: Int) -> Int:
        return a + b * c
    
    fn parameter_call():
        alias nelts = fma(32, 2, 16)
        var x: SIMD[f32, nelts]
  • You can now disable printing of types in an __mlir_attr substitution by using unary + expression.

  • πŸ“’ let declarations are now supported in functions. let declarations are local run-time constant values, which are always rvalues. They complement 'var' decls (which are mutable lvalues) and are the normal thing to use in most cases. They also generate less IR and are always in SSA form when initialized.

    We will want to extend this to support 'let' decls in structs at some point and support lazy initialized 'let' declarations (using dataflow analysis) but that isn't supported yet.

  • πŸ“š Add the NDBuffer struct.

  • Happy new year.

Week of 2022-12-19​

  • πŸ“š Start of the Standard library:

    1. Added Integer and SIMD structs to bootstrap the standard library.
    2. Added very basic buffer data structure.
  • We have basic support for parsing parameter results in function calls! Result parameters are an important Mojo metaprogramming feature. They allow functions to return compile-time constants.

    fn get_preferred_simdwidthof[() -> nelts: Int]():
        return[2]
    
    fn vectorized_function():
        get_preferred_simdwidthof[() -> nelts]()
        var x: SIMD[f32, nelts]
  • Types can now be used as parameters of !kgen.mlirtype in many more cases.

  • MLIR operations with zero results don't need to specify _type: [] anymore.

  • We support parsing triple quoted strings, for writing docstrings for your functions and structs!

  • A new __mlir_type[a,b,c] syntax is available for substituting into MLIR types and attributes is available, and the old placeholder approach is removed. This approach has a few advantages beyond what placeholders do:

    1. It's simpler.
    2. It doesn't form the intermediate result with placeholders, which gets rejected by MLIR's semantic analysis, e.g. the complex case couldn't be expressed before.
    3. It provides a simple way to break long attrs/types across multiple lines.
  • We now support an @evaluator decorator on functions for KGEN evaluators. This enables specifying user-defined interface evaluators when performing search during compilation.

  • πŸ“’ import syntax is now supported!

    This handles packaging imported modules into file ops, enables effective isolation from the other decls. "import" into the desired context is just aliasing decls, with the proper symbols references handle automatically during IR generation. As a starting point, this doesn't handle any notion of packages (as those haven't been sketched out enough).

  • πŸ“’ Reversed binary operators (like __radd__) are now looked up and used if the forward version (like __add__) doesn't work for some reason.

  • πŸ“’ Implicit conversions are now generally available, e.g. in assign statements, variable initializers etc. There are probably a few more places they should work, but we can start eliminating all the extraneous explicit casts from literals now.

  • Happy Holidays

Week of 2022-12-12​

  • πŸ“’ Function overloading now works. Call resolution filters candidate list according to the actual parameter and value argument specified at the site of the call, diagnosing an error if none of the candidates are viable or if multiple are viable and ambiguous. We also consider implicit conversions in overload look:

    fn foo(x: Int): pass
    fn foo(x: F64): pass
    
    foo(Int(1)) # resolves to the first overload
    foo(1.0)    # resolves to the second overload
    foo(1)      # error: both candidates viable with 1 implicit conversion!
  • The short circuiting binary and and or expressions are now supported.

  • Unary operator processing is a lot more robust, now handling the not expression and ~x on Bool.

  • πŸ“’ The compiler now generates debug information for use with GDB/LLDB that describes variables and functions.

  • The first version of the Mojo Visual Studio Code extension has been released! It supports syntax highlighting for Mojo files.

  • The first version of the Bool type has landed in the new Mojo standard library!

  • πŸ“’ Implicit conversions are now supported in return statements.

Week of 2022-12-05​

  • "Discard" patterns are now supported, e.g. _ = foo()

  • We now support implicit conversions in function call arguments, e.g. converting an index value to Int automatically. This eliminates a bunch of casts, e.g. the need to say F32(1.0) everywhere.

    This is limited for a few reasons that will be improved later:

    1. We don't support overloading, so lots of types aren't convertible from all the things they should be, e.g. you can't pass "1" to something that expects F32, because F32 can't be created from index.
    2. This doesn't "check to see if we can invoke __new__" it force applies it on a mismatch, which leads to poor QoI.
    3. This doesn't fix things that need radd.

Was this page helpful?