Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial bringup for Linux/Thumb2 #8683

Merged
merged 3 commits into from
May 6, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
stage1: Fix LLVM error in inline asm invocation
Pointer types need an extra indirection layer during the generation of
the function prototype for inline asm blocks.

Closes #3606
LemonBoy committed May 4, 2021
commit 389d1177a57a442b7814d9fdede2a088c614b69d
4 changes: 3 additions & 1 deletion src/stage1/codegen.cpp
Original file line number Diff line number Diff line change
@@ -4880,6 +4880,9 @@ static LLVMValueRef ir_render_asm_gen(CodeGen *g, IrExecutableGen *executable, I
type_ref = get_llvm_type(g, wider_type);
value_ref = gen_widen_or_shorten(g, false, type, wider_type, value_ref);
}
} else if (handle_is_ptr(g, type)) {
ZigType *gen_type = get_pointer_to_type(g, type, true);
type_ref = get_llvm_type(g, gen_type);
}

param_types[param_index] = type_ref;
@@ -9296,7 +9299,6 @@ static void init(CodeGen *g) {
char *layout_str = LLVMCopyStringRepOfTargetData(g->target_data_ref);
LLVMSetDataLayout(g->module, layout_str);


assert(g->pointer_size_bytes == LLVMPointerSize(g->target_data_ref));
g->is_big_endian = (LLVMByteOrder(g->target_data_ref) == LLVMBigEndian);

15 changes: 15 additions & 0 deletions test/stage1/behavior/asm.zig
Original file line number Diff line number Diff line change
@@ -87,6 +87,21 @@ test "sized integer/float in asm input" {
);
}

test "struct/array/union types as input values" {
asm volatile (""
:
: [_] "m" (@as([1]u32, undefined))
); // fails
asm volatile (""
:
: [_] "m" (@as(struct { x: u32, y: u8 }, undefined))
); // fails
asm volatile (""
:
: [_] "m" (@as(union { x: u32, y: u8 }, undefined))
); // fails
}

extern fn this_is_my_alias() i32;

export fn derp() i32 {