Skip to content

Commit

Permalink
Debug instr gen
Browse files Browse the repository at this point in the history
  • Loading branch information
BIsHetAntwoord committed Nov 9, 2021
1 parent cd9ade6 commit ce062eb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
9 changes: 9 additions & 0 deletions include/pareas/compiler/futhark_interop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ namespace futhark {
constexpr static const auto shape_fn = futhark_shape_i32_2d;
constexpr static const auto values_fn = futhark_values_i32_2d;
};

template<>
struct ArrayTraits<int64_t, 1> {
using Array = futhark_i64_1d;
constexpr static const auto new_fn = futhark_new_i64_1d;
constexpr static const auto free_fn = futhark_free_i64_1d;
constexpr static const auto shape_fn = futhark_shape_i64_1d;
constexpr static const auto values_fn = futhark_values_i64_1d;
};
}

#endif
17 changes: 17 additions & 0 deletions src/compiler/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,23 @@ namespace backend {
throw futhark::Error(ctx);
});

//Print instr gen
auto instr_gen_opcodes = futhark::UniqueArray<uint32_t, 1>(ctx);
auto instr_gen_rd = futhark::UniqueArray<int64_t, 1>(ctx);
auto instr_gen_rs1 = futhark::UniqueArray<int64_t, 1>(ctx);
auto instr_gen_rs2 = futhark::UniqueArray<int64_t, 1>(ctx);
auto instr_gen_jt = futhark::UniqueArray<uint32_t, 1>(ctx);
int err = futhark_entry_backend_split_instr(
ctx,
&instr_gen_opcodes,
&instr_gen_rd,
&instr_gen_rs1,
&instr_gen_rs2,
&instr_gen_jt,
instr
);


// Stage 4, optimizer
auto optimize = futhark::UniqueArray<bool, 1>(ctx);
p.measure("optimize", [&] {
Expand Down
13 changes: 0 additions & 13 deletions src/compiler/backend.fut
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,15 @@ import "codegen/tree"
import "codegen/datatypes"
import "codegen/instr"
import "codegen/instr_count"
import "codegen/symtab"
import "codegen/register"
import "codegen/preprocess"
import "codegen/optimizer"
import "codegen/postprocess"

type Tree [n] = Tree [n]
type Symtab [n] = Symtab [n]
type FuncInfo = FuncInfo
type Instr = Instr

let make_variable (data_type: u8) (offset: u32) : Variable =
{
decl_type = i32.u8 data_type,
offset = offset
}

let make_node (node_type: u8) (data_type: u8, parent: i32, depth: i32, child_idx: i32, node_data: u32) : Node =
{
node_type = i32.u8 node_type,
Expand All @@ -37,11 +29,6 @@ let make_functab (id: u32) (start: u32) (size: u32) =
}

-- Data structure rewrite functions
entry make_symtab [m] (data_types: [m]u8) (offsets: [m]u32) : Symtab[m] =
{
variables = map2 make_variable data_types offsets
}

entry make_tree [n] (max_depth: i32) (node_types: [n]u8) (data_types: [n]u8) (parents: [n]i32)
(depth: [n]i32) (child_idx: [n]i32) (node_data: [n]u32): Tree[n] =
{
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/main.fut
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,6 @@ entry backend_fix_jumps [n] [m] (instrs: [n]Instr) (func_tab: [m]FuncInfo): ([]I

entry backend_postprocess [n] (instrs: [n]Instr) =
backend.stage_postprocess instrs

entry backend_split_instr [n] (instrs: [n]Instr) =
map backend.split_instr instrs |> unzip5

0 comments on commit ce062eb

Please sign in to comment.