| author | |
| committer | |
| log | 389d1177a57a442b7814d9fdede2a088c614b69d |
| tree | cde4ee4841a020ece280e0c23634d3abf44a6be7 |
| parent | 97779442d0a551d96f2a0b1799e96944918af32e |
Pointer types need an extra indirection layer during the generation of
the function prototype for inline asm blocks.
Closes #36062 files changed, 18 insertions(+), 1 deletions(-)
src/stage1/codegen.cpp+3-1| ... | ... | @@ -4880,6 +4880,9 @@ static LLVMValueRef ir_render_asm_gen(CodeGen *g, IrExecutableGen *executable, I |
| 4880 | 4880 | type_ref = get_llvm_type(g, wider_type); |
| 4881 | 4881 | value_ref = gen_widen_or_shorten(g, false, type, wider_type, value_ref); |
| 4882 | 4882 | } |
| 4883 | } else if (handle_is_ptr(g, type)) { | |
| 4884 | ZigType *gen_type = get_pointer_to_type(g, type, true); | |
| 4885 | type_ref = get_llvm_type(g, gen_type); | |
| 4883 | 4886 | } |
| 4884 | 4887 | |
| 4885 | 4888 | param_types[param_index] = type_ref; |
| ... | ... | @@ -9296,7 +9299,6 @@ static void init(CodeGen *g) { |
| 9296 | 9299 | char *layout_str = LLVMCopyStringRepOfTargetData(g->target_data_ref); |
| 9297 | 9300 | LLVMSetDataLayout(g->module, layout_str); |
| 9298 | 9301 | |
| 9299 | ||
| 9300 | 9302 | assert(g->pointer_size_bytes == LLVMPointerSize(g->target_data_ref)); |
| 9301 | 9303 | g->is_big_endian = (LLVMByteOrder(g->target_data_ref) == LLVMBigEndian); |
| 9302 | 9304 |
test/stage1/behavior/asm.zig+15| ... | ... | @@ -87,6 +87,21 @@ test "sized integer/float in asm input" { |
| 87 | 87 | ); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | test "struct/array/union types as input values" { | |
| 91 | asm volatile ("" | |
| 92 | : | |
| 93 | : [_] "m" (@as([1]u32, undefined)) | |
| 94 | ); // fails | |
| 95 | asm volatile ("" | |
| 96 | : | |
| 97 | : [_] "m" (@as(struct { x: u32, y: u8 }, undefined)) | |
| 98 | ); // fails | |
| 99 | asm volatile ("" | |
| 100 | : | |
| 101 | : [_] "m" (@as(union { x: u32, y: u8 }, undefined)) | |
| 102 | ); // fails | |
| 103 | } | |
| 104 | ||
| 90 | 105 | extern fn this_is_my_alias() i32; |
| 91 | 106 | |
| 92 | 107 | export fn derp() i32 { |