| author | |
| committer | |
| log | 11a655032400fda22132c54131546f3e671476a9 |
| tree | 929648da483a3ec3693299e9f6aa8108a120ca09 |
| parent | 34eff503265834172f89a8635e49e9f4d124db51 |
16 files changed, 206 insertions(+), 193 deletions(-)
src/all_types.hpp+4-4| ... | ... | @@ -277,7 +277,7 @@ struct TldVar { |
| 277 | 277 | |
| 278 | 278 | VariableTableEntry *var; |
| 279 | 279 | AstNode *set_global_align_node; |
| 280 | uint64_t alignment; | |
| 280 | uint32_t alignment; | |
| 281 | 281 | AstNode *set_global_section_node; |
| 282 | 282 | Buf *section_name; |
| 283 | 283 | AstNode *set_global_linkage_node; |
| ... | ... | @@ -888,7 +888,7 @@ struct TypeTableEntryPointer { |
| 888 | 888 | }; |
| 889 | 889 | |
| 890 | 890 | struct TypeTableEntryInt { |
| 891 | size_t bit_count; | |
| 891 | uint32_t bit_count; | |
| 892 | 892 | bool is_signed; |
| 893 | 893 | }; |
| 894 | 894 | |
| ... | ... | @@ -1146,7 +1146,7 @@ struct FnTableEntry { |
| 1146 | 1146 | ZigList<VariableTableEntry *> variable_list; |
| 1147 | 1147 | |
| 1148 | 1148 | AstNode *set_global_align_node; |
| 1149 | uint64_t alignment; | |
| 1149 | uint32_t alignment; | |
| 1150 | 1150 | AstNode *set_global_section_node; |
| 1151 | 1151 | Buf *section_name; |
| 1152 | 1152 | AstNode *set_global_linkage_node; |
| ... | ... | @@ -1251,7 +1251,7 @@ struct TypeId { |
| 1251 | 1251 | } array; |
| 1252 | 1252 | struct { |
| 1253 | 1253 | bool is_signed; |
| 1254 | uint8_t bit_count; | |
| 1254 | uint32_t bit_count; | |
| 1255 | 1255 | } integer; |
| 1256 | 1256 | } data; |
| 1257 | 1257 | }; |
src/analyze.cpp+69-65| ... | ... | @@ -163,7 +163,7 @@ static TypeTableEntry *new_container_type_entry(TypeTableEntryId id, AstNode *so |
| 163 | 163 | |
| 164 | 164 | |
| 165 | 165 | // TODO no reason to limit to 8/16/32/64 |
| 166 | static size_t bits_needed_for_unsigned(uint64_t x) { | |
| 166 | static uint8_t bits_needed_for_unsigned(uint64_t x) { | |
| 167 | 167 | if (x <= UINT8_MAX) { |
| 168 | 168 | return 8; |
| 169 | 169 | } else if (x <= UINT16_MAX) { |
| ... | ... | @@ -578,13 +578,14 @@ TypeTableEntry *get_array_type(CodeGen *g, TypeTableEntry *child_type, uint64_t |
| 578 | 578 | buf_appendf(&entry->name, "[%" PRIu64 "]%s", array_size, buf_ptr(&child_type->name)); |
| 579 | 579 | |
| 580 | 580 | if (!entry->zero_bits) { |
| 581 | entry->type_ref = child_type->type_ref ? LLVMArrayType(child_type->type_ref, array_size) : nullptr; | |
| 581 | entry->type_ref = child_type->type_ref ? LLVMArrayType(child_type->type_ref, | |
| 582 | (unsigned int)array_size) : nullptr; | |
| 582 | 583 | |
| 583 | 584 | uint64_t debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, entry->type_ref); |
| 584 | 585 | uint64_t debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, entry->type_ref); |
| 585 | 586 | |
| 586 | 587 | entry->di_type = ZigLLVMCreateDebugArrayType(g->dbuilder, debug_size_in_bits, |
| 587 | debug_align_in_bits, child_type->di_type, array_size); | |
| 588 | debug_align_in_bits, child_type->di_type, (int)array_size); | |
| 588 | 589 | } |
| 589 | 590 | entry->data.array.child_type = child_type; |
| 590 | 591 | entry->data.array.len = array_size; |
| ... | ... | @@ -911,9 +912,9 @@ TypeTableEntry *get_fn_type(CodeGen *g, FnTypeId *fn_type_id) { |
| 911 | 912 | fn_type->data.fn.gen_param_count = gen_param_index; |
| 912 | 913 | |
| 913 | 914 | fn_type->data.fn.raw_type_ref = LLVMFunctionType(gen_return_type->type_ref, |
| 914 | gen_param_types, gen_param_index, fn_type_id->is_var_args); | |
| 915 | gen_param_types, (unsigned int)gen_param_index, fn_type_id->is_var_args); | |
| 915 | 916 | fn_type->type_ref = LLVMPointerType(fn_type->data.fn.raw_type_ref, 0); |
| 916 | fn_type->di_type = ZigLLVMCreateSubroutineType(g->dbuilder, param_di_types, gen_param_index + 1, 0); | |
| 917 | fn_type->di_type = ZigLLVMCreateSubroutineType(g->dbuilder, param_di_types, (int)(gen_param_index + 1), 0); | |
| 917 | 918 | } |
| 918 | 919 | |
| 919 | 920 | g->fn_type_table.put(&fn_type->data.fn.fn_type_id, fn_type); |
| ... | ... | @@ -954,13 +955,13 @@ TypeTableEntry *get_partial_container_type(CodeGen *g, Scope *scope, ContainerKi |
| 954 | 955 | break; |
| 955 | 956 | } |
| 956 | 957 | |
| 957 | unsigned line = decl_node ? decl_node->line : 0; | |
| 958 | size_t line = decl_node ? decl_node->line : 0; | |
| 958 | 959 | |
| 959 | 960 | ImportTableEntry *import = get_scope_import(scope); |
| 960 | 961 | entry->type_ref = LLVMStructCreateNamed(LLVMGetGlobalContext(), name); |
| 961 | 962 | entry->di_type = ZigLLVMCreateReplaceableCompositeType(g->dbuilder, |
| 962 | 963 | ZigLLVMTag_DW_structure_type(), name, |
| 963 | ZigLLVMFileToScope(import->di_file), import->di_file, line + 1); | |
| 964 | ZigLLVMFileToScope(import->di_file), import->di_file, (unsigned)(line + 1)); | |
| 964 | 965 | |
| 965 | 966 | buf_init_from_str(&entry->name, name); |
| 966 | 967 | |
| ... | ... | @@ -1264,7 +1265,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { |
| 1264 | 1265 | |
| 1265 | 1266 | union_inner_di_types[type_enum_field->gen_index] = ZigLLVMCreateDebugMemberType(g->dbuilder, |
| 1266 | 1267 | ZigLLVMTypeToScope(enum_type->di_type), buf_ptr(type_enum_field->name), |
| 1267 | import->di_file, field_node->line + 1, | |
| 1268 | import->di_file, (unsigned)(field_node->line + 1), | |
| 1268 | 1269 | debug_size_in_bits, |
| 1269 | 1270 | debug_align_in_bits, |
| 1270 | 1271 | 0, |
| ... | ... | @@ -1307,13 +1308,15 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { |
| 1307 | 1308 | uint64_t tag_debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, tag_type_entry->type_ref); |
| 1308 | 1309 | uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref); |
| 1309 | 1310 | ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder, |
| 1310 | ZigLLVMTypeToScope(enum_type->di_type), "AnonEnum", import->di_file, decl_node->line + 1, | |
| 1311 | ZigLLVMTypeToScope(enum_type->di_type), "AnonEnum", | |
| 1312 | import->di_file, (unsigned)(decl_node->line + 1), | |
| 1311 | 1313 | tag_debug_size_in_bits, tag_debug_align_in_bits, di_enumerators, field_count, |
| 1312 | 1314 | tag_type_entry->di_type, ""); |
| 1313 | 1315 | |
| 1314 | 1316 | // create debug type for union |
| 1315 | 1317 | ZigLLVMDIType *union_di_type = ZigLLVMCreateDebugUnionType(g->dbuilder, |
| 1316 | ZigLLVMTypeToScope(enum_type->di_type), "AnonUnion", import->di_file, decl_node->line + 1, | |
| 1318 | ZigLLVMTypeToScope(enum_type->di_type), "AnonUnion", | |
| 1319 | import->di_file, (unsigned)(decl_node->line + 1), | |
| 1317 | 1320 | biggest_union_member_size_in_bits, biggest_align_in_bits, 0, union_inner_di_types, |
| 1318 | 1321 | gen_field_count, 0, ""); |
| 1319 | 1322 | |
| ... | ... | @@ -1321,7 +1324,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { |
| 1321 | 1324 | uint64_t tag_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 0); |
| 1322 | 1325 | ZigLLVMDIType *tag_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder, |
| 1323 | 1326 | ZigLLVMTypeToScope(enum_type->di_type), "tag_field", |
| 1324 | import->di_file, decl_node->line + 1, | |
| 1327 | import->di_file, (unsigned)(decl_node->line + 1), | |
| 1325 | 1328 | tag_debug_size_in_bits, |
| 1326 | 1329 | tag_debug_align_in_bits, |
| 1327 | 1330 | tag_offset_in_bits, |
| ... | ... | @@ -1330,7 +1333,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { |
| 1330 | 1333 | uint64_t union_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, enum_type->type_ref, 1); |
| 1331 | 1334 | ZigLLVMDIType *union_member_di_type = ZigLLVMCreateDebugMemberType(g->dbuilder, |
| 1332 | 1335 | ZigLLVMTypeToScope(enum_type->di_type), "union_field", |
| 1333 | import->di_file, decl_node->line + 1, | |
| 1336 | import->di_file, (unsigned)(decl_node->line + 1), | |
| 1334 | 1337 | biggest_union_member_size_in_bits, |
| 1335 | 1338 | biggest_align_in_bits, |
| 1336 | 1339 | union_offset_in_bits, |
| ... | ... | @@ -1348,7 +1351,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { |
| 1348 | 1351 | ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder, |
| 1349 | 1352 | ZigLLVMFileToScope(import->di_file), |
| 1350 | 1353 | buf_ptr(&enum_type->name), |
| 1351 | import->di_file, decl_node->line + 1, | |
| 1354 | import->di_file, (unsigned)(decl_node->line + 1), | |
| 1352 | 1355 | debug_size_in_bits, |
| 1353 | 1356 | debug_align_in_bits, |
| 1354 | 1357 | 0, nullptr, di_root_members, 2, 0, nullptr, ""); |
| ... | ... | @@ -1364,7 +1367,7 @@ static void resolve_enum_type(CodeGen *g, TypeTableEntry *enum_type) { |
| 1364 | 1367 | uint64_t tag_debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, tag_type_entry->type_ref); |
| 1365 | 1368 | ZigLLVMDIType *tag_di_type = ZigLLVMCreateDebugEnumerationType(g->dbuilder, |
| 1366 | 1369 | ZigLLVMFileToScope(import->di_file), buf_ptr(&enum_type->name), |
| 1367 | import->di_file, decl_node->line + 1, | |
| 1370 | import->di_file, (unsigned)(decl_node->line + 1), | |
| 1368 | 1371 | tag_debug_size_in_bits, |
| 1369 | 1372 | tag_debug_align_in_bits, |
| 1370 | 1373 | di_enumerators, field_count, |
| ... | ... | @@ -1499,7 +1502,7 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1499 | 1502 | type_struct_field->unaligned_bit_count = field_size_in_bits; |
| 1500 | 1503 | |
| 1501 | 1504 | size_t full_bit_count = next_packed_bits_offset - first_packed_bits_offset_misalign; |
| 1502 | LLVMTypeRef int_type_ref = LLVMIntType(full_bit_count); | |
| 1505 | LLVMTypeRef int_type_ref = LLVMIntType((unsigned)(full_bit_count)); | |
| 1503 | 1506 | if (8 * LLVMStoreSizeOfType(g->target_data_ref, int_type_ref) == full_bit_count) { |
| 1504 | 1507 | // next field recovers store alignment |
| 1505 | 1508 | element_types[gen_field_index] = int_type_ref; |
| ... | ... | @@ -1529,9 +1532,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1529 | 1532 | } |
| 1530 | 1533 | if (first_packed_bits_offset_misalign != SIZE_MAX) { |
| 1531 | 1534 | size_t full_bit_count = packed_bits_offset - first_packed_bits_offset_misalign; |
| 1532 | LLVMTypeRef int_type_ref = LLVMIntType(full_bit_count); | |
| 1535 | LLVMTypeRef int_type_ref = LLVMIntType((unsigned)full_bit_count); | |
| 1533 | 1536 | size_t store_bit_count = 8 * LLVMStoreSizeOfType(g->target_data_ref, int_type_ref); |
| 1534 | element_types[gen_field_index] = LLVMIntType(store_bit_count); | |
| 1537 | element_types[gen_field_index] = LLVMIntType((unsigned)store_bit_count); | |
| 1535 | 1538 | gen_field_index += 1; |
| 1536 | 1539 | } |
| 1537 | 1540 | |
| ... | ... | @@ -1552,9 +1555,9 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1552 | 1555 | |
| 1553 | 1556 | // the count may have been adjusting from packing bit fields |
| 1554 | 1557 | gen_field_count = gen_field_index; |
| 1555 | struct_type->data.structure.gen_field_count = gen_field_count; | |
| 1558 | struct_type->data.structure.gen_field_count = (uint32_t)gen_field_count; | |
| 1556 | 1559 | |
| 1557 | LLVMStructSetBody(struct_type->type_ref, element_types, gen_field_count, packed); | |
| 1560 | LLVMStructSetBody(struct_type->type_ref, element_types, (unsigned)gen_field_count, packed); | |
| 1558 | 1561 | assert(LLVMStoreSizeOfType(g->target_data_ref, struct_type->type_ref) > 0); |
| 1559 | 1562 | |
| 1560 | 1563 | ZigLLVMDIType **di_element_types = allocate<ZigLLVMDIType*>(debug_field_count); |
| ... | ... | @@ -1593,15 +1596,16 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1593 | 1596 | debug_size_in_bits = type_struct_field->packed_bits_size; |
| 1594 | 1597 | debug_align_in_bits = 1; |
| 1595 | 1598 | debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, |
| 1596 | gen_field_index) + type_struct_field->packed_bits_offset; | |
| 1599 | (unsigned)gen_field_index) + type_struct_field->packed_bits_offset; | |
| 1597 | 1600 | } else { |
| 1598 | 1601 | debug_size_in_bits = 8*LLVMStoreSizeOfType(g->target_data_ref, field_type->type_ref); |
| 1599 | 1602 | debug_align_in_bits = 8*LLVMABISizeOfType(g->target_data_ref, field_type->type_ref); |
| 1600 | debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, gen_field_index); | |
| 1603 | debug_offset_in_bits = 8*LLVMOffsetOfElement(g->target_data_ref, struct_type->type_ref, | |
| 1604 | (unsigned)gen_field_index); | |
| 1601 | 1605 | } |
| 1602 | 1606 | di_element_types[debug_field_index] = ZigLLVMCreateDebugMemberType(g->dbuilder, |
| 1603 | 1607 | ZigLLVMTypeToScope(struct_type->di_type), buf_ptr(type_struct_field->name), |
| 1604 | import->di_file, field_node->line + 1, | |
| 1608 | import->di_file, (unsigned)(field_node->line + 1), | |
| 1605 | 1609 | debug_size_in_bits, |
| 1606 | 1610 | debug_align_in_bits, |
| 1607 | 1611 | debug_offset_in_bits, |
| ... | ... | @@ -1616,10 +1620,10 @@ static void resolve_struct_type(CodeGen *g, TypeTableEntry *struct_type) { |
| 1616 | 1620 | ZigLLVMDIType *replacement_di_type = ZigLLVMCreateDebugStructType(g->dbuilder, |
| 1617 | 1621 | ZigLLVMFileToScope(import->di_file), |
| 1618 | 1622 | buf_ptr(&struct_type->name), |
| 1619 | import->di_file, decl_node->line + 1, | |
| 1623 | import->di_file, (unsigned)(decl_node->line + 1), | |
| 1620 | 1624 | debug_size_in_bits, |
| 1621 | 1625 | debug_align_in_bits, |
| 1622 | 0, nullptr, di_element_types, debug_field_count, 0, nullptr, ""); | |
| 1626 | 0, nullptr, di_element_types, (int)debug_field_count, 0, nullptr, ""); | |
| 1623 | 1627 | |
| 1624 | 1628 | ZigLLVMReplaceTemporary(g->dbuilder, struct_type->di_type, replacement_di_type); |
| 1625 | 1629 | struct_type->di_type = replacement_di_type; |
| ... | ... | @@ -1647,7 +1651,7 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) { |
| 1647 | 1651 | assert(enum_type->di_type); |
| 1648 | 1652 | |
| 1649 | 1653 | assert(!enum_type->data.enumeration.fields); |
| 1650 | uint32_t field_count = decl_node->data.container_decl.fields.length; | |
| 1654 | uint32_t field_count = (uint32_t)decl_node->data.container_decl.fields.length; | |
| 1651 | 1655 | enum_type->data.enumeration.src_field_count = field_count; |
| 1652 | 1656 | enum_type->data.enumeration.fields = allocate<TypeEnumField>(field_count); |
| 1653 | 1657 | |
| ... | ... | @@ -1700,7 +1704,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) { |
| 1700 | 1704 | |
| 1701 | 1705 | assert(!struct_type->data.structure.fields); |
| 1702 | 1706 | size_t field_count = decl_node->data.container_decl.fields.length; |
| 1703 | struct_type->data.structure.src_field_count = field_count; | |
| 1707 | struct_type->data.structure.src_field_count = (uint32_t)field_count; | |
| 1704 | 1708 | struct_type->data.structure.fields = allocate<TypeStructField>(field_count); |
| 1705 | 1709 | |
| 1706 | 1710 | Scope *scope = &struct_type->data.structure.decls_scope->base; |
| ... | ... | @@ -1729,7 +1733,7 @@ static void resolve_struct_zero_bits(CodeGen *g, TypeTableEntry *struct_type) { |
| 1729 | 1733 | } |
| 1730 | 1734 | |
| 1731 | 1735 | struct_type->data.structure.zero_bits_loop_flag = false; |
| 1732 | struct_type->data.structure.gen_field_count = gen_field_index; | |
| 1736 | struct_type->data.structure.gen_field_count = (uint32_t)gen_field_index; | |
| 1733 | 1737 | struct_type->zero_bits = (gen_field_index == 0); |
| 1734 | 1738 | struct_type->data.structure.zero_bits_known = true; |
| 1735 | 1739 | } |
| ... | ... | @@ -1985,7 +1989,7 @@ static void preview_error_value_decl(CodeGen *g, AstNode *node) { |
| 1985 | 1989 | } else { |
| 1986 | 1990 | size_t error_value_count = g->error_decls.length; |
| 1987 | 1991 | assert((uint32_t)error_value_count < (((uint32_t)1) << (uint32_t)g->err_tag_type->data.integral.bit_count)); |
| 1988 | err->value = error_value_count; | |
| 1992 | err->value = (uint32_t)error_value_count; | |
| 1989 | 1993 | g->error_decls.append(node); |
| 1990 | 1994 | g->error_table.put(&err->name, err); |
| 1991 | 1995 | } |
| ... | ... | @@ -2999,7 +3003,7 @@ bool is_node_void_expr(AstNode *node) { |
| 2999 | 3003 | return false; |
| 3000 | 3004 | } |
| 3001 | 3005 | |
| 3002 | TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bits) { | |
| 3006 | TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint32_t size_in_bits) { | |
| 3003 | 3007 | size_t index; |
| 3004 | 3008 | if (size_in_bits == 8) { |
| 3005 | 3009 | index = 0; |
| ... | ... | @@ -3015,7 +3019,7 @@ TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bi |
| 3015 | 3019 | return &g->builtin_types.entry_int[is_signed ? 0 : 1][index]; |
| 3016 | 3020 | } |
| 3017 | 3021 | |
| 3018 | TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint8_t size_in_bits) { | |
| 3022 | TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) { | |
| 3019 | 3023 | TypeTableEntry **common_entry = get_int_type_ptr(g, is_signed, size_in_bits); |
| 3020 | 3024 | if (common_entry) |
| 3021 | 3025 | return *common_entry; |
| ... | ... | @@ -3104,11 +3108,11 @@ void find_libc_lib_path(CodeGen *g) { |
| 3104 | 3108 | } |
| 3105 | 3109 | |
| 3106 | 3110 | static uint32_t hash_ptr(void *ptr) { |
| 3107 | return ((uintptr_t)ptr) % UINT32_MAX; | |
| 3111 | return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX); | |
| 3108 | 3112 | } |
| 3109 | 3113 | |
| 3110 | 3114 | static uint32_t hash_size(size_t x) { |
| 3111 | return x % UINT32_MAX; | |
| 3115 | return (uint32_t)(x % UINT32_MAX); | |
| 3112 | 3116 | } |
| 3113 | 3117 | |
| 3114 | 3118 | uint32_t fn_table_entry_hash(FnTableEntry* value) { |
| ... | ... | @@ -3121,14 +3125,14 @@ bool fn_table_entry_eql(FnTableEntry *a, FnTableEntry *b) { |
| 3121 | 3125 | |
| 3122 | 3126 | uint32_t fn_type_id_hash(FnTypeId *id) { |
| 3123 | 3127 | uint32_t result = 0; |
| 3124 | result += id->is_extern ? 3349388391 : 0; | |
| 3125 | result += id->is_naked ? 608688877 : 0; | |
| 3126 | result += id->is_cold ? 3605523458 : 0; | |
| 3127 | result += id->is_var_args ? 1931444534 : 0; | |
| 3128 | result += id->is_extern ? (uint32_t)3349388391 : 0; | |
| 3129 | result += id->is_naked ? (uint32_t)608688877 : 0; | |
| 3130 | result += id->is_cold ? (uint32_t)3605523458 : 0; | |
| 3131 | result += id->is_var_args ? (uint32_t)1931444534 : 0; | |
| 3128 | 3132 | result += hash_ptr(id->return_type); |
| 3129 | 3133 | for (size_t i = 0; i < id->param_count; i += 1) { |
| 3130 | 3134 | FnTypeParamInfo *info = &id->param_info[i]; |
| 3131 | result += info->is_noalias ? 892356923 : 0; | |
| 3135 | result += info->is_noalias ? (uint32_t)892356923 : 0; | |
| 3132 | 3136 | result += hash_ptr(info->type); |
| 3133 | 3137 | } |
| 3134 | 3138 | return result; |
| ... | ... | @@ -3161,55 +3165,55 @@ static uint32_t hash_const_val(ConstExprValue *const_val) { |
| 3161 | 3165 | assert(const_val->special == ConstValSpecialStatic); |
| 3162 | 3166 | switch (const_val->type->id) { |
| 3163 | 3167 | case TypeTableEntryIdBool: |
| 3164 | return const_val->data.x_bool ? 127863866 : 215080464; | |
| 3168 | return const_val->data.x_bool ? (uint32_t)127863866 : (uint32_t)215080464; | |
| 3165 | 3169 | case TypeTableEntryIdMetaType: |
| 3166 | 3170 | return hash_ptr(const_val->data.x_type); |
| 3167 | 3171 | case TypeTableEntryIdVoid: |
| 3168 | return 4149439618; | |
| 3172 | return (uint32_t)4149439618; | |
| 3169 | 3173 | case TypeTableEntryIdInt: |
| 3170 | 3174 | case TypeTableEntryIdNumLitInt: |
| 3171 | 3175 | case TypeTableEntryIdEnumTag: |
| 3172 | return ((uint32_t)(bignum_to_twos_complement(&const_val->data.x_bignum) % UINT32_MAX)) * 1331471175; | |
| 3176 | return ((uint32_t)(bignum_to_twos_complement(&const_val->data.x_bignum) % UINT32_MAX)) * (uint32_t)1331471175; | |
| 3173 | 3177 | case TypeTableEntryIdFloat: |
| 3174 | 3178 | case TypeTableEntryIdNumLitFloat: |
| 3175 | return const_val->data.x_bignum.data.x_float * UINT32_MAX; | |
| 3179 | return (uint32_t)(const_val->data.x_bignum.data.x_float * (uint32_t)UINT32_MAX); | |
| 3176 | 3180 | case TypeTableEntryIdArgTuple: |
| 3177 | return const_val->data.x_arg_tuple.start_index * 281907309 + | |
| 3178 | const_val->data.x_arg_tuple.end_index * 2290442768; | |
| 3181 | return (uint32_t)const_val->data.x_arg_tuple.start_index * (uint32_t)281907309 + | |
| 3182 | (uint32_t)const_val->data.x_arg_tuple.end_index * (uint32_t)2290442768; | |
| 3179 | 3183 | case TypeTableEntryIdPointer: |
| 3180 | 3184 | { |
| 3181 | 3185 | uint32_t hash_val = 0; |
| 3182 | 3186 | switch (const_val->data.x_ptr.mut) { |
| 3183 | 3187 | case ConstPtrMutRuntimeVar: |
| 3184 | hash_val += 3500721036; | |
| 3188 | hash_val += (uint32_t)3500721036; | |
| 3185 | 3189 | break; |
| 3186 | 3190 | case ConstPtrMutComptimeConst: |
| 3187 | hash_val += 4214318515; | |
| 3191 | hash_val += (uint32_t)4214318515; | |
| 3188 | 3192 | break; |
| 3189 | 3193 | case ConstPtrMutComptimeVar: |
| 3190 | hash_val += 1103195694; | |
| 3194 | hash_val += (uint32_t)1103195694; | |
| 3191 | 3195 | break; |
| 3192 | 3196 | } |
| 3193 | 3197 | switch (const_val->data.x_ptr.special) { |
| 3194 | 3198 | case ConstPtrSpecialInvalid: |
| 3195 | 3199 | zig_unreachable(); |
| 3196 | 3200 | case ConstPtrSpecialRef: |
| 3197 | hash_val += 2478261866; | |
| 3201 | hash_val += (uint32_t)2478261866; | |
| 3198 | 3202 | hash_val += hash_ptr(const_val->data.x_ptr.data.ref.pointee); |
| 3199 | 3203 | return hash_val; |
| 3200 | 3204 | case ConstPtrSpecialBaseArray: |
| 3201 | hash_val += 1764906839; | |
| 3205 | hash_val += (uint32_t)1764906839; | |
| 3202 | 3206 | hash_val += hash_ptr(const_val->data.x_ptr.data.base_array.array_val); |
| 3203 | 3207 | hash_val += hash_size(const_val->data.x_ptr.data.base_array.elem_index); |
| 3204 | 3208 | hash_val += const_val->data.x_ptr.data.base_array.is_cstr ? 1297263887 : 200363492; |
| 3205 | 3209 | return hash_val; |
| 3206 | 3210 | case ConstPtrSpecialBaseStruct: |
| 3207 | hash_val += 3518317043; | |
| 3211 | hash_val += (uint32_t)3518317043; | |
| 3208 | 3212 | hash_val += hash_ptr(const_val->data.x_ptr.data.base_struct.struct_val); |
| 3209 | 3213 | hash_val += hash_size(const_val->data.x_ptr.data.base_struct.field_index); |
| 3210 | 3214 | return hash_val; |
| 3211 | 3215 | case ConstPtrSpecialHardCodedAddr: |
| 3212 | hash_val += 4048518294; | |
| 3216 | hash_val += (uint32_t)4048518294; | |
| 3213 | 3217 | hash_val += hash_size(const_val->data.x_ptr.data.hard_coded_addr.addr); |
| 3214 | 3218 | return hash_val; |
| 3215 | 3219 | case ConstPtrSpecialDiscard: |
| ... | ... | @@ -3954,7 +3958,7 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) { |
| 3954 | 3958 | ConstExprValue *child_value = &const_val->data.x_array.elements[i]; |
| 3955 | 3959 | uint64_t big_c = child_value->data.x_bignum.data.x_uint; |
| 3956 | 3960 | assert(big_c <= UINT8_MAX); |
| 3957 | uint8_t c = big_c; | |
| 3961 | uint8_t c = (uint8_t)big_c; | |
| 3958 | 3962 | if (c == '"') { |
| 3959 | 3963 | buf_append_str(buf, "\\\""); |
| 3960 | 3964 | } else { |
| ... | ... | @@ -4051,14 +4055,14 @@ void render_const_value(Buf *buf, ConstExprValue *const_val) { |
| 4051 | 4055 | zig_unreachable(); |
| 4052 | 4056 | } |
| 4053 | 4057 | |
| 4054 | TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, size_t size_in_bits) { | |
| 4058 | TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits) { | |
| 4055 | 4059 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt); |
| 4056 | 4060 | entry->is_copyable = true; |
| 4057 | 4061 | entry->type_ref = LLVMIntType(size_in_bits); |
| 4058 | 4062 | |
| 4059 | 4063 | const char u_or_i = is_signed ? 'i' : 'u'; |
| 4060 | 4064 | buf_resize(&entry->name, 0); |
| 4061 | buf_appendf(&entry->name, "%c%zu", u_or_i, size_in_bits); | |
| 4065 | buf_appendf(&entry->name, "%c%" PRIu8, u_or_i, size_in_bits); | |
| 4062 | 4066 | |
| 4063 | 4067 | unsigned dwarf_tag; |
| 4064 | 4068 | if (is_signed) { |
| ... | ... | @@ -4111,16 +4115,16 @@ uint32_t type_id_hash(TypeId x) { |
| 4111 | 4115 | zig_unreachable(); |
| 4112 | 4116 | case TypeTableEntryIdPointer: |
| 4113 | 4117 | return hash_ptr(x.data.pointer.child_type) + |
| 4114 | (x.data.pointer.is_const ? 2749109194 : 4047371087) + | |
| 4115 | (x.data.pointer.is_volatile ? 536730450 : 1685612214) + | |
| 4116 | (((uint32_t)x.data.pointer.bit_offset) * 2639019452) + | |
| 4117 | (((uint32_t)x.data.pointer.unaligned_bit_count) * 529908881); | |
| 4118 | (x.data.pointer.is_const ? (uint32_t)2749109194 : (uint32_t)4047371087) + | |
| 4119 | (x.data.pointer.is_volatile ? (uint32_t)536730450 : (uint32_t)1685612214) + | |
| 4120 | (((uint32_t)x.data.pointer.bit_offset) * (uint32_t)2639019452) + | |
| 4121 | (((uint32_t)x.data.pointer.unaligned_bit_count) * (uint32_t)529908881); | |
| 4118 | 4122 | case TypeTableEntryIdArray: |
| 4119 | 4123 | return hash_ptr(x.data.array.child_type) + |
| 4120 | (x.data.array.size * 2122979968); | |
| 4124 | ((uint32_t)x.data.array.size * (uint32_t)2122979968); | |
| 4121 | 4125 | case TypeTableEntryIdInt: |
| 4122 | return (x.data.integer.is_signed ? 2652528194 : 163929201) + | |
| 4123 | (((uint32_t)x.data.integer.bit_count) * 2998081557); | |
| 4126 | return (x.data.integer.is_signed ? (uint32_t)2652528194 : (uint32_t)163929201) + | |
| 4127 | (((uint32_t)x.data.integer.bit_count) * (uint32_t)2998081557); | |
| 4124 | 4128 | } |
| 4125 | 4129 | zig_unreachable(); |
| 4126 | 4130 | } |
| ... | ... | @@ -4173,13 +4177,13 @@ bool type_id_eql(TypeId a, TypeId b) { |
| 4173 | 4177 | uint32_t zig_llvm_fn_key_hash(ZigLLVMFnKey x) { |
| 4174 | 4178 | switch (x.id) { |
| 4175 | 4179 | case ZigLLVMFnIdCtz: |
| 4176 | return x.data.ctz.bit_count * 810453934; | |
| 4180 | return (uint32_t)(x.data.ctz.bit_count) * (uint32_t)810453934; | |
| 4177 | 4181 | case ZigLLVMFnIdClz: |
| 4178 | return x.data.clz.bit_count * 2428952817; | |
| 4182 | return (uint32_t)(x.data.clz.bit_count) * (uint32_t)2428952817; | |
| 4179 | 4183 | case ZigLLVMFnIdOverflowArithmetic: |
| 4180 | return (x.data.overflow_arithmetic.bit_count * 87135777) + | |
| 4181 | (x.data.overflow_arithmetic.add_sub_mul * 31640542) + | |
| 4182 | (x.data.overflow_arithmetic.is_signed ? 1062315172 : 314955820); | |
| 4184 | return ((uint32_t)(x.data.overflow_arithmetic.bit_count) * 87135777) + | |
| 4185 | ((uint32_t)(x.data.overflow_arithmetic.add_sub_mul) * 31640542) + | |
| 4186 | ((uint32_t)(x.data.overflow_arithmetic.is_signed) ? 1062315172 : 314955820); | |
| 4183 | 4187 | } |
| 4184 | 4188 | zig_unreachable(); |
| 4185 | 4189 | } |
src/analyze.hpp+3-3| ... | ... | @@ -20,8 +20,8 @@ TypeTableEntry *get_pointer_to_type_extra(CodeGen *g, TypeTableEntry *child_type |
| 20 | 20 | bool is_node_void_expr(AstNode *node); |
| 21 | 21 | uint64_t type_size(CodeGen *g, TypeTableEntry *type_entry); |
| 22 | 22 | uint64_t type_size_bits(CodeGen *g, TypeTableEntry *type_entry); |
| 23 | TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint8_t size_in_bits); | |
| 24 | TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint8_t size_in_bits); | |
| 23 | TypeTableEntry **get_int_type_ptr(CodeGen *g, bool is_signed, uint32_t size_in_bits); | |
| 24 | TypeTableEntry *get_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits); | |
| 25 | 25 | TypeTableEntry **get_c_int_type_ptr(CodeGen *g, CIntType c_int_type); |
| 26 | 26 | TypeTableEntry *get_c_int_type(CodeGen *g, CIntType c_int_type); |
| 27 | 27 | TypeTableEntry *get_typedecl_type(CodeGen *g, const char *name, TypeTableEntry *child_type); |
| ... | ... | @@ -146,7 +146,7 @@ ConstExprValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_ |
| 146 | 146 | |
| 147 | 147 | void init_const_undefined(CodeGen *g, ConstExprValue *const_val); |
| 148 | 148 | |
| 149 | TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, size_t size_in_bits); | |
| 149 | TypeTableEntry *make_int_type(CodeGen *g, bool is_signed, uint32_t size_in_bits); | |
| 150 | 150 | ConstParent *get_const_val_parent(ConstExprValue *value); |
| 151 | 151 | FnTableEntry *get_extern_panic_fn(CodeGen *g); |
| 152 | 152 | TypeTableEntry *create_enum_tag_type(CodeGen *g, TypeTableEntry *enum_type, TypeTableEntry *int_type); |
src/ast_render.cpp+2-2| ... | ... | @@ -409,8 +409,8 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 409 | 409 | fprintf(ar->f, "%s%s%sfn ", pub_str, inline_str, extern_str); |
| 410 | 410 | print_symbol(ar, node->data.fn_proto.name); |
| 411 | 411 | fprintf(ar->f, "("); |
| 412 | int arg_count = node->data.fn_proto.params.length; | |
| 413 | for (int arg_i = 0; arg_i < arg_count; arg_i += 1) { | |
| 412 | size_t arg_count = node->data.fn_proto.params.length; | |
| 413 | for (size_t arg_i = 0; arg_i < arg_count; arg_i += 1) { | |
| 414 | 414 | AstNode *param_decl = node->data.fn_proto.params.at(arg_i); |
| 415 | 415 | assert(param_decl->type == NodeTypeParamDecl); |
| 416 | 416 | if (buf_len(param_decl->data.param_decl.name) > 0) { |
src/bignum.cpp+3-3| ... | ... | @@ -154,7 +154,7 @@ void bignum_cast_to_float(BigNum *dest, BigNum *op) { |
| 154 | 154 | assert(op->kind == BigNumKindInt); |
| 155 | 155 | dest->kind = BigNumKindFloat; |
| 156 | 156 | |
| 157 | dest->data.x_float = op->data.x_uint; | |
| 157 | dest->data.x_float = (double)op->data.x_uint; | |
| 158 | 158 | |
| 159 | 159 | if (op->is_negative) { |
| 160 | 160 | dest->data.x_float = -dest->data.x_float; |
| ... | ... | @@ -166,10 +166,10 @@ void bignum_cast_to_int(BigNum *dest, BigNum *op) { |
| 166 | 166 | dest->kind = BigNumKindInt; |
| 167 | 167 | |
| 168 | 168 | if (op->data.x_float >= 0) { |
| 169 | dest->data.x_uint = op->data.x_float; | |
| 169 | dest->data.x_uint = (unsigned long long)op->data.x_float; | |
| 170 | 170 | dest->is_negative = false; |
| 171 | 171 | } else { |
| 172 | dest->data.x_uint = -op->data.x_float; | |
| 172 | dest->data.x_uint = (unsigned long long)-op->data.x_float; | |
| 173 | 173 | dest->is_negative = true; |
| 174 | 174 | } |
| 175 | 175 | } |
src/buffer.hpp+1-1| ... | ... | @@ -169,7 +169,7 @@ uint32_t buf_hash(Buf *buf); |
| 169 | 169 | |
| 170 | 170 | static inline void buf_upcase(Buf *buf) { |
| 171 | 171 | for (size_t i = 0; i < buf_len(buf); i += 1) { |
| 172 | buf_ptr(buf)[i] = toupper(buf_ptr(buf)[i]); | |
| 172 | buf_ptr(buf)[i] = (char)toupper(buf_ptr(buf)[i]); | |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 |
src/c_tokenizer.cpp+3-3| ... | ... | @@ -548,7 +548,7 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) { |
| 548 | 548 | case '6': |
| 549 | 549 | case '7': |
| 550 | 550 | ctok->state = CTokStateStrOctal; |
| 551 | ctok->cur_char = *c - '0'; | |
| 551 | ctok->cur_char = (uint8_t)(*c - '0'); | |
| 552 | 552 | ctok->octal_index = 1; |
| 553 | 553 | break; |
| 554 | 554 | case 'x': |
| ... | ... | @@ -578,12 +578,12 @@ void tokenize_c_macro(CTokenize *ctok, const uint8_t *c) { |
| 578 | 578 | if (((long)ctok->cur_char) * 8 >= 256) { |
| 579 | 579 | zig_panic("TODO"); |
| 580 | 580 | } |
| 581 | ctok->cur_char *= 8; | |
| 581 | ctok->cur_char = (uint8_t)(ctok->cur_char * (uint8_t)8); | |
| 582 | 582 | // TODO @add_with_overflow |
| 583 | 583 | if (((long)ctok->cur_char) + (long)(*c - '0') >= 256) { |
| 584 | 584 | zig_panic("TODO"); |
| 585 | 585 | } |
| 586 | ctok->cur_char += *c - '0'; | |
| 586 | ctok->cur_char = (uint8_t)(ctok->cur_char + (uint8_t)(*c - '0')); | |
| 587 | 587 | ctok->octal_index += 1; |
| 588 | 588 | if (ctok->octal_index == 3) { |
| 589 | 589 | if (ctok->cur_tok->id == CTokIdStrLit) { |
src/codegen.cpp+79-71| ... | ... | @@ -267,7 +267,7 @@ static void addLLVMAttrStr(LLVMValueRef val, LLVMAttributeIndex attr_index, |
| 267 | 267 | const char *attr_name, const char *attr_val) |
| 268 | 268 | { |
| 269 | 269 | LLVMAttributeRef llvm_attr = LLVMCreateStringAttribute(LLVMGetGlobalContext(), |
| 270 | attr_name, strlen(attr_name), attr_val, strlen(attr_val)); | |
| 270 | attr_name, (unsigned)strlen(attr_name), attr_val, (unsigned)strlen(attr_val)); | |
| 271 | 271 | LLVMAddAttributeAtIndex(val, attr_index, llvm_attr); |
| 272 | 272 | } |
| 273 | 273 | |
| ... | ... | @@ -384,7 +384,7 @@ static LLVMValueRef fn_llvm_value(CodeGen *g, FnTableEntry *fn_table_entry) { |
| 384 | 384 | LLVMSetSection(fn_table_entry->llvm_value, buf_ptr(fn_table_entry->section_name)); |
| 385 | 385 | } |
| 386 | 386 | if (fn_table_entry->alignment) { |
| 387 | LLVMSetAlignment(fn_table_entry->llvm_value, fn_table_entry->alignment); | |
| 387 | LLVMSetAlignment(fn_table_entry->llvm_value, (unsigned)fn_table_entry->alignment); | |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | return fn_table_entry->llvm_value; |
| ... | ... | @@ -405,7 +405,7 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { |
| 405 | 405 | FnTableEntry *fn_table_entry = fn_scope->fn_entry; |
| 406 | 406 | if (!fn_table_entry->proto_node) |
| 407 | 407 | return get_di_scope(g, scope->parent); |
| 408 | unsigned line_number = fn_table_entry->proto_node->line + 1; | |
| 408 | unsigned line_number = (unsigned)fn_table_entry->proto_node->line + 1; | |
| 409 | 409 | unsigned scope_line = line_number; |
| 410 | 410 | bool is_definition = fn_table_entry->body_node != nullptr; |
| 411 | 411 | unsigned flags = 0; |
| ... | ... | @@ -438,8 +438,8 @@ static ZigLLVMDIScope *get_di_scope(CodeGen *g, Scope *scope) { |
| 438 | 438 | ZigLLVMDILexicalBlock *di_block = ZigLLVMCreateLexicalBlock(g->dbuilder, |
| 439 | 439 | get_di_scope(g, scope->parent), |
| 440 | 440 | import->di_file, |
| 441 | scope->source_node->line + 1, | |
| 442 | scope->source_node->column + 1); | |
| 441 | (unsigned)scope->source_node->line + 1, | |
| 442 | (unsigned)scope->source_node->column + 1); | |
| 443 | 443 | scope->di_scope = ZigLLVMLexicalBlockToScope(di_block); |
| 444 | 444 | return scope->di_scope; |
| 445 | 445 | } |
| ... | ... | @@ -462,7 +462,7 @@ static LLVMValueRef get_arithmetic_overflow_fn(CodeGen *g, TypeTableEntry *type_ |
| 462 | 462 | |
| 463 | 463 | assert(type_entry->id == TypeTableEntryIdInt); |
| 464 | 464 | const char *signed_str = type_entry->data.integral.is_signed ? signed_name : unsigned_name; |
| 465 | sprintf(fn_name, "llvm.%s.with.overflow.i%zu", signed_str, type_entry->data.integral.bit_count); | |
| 465 | sprintf(fn_name, "llvm.%s.with.overflow.i%" PRIu32, signed_str, type_entry->data.integral.bit_count); | |
| 466 | 466 | |
| 467 | 467 | LLVMTypeRef return_elem_types[] = { |
| 468 | 468 | type_entry->type_ref, |
| ... | ... | @@ -486,7 +486,7 @@ static LLVMValueRef get_int_overflow_fn(CodeGen *g, TypeTableEntry *type_entry, |
| 486 | 486 | key.id = ZigLLVMFnIdOverflowArithmetic; |
| 487 | 487 | key.data.overflow_arithmetic.is_signed = type_entry->data.integral.is_signed; |
| 488 | 488 | key.data.overflow_arithmetic.add_sub_mul = add_sub_mul; |
| 489 | key.data.overflow_arithmetic.bit_count = type_entry->data.integral.bit_count; | |
| 489 | key.data.overflow_arithmetic.bit_count = (uint32_t)type_entry->data.integral.bit_count; | |
| 490 | 490 | |
| 491 | 491 | auto existing_entry = g->llvm_fn_table.maybe_get(key); |
| 492 | 492 | if (existing_entry) |
| ... | ... | @@ -601,8 +601,8 @@ static void gen_panic(CodeGen *g, LLVMValueRef msg_arg) { |
| 601 | 601 | TypeTableEntry *str_type = get_slice_type(g, g->builtin_types.entry_u8, true); |
| 602 | 602 | size_t ptr_index = str_type->data.structure.fields[slice_ptr_index].gen_index; |
| 603 | 603 | size_t len_index = str_type->data.structure.fields[slice_len_index].gen_index; |
| 604 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, ptr_index, ""); | |
| 605 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, len_index, ""); | |
| 604 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)ptr_index, ""); | |
| 605 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, msg_arg, (unsigned)len_index, ""); | |
| 606 | 606 | |
| 607 | 607 | LLVMValueRef args[] = { |
| 608 | 608 | LLVMBuildLoad(g->builder, ptr_ptr, ""), |
| ... | ... | @@ -891,8 +891,8 @@ static LLVMValueRef gen_assign_raw(CodeGen *g, LLVMValueRef ptr, TypeTableEntry |
| 891 | 891 | |
| 892 | 892 | static void gen_var_debug_decl(CodeGen *g, VariableTableEntry *var) { |
| 893 | 893 | AstNode *source_node = var->decl_node; |
| 894 | ZigLLVMDILocation *debug_loc = ZigLLVMGetDebugLoc(source_node->line + 1, source_node->column + 1, | |
| 895 | get_di_scope(g, var->parent_scope)); | |
| 894 | ZigLLVMDILocation *debug_loc = ZigLLVMGetDebugLoc((unsigned)source_node->line + 1, | |
| 895 | (unsigned)source_node->column + 1, get_di_scope(g, var->parent_scope)); | |
| 896 | 896 | ZigLLVMInsertDeclareAtEnd(g->dbuilder, var->value_ref, var->di_loc_var, debug_loc, |
| 897 | 897 | LLVMGetInsertBlock(g->builder)); |
| 898 | 898 | } |
| ... | ... | @@ -1272,20 +1272,20 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable, |
| 1272 | 1272 | TypeTableEntry *wanted_child_type = wanted_pointer_type->data.pointer.child_type; |
| 1273 | 1273 | |
| 1274 | 1274 | |
| 1275 | size_t actual_ptr_index = actual_type->data.structure.fields[0].gen_index; | |
| 1276 | size_t actual_len_index = actual_type->data.structure.fields[1].gen_index; | |
| 1277 | size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index; | |
| 1278 | size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index; | |
| 1275 | size_t actual_ptr_index = actual_type->data.structure.fields[slice_ptr_index].gen_index; | |
| 1276 | size_t actual_len_index = actual_type->data.structure.fields[slice_len_index].gen_index; | |
| 1277 | size_t wanted_ptr_index = wanted_type->data.structure.fields[slice_ptr_index].gen_index; | |
| 1278 | size_t wanted_len_index = wanted_type->data.structure.fields[slice_len_index].gen_index; | |
| 1279 | 1279 | |
| 1280 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, expr_val, actual_ptr_index, ""); | |
| 1280 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_ptr_index, ""); | |
| 1281 | 1281 | LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, ""); |
| 1282 | 1282 | LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr, |
| 1283 | 1283 | wanted_type->data.structure.fields[0].type_entry->type_ref, ""); |
| 1284 | 1284 | LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, |
| 1285 | wanted_ptr_index, ""); | |
| 1285 | (unsigned)wanted_ptr_index, ""); | |
| 1286 | 1286 | LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr); |
| 1287 | 1287 | |
| 1288 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, expr_val, actual_len_index, ""); | |
| 1288 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_len_index, ""); | |
| 1289 | 1289 | LLVMValueRef src_len = LLVMBuildLoad(g->builder, src_len_ptr, ""); |
| 1290 | 1290 | uint64_t src_size = type_size(g, actual_child_type); |
| 1291 | 1291 | uint64_t dest_size = type_size(g, wanted_child_type); |
| ... | ... | @@ -1315,7 +1315,7 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable, |
| 1315 | 1315 | } |
| 1316 | 1316 | |
| 1317 | 1317 | LLVMValueRef dest_len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, |
| 1318 | wanted_len_index, ""); | |
| 1318 | (unsigned)wanted_len_index, ""); | |
| 1319 | 1319 | LLVMBuildStore(g->builder, new_len, dest_len_ptr); |
| 1320 | 1320 | |
| 1321 | 1321 | |
| ... | ... | @@ -1333,12 +1333,14 @@ static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutable *executable, |
| 1333 | 1333 | |
| 1334 | 1334 | |
| 1335 | 1335 | size_t wanted_ptr_index = wanted_type->data.structure.fields[0].gen_index; |
| 1336 | LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, wanted_ptr_index, ""); | |
| 1336 | LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, | |
| 1337 | (unsigned)wanted_ptr_index, ""); | |
| 1337 | 1338 | LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, expr_val, wanted_pointer_type->type_ref, ""); |
| 1338 | 1339 | LLVMBuildStore(g->builder, src_ptr_casted, dest_ptr_ptr); |
| 1339 | 1340 | |
| 1340 | 1341 | size_t wanted_len_index = wanted_type->data.structure.fields[1].gen_index; |
| 1341 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, wanted_len_index, ""); | |
| 1342 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, cast_instruction->tmp_ptr, | |
| 1343 | (unsigned)wanted_len_index, ""); | |
| 1342 | 1344 | LLVMValueRef len_val = LLVMConstInt(g->builtin_types.entry_usize->type_ref, |
| 1343 | 1345 | actual_type->data.array.len / type_size(g, wanted_child_type), false); |
| 1344 | 1346 | LLVMBuildStore(g->builder, len_val, len_ptr); |
| ... | ... | @@ -1721,14 +1723,14 @@ static LLVMValueRef ir_render_elem_ptr(CodeGen *g, IrExecutable *executable, IrI |
| 1721 | 1723 | if (safety_check_on) { |
| 1722 | 1724 | size_t len_index = array_type->data.structure.fields[1].gen_index; |
| 1723 | 1725 | assert(len_index != SIZE_MAX); |
| 1724 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, len_index, ""); | |
| 1726 | LLVMValueRef len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, ""); | |
| 1725 | 1727 | LLVMValueRef len = LLVMBuildLoad(g->builder, len_ptr, ""); |
| 1726 | 1728 | add_bounds_check(g, subscript_value, LLVMIntEQ, nullptr, LLVMIntULT, len); |
| 1727 | 1729 | } |
| 1728 | 1730 | |
| 1729 | 1731 | size_t ptr_index = array_type->data.structure.fields[0].gen_index; |
| 1730 | 1732 | assert(ptr_index != SIZE_MAX); |
| 1731 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, ptr_index, ""); | |
| 1733 | LLVMValueRef ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, ""); | |
| 1732 | 1734 | LLVMValueRef ptr = LLVMBuildLoad(g->builder, ptr_ptr, ""); |
| 1733 | 1735 | return LLVMBuildInBoundsGEP(g->builder, ptr, &subscript_value, 1, ""); |
| 1734 | 1736 | } else { |
| ... | ... | @@ -1772,12 +1774,12 @@ static LLVMValueRef ir_render_call(CodeGen *g, IrExecutable *executable, IrInstr |
| 1772 | 1774 | } |
| 1773 | 1775 | |
| 1774 | 1776 | LLVMValueRef result = ZigLLVMBuildCall(g->builder, fn_val, |
| 1775 | gen_param_values, gen_param_index, fn_type->data.fn.calling_convention, ""); | |
| 1777 | gen_param_values, (unsigned)gen_param_index, fn_type->data.fn.calling_convention, ""); | |
| 1776 | 1778 | |
| 1777 | 1779 | for (size_t param_i = 0; param_i < fn_type_id->param_count; param_i += 1) { |
| 1778 | 1780 | FnGenParamInfo *gen_info = &fn_type->data.fn.gen_param_info[param_i]; |
| 1779 | 1781 | if (gen_info->is_byval) { |
| 1780 | addLLVMCallsiteAttr(result, gen_info->gen_index, "byval"); | |
| 1782 | addLLVMCallsiteAttr(result, (unsigned)gen_info->gen_index, "byval"); | |
| 1781 | 1783 | } |
| 1782 | 1784 | } |
| 1783 | 1785 | |
| ... | ... | @@ -1810,7 +1812,7 @@ static LLVMValueRef ir_render_struct_field_ptr(CodeGen *g, IrExecutable *executa |
| 1810 | 1812 | } |
| 1811 | 1813 | |
| 1812 | 1814 | assert(field->gen_index != SIZE_MAX); |
| 1813 | return LLVMBuildStructGEP(g->builder, struct_ptr, field->gen_index, ""); | |
| 1815 | return LLVMBuildStructGEP(g->builder, struct_ptr, (unsigned)field->gen_index, ""); | |
| 1814 | 1816 | } |
| 1815 | 1817 | |
| 1816 | 1818 | static LLVMValueRef ir_render_enum_field_ptr(CodeGen *g, IrExecutable *executable, |
| ... | ... | @@ -1948,14 +1950,14 @@ static LLVMValueRef ir_render_asm(CodeGen *g, IrExecutable *executable, IrInstru |
| 1948 | 1950 | } else { |
| 1949 | 1951 | ret_type = instruction->base.value.type->type_ref; |
| 1950 | 1952 | } |
| 1951 | LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, input_and_output_count, false); | |
| 1953 | LLVMTypeRef function_type = LLVMFunctionType(ret_type, param_types, (unsigned)input_and_output_count, false); | |
| 1952 | 1954 | |
| 1953 | 1955 | bool is_x86 = (g->zig_target.arch.arch == ZigLLVM_x86 || g->zig_target.arch.arch == ZigLLVM_x86_64); |
| 1954 | 1956 | bool is_volatile = asm_expr->is_volatile || (asm_expr->output_list.length == 0); |
| 1955 | 1957 | LLVMValueRef asm_fn = ZigLLVMConstInlineAsm(function_type, buf_ptr(&llvm_template), |
| 1956 | 1958 | buf_ptr(&constraint_buf), is_volatile, false, is_x86); |
| 1957 | 1959 | |
| 1958 | return LLVMBuildCall(g->builder, asm_fn, param_values, input_and_output_count, ""); | |
| 1960 | return LLVMBuildCall(g->builder, asm_fn, param_values, (unsigned)input_and_output_count, ""); | |
| 1959 | 1961 | } |
| 1960 | 1962 | |
| 1961 | 1963 | static LLVMValueRef gen_non_null_bit(CodeGen *g, TypeTableEntry *maybe_type, LLVMValueRef maybe_handle) { |
| ... | ... | @@ -2021,11 +2023,11 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui |
| 2021 | 2023 | if (fn_id == BuiltinFnIdCtz) { |
| 2022 | 2024 | fn_name = "cttz"; |
| 2023 | 2025 | key.id = ZigLLVMFnIdCtz; |
| 2024 | key.data.ctz.bit_count = int_type->data.integral.bit_count; | |
| 2026 | key.data.ctz.bit_count = (uint32_t)int_type->data.integral.bit_count; | |
| 2025 | 2027 | } else { |
| 2026 | 2028 | fn_name = "ctlz"; |
| 2027 | 2029 | key.id = ZigLLVMFnIdClz; |
| 2028 | key.data.clz.bit_count = int_type->data.integral.bit_count; | |
| 2030 | key.data.clz.bit_count = (uint32_t)int_type->data.integral.bit_count; | |
| 2029 | 2031 | } |
| 2030 | 2032 | |
| 2031 | 2033 | auto existing_entry = g->llvm_fn_table.maybe_get(key); |
| ... | ... | @@ -2033,7 +2035,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, TypeTableEntry *int_type, Bui |
| 2033 | 2035 | return existing_entry->value; |
| 2034 | 2036 | |
| 2035 | 2037 | char llvm_name[64]; |
| 2036 | sprintf(llvm_name, "llvm.%s.i%zu", fn_name, int_type->data.integral.bit_count); | |
| 2038 | sprintf(llvm_name, "llvm.%s.i%" PRIu32, fn_name, int_type->data.integral.bit_count); | |
| 2037 | 2039 | LLVMTypeRef param_types[] = { |
| 2038 | 2040 | int_type->type_ref, |
| 2039 | 2041 | LLVMInt1Type(), |
| ... | ... | @@ -2071,7 +2073,8 @@ static LLVMValueRef ir_render_ctz(CodeGen *g, IrExecutable *executable, IrInstru |
| 2071 | 2073 | static LLVMValueRef ir_render_switch_br(CodeGen *g, IrExecutable *executable, IrInstructionSwitchBr *instruction) { |
| 2072 | 2074 | LLVMValueRef target_value = ir_llvm_value(g, instruction->target_value); |
| 2073 | 2075 | LLVMBasicBlockRef else_block = instruction->else_block->llvm_block; |
| 2074 | LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, target_value, else_block, instruction->case_count); | |
| 2076 | LLVMValueRef switch_instr = LLVMBuildSwitch(g->builder, target_value, else_block, | |
| 2077 | (unsigned)instruction->case_count); | |
| 2075 | 2078 | for (size_t i = 0; i < instruction->case_count; i += 1) { |
| 2076 | 2079 | IrInstructionSwitchBrCase *this_case = &instruction->cases[i]; |
| 2077 | 2080 | LLVMAddCase(switch_instr, ir_llvm_value(g, this_case->value), this_case->block->llvm_block); |
| ... | ... | @@ -2097,7 +2100,7 @@ static LLVMValueRef ir_render_phi(CodeGen *g, IrExecutable *executable, IrInstru |
| 2097 | 2100 | incoming_values[i] = ir_llvm_value(g, instruction->incoming_values[i]); |
| 2098 | 2101 | incoming_blocks[i] = instruction->incoming_blocks[i]->llvm_exit_block; |
| 2099 | 2102 | } |
| 2100 | LLVMAddIncoming(phi, incoming_values, incoming_blocks, instruction->incoming_count); | |
| 2103 | LLVMAddIncoming(phi, incoming_values, incoming_blocks, (unsigned)instruction->incoming_count); | |
| 2101 | 2104 | return phi; |
| 2102 | 2105 | } |
| 2103 | 2106 | |
| ... | ... | @@ -2337,14 +2340,14 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst |
| 2337 | 2340 | assert(LLVMGetTypeKind(LLVMTypeOf(array_ptr)) == LLVMPointerTypeKind); |
| 2338 | 2341 | assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(array_ptr))) == LLVMStructTypeKind); |
| 2339 | 2342 | |
| 2340 | size_t ptr_index = array_type->data.structure.fields[0].gen_index; | |
| 2343 | size_t ptr_index = array_type->data.structure.fields[slice_ptr_index].gen_index; | |
| 2341 | 2344 | assert(ptr_index != SIZE_MAX); |
| 2342 | size_t len_index = array_type->data.structure.fields[1].gen_index; | |
| 2345 | size_t len_index = array_type->data.structure.fields[slice_len_index].gen_index; | |
| 2343 | 2346 | assert(len_index != SIZE_MAX); |
| 2344 | 2347 | |
| 2345 | 2348 | LLVMValueRef prev_end = nullptr; |
| 2346 | 2349 | if (!instruction->end || want_debug_safety) { |
| 2347 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, len_index, ""); | |
| 2350 | LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)len_index, ""); | |
| 2348 | 2351 | prev_end = LLVMBuildLoad(g->builder, src_len_ptr, ""); |
| 2349 | 2352 | } |
| 2350 | 2353 | |
| ... | ... | @@ -2364,13 +2367,13 @@ static LLVMValueRef ir_render_slice(CodeGen *g, IrExecutable *executable, IrInst |
| 2364 | 2367 | } |
| 2365 | 2368 | } |
| 2366 | 2369 | |
| 2367 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, ptr_index, ""); | |
| 2370 | LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, array_ptr, (unsigned)ptr_index, ""); | |
| 2368 | 2371 | LLVMValueRef src_ptr = LLVMBuildLoad(g->builder, src_ptr_ptr, ""); |
| 2369 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, ptr_index, ""); | |
| 2370 | LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, len_index, ""); | |
| 2372 | LLVMValueRef ptr_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)ptr_index, ""); | |
| 2373 | LLVMValueRef slice_start_ptr = LLVMBuildInBoundsGEP(g->builder, src_ptr, &start_val, (unsigned)len_index, ""); | |
| 2371 | 2374 | LLVMBuildStore(g->builder, slice_start_ptr, ptr_field_ptr); |
| 2372 | 2375 | |
| 2373 | LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, len_index, ""); | |
| 2376 | LLVMValueRef len_field_ptr = LLVMBuildStructGEP(g->builder, tmp_struct_ptr, (unsigned)len_index, ""); | |
| 2374 | 2377 | LLVMValueRef len_value = LLVMBuildNSWSub(g->builder, end_val, start_val, ""); |
| 2375 | 2378 | LLVMBuildStore(g->builder, len_value, len_field_ptr); |
| 2376 | 2379 | |
| ... | ... | @@ -2650,12 +2653,13 @@ static LLVMValueRef ir_render_struct_init(CodeGen *g, IrExecutable *executable, |
| 2650 | 2653 | if (!type_has_bits(type_struct_field->type_entry)) |
| 2651 | 2654 | continue; |
| 2652 | 2655 | |
| 2653 | LLVMValueRef field_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr, type_struct_field->gen_index, ""); | |
| 2656 | LLVMValueRef field_ptr = LLVMBuildStructGEP(g->builder, instruction->tmp_ptr, | |
| 2657 | (unsigned)type_struct_field->gen_index, ""); | |
| 2654 | 2658 | LLVMValueRef value = ir_llvm_value(g, field->value); |
| 2655 | 2659 | |
| 2656 | 2660 | TypeTableEntry *ptr_type = get_pointer_to_type_extra(g, type_struct_field->type_entry, |
| 2657 | 2661 | false, false, |
| 2658 | type_struct_field->packed_bits_offset, type_struct_field->unaligned_bit_count); | |
| 2662 | (uint32_t)type_struct_field->packed_bits_offset, (uint32_t)type_struct_field->unaligned_bit_count); | |
| 2659 | 2663 | |
| 2660 | 2664 | gen_assign_raw(g, field_ptr, ptr_type, value); |
| 2661 | 2665 | } |
| ... | ... | @@ -2698,7 +2702,8 @@ static void set_debug_location(CodeGen *g, IrInstruction *instruction) { |
| 2698 | 2702 | assert(source_node); |
| 2699 | 2703 | assert(scope); |
| 2700 | 2704 | |
| 2701 | ZigLLVMSetCurrentDebugLocation(g->builder, source_node->line + 1, source_node->column + 1, get_di_scope(g, scope)); | |
| 2705 | ZigLLVMSetCurrentDebugLocation(g->builder, (int)source_node->line + 1, | |
| 2706 | (int)source_node->column + 1, get_di_scope(g, scope)); | |
| 2702 | 2707 | } |
| 2703 | 2708 | |
| 2704 | 2709 | static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutable *executable, IrInstruction *instruction) { |
| ... | ... | @@ -2964,7 +2969,8 @@ static LLVMValueRef pack_const_int(CodeGen *g, LLVMTypeRef big_int_type_ref, Con |
| 2964 | 2969 | case TypeTableEntryIdFloat: |
| 2965 | 2970 | { |
| 2966 | 2971 | LLVMValueRef float_val = gen_const_val(g, const_val); |
| 2967 | LLVMValueRef int_val = LLVMConstFPToUI(float_val, LLVMIntType(canon_type->data.floating.bit_count)); | |
| 2972 | LLVMValueRef int_val = LLVMConstFPToUI(float_val, | |
| 2973 | LLVMIntType((unsigned)canon_type->data.floating.bit_count)); | |
| 2968 | 2974 | return LLVMConstZExt(int_val, big_int_type_ref); |
| 2969 | 2975 | } |
| 2970 | 2976 | case TypeTableEntryIdPointer: |
| ... | ... | @@ -3027,7 +3033,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { |
| 3027 | 3033 | if (const_val->data.x_bignum.kind == BigNumKindFloat) { |
| 3028 | 3034 | return LLVMConstReal(canon_type->type_ref, const_val->data.x_bignum.data.x_float); |
| 3029 | 3035 | } else { |
| 3030 | int64_t x = const_val->data.x_bignum.data.x_uint; | |
| 3036 | double x = (double)const_val->data.x_bignum.data.x_uint; | |
| 3031 | 3037 | if (const_val->data.x_bignum.is_negative) { |
| 3032 | 3038 | x = -x; |
| 3033 | 3039 | } |
| ... | ... | @@ -3094,7 +3100,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { |
| 3094 | 3100 | gen_const_val(g, &const_val->data.x_struct.fields[src_field_index]); |
| 3095 | 3101 | } else { |
| 3096 | 3102 | LLVMTypeRef big_int_type_ref = LLVMStructGetTypeAtIndex(canon_type->type_ref, |
| 3097 | type_struct_field->gen_index); | |
| 3103 | (unsigned)type_struct_field->gen_index); | |
| 3098 | 3104 | LLVMValueRef val = LLVMConstInt(big_int_type_ref, 0, false); |
| 3099 | 3105 | for (size_t i = src_field_index; i < src_field_index_end; i += 1) { |
| 3100 | 3106 | TypeStructField *it_field = &canon_type->data.structure.fields[i]; |
| ... | ... | @@ -3136,7 +3142,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { |
| 3136 | 3142 | ConstExprValue *elem_value = &const_val->data.x_array.elements[i]; |
| 3137 | 3143 | values[i] = gen_const_val(g, elem_value); |
| 3138 | 3144 | } |
| 3139 | return LLVMConstArray(LLVMTypeOf(values[0]), values, len); | |
| 3145 | return LLVMConstArray(LLVMTypeOf(values[0]), values, (unsigned)len); | |
| 3140 | 3146 | } |
| 3141 | 3147 | case TypeTableEntryIdEnum: |
| 3142 | 3148 | { |
| ... | ... | @@ -3162,7 +3168,7 @@ static LLVMValueRef gen_const_val(CodeGen *g, ConstExprValue *const_val) { |
| 3162 | 3168 | } else { |
| 3163 | 3169 | LLVMValueRef fields[] = { |
| 3164 | 3170 | correctly_typed_value, |
| 3165 | LLVMGetUndef(LLVMArrayType(LLVMInt8Type(), pad_bytes)), | |
| 3171 | LLVMGetUndef(LLVMArrayType(LLVMInt8Type(), (unsigned)pad_bytes)), | |
| 3166 | 3172 | }; |
| 3167 | 3173 | union_value = LLVMConstStruct(fields, 2, false); |
| 3168 | 3174 | } |
| ... | ... | @@ -3352,7 +3358,7 @@ static bool should_skip_fn_codegen(CodeGen *g, FnTableEntry *fn_entry) { |
| 3352 | 3358 | static LLVMValueRef gen_test_fn_val(CodeGen *g, FnTableEntry *fn_entry) { |
| 3353 | 3359 | // Must match TestFn struct from test_runner.zig |
| 3354 | 3360 | Buf *fn_name = &fn_entry->symbol_name; |
| 3355 | LLVMValueRef str_init = LLVMConstString(buf_ptr(fn_name), buf_len(fn_name), true); | |
| 3361 | LLVMValueRef str_init = LLVMConstString(buf_ptr(fn_name), (unsigned)buf_len(fn_name), true); | |
| 3356 | 3362 | LLVMValueRef str_global_val = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), ""); |
| 3357 | 3363 | LLVMSetInitializer(str_global_val, str_init); |
| 3358 | 3364 | LLVMSetLinkage(str_global_val, LLVMPrivateLinkage); |
| ... | ... | @@ -3392,7 +3398,7 @@ static void generate_error_name_table(CodeGen *g) { |
| 3392 | 3398 | assert(error_decl_node->type == NodeTypeErrorValueDecl); |
| 3393 | 3399 | Buf *name = error_decl_node->data.error_value_decl.name; |
| 3394 | 3400 | |
| 3395 | LLVMValueRef str_init = LLVMConstString(buf_ptr(name), buf_len(name), true); | |
| 3401 | LLVMValueRef str_init = LLVMConstString(buf_ptr(name), (unsigned)buf_len(name), true); | |
| 3396 | 3402 | LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), ""); |
| 3397 | 3403 | LLVMSetInitializer(str_global, str_init); |
| 3398 | 3404 | LLVMSetLinkage(str_global, LLVMPrivateLinkage); |
| ... | ... | @@ -3406,7 +3412,7 @@ static void generate_error_name_table(CodeGen *g) { |
| 3406 | 3412 | values[i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2); |
| 3407 | 3413 | } |
| 3408 | 3414 | |
| 3409 | LLVMValueRef err_name_table_init = LLVMConstArray(str_type->type_ref, values, g->error_decls.length); | |
| 3415 | LLVMValueRef err_name_table_init = LLVMConstArray(str_type->type_ref, values, (unsigned)g->error_decls.length); | |
| 3410 | 3416 | |
| 3411 | 3417 | g->err_name_table = LLVMAddGlobal(g->module, LLVMTypeOf(err_name_table_init), |
| 3412 | 3418 | buf_ptr(get_mangled_name(g, buf_create_from_str("err_name_table"), false))); |
| ... | ... | @@ -3430,7 +3436,7 @@ static void generate_enum_name_tables(CodeGen *g) { |
| 3430 | 3436 | for (size_t field_i = 0; field_i < field_count; field_i += 1) { |
| 3431 | 3437 | Buf *name = enum_type->data.enumeration.fields[field_i].name; |
| 3432 | 3438 | |
| 3433 | LLVMValueRef str_init = LLVMConstString(buf_ptr(name), buf_len(name), true); | |
| 3439 | LLVMValueRef str_init = LLVMConstString(buf_ptr(name), (unsigned)buf_len(name), true); | |
| 3434 | 3440 | LLVMValueRef str_global = LLVMAddGlobal(g->module, LLVMTypeOf(str_init), ""); |
| 3435 | 3441 | LLVMSetInitializer(str_global, str_init); |
| 3436 | 3442 | LLVMSetLinkage(str_global, LLVMPrivateLinkage); |
| ... | ... | @@ -3444,7 +3450,7 @@ static void generate_enum_name_tables(CodeGen *g) { |
| 3444 | 3450 | values[field_i] = LLVMConstNamedStruct(str_type->type_ref, fields, 2); |
| 3445 | 3451 | } |
| 3446 | 3452 | |
| 3447 | LLVMValueRef name_table_init = LLVMConstArray(str_type->type_ref, values, field_count); | |
| 3453 | LLVMValueRef name_table_init = LLVMConstArray(str_type->type_ref, values, (unsigned)field_count); | |
| 3448 | 3454 | |
| 3449 | 3455 | Buf *table_name = get_mangled_name(g, buf_sprintf("%s_name_table", buf_ptr(&enum_type->name)), false); |
| 3450 | 3456 | LLVMValueRef name_table = LLVMAddGlobal(g->module, LLVMTypeOf(name_table_init), buf_ptr(table_name)); |
| ... | ... | @@ -3478,7 +3484,8 @@ static void gen_global_var(CodeGen *g, VariableTableEntry *var, LLVMValueRef ini |
| 3478 | 3484 | |
| 3479 | 3485 | bool is_local_to_unit = true; |
| 3480 | 3486 | ZigLLVMCreateGlobalVariable(g->dbuilder, get_di_scope(g, var->parent_scope), buf_ptr(&var->name), |
| 3481 | buf_ptr(&var->name), import->di_file, var->decl_node->line + 1, | |
| 3487 | buf_ptr(&var->name), import->di_file, | |
| 3488 | (unsigned)(var->decl_node->line + 1), | |
| 3482 | 3489 | type_entry->di_type, is_local_to_unit); |
| 3483 | 3490 | // TODO ^^ make an actual global variable |
| 3484 | 3491 | } |
| ... | ... | @@ -3606,16 +3613,16 @@ static void do_code_gen(CodeGen *g) { |
| 3606 | 3613 | |
| 3607 | 3614 | TypeTableEntry *param_type = gen_info->type; |
| 3608 | 3615 | if (param_info->is_noalias) { |
| 3609 | addLLVMArgAttr(fn_val, gen_index, "noalias"); | |
| 3616 | addLLVMArgAttr(fn_val, (unsigned)gen_index, "noalias"); | |
| 3610 | 3617 | } |
| 3611 | 3618 | if ((param_type->id == TypeTableEntryIdPointer && param_type->data.pointer.is_const) || is_byval) { |
| 3612 | addLLVMArgAttr(fn_val, gen_index, "readonly"); | |
| 3619 | addLLVMArgAttr(fn_val, (unsigned)gen_index, "readonly"); | |
| 3613 | 3620 | } |
| 3614 | 3621 | if (param_type->id == TypeTableEntryIdPointer) { |
| 3615 | addLLVMArgAttr(fn_val, gen_index, "nonnull"); | |
| 3622 | addLLVMArgAttr(fn_val, (unsigned)gen_index, "nonnull"); | |
| 3616 | 3623 | } |
| 3617 | 3624 | if (is_byval) { |
| 3618 | addLLVMArgAttr(fn_val, gen_index, "byval"); | |
| 3625 | addLLVMArgAttr(fn_val, (unsigned)gen_index, "byval"); | |
| 3619 | 3626 | } |
| 3620 | 3627 | } |
| 3621 | 3628 | |
| ... | ... | @@ -3737,7 +3744,7 @@ static void do_code_gen(CodeGen *g) { |
| 3737 | 3744 | var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name)); |
| 3738 | 3745 | |
| 3739 | 3746 | var->di_loc_var = ZigLLVMCreateAutoVariable(g->dbuilder, get_di_scope(g, var->parent_scope), |
| 3740 | buf_ptr(&var->name), import->di_file, var->decl_node->line + 1, | |
| 3747 | buf_ptr(&var->name), import->di_file, (unsigned)(var->decl_node->line + 1), | |
| 3741 | 3748 | var->value->type->di_type, !g->strip_debug_symbols, 0); |
| 3742 | 3749 | |
| 3743 | 3750 | } else { |
| ... | ... | @@ -3751,15 +3758,16 @@ static void do_code_gen(CodeGen *g) { |
| 3751 | 3758 | } else { |
| 3752 | 3759 | gen_type = gen_info->type; |
| 3753 | 3760 | } |
| 3754 | var->value_ref = LLVMGetParam(fn, var->gen_arg_index); | |
| 3761 | var->value_ref = LLVMGetParam(fn, (unsigned)var->gen_arg_index); | |
| 3755 | 3762 | } else { |
| 3756 | 3763 | gen_type = var->value->type; |
| 3757 | 3764 | var->value_ref = build_alloca(g, var->value->type, buf_ptr(&var->name)); |
| 3758 | 3765 | } |
| 3759 | 3766 | if (var->decl_node) { |
| 3760 | 3767 | var->di_loc_var = ZigLLVMCreateParameterVariable(g->dbuilder, get_di_scope(g, var->parent_scope), |
| 3761 | buf_ptr(&var->name), import->di_file, var->decl_node->line + 1, | |
| 3762 | gen_type->di_type, !g->strip_debug_symbols, 0, var->gen_arg_index + 1); | |
| 3768 | buf_ptr(&var->name), import->di_file, | |
| 3769 | (unsigned)(var->decl_node->line + 1), | |
| 3770 | gen_type->di_type, !g->strip_debug_symbols, 0, (unsigned)(var->gen_arg_index + 1)); | |
| 3763 | 3771 | } |
| 3764 | 3772 | |
| 3765 | 3773 | } |
| ... | ... | @@ -3784,7 +3792,7 @@ static void do_code_gen(CodeGen *g) { |
| 3784 | 3792 | |
| 3785 | 3793 | if (!handle_is_ptr(variable->value->type)) { |
| 3786 | 3794 | clear_debug_source_node(g); |
| 3787 | LLVMBuildStore(g->builder, LLVMGetParam(fn, variable->gen_arg_index), variable->value_ref); | |
| 3795 | LLVMBuildStore(g->builder, LLVMGetParam(fn, (unsigned)variable->gen_arg_index), variable->value_ref); | |
| 3788 | 3796 | } |
| 3789 | 3797 | |
| 3790 | 3798 | if (variable->decl_node) { |
| ... | ... | @@ -3827,7 +3835,7 @@ static void do_code_gen(CodeGen *g) { |
| 3827 | 3835 | g->link_objects.append(out_file_o); |
| 3828 | 3836 | } |
| 3829 | 3837 | |
| 3830 | static const size_t int_sizes_in_bits[] = { | |
| 3838 | static const uint8_t int_sizes_in_bits[] = { | |
| 3831 | 3839 | 8, |
| 3832 | 3840 | 16, |
| 3833 | 3841 | 32, |
| ... | ... | @@ -3950,7 +3958,7 @@ static void define_builtin_types(CodeGen *g) { |
| 3950 | 3958 | } |
| 3951 | 3959 | |
| 3952 | 3960 | for (size_t int_size_i = 0; int_size_i < array_length(int_sizes_in_bits); int_size_i += 1) { |
| 3953 | size_t size_in_bits = int_sizes_in_bits[int_size_i]; | |
| 3961 | uint8_t size_in_bits = int_sizes_in_bits[int_size_i]; | |
| 3954 | 3962 | for (size_t is_sign_i = 0; is_sign_i < array_length(is_signed_list); is_sign_i += 1) { |
| 3955 | 3963 | bool is_signed = is_signed_list[is_sign_i]; |
| 3956 | 3964 | TypeTableEntry *entry = make_int_type(g, is_signed, size_in_bits); |
| ... | ... | @@ -3961,7 +3969,7 @@ static void define_builtin_types(CodeGen *g) { |
| 3961 | 3969 | |
| 3962 | 3970 | for (size_t i = 0; i < array_length(c_int_type_infos); i += 1) { |
| 3963 | 3971 | const CIntTypeInfo *info = &c_int_type_infos[i]; |
| 3964 | uint64_t size_in_bits = get_c_type_size_in_bits(&g->zig_target, info->id); | |
| 3972 | uint32_t size_in_bits = target_c_type_size_in_bits(&g->zig_target, info->id); | |
| 3965 | 3973 | bool is_signed = info->is_signed; |
| 3966 | 3974 | |
| 3967 | 3975 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdInt); |
| ... | ... | @@ -4116,7 +4124,7 @@ static void define_builtin_types(CodeGen *g) { |
| 4116 | 4124 | { |
| 4117 | 4125 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); |
| 4118 | 4126 | buf_init_from_str(&entry->name, "Os"); |
| 4119 | uint32_t field_count = target_os_count(); | |
| 4127 | uint32_t field_count = (uint32_t)target_os_count(); | |
| 4120 | 4128 | entry->data.enumeration.src_field_count = field_count; |
| 4121 | 4129 | entry->data.enumeration.fields = allocate<TypeEnumField>(field_count); |
| 4122 | 4130 | for (uint32_t i = 0; i < field_count; i += 1) { |
| ... | ... | @@ -4140,7 +4148,7 @@ static void define_builtin_types(CodeGen *g) { |
| 4140 | 4148 | { |
| 4141 | 4149 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); |
| 4142 | 4150 | buf_init_from_str(&entry->name, "Arch"); |
| 4143 | uint32_t field_count = target_arch_count(); | |
| 4151 | uint32_t field_count = (uint32_t)target_arch_count(); | |
| 4144 | 4152 | entry->data.enumeration.src_field_count = field_count; |
| 4145 | 4153 | entry->data.enumeration.fields = allocate<TypeEnumField>(field_count); |
| 4146 | 4154 | for (uint32_t i = 0; i < field_count; i += 1) { |
| ... | ... | @@ -4170,7 +4178,7 @@ static void define_builtin_types(CodeGen *g) { |
| 4170 | 4178 | { |
| 4171 | 4179 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); |
| 4172 | 4180 | buf_init_from_str(&entry->name, "Environ"); |
| 4173 | uint32_t field_count = target_environ_count(); | |
| 4181 | uint32_t field_count = (uint32_t)target_environ_count(); | |
| 4174 | 4182 | entry->data.enumeration.src_field_count = field_count; |
| 4175 | 4183 | entry->data.enumeration.fields = allocate<TypeEnumField>(field_count); |
| 4176 | 4184 | for (uint32_t i = 0; i < field_count; i += 1) { |
| ... | ... | @@ -4194,7 +4202,7 @@ static void define_builtin_types(CodeGen *g) { |
| 4194 | 4202 | { |
| 4195 | 4203 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdEnum); |
| 4196 | 4204 | buf_init_from_str(&entry->name, "ObjectFormat"); |
| 4197 | uint32_t field_count = target_oformat_count(); | |
| 4205 | uint32_t field_count = (uint32_t)target_oformat_count(); | |
| 4198 | 4206 | entry->data.enumeration.src_field_count = field_count; |
| 4199 | 4207 | entry->data.enumeration.fields = allocate<TypeEnumField>(field_count); |
| 4200 | 4208 | for (uint32_t i = 0; i < field_count; i += 1) { |
| ... | ... | @@ -4705,7 +4713,7 @@ static void get_c_type(CodeGen *g, TypeTableEntry *type_entry, Buf *out_buf) { |
| 4705 | 4713 | case TypeTableEntryIdInt: |
| 4706 | 4714 | g->c_want_stdint = true; |
| 4707 | 4715 | buf_resize(out_buf, 0); |
| 4708 | buf_appendf(out_buf, "%sint%zu_t", | |
| 4716 | buf_appendf(out_buf, "%sint%" PRIu32 "_t", | |
| 4709 | 4717 | type_entry->data.integral.is_signed ? "" : "u", |
| 4710 | 4718 | type_entry->data.integral.bit_count); |
| 4711 | 4719 | break; |
src/ir.cpp+7-6| ... | ... | @@ -7295,7 +7295,7 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 7295 | 7295 | ConstExprValue *char_val = &array_val->data.x_array.elements[new_index]; |
| 7296 | 7296 | uint64_t big_c = char_val->data.x_bignum.data.x_uint; |
| 7297 | 7297 | assert(big_c <= UINT8_MAX); |
| 7298 | uint8_t c = big_c; | |
| 7298 | uint8_t c = (uint8_t)big_c; | |
| 7299 | 7299 | buf_ptr(result)[i] = c; |
| 7300 | 7300 | } |
| 7301 | 7301 | return result; |
| ... | ... | @@ -9062,7 +9062,7 @@ static TypeTableEntry *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruc |
| 9062 | 9062 | |
| 9063 | 9063 | return_type = get_pointer_to_type_extra(ira->codegen, child_type, |
| 9064 | 9064 | ptr_type->data.pointer.is_const, ptr_type->data.pointer.is_volatile, |
| 9065 | bit_offset, bit_width); | |
| 9065 | (uint32_t)bit_offset, (uint32_t)bit_width); | |
| 9066 | 9066 | } |
| 9067 | 9067 | } else if (array_type->id == TypeTableEntryIdPointer) { |
| 9068 | 9068 | return_type = array_type; |
| ... | ... | @@ -9299,7 +9299,8 @@ static TypeTableEntry *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field |
| 9299 | 9299 | field->unaligned_bit_count : type_size_bits(ira->codegen, field->type_entry); |
| 9300 | 9300 | ir_build_struct_field_ptr_from(&ira->new_irb, &field_ptr_instruction->base, container_ptr, field); |
| 9301 | 9301 | return get_pointer_to_type_extra(ira->codegen, field->type_entry, is_const, is_volatile, |
| 9302 | ptr_bit_offset + field->packed_bits_offset, unaligned_bit_count_for_result_type); | |
| 9302 | (uint32_t)(ptr_bit_offset + field->packed_bits_offset), | |
| 9303 | (uint32_t)unaligned_bit_count_for_result_type); | |
| 9303 | 9304 | } else { |
| 9304 | 9305 | return ir_analyze_container_member_access_inner(ira, bare_type, field_name, |
| 9305 | 9306 | field_ptr_instruction, container_ptr, container_type); |
| ... | ... | @@ -9759,7 +9760,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9759 | 9760 | } |
| 9760 | 9761 | |
| 9761 | 9762 | AstNode **set_global_align_node; |
| 9762 | uint64_t *alignment_ptr; | |
| 9763 | uint32_t *alignment_ptr; | |
| 9763 | 9764 | if (tld->id == TldIdVar) { |
| 9764 | 9765 | TldVar *tld_var = (TldVar *)tld; |
| 9765 | 9766 | set_global_align_node = &tld_var->set_global_align_node; |
| ... | ... | @@ -9782,7 +9783,7 @@ static TypeTableEntry *ir_analyze_instruction_set_global_align(IrAnalyze *ira, |
| 9782 | 9783 | return ira->codegen->builtin_types.entry_invalid; |
| 9783 | 9784 | } |
| 9784 | 9785 | *set_global_align_node = source_node; |
| 9785 | *alignment_ptr = scalar_align; | |
| 9786 | *alignment_ptr = (uint32_t)scalar_align; | |
| 9786 | 9787 | |
| 9787 | 9788 | ir_build_const_from(ira, &instruction->base); |
| 9788 | 9789 | return ira->codegen->builtin_types.entry_void; |
| ... | ... | @@ -11547,7 +11548,7 @@ static TypeTableEntry *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstruc |
| 11547 | 11548 | return ira->codegen->builtin_types.entry_invalid; |
| 11548 | 11549 | |
| 11549 | 11550 | ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base); |
| 11550 | out_val->data.x_type = get_int_type(ira->codegen, is_signed, bit_count); | |
| 11551 | out_val->data.x_type = get_int_type(ira->codegen, is_signed, (uint32_t)bit_count); | |
| 11551 | 11552 | return ira->codegen->builtin_types.entry_type; |
| 11552 | 11553 | } |
| 11553 | 11554 |
src/link.cpp+3-3| ... | ... | @@ -503,21 +503,21 @@ static bool darwin_get_release_version(const char *str, int *major, int *minor, |
| 503 | 503 | return false; |
| 504 | 504 | |
| 505 | 505 | char *end; |
| 506 | *major = strtol(str, &end, 10); | |
| 506 | *major = (int)strtol(str, &end, 10); | |
| 507 | 507 | if (*str != '\0' && *end == '\0') |
| 508 | 508 | return true; |
| 509 | 509 | if (*end != '.') |
| 510 | 510 | return false; |
| 511 | 511 | |
| 512 | 512 | str = end + 1; |
| 513 | *minor = strtol(str, &end, 10); | |
| 513 | *minor = (int)strtol(str, &end, 10); | |
| 514 | 514 | if (*str != '\0' && *end == '\0') |
| 515 | 515 | return true; |
| 516 | 516 | if (*end != '.') |
| 517 | 517 | return false; |
| 518 | 518 | |
| 519 | 519 | str = end + 1; |
| 520 | *micro = strtol(str, &end, 10); | |
| 520 | *micro = (int)strtol(str, &end, 10); | |
| 521 | 521 | if (*str != '\0' && *end == '\0') |
| 522 | 522 | return true; |
| 523 | 523 | if (str == end) |
src/list.hpp+1-1| ... | ... | @@ -69,7 +69,7 @@ struct ZigList { |
| 69 | 69 | |
| 70 | 70 | size_t better_capacity = capacity; |
| 71 | 71 | do { |
| 72 | better_capacity = better_capacity * 1.4 + 8; | |
| 72 | better_capacity = better_capacity * 5 / 2 + 8; | |
| 73 | 73 | } while (better_capacity < new_capacity); |
| 74 | 74 | |
| 75 | 75 | items = reallocate_nonzero(items, capacity, better_capacity); |
src/os.cpp+2-2| ... | ... | @@ -556,7 +556,7 @@ static int os_buf_to_tmp_file_posix(Buf *contents, Buf *suffix, Buf *out_tmp_pat |
| 556 | 556 | buf_resize(out_tmp_path, 0); |
| 557 | 557 | buf_appendf(out_tmp_path, "%s/XXXXXX%s", tmp_dir, buf_ptr(suffix)); |
| 558 | 558 | |
| 559 | int fd = mkstemps(buf_ptr(out_tmp_path), buf_len(suffix)); | |
| 559 | int fd = mkstemps(buf_ptr(out_tmp_path), (int)buf_len(suffix)); | |
| 560 | 560 | if (fd < 0) { |
| 561 | 561 | return ErrorFileSystem; |
| 562 | 562 | } |
| ... | ... | @@ -629,5 +629,5 @@ int os_delete_file(Buf *path) { |
| 629 | 629 | } |
| 630 | 630 | |
| 631 | 631 | void os_init(void) { |
| 632 | srand(time(NULL)); | |
| 632 | srand((unsigned)time(NULL)); | |
| 633 | 633 | } |
src/target.cpp+6-6| ... | ... | @@ -161,7 +161,7 @@ size_t target_oformat_count(void) { |
| 161 | 161 | return array_length(oformat_list); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | const ZigLLVM_ObjectFormatType get_target_oformat(int index) { | |
| 164 | const ZigLLVM_ObjectFormatType get_target_oformat(size_t index) { | |
| 165 | 165 | return oformat_list[index]; |
| 166 | 166 | } |
| 167 | 167 | |
| ... | ... | @@ -179,7 +179,7 @@ size_t target_arch_count(void) { |
| 179 | 179 | return array_length(arch_list); |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | const ArchType *get_target_arch(int index) { | |
| 182 | const ArchType *get_target_arch(size_t index) { | |
| 183 | 183 | return &arch_list[index]; |
| 184 | 184 | } |
| 185 | 185 | |
| ... | ... | @@ -187,14 +187,14 @@ size_t target_vendor_count(void) { |
| 187 | 187 | return array_length(vendor_list); |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | ZigLLVM_VendorType get_target_vendor(int index) { | |
| 190 | ZigLLVM_VendorType get_target_vendor(size_t index) { | |
| 191 | 191 | return vendor_list[index]; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | size_t target_os_count(void) { |
| 195 | 195 | return array_length(os_list); |
| 196 | 196 | } |
| 197 | ZigLLVM_OSType get_target_os(int index) { | |
| 197 | ZigLLVM_OSType get_target_os(size_t index) { | |
| 198 | 198 | return os_list[index]; |
| 199 | 199 | } |
| 200 | 200 | |
| ... | ... | @@ -205,7 +205,7 @@ const char *get_target_os_name(ZigLLVM_OSType os_type) { |
| 205 | 205 | size_t target_environ_count(void) { |
| 206 | 206 | return array_length(environ_list); |
| 207 | 207 | } |
| 208 | ZigLLVM_EnvironmentType get_target_environ(int index) { | |
| 208 | ZigLLVM_EnvironmentType get_target_environ(size_t index) { | |
| 209 | 209 | return environ_list[index]; |
| 210 | 210 | } |
| 211 | 211 | |
| ... | ... | @@ -443,7 +443,7 @@ static int get_arch_pointer_bit_width(ZigLLVM_ArchType arch) { |
| 443 | 443 | zig_unreachable(); |
| 444 | 444 | } |
| 445 | 445 | |
| 446 | int get_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | |
| 446 | uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id) { | |
| 447 | 447 | switch (target->os) { |
| 448 | 448 | case ZigLLVM_UnknownOS: |
| 449 | 449 | switch (id) { |
src/target.hpp+6-6| ... | ... | @@ -39,22 +39,22 @@ enum CIntType { |
| 39 | 39 | }; |
| 40 | 40 | |
| 41 | 41 | size_t target_arch_count(void); |
| 42 | const ArchType *get_target_arch(int index); | |
| 42 | const ArchType *get_target_arch(size_t index); | |
| 43 | 43 | void get_arch_name(char *out_str, const ArchType *arch); |
| 44 | 44 | |
| 45 | 45 | size_t target_vendor_count(void); |
| 46 | ZigLLVM_VendorType get_target_vendor(int index); | |
| 46 | ZigLLVM_VendorType get_target_vendor(size_t index); | |
| 47 | 47 | |
| 48 | 48 | size_t target_os_count(void); |
| 49 | ZigLLVM_OSType get_target_os(int index); | |
| 49 | ZigLLVM_OSType get_target_os(size_t index); | |
| 50 | 50 | const char *get_target_os_name(ZigLLVM_OSType os_type); |
| 51 | 51 | |
| 52 | 52 | size_t target_environ_count(void); |
| 53 | ZigLLVM_EnvironmentType get_target_environ(int index); | |
| 53 | ZigLLVM_EnvironmentType get_target_environ(size_t index); | |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | size_t target_oformat_count(void); |
| 57 | const ZigLLVM_ObjectFormatType get_target_oformat(int index); | |
| 57 | const ZigLLVM_ObjectFormatType get_target_oformat(size_t index); | |
| 58 | 58 | const char *get_target_oformat_name(ZigLLVM_ObjectFormatType oformat); |
| 59 | 59 | |
| 60 | 60 | void get_native_target(ZigTarget *target); |
| ... | ... | @@ -70,7 +70,7 @@ void get_target_triple(Buf *triple, const ZigTarget *target); |
| 70 | 70 | |
| 71 | 71 | void resolve_target_object_format(ZigTarget *target); |
| 72 | 72 | |
| 73 | int get_c_type_size_in_bits(const ZigTarget *target, CIntType id); | |
| 73 | uint32_t target_c_type_size_in_bits(const ZigTarget *target, CIntType id); | |
| 74 | 74 | |
| 75 | 75 | const char *target_o_file_ext(ZigTarget *target); |
| 76 | 76 |
src/tokenizer.cpp+16-16| ... | ... | @@ -309,7 +309,7 @@ static void end_float_token(Tokenize *t) { |
| 309 | 309 | if (t->is_exp_negative) { |
| 310 | 310 | specified_exponent = -specified_exponent; |
| 311 | 311 | } |
| 312 | t->exponent_in_bin_or_dec += specified_exponent; | |
| 312 | t->exponent_in_bin_or_dec = (int)(t->exponent_in_bin_or_dec + specified_exponent); | |
| 313 | 313 | |
| 314 | 314 | uint64_t significand = t->cur_tok->data.num_lit.bignum.data.x_uint; |
| 315 | 315 | uint64_t significand_bits; |
| ... | ... | @@ -352,7 +352,7 @@ static void end_token(Tokenize *t) { |
| 352 | 352 | } |
| 353 | 353 | } else if (t->cur_tok->id == TokenIdSymbol) { |
| 354 | 354 | char *token_mem = buf_ptr(t->buf) + t->cur_tok->start_pos; |
| 355 | int token_len = t->cur_tok->end_pos - t->cur_tok->start_pos; | |
| 355 | int token_len = (int)(t->cur_tok->end_pos - t->cur_tok->start_pos); | |
| 356 | 356 | |
| 357 | 357 | for (size_t i = 0; i < array_length(zig_keywords); i += 1) { |
| 358 | 358 | if (mem_eql_str(token_mem, token_len, zig_keywords[i].text)) { |
| ... | ... | @@ -1088,39 +1088,39 @@ void tokenize(Buf *buf, Tokenization *out) { |
| 1088 | 1088 | if (t.unicode) { |
| 1089 | 1089 | if (t.char_code <= 0x7f) { |
| 1090 | 1090 | // 00000000 00000000 00000000 0xxxxxxx |
| 1091 | handle_string_escape(&t, t.char_code); | |
| 1091 | handle_string_escape(&t, (uint8_t)t.char_code); | |
| 1092 | 1092 | } else if (t.cur_tok->id == TokenIdCharLiteral) { |
| 1093 | 1093 | tokenize_error(&t, "unicode value too large for character literal: %x", t.char_code); |
| 1094 | 1094 | } else if (t.char_code <= 0x7ff) { |
| 1095 | 1095 | // 00000000 00000000 00000xxx xx000000 |
| 1096 | handle_string_escape(&t, 0xc0 | (t.char_code >> 6)); | |
| 1096 | handle_string_escape(&t, (uint8_t)(0xc0 | (t.char_code >> 6))); | |
| 1097 | 1097 | // 00000000 00000000 00000000 00xxxxxx |
| 1098 | handle_string_escape(&t, 0x80 | (t.char_code & 0x3f)); | |
| 1098 | handle_string_escape(&t, (uint8_t)(0x80 | (t.char_code & 0x3f))); | |
| 1099 | 1099 | } else if (t.char_code <= 0xffff) { |
| 1100 | 1100 | // 00000000 00000000 xxxx0000 00000000 |
| 1101 | handle_string_escape(&t, 0xe0 | (t.char_code >> 12)); | |
| 1101 | handle_string_escape(&t, (uint8_t)(0xe0 | (t.char_code >> 12))); | |
| 1102 | 1102 | // 00000000 00000000 0000xxxx xx000000 |
| 1103 | handle_string_escape(&t, 0x80 | ((t.char_code >> 6) & 0x3f)); | |
| 1103 | handle_string_escape(&t, (uint8_t)(0x80 | ((t.char_code >> 6) & 0x3f))); | |
| 1104 | 1104 | // 00000000 00000000 00000000 00xxxxxx |
| 1105 | handle_string_escape(&t, 0x80 | (t.char_code & 0x3f)); | |
| 1105 | handle_string_escape(&t, (uint8_t)(0x80 | (t.char_code & 0x3f))); | |
| 1106 | 1106 | } else if (t.char_code <= 0x10ffff) { |
| 1107 | 1107 | // 00000000 000xxx00 00000000 00000000 |
| 1108 | handle_string_escape(&t, 0xf0 | (t.char_code >> 18)); | |
| 1108 | handle_string_escape(&t, (uint8_t)(0xf0 | (t.char_code >> 18))); | |
| 1109 | 1109 | // 00000000 000000xx xxxx0000 00000000 |
| 1110 | handle_string_escape(&t, 0x80 | ((t.char_code >> 12) & 0x3f)); | |
| 1110 | handle_string_escape(&t, (uint8_t)(0x80 | ((t.char_code >> 12) & 0x3f))); | |
| 1111 | 1111 | // 00000000 00000000 0000xxxx xx000000 |
| 1112 | handle_string_escape(&t, 0x80 | ((t.char_code >> 6) & 0x3f)); | |
| 1112 | handle_string_escape(&t, (uint8_t)(0x80 | ((t.char_code >> 6) & 0x3f))); | |
| 1113 | 1113 | // 00000000 00000000 00000000 00xxxxxx |
| 1114 | handle_string_escape(&t, 0x80 | (t.char_code & 0x3f)); | |
| 1114 | handle_string_escape(&t, (uint8_t)(0x80 | (t.char_code & 0x3f))); | |
| 1115 | 1115 | } else { |
| 1116 | 1116 | tokenize_error(&t, "unicode value out of range: %x", t.char_code); |
| 1117 | 1117 | } |
| 1118 | 1118 | } else { |
| 1119 | if (t.cur_tok->id == TokenIdCharLiteral && t.char_code >= sizeof(uint8_t)) { | |
| 1119 | if (t.cur_tok->id == TokenIdCharLiteral && t.char_code > UINT8_MAX) { | |
| 1120 | 1120 | tokenize_error(&t, "value too large for character literal: '%x'", |
| 1121 | 1121 | t.char_code); |
| 1122 | 1122 | } |
| 1123 | handle_string_escape(&t, t.char_code); | |
| 1123 | handle_string_escape(&t, (uint8_t)t.char_code); | |
| 1124 | 1124 | } |
| 1125 | 1125 | } |
| 1126 | 1126 | } |
| ... | ... | @@ -1396,8 +1396,8 @@ void tokenize(Buf *buf, Tokenization *out) { |
| 1396 | 1396 | if (t.state != TokenizeStateError) { |
| 1397 | 1397 | if (t.tokens->length > 0) { |
| 1398 | 1398 | Token *last_token = &t.tokens->last(); |
| 1399 | t.line = last_token->start_line; | |
| 1400 | t.column = last_token->start_column; | |
| 1399 | t.line = (int)last_token->start_line; | |
| 1400 | t.column = (int)last_token->start_column; | |
| 1401 | 1401 | t.pos = last_token->start_pos; |
| 1402 | 1402 | } else { |
| 1403 | 1403 | t.pos = 0; |
src/util.cpp+1-1| ... | ... | @@ -36,7 +36,7 @@ bool uint64_eq(uint64_t a, uint64_t b) { |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | uint32_t ptr_hash(const void *ptr) { |
| 39 | return ((uintptr_t)ptr) % UINT32_MAX; | |
| 39 | return (uint32_t)(((uintptr_t)ptr) % UINT32_MAX); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | bool ptr_eq(const void *a, const void *b) { |