From d299d4e1cd009a66ce72371b4e7ab6c61811f9fc Mon Sep 17 00:00:00 2001 From: Laytan Date: Sun, 25 Aug 2024 21:15:25 +0200 Subject: riscv: add an error when atomics are used without the atomics extension --- src/check_builtin.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/check_builtin.cpp') diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index fa03da946..3742caeda 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -2048,6 +2048,14 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As return ok; } + if (BuiltinProc__atomic_begin < id && id < BuiltinProc__atomic_end) { + if (build_context.metrics.arch == TargetArch_riscv64) { + if (!check_target_feature_is_enabled(str_lit("a"), nullptr)) { + error(call, "missing required target feature \"a\" for atomics, enable it by setting a different -microarch or explicitly adding it through -target-features"); + } + } + } + switch (id) { default: GB_PANIC("Implement built-in procedure: %.*s", LIT(builtin_name)); -- cgit v1.2.3