From 4629754f7ced5df477eb017872ef65539db64a27 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 24 Oct 2020 16:32:37 +0100 Subject: Inline asm expression (-llvm-api) See https://llvm.org/docs/LangRef.html#inline-assembler-expressions Example: ``` x := asm(i32) -> i32 { "bswap $0", "=r,r", }(123); ``` Allowed directives `#side_effect`, `#align_stack`, `#att`, `#intel` e.g. `asm() #side_effect #intel {...}` --- src/check_decl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 639bf7d4f..1aafa6e1c 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -79,7 +79,11 @@ Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *operand, Stri } t = default_type(t); } - if (is_type_polymorphic(t)) { + if (is_type_asm_proc(t)) { + error(e->token, "Invalid use of inline asm in %.*s", LIT(context_name)); + e->type = t_invalid; + return nullptr; + } else if (is_type_polymorphic(t)) { gbString str = type_to_string(t); defer (gb_string_free(str)); error(e->token, "Invalid use of a polymorphic type '%s' in %.*s", str, LIT(context_name)); -- cgit v1.2.3