62 assert(!
Axm::isa<matrix::prod>(app) &&
"high level operations should have been lowered to for loops by now");
64 assert(!
Axm::isa<matrix::sum>(app) &&
"high level operations should have been lowered to for loops by now");
69 auto [_, S, T] = mat_ax->args<3>();
72 auto arr_ty = arr_ty_of_matrix_ty(S, T);
74 auto addr_space = w.lit_nat_0();
75 auto ptr_ty = w.call<
mem::Ptr>(
Defs{arr_ty, addr_space});
79 DLOG(
"init {} : {}", app, app->
type());
80 auto [_, S, T,
mem] = init_ax->args<4>();
81 DLOG(
" S T mem {} {} {}", S, T,
mem);
85 DLOG(
" S T mem {} {} {}", S, T,
mem);
86 auto arr_ty = arr_ty_of_matrix_ty(S, T);
88 auto res = w.tuple({mem2, ptr_mat});
89 DLOG(
" res {} : {}", res, res->type());
92 auto [
mem, mat, idx] = read_ax->args<3>();
93 DLOG(
"read_ax: {}", read_ax);
95 DLOG(
" mat: {} : {}", mat, mat->type());
96 DLOG(
" idx: {} : {}", idx, idx->type());
100 DLOG(
"rewritten read");
102 DLOG(
" mat: {} : {}", mat, mat->type());
103 DLOG(
" idx: {} : {}", idx, idx->type());
106 auto element_ptr = op_lea_tuple(ptr_mat, idx);
108 return w.tuple({mem2, val});
110 auto [
mem, mat, idx, val] = insert_ax->args<4>();
111 DLOG(
"insert_ax: {}", insert_ax);
113 DLOG(
" mat: {} : {}", mat, mat->type());
114 DLOG(
" idx: {} : {}", idx, idx->type());
115 DLOG(
" val: {} : {}", val, val->type());
120 DLOG(
"rewritten insert");
122 DLOG(
" mat: {} : {}", mat, mat->type());
123 DLOG(
" idx: {} : {}", idx, idx->type());
124 DLOG(
" val: {} : {}", val, val->type());
126 auto element_ptr = op_lea_tuple(ptr_mat, idx);
128 return w.tuple({mem2, ptr_mat});
130 auto [
mem, val] = const_ax->args<2>();
133 auto [n_def, S, T] = const_ax->callee()->as<
App>()->args<3>();
136 auto arr_ty = arr_ty_of_matrix_ty(S, T);
141 auto initial = op_pack_tuple(n, S, val);
145 return w.tuple({mem3, ptr_mat});
148 return Rewriter::rewrite_imm_App(app);