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 T_CHECK(root->kind == TOBI_IR_ROOT);
12 T_CHECK(root->child_len == 1);
13 T_CHECK(root->child[0]->off == 2 && root->child[0]->len == 8);
14 T_CHECK(tobi_ir_find_child(root, TOBI_IR_METHOD) == m);
15 T_CHECK(tobi_ir_count_kind(root, TOBI_IR_METHOD) == 1);
16 tobi_ir *u = tobi_ir_new(TOBI_IR_UNKNOWN, 4, 1);
17 u->raw_op = 0xfe;
18 tobi_ir_add(m->child[0], u);
19 T_CHECK(m->child[0]->child[0]->raw_op == 0xfe);
20 tobi_ir_free(root);
21 return 0;
22}