| author | |
| committer | |
| log | 16b8467a5eb983d76d77b7a679af535c950e94b3 |
| tree | bfcf7341ebcc72dbd31d6ed22a3de62d93e03e94 |
| parent | c00216701c64269a2395e84f3ccff99d6fb89ffc |
6 files changed, 50 insertions(+), 15 deletions(-)
src/codegen.cpp+2-6| ... | ... | @@ -643,18 +643,14 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { |
| 643 | 643 | unsigned line_number = (unsigned)(fn_table_entry->proto_node->line == 0) ? |
| 644 | 644 | 0 : (fn_table_entry->proto_node->line + 1); |
| 645 | 645 | unsigned scope_line = line_number; |
| 646 | bool is_definition = fn_table_entry->body_node != nullptr; | |
| 647 | 646 | unsigned flags = 0; |
| 648 | bool is_optimized = g->build_mode != BuildModeDebug; | |
| 649 | bool is_internal_linkage = (fn_table_entry->body_node != nullptr && | |
| 650 | fn_table_entry->export_list.length == 0); | |
| 651 | 647 | ZigLLVMDIScope *fn_di_scope = get_di_scope(g, scope->parent); |
| 652 | 648 | assert(fn_di_scope != nullptr); |
| 653 | 649 | ZigLLVMDISubprogram *subprogram = ZigLLVMCreateFunction(g->dbuilder, |
| 654 | 650 | fn_di_scope, buf_ptr(&fn_table_entry->symbol_name), "", |
| 655 | 651 | import->di_file, line_number, |
| 656 | fn_table_entry->type_entry->di_type, is_internal_linkage, | |
| 657 | is_definition, scope_line, flags, is_optimized, nullptr); | |
| 652 | fn_table_entry->type_entry->di_type, | |
| 653 | scope_line, flags, nullptr); | |
| 658 | 654 | |
| 659 | 655 | scope->di_scope = ZigLLVMSubprogramToScope(subprogram); |
| 660 | 656 | ZigLLVMFnSetSubprogram(fn_llvm_value(g, fn_table_entry), subprogram); |
src/target.cpp+7| ... | ... | @@ -184,6 +184,7 @@ static const Os os_list[] = { |
| 184 | 184 | OsContiki, |
| 185 | 185 | OsAMDPAL, |
| 186 | 186 | OsHermitCore, |
| 187 | OsHurd, | |
| 187 | 188 | OsZen, |
| 188 | 189 | }; |
| 189 | 190 | |
| ... | ... | @@ -328,6 +329,8 @@ ZigLLVM_OSType get_llvm_os_type(Os os_type) { |
| 328 | 329 | return ZigLLVM_AMDPAL; |
| 329 | 330 | case OsHermitCore: |
| 330 | 331 | return ZigLLVM_HermitCore; |
| 332 | case OsHurd: | |
| 333 | return ZigLLVM_Hurd; | |
| 331 | 334 | } |
| 332 | 335 | zig_unreachable(); |
| 333 | 336 | } |
| ... | ... | @@ -399,6 +402,8 @@ static Os get_zig_os_type(ZigLLVM_OSType os_type) { |
| 399 | 402 | return OsAMDPAL; |
| 400 | 403 | case ZigLLVM_HermitCore: |
| 401 | 404 | return OsHermitCore; |
| 405 | case ZigLLVM_Hurd: | |
| 406 | return OsHurd; | |
| 402 | 407 | } |
| 403 | 408 | zig_unreachable(); |
| 404 | 409 | } |
| ... | ... | @@ -440,6 +445,7 @@ const char *get_target_os_name(Os os_type) { |
| 440 | 445 | case OsContiki: |
| 441 | 446 | case OsAMDPAL: |
| 442 | 447 | case OsHermitCore: |
| 448 | case OsHurd: | |
| 443 | 449 | return ZigLLVMGetOSTypeName(get_llvm_os_type(os_type)); |
| 444 | 450 | } |
| 445 | 451 | zig_unreachable(); |
| ... | ... | @@ -814,6 +820,7 @@ uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { |
| 814 | 820 | case OsContiki: |
| 815 | 821 | case OsAMDPAL: |
| 816 | 822 | case OsHermitCore: |
| 823 | case OsHurd: | |
| 817 | 824 | zig_panic("TODO c type size in bits for this target"); |
| 818 | 825 | } |
| 819 | 826 | zig_unreachable(); |
src/target.hpp+1| ... | ... | @@ -51,6 +51,7 @@ enum Os { |
| 51 | 51 | OsContiki, |
| 52 | 52 | OsAMDPAL, |
| 53 | 53 | OsHermitCore, |
| 54 | OsHurd, | |
| 54 | 55 | OsZen, |
| 55 | 56 | }; |
| 56 | 57 |
src/translate_c.cpp+29-2| ... | ... | @@ -906,6 +906,18 @@ static AstNode *trans_type(Context *c, const Type *ty, const SourceLocation &sou |
| 906 | 906 | case BuiltinType::SatUShortFract: |
| 907 | 907 | case BuiltinType::SatUFract: |
| 908 | 908 | case BuiltinType::SatULongFract: |
| 909 | case BuiltinType::OCLIntelSubgroupAVCMcePayload: | |
| 910 | case BuiltinType::OCLIntelSubgroupAVCImePayload: | |
| 911 | case BuiltinType::OCLIntelSubgroupAVCRefPayload: | |
| 912 | case BuiltinType::OCLIntelSubgroupAVCSicPayload: | |
| 913 | case BuiltinType::OCLIntelSubgroupAVCMceResult: | |
| 914 | case BuiltinType::OCLIntelSubgroupAVCImeResult: | |
| 915 | case BuiltinType::OCLIntelSubgroupAVCRefResult: | |
| 916 | case BuiltinType::OCLIntelSubgroupAVCSicResult: | |
| 917 | case BuiltinType::OCLIntelSubgroupAVCImeResultSingleRefStreamout: | |
| 918 | case BuiltinType::OCLIntelSubgroupAVCImeResultDualRefStreamout: | |
| 919 | case BuiltinType::OCLIntelSubgroupAVCImeSingleRefStreamin: | |
| 920 | case BuiltinType::OCLIntelSubgroupAVCImeDualRefStreamin: | |
| 909 | 921 | emit_warning(c, source_loc, "unsupported builtin type"); |
| 910 | 922 | return nullptr; |
| 911 | 923 | } |
| ... | ... | @@ -1011,6 +1023,9 @@ static AstNode *trans_type(Context *c, const Type *ty, const SourceLocation &sou |
| 1011 | 1023 | case CC_PreserveAll: |
| 1012 | 1024 | emit_warning(c, source_loc, "unsupported calling convention: PreserveAll"); |
| 1013 | 1025 | return nullptr; |
| 1026 | case CC_AArch64VectorCall: | |
| 1027 | emit_warning(c, source_loc, "unsupported calling convention: AArch64VectorCall"); | |
| 1028 | return nullptr; | |
| 1014 | 1029 | } |
| 1015 | 1030 | |
| 1016 | 1031 | proto_node->data.fn_proto.is_var_args = fn_proto_ty->isVariadic(); |
| ... | ... | @@ -1202,12 +1217,12 @@ static AstNode *trans_return_stmt(Context *c, TransScope *scope, const ReturnStm |
| 1202 | 1217 | } |
| 1203 | 1218 | |
| 1204 | 1219 | static AstNode *trans_integer_literal(Context *c, const IntegerLiteral *stmt) { |
| 1205 | llvm::APSInt result; | |
| 1220 | Expr::EvalResult result; | |
| 1206 | 1221 | if (!stmt->EvaluateAsInt(result, *c->ctx)) { |
| 1207 | 1222 | emit_warning(c, stmt->getBeginLoc(), "invalid integer literal"); |
| 1208 | 1223 | return nullptr; |
| 1209 | 1224 | } |
| 1210 | return trans_create_node_apint(c, result); | |
| 1225 | return trans_create_node_apint(c, result.Val.getInt()); | |
| 1211 | 1226 | } |
| 1212 | 1227 | |
| 1213 | 1228 | static AstNode *trans_conditional_operator(Context *c, ResultUsed result_used, TransScope *scope, |
| ... | ... | @@ -2510,6 +2525,18 @@ static AstNode *trans_bool_expr(Context *c, ResultUsed result_used, TransScope * |
| 2510 | 2525 | case BuiltinType::SatUShortFract: |
| 2511 | 2526 | case BuiltinType::SatUFract: |
| 2512 | 2527 | case BuiltinType::SatULongFract: |
| 2528 | case BuiltinType::OCLIntelSubgroupAVCMcePayload: | |
| 2529 | case BuiltinType::OCLIntelSubgroupAVCImePayload: | |
| 2530 | case BuiltinType::OCLIntelSubgroupAVCRefPayload: | |
| 2531 | case BuiltinType::OCLIntelSubgroupAVCSicPayload: | |
| 2532 | case BuiltinType::OCLIntelSubgroupAVCMceResult: | |
| 2533 | case BuiltinType::OCLIntelSubgroupAVCImeResult: | |
| 2534 | case BuiltinType::OCLIntelSubgroupAVCRefResult: | |
| 2535 | case BuiltinType::OCLIntelSubgroupAVCSicResult: | |
| 2536 | case BuiltinType::OCLIntelSubgroupAVCImeResultSingleRefStreamout: | |
| 2537 | case BuiltinType::OCLIntelSubgroupAVCImeResultDualRefStreamout: | |
| 2538 | case BuiltinType::OCLIntelSubgroupAVCImeSingleRefStreamin: | |
| 2539 | case BuiltinType::OCLIntelSubgroupAVCImeDualRefStreamin: | |
| 2513 | 2540 | return res; |
| 2514 | 2541 | } |
| 2515 | 2542 | break; |
src/zig_llvm.cpp+7-4| ... | ... | @@ -594,8 +594,8 @@ ZigLLVMDIFile *ZigLLVMCreateFile(ZigLLVMDIBuilder *dibuilder, const char *filena |
| 594 | 594 | |
| 595 | 595 | ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope, |
| 596 | 596 | const char *name, const char *linkage_name, ZigLLVMDIFile *file, unsigned lineno, |
| 597 | ZigLLVMDIType *fn_di_type, bool is_local_to_unit, bool is_definition, unsigned scope_line, | |
| 598 | unsigned flags, bool is_optimized, ZigLLVMDISubprogram *decl_subprogram) | |
| 597 | ZigLLVMDIType *fn_di_type, unsigned scope_line, | |
| 598 | unsigned flags, ZigLLVMDISubprogram *decl_subprogram) | |
| 599 | 599 | { |
| 600 | 600 | DISubroutineType *di_sub_type = static_cast<DISubroutineType*>(reinterpret_cast<DIType*>(fn_di_type)); |
| 601 | 601 | assert(flags == 0); |
| ... | ... | @@ -605,9 +605,12 @@ ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMD |
| 605 | 605 | reinterpret_cast<DIFile*>(file), |
| 606 | 606 | lineno, |
| 607 | 607 | di_sub_type, |
| 608 | is_local_to_unit, is_definition, scope_line, DINode::FlagZero, is_optimized, | |
| 608 | scope_line, | |
| 609 | DINode::FlagZero, | |
| 610 | DISubprogram::SPFlagZero, | |
| 609 | 611 | nullptr, |
| 610 | reinterpret_cast<DISubprogram *>(decl_subprogram)); | |
| 612 | reinterpret_cast<DISubprogram *>(decl_subprogram), | |
| 613 | nullptr); | |
| 611 | 614 | return reinterpret_cast<ZigLLVMDISubprogram*>(result); |
| 612 | 615 | } |
| 613 | 616 |
src/zig_llvm.h+4-3| ... | ... | @@ -188,8 +188,8 @@ ZIG_EXTERN_C struct ZigLLVMDIFile *ZigLLVMCreateFile(struct ZigLLVMDIBuilder *di |
| 188 | 188 | |
| 189 | 189 | ZIG_EXTERN_C struct ZigLLVMDISubprogram *ZigLLVMCreateFunction(struct ZigLLVMDIBuilder *dibuilder, |
| 190 | 190 | struct ZigLLVMDIScope *scope, const char *name, const char *linkage_name, struct ZigLLVMDIFile *file, |
| 191 | unsigned lineno, struct ZigLLVMDIType *fn_di_type, bool is_local_to_unit, bool is_definition, | |
| 192 | unsigned scope_line, unsigned flags, bool is_optimized, struct ZigLLVMDISubprogram *decl_subprogram); | |
| 191 | unsigned lineno, struct ZigLLVMDIType *fn_di_type, | |
| 192 | unsigned scope_line, unsigned flags, struct ZigLLVMDISubprogram *decl_subprogram); | |
| 193 | 193 | |
| 194 | 194 | ZIG_EXTERN_C void ZigLLVMFnSetSubprogram(LLVMValueRef fn, struct ZigLLVMDISubprogram *subprogram); |
| 195 | 195 | |
| ... | ... | @@ -361,8 +361,9 @@ enum ZigLLVM_OSType { |
| 361 | 361 | ZigLLVM_Contiki, |
| 362 | 362 | ZigLLVM_AMDPAL, // AMD PAL Runtime |
| 363 | 363 | ZigLLVM_HermitCore, // HermitCore Unikernel/Multikernel |
| 364 | ZigLLVM_Hurd, // GNU/Hurd | |
| 364 | 365 | |
| 365 | ZigLLVM_LastOSType = ZigLLVM_HermitCore | |
| 366 | ZigLLVM_LastOSType = ZigLLVM_Hurd | |
| 366 | 367 | }; |
| 367 | 368 | |
| 368 | 369 | // Synchronize with target.cpp::environ_list |