|
| 1 | +const MTLLOG_SUBSYSTEM = "com.juliagpu.metal.jl" |
| 2 | +const MTLLOG_CATEGRORY = "mtlprintf" |
| 3 | + |
| 4 | +const __METAL_OS_LOG_TYPE_DEBUG__ = Int32(2) |
| 5 | +const __METAL_OS_LOG_TYPE_INFO__ = Int32(1) |
| 6 | +const __METAL_OS_LOG_TYPE_DEFAULT__ = Int32(0) |
| 7 | +const __METAL_OS_LOG_TYPE_ERROR__ = Int32(16) |
| 8 | +const __METAL_OS_LOG_TYPE_FAULT__ = Int32(17) |
| 9 | + |
1 | 10 | export @mtlprintf |
2 | 11 |
|
3 | 12 | @generated function promote_c_argument(arg) |
|
72 | 81 | end |
73 | 82 |
|
74 | 83 | # invoke @air.os_log and return |
75 | | - subsystem_str = LLVM.PointerNull(T_pint8a2) |
76 | | - intptr = LLVM.ConstantInt(T_int64, Int64(-1)) |
77 | | - category_str = const_inttoptr(intptr, T_pint8a2) |
78 | | - log_type_default = LLVM.ConstantInt(T_int32, Int32(0)) |
79 | | - log_type_debug = LLVM.ConstantInt(T_int32, Int32(2)) |
80 | | - log_type_error = LLVM.ConstantInt(T_int32, Int32(16)) |
| 84 | + subsystem_str = globalstring_ptr!(builder, MTLLOG_SUBSYSTEM, addrspace=2) |
| 85 | + # subsystem_str = LLVM.PointerNull(T_pint8a2) |
| 86 | + # intptr = LLVM.ConstantInt(T_int64, Int64(-1)) |
| 87 | + # category_str = const_inttoptr(intptr, T_pint8a2) |
| 88 | + category_str = globalstring_ptr!(builder, MTLLOG_CATEGRORY, addrspace=2) |
| 89 | + log_type = LLVM.ConstantInt(T_int32, __METAL_OS_LOG_TYPE_DEBUG__) |
81 | 90 | arg_size = LLVM.ConstantInt(T_int64, Int64(argsize)) |
82 | 91 |
|
83 | 92 | # declare void @air.os_log(i8 addrspace(2)*, i8 addrspace(2)*, i32, i8 addrspace(2)*, i8*, i64) local_unnamed_addr #4 |
84 | 93 | os_log_fty = LLVM.FunctionType(T_void, [T_pint8a2, T_pint8a2, T_int32, T_pint8a2, T_pint8, T_int64]) |
85 | 94 | os_log = LLVM.Function(mod, "air.os_log", os_log_fty) |
86 | | - call!(builder, os_log_fty, os_log, [subsystem_str, category_str, log_type_error, str, buffer, arg_size]) |
| 95 | + call!(builder, os_log_fty, os_log, [subsystem_str, category_str, log_type, str, buffer, arg_size]) |
87 | 96 | ret!(builder) |
88 | 97 | end |
89 | 98 |
|
|
0 commit comments