Skip to content

Commit

Permalink
Update default asm dialect on asm strings. Fix naked function analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Oct 14, 2023
1 parent 80a9842 commit 682dfd0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 2 additions & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.5.0 Change List

### Changes / improvements
- Asm string blocks use AT&T syntax for better reliability.
- Distinct methods changed to separate syntax.
- 'exec' directive to run scripts at compile time.
- Project key descriptions in --list command.
Expand Down Expand Up @@ -174,6 +175,7 @@
- Added posix socket functions.
### Fixes
- Naked functions now correctly handles `asm`.
- Indexing into arrays would not always widen the index safely.
- Macros with implicit return didn't correctly deduct the return type.
- Reevaluating a bitstruct (due to checked) would break.
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/llvm_codegen_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ static inline void llvm_emit_asm_block_stmt(GenContext *c, Ast *ast)
strlen(clobbers),
ast->asm_block_stmt.is_volatile,
true,
ast->asm_block_stmt.is_string ? LLVMInlineAsmDialectIntel : LLVMInlineAsmDialectATT,
LLVMInlineAsmDialectATT,
/* can throw */ false
);
LLVMValueRef res = LLVMBuildCall2(c->builder, asm_fn_type, asm_fn, args, param_count, "");
Expand Down
1 change: 1 addition & 0 deletions src/compiler/sema_stmts.c
Original file line number Diff line number Diff line change
Expand Up @@ -3115,6 +3115,7 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func)
}
}
assert_first = 0;
if (!sema_analyse_compound_statement_no_scope(context, body)) return false;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMPILER_VERSION "0.4.681"
#define COMPILER_VERSION "0.4.682"
22 changes: 15 additions & 7 deletions test/test_suite/asm/naked.c3t
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
// #target: macos-x64
module testing;
import std::io;

fn void test() @naked @export("hello")
{
asm("nop");
fn void start() @export("_start") @naked @nostrip {
asm {
movq $rax, 0x3c;
movq $rdi, 42;
syscall;
}
}
fn void main()
{
}

/* #expect: testing.ll

define void @_start() #0 {
entry:
call void asm alignstack "movq $$60, %rax\0Amovq $$42, %rdi\0Asyscall \0A", "~{cc},~{rax},~{rcx},~{r8},~{r11},~{flags},~{dirflag},~{fspr}"()
ret void
}

0 comments on commit 682dfd0

Please sign in to comment.