-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.c
32 lines (24 loc) · 915 Bytes
/
debug.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
Utility file to facilitate debugging of an .mlir file
See example at the end of the file
*/
#include <stdio.h>
void print_time(long unsigned i) {
printf("time: %lu\n", i);
}
void print_float(float i) {
printf("element value: %.2f\n", i);
}
void print_idx_3(float i, long unsigned t, long unsigned x, long unsigned y) {
printf("u[%lu][%lu][%lu] = %.2f\n", t, x, y, i);
}
/*
Add these manually in the generated `.iet.mlir` file, at the bottom into the "builtin.module"
llvm.func @print_time(i32) -> () attributes {sym_visibility = "private"}
llvm.func @print_float(f32) -> () attributes {sym_visibility = "private"}
llvm.func @print_idx_3(f32, i32, i32, i32) -> () attributes {sym_visibility = "private"}
Then you can call them using:
llvm.call @print_time(%time) : (i32) -> ()
llvm.call @print_float(%val) : (f32) -> ()
llvm.call @print_idx_3(%val, %t, %x, %y) : (f32, i32, i32, i32) -> ()
*/