add @breakpoint()
parent
21eca6478f
commit
7eb6af1d3e
|
@ -1050,6 +1050,7 @@ enum BuiltinFnId {
|
|||
BuiltinFnIdImport,
|
||||
BuiltinFnIdCImport,
|
||||
BuiltinFnIdErrName,
|
||||
BuiltinFnIdBreakpoint,
|
||||
};
|
||||
|
||||
struct BuiltinFnEntry {
|
||||
|
|
|
@ -4606,6 +4606,8 @@ static TypeTableEntry *analyze_builtin_fn_call_expr(CodeGen *g, ImportTableEntry
|
|||
return analyze_c_import(g, import, context, node);
|
||||
case BuiltinFnIdErrName:
|
||||
return analyze_err_name(g, import, context, node);
|
||||
case BuiltinFnIdBreakpoint:
|
||||
return g->builtin_types.entry_void;
|
||||
}
|
||||
zig_unreachable();
|
||||
}
|
||||
|
|
|
@ -513,6 +513,8 @@ static LLVMValueRef gen_builtin_fn_call_expr(CodeGen *g, AstNode *node) {
|
|||
return nullptr;
|
||||
case BuiltinFnIdErrName:
|
||||
return gen_err_name(g, node);
|
||||
case BuiltinFnIdBreakpoint:
|
||||
return LLVMBuildCall(g->builder, g->trap_fn_val, nullptr, 0, "");
|
||||
}
|
||||
zig_unreachable();
|
||||
}
|
||||
|
@ -3790,9 +3792,15 @@ static BuiltinFnEntry *create_builtin_fn_with_arg_count(CodeGen *g, BuiltinFnId
|
|||
|
||||
static void define_builtin_fns(CodeGen *g) {
|
||||
{
|
||||
BuiltinFnEntry *builtin_fn = create_builtin_fn_with_arg_count(g, BuiltinFnIdBreakpoint, "breakpoint", 0);
|
||||
builtin_fn->return_type = g->builtin_types.entry_void;
|
||||
builtin_fn->ref_count = 1;
|
||||
|
||||
LLVMTypeRef fn_type = LLVMFunctionType(LLVMVoidType(), nullptr, 0, false);
|
||||
g->trap_fn_val = LLVMAddFunction(g->module, "llvm.debugtrap", fn_type);
|
||||
assert(LLVMGetIntrinsicID(g->trap_fn_val));
|
||||
builtin_fn->fn_val = LLVMAddFunction(g->module, "llvm.debugtrap", fn_type);
|
||||
assert(LLVMGetIntrinsicID(builtin_fn->fn_val));
|
||||
|
||||
g->trap_fn_val = builtin_fn->fn_val;
|
||||
}
|
||||
{
|
||||
BuiltinFnEntry *builtin_fn = create_builtin_fn(g, BuiltinFnIdMemcpy, "memcpy");
|
||||
|
|
Loading…
Reference in New Issue