Hi Richard,

The signedness now works correctly. A few more comments:

+static rtx
+aarch64_expand_atomic_hints_builtins_fetch (tree exp)
+{
+  machine_mode mode = TYPE_MODE (TREE_TYPE (CALL_EXPR_ARG (exp, 1)));
+  rtx val = expand_normal (CALL_EXPR_ARG (exp, 1));
+  rtx mem_order = expand_normal (CALL_EXPR_ARG (exp, 2));
+  rtx hint = expand_normal (CALL_EXPR_ARG (exp, 3));
+  rtx fetch_type = expand_normal (CALL_EXPR_ARG (exp, 4));
+
+  require_const_argument (exp, 3, 0, 2);
+  require_const_argument (exp, 2, 0, 6);
+  require_const_argument (exp, 4, 0, 6);
+  if (seen_error ())
+    return NULL_RTX;

This crashes, you need to return a non-NULL pointer like const0.

This also crashes if you don't have LSE, so we need an error message here.

+  val = force_reg (mode, val);
+  rtx addr = expand_normal (CALL_EXPR_ARG (exp, 0));
+  addr = force_reg (Pmode, addr);
+  rtx mem = gen_rtx_MEM (mode, addr);
+
+  rtx return_val = gen_reg_rtx (mode);
+  expand_operand ops[6];
+  enum insn_code icode;
+  create_output_operand (&ops[0], return_val, mode);
+  create_input_operand (&ops[1], mem, mode);
+  create_input_operand (&ops[2], val, mode);
+  create_input_operand (&ops[3], mem_order, SImode);
+  create_input_operand (&ops[4], hint, SImode);
+  create_input_operand (&ops[5], fetch_type, SImode);
+  icode = code_for_aarch64_atomic_hints_fetch (mode);
+  expand_insn (icode, 6, ops);
+  return (ops[0].value);
+}

+static tree
+aarch64_resolve_overloaded_builtin_atomic_hint_fetch (void *pass_params)
+{
+  vec<tree, va_gc> *params = static_cast<vec<tree, va_gc> *> (pass_params);
+
+  tree addr = (*params)[0];
+
+  tree addr_type = TREE_TYPE (addr);
+  if (!POINTER_TYPE_P (addr_type))
+    return NULL_TREE;
+
+  tree ptr_type = TYPE_MAIN_VARIANT (TREE_TYPE (addr_type));
+
+  if (vec_safe_length (params) != 5)
+    return NULL_TREE;
+  if (POINTER_TYPE_P (ptr_type))
+    return aarch64_builtin_decls[AARCH64_BUILTIN_ATOMIC_HINTS_FETCH_PTR];
+  if TYPE_UNSIGNED (ptr_type)

Missing parenthesis.

Cheers,
Wilco

Reply via email to