MimIR
0.1
MimIR is my Intermediate Representation
Toggle main menu visibility
Main Page
Documentation
Mim Command-Line Reference
Mim Language Reference
Coding & Debugging
Developer Guide
Passes
Plugins
affine
autodiff
clos
compile
core
demo
direct
math
matrix
mem
opt
ord
refly
regex
tensor
tuple
vec
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
z
Variables
Typedefs
b
d
f
g
j
l
m
n
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
i
j
k
l
m
n
p
q
r
s
t
v
w
z
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
z
~
Variables
a
b
c
d
f
g
i
l
m
n
o
p
r
s
t
w
Typedefs
Enumerations
Enumerator
Related Symbols
a
b
c
f
i
l
n
o
p
s
w
Files
File List
File Members
All
a
c
d
e
g
h
i
m
r
v
w
Functions
Typedefs
Macros
a
c
d
e
g
h
i
m
v
w
▼
MimIR
►
Introduction
►
Documentation
►
Plugins
►
Namespaces
►
Concepts
►
Classes
▼
Files
▼
File List
►
build
docs
►
include
▼
src
►
automaton
▼
mim
►
ast
►
cli
►
pass
►
phase
▼
plug
►
affine
►
autodiff
►
clos
►
compile
►
core
►
demo
►
direct
►
math
►
matrix
►
mem
►
opt
►
ord
►
refly
▼
regex
▼
pass
lower_regex.cpp
►
dfa2matcher.cpp
►
normalizers.cpp
►
regex.cpp
►
regex2nfa.cpp
►
tensor
►
tuple
►
vec
►
util
axm.cpp
check.cpp
►
def.cpp
dot.cpp
driver.cpp
►
dump.cpp
►
lam.cpp
lattice.cpp
nest.cpp
►
normalize.cpp
plugin.cpp
rewrite.cpp
►
schedule.cpp
►
tuple.cpp
world.cpp
►
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
lower_regex.cpp
Go to the documentation of this file.
1
#include "
mim/plug/regex/pass/lower_regex.h
"
2
3
#include <
automaton/dfa.h
>
4
#include <
automaton/dfamin.h
>
5
#include <
automaton/nfa2dfa.h
>
6
7
#include <
mim/def.h
>
8
9
#include <
mim/plug/core/core.h
>
10
#include <
mim/plug/direct/direct.h
>
11
#include <
mim/plug/mem/mem.h
>
12
13
#include "
mim/plug/regex/autogen.h
"
14
#include "
mim/plug/regex/dfa2matcher.h
"
15
#include "
mim/plug/regex/regex.h
"
16
#include "
mim/plug/regex/regex2nfa.h
"
17
18
namespace
mim::plug::regex
{
19
20
namespace
{
21
const
Def* wrap_in_cps2ds(
const
Def* callee) {
return
direct::op_cps2ds_dep
(callee); }
22
}
// namespace
23
24
const
Def
*
LowerRegex::rewrite
(
const
Def
* def) {
25
const
Def
* new_app = def;
26
27
if
(
auto
app = def->isa<
App
>()) {
28
auto
callee = app->callee();
29
if
(
Axm::isa<regex::conj>
(callee) ||
Axm::isa<regex::disj>
(callee) ||
Axm::isa<regex::not_>
(callee)
30
||
Axm::isa<regex::range>
(callee) ||
Axm::isa<regex::any>
(callee) ||
Axm::isa<quant>
(callee)) {
31
const
auto
n = app->arg();
32
auto
nfa =
regex2nfa
(callee);
33
world
().DLOG(
"nfa: {}"
, *nfa);
34
35
auto
dfa =
automaton::nfa2dfa
(*nfa);
36
world
().DLOG(
"dfa: {}"
, *dfa);
37
38
auto
min_dfa =
automaton::minimize_dfa
(*dfa);
39
new_app = wrap_in_cps2ds(
dfa2matcher
(
world
(), *min_dfa, n));
40
}
41
}
42
43
return
new_app;
44
}
24
const
Def
*
LowerRegex::rewrite
(
const
Def
* def) {
…
}
45
46
}
// namespace mim::plug::regex
mim::App
Definition
lam.h:207
mim::Axm::isa
static auto isa(const Def *def)
Definition
axm.h:104
mim::Def
Base class for all Defs.
Definition
def.h:203
mim::Pass::world
World & world()
Definition
pass.h:296
mim::plug::regex::LowerRegex::rewrite
const Def * rewrite(const Def *) override
Definition
lower_regex.cpp:24
core.h
def.h
dfa2matcher.h
dfa2matcher
const mim::Def * dfa2matcher(mim::World &, const automaton::DFA &, const mim::Def *)
You can dl::get this function.
Definition
dfa2matcher.cpp:95
dfa.h
dfamin.h
direct.h
lower_regex.h
mem.h
automaton::minimize_dfa
std::unique_ptr< DFA > minimize_dfa(const DFA &dfa)
Definition
dfamin.cpp:114
automaton::nfa2dfa
std::unique_ptr< DFA > nfa2dfa(const NFA &nfa)
Definition
nfa2dfa.cpp:33
mim::plug::direct::op_cps2ds_dep
const Def * op_cps2ds_dep(const Def *k)
Definition
direct.h:15
mim::plug::regex
The regex Plugin
Definition
lower_regex.h:5
mim::plug::regex::regex2nfa
std::unique_ptr< automaton::NFA > regex2nfa(const Def *regex)
Definition
regex2nfa.cpp:90
nfa2dfa.h
regex2nfa.h
autogen.h
regex.h
src
mim
plug
regex
pass
lower_regex.cpp
Generated by
1.13.2