From 82e840a0ca3fb547ac93e680a3dcbbb67958077f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 17 Aug 2022 13:52:13 +0100 Subject: EXPERIMENTAL `intrinsics.valgrind_client_request` --- src/check_builtin.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/check_builtin.cpp') diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 687f1694b..83136d576 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -5388,6 +5388,41 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 } break; + case BuiltinProc_valgrind_client_request: + { + if (!is_arch_x86()) { + error(call, "'%.*s' is only allowed on x86 targets (i386, amd64)", LIT(builtin_name)); + return false; + } + + enum {ARG_COUNT = 7}; + GB_ASSERT(builtin_procs[BuiltinProc_valgrind_client_request].arg_count == ARG_COUNT); + + Operand operands[ARG_COUNT] = {}; + for (isize i = 0; i < ARG_COUNT; i++) { + Operand *op = &operands[i]; + check_expr_with_type_hint(c, op, ce->args[i], t_uintptr); + if (op->mode == Addressing_Invalid) { + return false; + } + convert_to_typed(c, op, t_uintptr); + if (op->mode == Addressing_Invalid) { + return false; + } + if (!are_types_identical(op->type, t_uintptr)) { + gbString str = type_to_string(op->type); + error(op->expr, "'%.*s' expected a uintptr, got %s", LIT(builtin_name), str); + gb_string_free(str); + return false; + } + } + + operand->type = t_uintptr; + operand->mode = Addressing_Value; + operand->value = {}; + return true; + } + } return true; -- cgit v1.2.3