ACPI AML decompiler w/ CFG recovery and structured pseudocode
1#include "t.h"
2
3#include "ir.h"
4
5int t_ir(void) {
6 tobi_ir *root = tobi_ir_new(TOBI_IR_ROOT, 0, 10);
7 tobi_ir *m = tobi_ir_new(TOBI_IR_METHOD, 2, 8);
8 tobi_ir_set_name(m, "MTH0");
9 tobi_ir_add(root, m);
10 tobi_ir_add(m, tobi_ir_new(TOBI_IR_BLOCK, 7, 3));
11 tobi_ir_assign_ids(root);
12 T_CHECK(root->kind == TOBI_IR_ROOT);
13 T_CHECK(root->id == 1 && root->parent_id == 0);
14 T_CHECK(root->child_len == 1);
15 T_CHECK(root->child[0]->off == 2 && root->child[0]->len == 8);
16 T_CHECK(root->child[0]->id == 2 && root->child[0]->parent_id == root->id);
17 T_CHECK(root->child[0]->parent_index == 0);
18 T_CHECK(m->child[0]->id == 3 && m->child[0]->parent_id == m->id);
19 T_CHECK(tobi_ir_find_child(root, TOBI_IR_METHOD) == m);
20 T_CHECK(tobi_ir_count_kind(root, TOBI_IR_METHOD) == 1);
21 tobi_ir *u = tobi_ir_new(TOBI_IR_UNKNOWN, 4, 1);
22 u->raw_op = 0xfe;
23 tobi_ir_add(m->child[0], u);
24 tobi_ir_assign_ids(root);
25 T_CHECK(m->child[0]->child[0]->raw_op == 0xfe);
26 T_CHECK(m->child[0]->child[0]->id == 4);
27 T_CHECK(m->child[0]->child[0]->parent_id == m->child[0]->id);
28 T_CHECK(m->child[0]->child[0]->parent_index == 0);
29 tobi_ir_free(root);
30 return 0;
31}