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 {...}`
This commit is contained in:
gingerBill
2020-10-24 16:32:37 +01:00
parent 0061e63db0
commit 4629754f7c
8 changed files with 271 additions and 14 deletions

View File

@@ -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));