Skip to content

Commit

Permalink
removed . from keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
leissa committed Oct 20, 2024
1 parent 72640b1 commit 5dc116a
Show file tree
Hide file tree
Showing 277 changed files with 3,505 additions and 3,546 deletions.
16 changes: 8 additions & 8 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In direct style, its type looks like this:
Converted to [continuation-passing style (CPS)](https://en.wikipedia.org/wiki/Continuation-passing_style) this type looks like this:

```
.Cn [%mem.M, I32, %mem.Ptr (I32, 0), .Cn [%mem.M, I32]]
Cn [%mem.M, I32, %mem.Ptr (I32, 0), Cn [%mem.M, I32]]
```

The `%%mem.M` type is a type that keeps track of side effects that may occur.
Expand Down Expand Up @@ -198,11 +198,11 @@ Here are some examples:
```cpp
void foo(Ref def) {
if (auto size = Idx::size(def)) {
// def = .Idx size
// def = Idx size
}
if (auto lam = Lam::isa_mut_cn(def)) {
// def isa mutable Lam of type .Cn T
// def isa mutable Lam of type Cn T
}
if (auto pi = Pi::isa_basicblock(def)) {
Expand Down Expand Up @@ -353,10 +353,10 @@ TODO
| `(0, 1, 2)` | [Tuple](@ref mim::Tuple) | `3` | `3` | `3` | `3` | `3` |
| `‹3; 0›` | [Pack](@ref mim::Pack) | `3` | `3` | `3` | `3` | `3` |
| `‹n; 0›` | [Pack](@ref mim::Pack) | `n` | `std::nullopt` | asserts | `1` | `1` |
| `[.Nat, .Bool, .Nat]` | [Sigma](@ref mim::Sigma) | `3` | `3` | `3` | `3` | `3` |
| `«3; .Nat»` | [Arr](@ref mim::Arr) | `3` | `3` | `3` | `3` | `3` |
| `«n; .Nat»` | [Arr](@ref mim::Arr) | `n` | `std::nullopt` | asserts | `1` | `1` |
| `x: [.Nat, .Bool]` | [Var](@ref mim::Var) | `2` | `2` | `2` | `2` | `2` |
| `[Nat, Bool, Nat]` | [Sigma](@ref mim::Sigma) | `3` | `3` | `3` | `3` | `3` |
| `«3; Nat»` | [Arr](@ref mim::Arr) | `3` | `3` | `3` | `3` | `3` |
| `«n; Nat»` | [Arr](@ref mim::Arr) | `n` | `std::nullopt` | asserts | `1` | `1` |
| `x: [Nat, Bool]` | [Var](@ref mim::Var) | `2` | `2` | `2` | `2` | `2` |
| `‹32; 0›` | [Pack](@ref mim::Pack) | `32` | `32` | `32` | `32` | `1` |
The last line assumes mim::Flags::scalarize_threshold = 32.
Expand All @@ -369,7 +369,7 @@ The simplest way is to kick off with [World::externals](@ref mim::World::externa
```cpp
DefSet done;
for (const auto& [_, mut] : world.externals())
for (const auto& [_, mut] : worldexternals())
visit(done, mut);
void visit(DefSet& done, const Def* def) {
Expand Down
172 changes: 86 additions & 86 deletions docs/langref.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/hello.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main(int, char**) {
auto parser = ast::Parser(ast);
for (auto plugin : {"compile", "core"}) parser.plugin(plugin);

// .Cn [%mem.M, I32, %mem.Ptr (I32, 0) .Cn [%mem.M, I32]]
// Cn [%mem.M, I32, %mem.Ptr (I32, 0) Cn [%mem.M, I32]]
auto mem_t = w.annex<mem::M>();
auto argv_t = w.call<mem::Ptr0>(w.call<mem::Ptr0>(w.type_i32()));
auto main = w.mut_fun({mem_t, w.type_i32(), argv_t}, {mem_t, w.type_i32()})->set("main");
Expand Down
2 changes: 1 addition & 1 deletion gtest/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TEST(Lexer, Toks) {
Driver driver;
auto& w = driver.world();
auto ast = AST(w);
std::istringstream is("{ } ( ) [ ] ‹ › « » : , . .lam λ 23₀₁₂₃₄₅₆₇₈₉");
std::istringstream is("{ } ( ) [ ] ‹ › « » : , . lam λ 23₀₁₂₃₄₅₆₇₈₉");
Lexer lexer(ast, is);

EXPECT_TRUE(lexer.lex().isa(Tok::Tag::D_brace_l));
Expand Down
10 changes: 5 additions & 5 deletions gtest/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ TEST(Zip, fold) {
auto ast = ast::AST(w);
auto parser = ast::Parser(ast);

std::istringstream iss(".plugin core;"
".let a = ((0I32, 1I32, 2I32), ( 3I32, 4I32, 5I32));"
".let b = ((6I32, 7I32, 8I32), ( 9I32, 10I32, 11I32));"
".let c = ((6I32, 8I32, 10I32), (12I32, 14I32, 16I32));"
".let r = %core.zip (2, (2, 3)) (2, (.I32, .I32), 1, .I32, %core.wrap.add 0) (a, b);");
std::istringstream iss("plugin core;"
"let a = ((0I32, 1I32, 2I32), ( 3I32, 4I32, 5I32));"
"let b = ((6I32, 7I32, 8I32), ( 9I32, 10I32, 11I32));"
"let c = ((6I32, 8I32, 10I32), (12I32, 14I32, 16I32));"
"let r = %core.zip (2, (2, 3)) (2, (I32, I32), 1, I32, %core.wrap.add 0) (a, b);");
parser.import(iss);
// auto c = parser.scopes().find({Loc(), driver.sym("c")});
// auto r = parser.scopes().find({Loc(), driver.sym("r")});
Expand Down
3 changes: 0 additions & 3 deletions include/automaton/automaton.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
#pragma once

#include <cstdint>

#include <iostream>
#include <list>
#include <set>
#include <unordered_map>
#include <vector>

#include <absl/container/flat_hash_map.h>
Expand Down
2 changes: 0 additions & 2 deletions include/automaton/dfa.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <cstdint>

#include <vector>

#include <absl/container/flat_hash_map.h>

#include "automaton/automaton.h"
Expand Down
1 change: 0 additions & 1 deletion include/mim/analyses/scope.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "mim/def.h"
#include "mim/util/print.h"

namespace mim {

Expand Down
28 changes: 14 additions & 14 deletions include/mim/ast/ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ class LitExpr : public Expr {
Ptr<Expr> type_;
};

/// `decls e` or `e .where decls` if @p where is `true`.
/// `decls e` or `e where decls` if @p where is `true`.
class DeclExpr : public Expr {
public:
DeclExpr(Loc loc, Ptrs<ValDecl>&& decls, Ptr<Expr>&& expr, bool is_where)
Expand All @@ -389,7 +389,7 @@ class DeclExpr : public Expr {
bool is_where_;
};

/// `.Type level`
/// `Type level`
class TypeExpr : public Expr {
public:
TypeExpr(Loc loc, Ptr<Expr>&& level)
Expand Down Expand Up @@ -436,8 +436,8 @@ class ArrowExpr : public Expr {

/// One of:
/// * ` dom_0 ... dom_n-1 -> codom`
/// * `.Cn dom_0 ... dom_n-1`
/// * `.Fn dom_0 ... dom_n-1 -> codom`
/// * `Cn dom_0 ... dom_n-1`
/// * `Fn dom_0 ... dom_n-1 -> codom`
class PiExpr : public Expr {
public:
class Dom : public Node {
Expand Down Expand Up @@ -542,7 +542,7 @@ class AppExpr : public Expr {
Ptr<Expr> arg_;
};

/// `.ret ptrn = callee $ arg; body`
/// `ret ptrn = callee $ arg; body`
class RetExpr : public Expr {
public:
RetExpr(Loc loc, Ptr<Ptrn>&& ptrn, Ptr<Expr>&& callee, Ptr<Expr>&& arg, Ptr<Expr> body)
Expand Down Expand Up @@ -663,7 +663,7 @@ class ExtractExpr : public Expr {
mutable const Decl* decl_ = nullptr;
};

/// `.ins(tuple, index, value)`
/// `ins(tuple, index, value)`
class InsertExpr : public Expr {
public:
InsertExpr(Loc loc, Ptr<Expr>&& tuple, Ptr<Expr>&& index, Ptr<Expr>&& value)
Expand Down Expand Up @@ -691,7 +691,7 @@ class InsertExpr : public Expr {
* Decls
*/

/// `.let ptrn: type = value;`
/// `let ptrn: type = value;`
class LetDecl : public ValDecl {
public:
LetDecl(Loc loc, Ptr<Ptrn>&& ptrn, Ptr<Expr>&& value)
Expand All @@ -713,7 +713,7 @@ class LetDecl : public ValDecl {
mutable sub_t sub_;
};

/// `.ax ptrn: type = value;`
/// `axm ptrn: type = value;`
class AxiomDecl : public ValDecl {
public:
class Alias : public Decl {
Expand Down Expand Up @@ -802,11 +802,11 @@ class RecDecl : public ValDecl {

/// One of:
/// * `λ dom_0 ... dom_n-1 -> codom`
/// * `.cn dom_0 ... dom_n-1`
/// * `.fn dom_0 ... dom_n-1 -> codom`
/// * `.lam dbg dom_0 ... dom_n-1 -> codom`
/// * `.con dbg dom_0 ... dom_n-1`
/// * `.fun dbg dom_0 ... dom_n-1 -> codom`
/// * `cn dom_0 ... dom_n-1`
/// * `fn dom_0 ... dom_n-1 -> codom`
/// * `lam dbg dom_0 ... dom_n-1 -> codom`
/// * `con dbg dom_0 ... dom_n-1`
/// * `fun dbg dom_0 ... dom_n-1 -> codom`
class LamDecl : public RecDecl {
public:
class Dom : public PiExpr::Dom {
Expand Down Expand Up @@ -866,7 +866,7 @@ class LamDecl : public RecDecl {
mutable sub_t sub_;
};

/// `.cfun dbg dom -> codom`
/// `cfun dbg dom -> codom`
class CDecl : public ValDecl {
public:
CDecl(Loc loc, Tok::Tag tag, Dbg dbg, Ptr<Ptrn>&& dom, Ptr<Expr>&& codom)
Expand Down
86 changes: 43 additions & 43 deletions include/mim/ast/tok.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,44 @@ namespace ast {

// clang-format off
#define MIM_KEY(m) \
m(K_module, ".module") \
m(K_import, ".import") \
m(K_plugin, ".plugin") \
m(K_and, ".and" ) \
m(K_ax, ".ax" ) \
m(K_let, ".let" ) \
m(K_rec, ".rec" ) \
m(K_ret, ".ret" ) \
m(K_where, ".where" ) \
m(K_end, ".end" ) \
m(K_Nat, ".Nat" ) \
m(K_Idx, ".Idx" ) \
m(K_extern, ".extern") \
m(K_Type, ".Type" ) \
m(K_Univ, ".Univ" ) \
m(K_Cn, ".Cn" ) \
m(K_Fn, ".Fn" ) \
m(K_con, ".con" ) \
m(K_fun, ".fun" ) \
m(K_lam, ".lam" ) \
m(K_ccon, ".ccon" ) \
m(K_cfun, ".cfun" ) \
m(K_cn, ".cn" ) \
m(K_fn, ".fn" ) \
m(K_ff, ".ff" ) \
m(K_tt, ".tt" ) \
m(K_ins, ".ins" ) \
m(K_i1, ".i1" ) \
m(K_i8, ".i8" ) \
m(K_i16, ".i16" ) \
m(K_i32, ".i32" ) \
m(K_i64, ".i64" ) \
m(K_Bool, ".Bool" ) \
m(K_I1, ".I1" ) \
m(K_I8, ".I8" ) \
m(K_I16, ".I16" ) \
m(K_I32, ".I32" ) \
m(K_I64, ".I64" ) \
m(K_module, "module") \
m(K_import, "import") \
m(K_plugin, "plugin") \
m(K_and, "and" ) \
m(K_ax, "axm" ) \
m(K_let, "let" ) \
m(K_rec, "rec" ) \
m(K_ret, "ret" ) \
m(K_where, "where" ) \
m(K_end, "end" ) \
m(K_Nat, "Nat" ) \
m(K_Idx, "Idx" ) \
m(K_extern, "extern") \
m(K_Type, "Type" ) \
m(K_Univ, "Univ" ) \
m(K_Cn, "Cn" ) \
m(K_Fn, "Fn" ) \
m(K_con, "con" ) \
m(K_fun, "fun" ) \
m(K_lam, "lam" ) \
m(K_ccon, "ccon" ) \
m(K_cfun, "cfun" ) \
m(K_cn, "cn" ) \
m(K_fn, "fn" ) \
m(K_ff, "ff" ) \
m(K_tt, "tt" ) \
m(K_ins, "ins" ) \
m(K_i1, "i1" ) \
m(K_i8, "i8" ) \
m(K_i16, "i16" ) \
m(K_i32, "i32" ) \
m(K_i64, "i64" ) \
m(K_Bool, "Bool" ) \
m(K_I1, "I1" ) \
m(K_I8, "I8" ) \
m(K_I16, "I16" ) \
m(K_I32, "I32" ) \
m(K_I64, "I64" ) \

#define CODE(t, str) + size_t(1)
constexpr auto Num_Keys = size_t(0) MIM_KEY(CODE);
Expand Down Expand Up @@ -95,11 +95,11 @@ constexpr auto Num_Keys = size_t(0) MIM_KEY(CODE);
m(T_semicolon, ";") \
m(T_star, "*") \

#define MIM_SUBST(m) \
m(".lm", T_lm ) \
m(".bot", T_bot ) \
m(".top", T_top ) \
m(".insert", K_ins ) \
#define MIM_SUBST(m) \
m("lm", T_lm ) \
m("bot", T_bot ) \
m("top", T_top ) \
m("insert", K_ins ) \

/// @name Precedence
///@{
Expand Down
8 changes: 4 additions & 4 deletions include/mim/def.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ class Def : public fe::RuntimeCast<Def> {
///@{
/// Yields the **raw** type of this Def, i.e. maybe `nullptr`. @see Def::unfold_type.
const Def* type() const { return type_; }
/// Yields the type of this Def and builds a new `.Type (UInc n)` if necessary.
/// Yields the type of this Def and builds a new `Type (UInc n)` if necessary.
const Def* unfold_type() const;
/// Yields `true` if `this:T` and `T:(.Type 0)`.
/// Yields `true` if `this:T` and `T:(Type 0)`.
bool is_term() const;
///@}

Expand Down Expand Up @@ -727,14 +727,14 @@ class Nat : public Def {
MIM_DEF_MIXIN(Nat)
};

/// A built-in constant of type `.Nat -> *`.
/// A built-in constant of type `Nat -> *`.
class Idx : public Def {
private:
Idx(const Def* type)
: Def(Node, type, Defs{}, 0) {}

public:
/// Checks if @p def is a `.Idx s` and returns `s` or `nullptr` otherwise.
/// Checks if @p def is a `Idx s` and returns `s` or `nullptr` otherwise.
static Ref size(Ref def);

/// @name Convert between Idx::size and bitwidth and vice versa
Expand Down
2 changes: 1 addition & 1 deletion include/mim/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Driver : public fe::SymPool {
/// @name Manage Imports
/// This is a list of pairs where each pair contains:
/// 1. The `fs::path` used during import,
/// 2. The name as Sym%bol used in the `.import` directive or in Parser::import.
/// 2. The name as Sym%bol used in the `import` directive or in Parser::import.
///@{
const auto& imports() { return imports_; }
/// Yields a `fs::path*` if not already added that you can use in Loc%ation; returns `nullptr` otherwise.
Expand Down
8 changes: 4 additions & 4 deletions include/mim/lam.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ std::deque<const App*> decurry(const Def*);
/// ```
/// In CPS the types look like:
/// ```
/// f: .Cn[B, .Cn C]
/// g: .Cn[A, .Cn B]
/// f: Cn[B, Cn C]
/// g: Cn[A, Cn B]
/// h = f o g
/// h: .Cn[A, cn C]
/// h: Cn[A, cn C]
/// h = λ (a ret_h) = g (a, h')
/// h': .Cn B
/// h': Cn B
/// h'= λ b = f (b, ret_h)
/// ```
const Def* compose_cn(const Def* f, const Def* g);
Expand Down
19 changes: 10 additions & 9 deletions include/mim/plug/affine/pass/lower_for.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
#pragma once

#include <mim/def.h>

#include <mim/pass/pass.h>

namespace mim::plug::affine {

/// Lowers the for axiom to actual control flow in CPS.
/// It basically mimics this implementation:
/// ```
/// .con %affine.For_impl
/// (m: .Nat , n: .Nat , Ts: «n; *»)
/// (begin: .Idx m, end: .Idx m, step: .Idx m, init: «i: n; Ts#i»,
/// body: .Cn [iter: .Idx m, acc: «i: n; Ts#i», yield: .Cn [«i: n; Ts#i»]],
/// exit: .Cn [«i: n; Ts#i»]
/// con %affine.For_impl
/// (m: Nat , n: Nat , Ts: «n; *»)
/// (begin: Idx m, end: Idx m, step: Idx m, init: «i: n; Ts#i»,
/// body: Cn [iter: Idx m, acc: «i: n; Ts#i», yield: Cn [«i: n; Ts#i»]],
/// exit: Cn [«i: n; Ts#i»]
/// ) =
/// .con head(iter: .Idx m, acc: «i: n; Ts#i») =
/// .con new_body() = body (iter, acc, .cn acc: «i: n; Ts#i» =
/// .let iter2 = %core.wrap.add %core.mode.nsuw (iter, step);
/// con head(iter: Idx m, acc: «i: n; Ts#i») =
/// con new_body() = body (iter, acc, cn acc: «i: n; Ts#i» =
/// let iter2 = %core.wrap.add %core.mode.nsuw (iter, step);
/// head (iter2, acc));
/// .con new_exit() = exit (acc);
/// con new_exit() = exit (acc);
/// (new_exit, new_body)#(%core.icmp.ul (iter, end)) ();
/// head(begin, init);
/// ```
Expand Down
Loading

0 comments on commit 5dc116a

Please sign in to comment.