diff options
| author | gingerBill <bill@gingerbill.org> | 2022-10-30 22:05:29 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2022-10-30 22:05:29 +0000 |
| commit | 6a14c3edb42fbbcc9ab0df962458f1da16f6f508 (patch) | |
| tree | 1ff3d2f93a65e65aaa12a304c4bf09764a50163d /src/llvm_backend_proc.cpp | |
| parent | 2cd895c50b788c6bec8a198820611c6a31ee31a7 (diff) | |
Make `raw_data` an intrinsic rather a `@(builtin)` runtime procedure
Diffstat (limited to 'src/llvm_backend_proc.cpp')
| -rw-r--r-- | src/llvm_backend_proc.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 4d7896c8a..a88c8f2ee 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -1850,6 +1850,37 @@ lbValue lb_build_builtin_proc(lbProcedure *p, Ast *expr, TypeAndValue const &tv, lb_emit_unreachable(p); return {}; + case BuiltinProc_raw_data: + { + lbValue x = lb_build_expr(p, ce->args[0]); + Type *t = base_type(x.type); + lbValue res = {}; + switch (t->kind) { + case Type_Slice: + res = lb_slice_elem(p, x); + res = lb_emit_conv(p, res, tv.type); + break; + case Type_DynamicArray: + res = lb_dynamic_array_elem(p, x); + res = lb_emit_conv(p, res, tv.type); + break; + case Type_Basic: + if (t->Basic.kind == Basic_string) { + res = lb_string_elem(p, x); + res = lb_emit_conv(p, res, tv.type); + } else if (t->Basic.kind == Basic_cstring) { + res = lb_emit_conv(p, x, tv.type); + } + break; + case Type_Pointer: + case Type_MultiPointer: + res = lb_emit_conv(p, x, tv.type); + break; + } + GB_ASSERT(res.value != nullptr); + return res; + } + // "Intrinsics" |