| ... | ... | @@ -8792,11 +8792,25 @@ static bool ir_resolve_comptime(IrAnalyze *ira, IrInstruction *value, bool *out) |
| 8792 | 8792 | return ir_resolve_bool(ira, value, out); |
| 8793 | 8793 | } |
| 8794 | 8794 | |
| 8795 | static ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name) { |
| 8796 | Tld *tld = codegen->compile_var_import->decls_scope->decl_table.get(buf_create_from_str(name)); |
| 8797 | resolve_top_level_decl(codegen, tld, false, nullptr); |
| 8798 | assert(tld->id == TldIdVar); |
| 8799 | TldVar *tld_var = (TldVar *)tld; |
| 8800 | ConstExprValue *var_value = tld_var->var->value; |
| 8801 | assert(var_value != nullptr); |
| 8802 | return var_value; |
| 8803 | } |
| 8804 | |
| 8795 | 8805 | static bool ir_resolve_atomic_order(IrAnalyze *ira, IrInstruction *value, AtomicOrder *out) { |
| 8796 | 8806 | if (type_is_invalid(value->value.type)) |
| 8797 | 8807 | return false; |
| 8798 | 8808 | |
| 8799 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_atomic_order_enum); |
| 8809 | ConstExprValue *atomic_order_val = get_builtin_value(ira->codegen, "AtomicOrder"); |
| 8810 | assert(atomic_order_val->type->id == TypeTableEntryIdMetaType); |
| 8811 | TypeTableEntry *atomic_order_type = atomic_order_val->data.x_type; |
| 8812 | |
| 8813 | IrInstruction *casted_value = ir_implicit_cast(ira, value, atomic_order_type); |
| 8800 | 8814 | if (type_is_invalid(casted_value->value.type)) |
| 8801 | 8815 | return false; |
| 8802 | 8816 | |
| ... | ... | @@ -8812,7 +8826,11 @@ static bool ir_resolve_global_linkage(IrAnalyze *ira, IrInstruction *value, Glob |
| 8812 | 8826 | if (type_is_invalid(value->value.type)) |
| 8813 | 8827 | return false; |
| 8814 | 8828 | |
| 8815 | | IrInstruction *casted_value = ir_implicit_cast(ira, value, ira->codegen->builtin_types.entry_global_linkage_enum); |
| 8829 | ConstExprValue *global_linkage_val = get_builtin_value(ira->codegen, "GlobalLinkage"); |
| 8830 | assert(global_linkage_val->type->id == TypeTableEntryIdMetaType); |
| 8831 | TypeTableEntry *global_linkage_type = global_linkage_val->data.x_type; |
| 8832 | |
| 8833 | IrInstruction *casted_value = ir_implicit_cast(ira, value, global_linkage_type); |
| 8816 | 8834 | if (type_is_invalid(casted_value->value.type)) |
| 8817 | 8835 | return false; |
| 8818 | 8836 | |
| ... | ... | @@ -8863,16 +8881,6 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 8863 | 8881 | return result; |
| 8864 | 8882 | } |
| 8865 | 8883 | |
| 8866 | | static ConstExprValue *get_builtin_value(CodeGen *codegen, const char *name) { |
| 8867 | | Tld *tld = codegen->compile_var_import->decls_scope->decl_table.get(buf_create_from_str(name)); |
| 8868 | | resolve_top_level_decl(codegen, tld, false, nullptr); |
| 8869 | | assert(tld->id == TldIdVar); |
| 8870 | | TldVar *tld_var = (TldVar *)tld; |
| 8871 | | ConstExprValue *var_value = tld_var->var->value; |
| 8872 | | assert(var_value != nullptr); |
| 8873 | | return var_value; |
| 8874 | | } |
| 8875 | | |
| 8876 | 8884 | static TypeTableEntry *ir_analyze_instruction_return(IrAnalyze *ira, |
| 8877 | 8885 | IrInstructionReturn *return_instruction) |
| 8878 | 8886 | { |