From 81cc52d4af1f1ecd05d8b75c3cfdc0105a3c53c3 Mon Sep 17 00:00:00 2001
From: Michael Dusan
Date: Thu, 20 Feb 2020 00:38:35 -0500
Subject: stage1/ir_print: show GenConst in trailing fahsion
---
src/ir_print.cpp | 5 -----
1 file changed, 5 deletions(-)
(limited to 'src/ir_print.cpp')
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 47c984f2ef..c0a127dd16 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -590,11 +590,6 @@ static void ir_print_const_value(CodeGen *g, FILE *f, ZigValue *const_val) {
static void ir_print_other_inst_gen(IrPrintGen *irp, IrInstGen *inst) {
if (inst == nullptr) {
fprintf(irp->f, "(null)");
- return;
- }
-
- if (inst->value->special != ConstValSpecialRuntime) {
- ir_print_const_value(irp->codegen, irp->f, inst->value);
} else {
ir_print_var_gen(irp, inst);
}
--
cgit v1.2.3
From 9c35f680f73538b8c36121ff938cc0b19eadbb42 Mon Sep 17 00:00:00 2001
From: xackus <14938807+xackus@users.noreply.github.com>
Date: Sun, 23 Feb 2020 19:03:55 +0100
Subject: nuke @bytesToSlice, @sliceToBytes in stage1
---
src/all_types.hpp | 28 ------
src/codegen.cpp | 74 ----------------
src/ir.cpp | 256 ------------------------------------------------------
src/ir_print.cpp | 36 --------
4 files changed, 394 deletions(-)
(limited to 'src/ir_print.cpp')
diff --git a/src/all_types.hpp b/src/all_types.hpp
index c1348d3abd..117a0004f0 100644
--- a/src/all_types.hpp
+++ b/src/all_types.hpp
@@ -1750,8 +1750,6 @@ enum BuiltinFnId {
BuiltinFnIdIntCast,
BuiltinFnIdFloatCast,
BuiltinFnIdErrSetCast,
- BuiltinFnIdToBytes,
- BuiltinFnIdFromBytes,
BuiltinFnIdIntToFloat,
BuiltinFnIdFloatToInt,
BuiltinFnIdBoolToInt,
@@ -1821,7 +1819,6 @@ enum PanicMsgId {
PanicMsgIdDivisionByZero,
PanicMsgIdRemainderDivisionByZero,
PanicMsgIdExactDivisionRemainder,
- PanicMsgIdSliceWidenRemainder,
PanicMsgIdUnwrapOptionalFail,
PanicMsgIdInvalidErrorCode,
PanicMsgIdIncorrectAlignment,
@@ -2699,8 +2696,6 @@ enum IrInstSrcId {
IrInstSrcIdSaveErrRetAddr,
IrInstSrcIdAddImplicitReturnType,
IrInstSrcIdErrSetCast,
- IrInstSrcIdToBytes,
- IrInstSrcIdFromBytes,
IrInstSrcIdCheckRuntimeScope,
IrInstSrcIdHasDecl,
IrInstSrcIdUndeclaredIdent,
@@ -2739,7 +2734,6 @@ enum IrInstGenId {
IrInstGenIdCall,
IrInstGenIdReturn,
IrInstGenIdCast,
- IrInstGenIdResizeSlice,
IrInstGenIdUnreachable,
IrInstGenIdAsm,
IrInstGenIdTestNonNull,
@@ -3271,13 +3265,6 @@ struct IrInstGenCast {
CastOp cast_op;
};
-struct IrInstGenResizeSlice {
- IrInstGen base;
-
- IrInstGen *operand;
- IrInstGen *result_loc;
-};
-
struct IrInstSrcContainerInitList {
IrInstSrc base;
@@ -3629,21 +3616,6 @@ struct IrInstSrcErrSetCast {
IrInstSrc *target;
};
-struct IrInstSrcToBytes {
- IrInstSrc base;
-
- IrInstSrc *target;
- ResultLoc *result_loc;
-};
-
-struct IrInstSrcFromBytes {
- IrInstSrc base;
-
- IrInstSrc *dest_child_type;
- IrInstSrc *target;
- ResultLoc *result_loc;
-};
-
struct IrInstSrcIntToFloat {
IrInstSrc base;
diff --git a/src/codegen.cpp b/src/codegen.cpp
index a28d2d469d..c193b4e443 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -972,8 +972,6 @@ static Buf *panic_msg_buf(PanicMsgId msg_id) {
return buf_create_from_str("remainder division by zero or negative value");
case PanicMsgIdExactDivisionRemainder:
return buf_create_from_str("exact division produced remainder");
- case PanicMsgIdSliceWidenRemainder:
- return buf_create_from_str("slice widening size mismatch");
case PanicMsgIdUnwrapOptionalFail:
return buf_create_from_str("attempt to unwrap null");
case PanicMsgIdUnreachable:
@@ -3085,74 +3083,6 @@ static void add_error_range_check(CodeGen *g, ZigType *err_set_type, ZigType *in
}
}
-static LLVMValueRef ir_render_resize_slice(CodeGen *g, IrExecutableGen *executable,
- IrInstGenResizeSlice *instruction)
-{
- ZigType *actual_type = instruction->operand->value->type;
- ZigType *wanted_type = instruction->base.value->type;
- LLVMValueRef expr_val = ir_llvm_value(g, instruction->operand);
- assert(expr_val);
-
- LLVMValueRef result_loc = ir_llvm_value(g, instruction->result_loc);
- assert(wanted_type->id == ZigTypeIdStruct);
- assert(wanted_type->data.structure.special == StructSpecialSlice);
- assert(actual_type->id == ZigTypeIdStruct);
- assert(actual_type->data.structure.special == StructSpecialSlice);
-
- ZigType *actual_pointer_type = actual_type->data.structure.fields[0]->type_entry;
- ZigType *actual_child_type = actual_pointer_type->data.pointer.child_type;
- ZigType *wanted_pointer_type = wanted_type->data.structure.fields[0]->type_entry;
- ZigType *wanted_child_type = wanted_pointer_type->data.pointer.child_type;
-
-
- size_t actual_ptr_index = actual_type->data.structure.fields[slice_ptr_index]->gen_index;
- size_t actual_len_index = actual_type->data.structure.fields[slice_len_index]->gen_index;
- size_t wanted_ptr_index = wanted_type->data.structure.fields[slice_ptr_index]->gen_index;
- size_t wanted_len_index = wanted_type->data.structure.fields[slice_len_index]->gen_index;
-
- LLVMValueRef src_ptr_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_ptr_index, "");
- LLVMValueRef src_ptr = gen_load_untyped(g, src_ptr_ptr, 0, false, "");
- LLVMValueRef src_ptr_casted = LLVMBuildBitCast(g->builder, src_ptr,
- get_llvm_type(g, wanted_type->data.structure.fields[0]->type_entry), "");
- LLVMValueRef dest_ptr_ptr = LLVMBuildStructGEP(g->builder, result_loc,
- (unsigned)wanted_ptr_index, "");
- gen_store_untyped(g, src_ptr_casted, dest_ptr_ptr, 0, false);
-
- LLVMValueRef src_len_ptr = LLVMBuildStructGEP(g->builder, expr_val, (unsigned)actual_len_index, "");
- LLVMValueRef src_len = gen_load_untyped(g, src_len_ptr, 0, false, "");
- uint64_t src_size = type_size(g, actual_child_type);
- uint64_t dest_size = type_size(g, wanted_child_type);
-
- LLVMValueRef new_len;
- if (dest_size == 1) {
- LLVMValueRef src_size_val = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, src_size, false);
- new_len = LLVMBuildMul(g->builder, src_len, src_size_val, "");
- } else if (src_size == 1) {
- LLVMValueRef dest_size_val = LLVMConstInt(g->builtin_types.entry_usize->llvm_type, dest_size, false);
- if (ir_want_runtime_safety(g, &instruction->base)) {
- LLVMValueRef remainder_val = LLVMBuildURem(g->builder, src_len, dest_size_val, "");
- LLVMValueRef zero = LLVMConstNull(g->builtin_types.entry_usize->llvm_type);
- LLVMValueRef ok_bit = LLVMBuildICmp(g->builder, LLVMIntEQ, remainder_val, zero, "");
- LLVMBasicBlockRef ok_block = LLVMAppendBasicBlock(g->cur_fn_val, "SliceWidenOk");
- LLVMBasicBlockRef fail_block = LLVMAppendBasicBlock(g->cur_fn_val, "SliceWidenFail");
- LLVMBuildCondBr(g->builder, ok_bit, ok_block, fail_block);
-
- LLVMPositionBuilderAtEnd(g->builder, fail_block);
- gen_safety_crash(g, PanicMsgIdSliceWidenRemainder);
-
- LLVMPositionBuilderAtEnd(g->builder, ok_block);
- }
- new_len = LLVMBuildExactUDiv(g->builder, src_len, dest_size_val, "");
- } else {
- zig_unreachable();
- }
-
- LLVMValueRef dest_len_ptr = LLVMBuildStructGEP(g->builder, result_loc, (unsigned)wanted_len_index, "");
- gen_store_untyped(g, new_len, dest_len_ptr, 0, false);
-
- return result_loc;
-}
-
static LLVMValueRef ir_render_cast(CodeGen *g, IrExecutableGen *executable,
IrInstGenCast *cast_instruction)
{
@@ -6485,8 +6415,6 @@ static LLVMValueRef ir_render_instruction(CodeGen *g, IrExecutableGen *executabl
return ir_render_assert_zero(g, executable, (IrInstGenAssertZero *)instruction);
case IrInstGenIdAssertNonNull:
return ir_render_assert_non_null(g, executable, (IrInstGenAssertNonNull *)instruction);
- case IrInstGenIdResizeSlice:
- return ir_render_resize_slice(g, executable, (IrInstGenResizeSlice *)instruction);
case IrInstGenIdPtrOfArrayToSlice:
return ir_render_ptr_of_array_to_slice(g, executable, (IrInstGenPtrOfArrayToSlice *)instruction);
case IrInstGenIdSuspendBegin:
@@ -8317,8 +8245,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdAtomicLoad, "atomicLoad", 3);
create_builtin_fn(g, BuiltinFnIdAtomicStore, "atomicStore", 4);
create_builtin_fn(g, BuiltinFnIdErrSetCast, "errSetCast", 2);
- create_builtin_fn(g, BuiltinFnIdToBytes, "sliceToBytes", 1);
- create_builtin_fn(g, BuiltinFnIdFromBytes, "bytesToSlice", 2);
create_builtin_fn(g, BuiltinFnIdThis, "This", 0);
create_builtin_fn(g, BuiltinFnIdHasDecl, "hasDecl", 2);
create_builtin_fn(g, BuiltinFnIdUnionInit, "unionInit", 3);
diff --git a/src/ir.cpp b/src/ir.cpp
index 5f50586f72..80fef04496 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -383,10 +383,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdErrSetCast:
return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstSrcIdFromBytes:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstSrcIdToBytes:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdIntToFloat:
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdFloatToInt:
@@ -707,8 +703,6 @@ void destroy_instruction_gen(IrInstGen *inst) {
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstGenIdAssertNonNull:
return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstGenIdResizeSlice:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstGenIdAlloca:
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstGenIdSuspendBegin:
@@ -1563,14 +1557,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcErrSetCast *) {
return IrInstSrcIdErrSetCast;
}
-static constexpr IrInstSrcId ir_inst_id(IrInstSrcToBytes *) {
- return IrInstSrcIdToBytes;
-}
-
-static constexpr IrInstSrcId ir_inst_id(IrInstSrcFromBytes *) {
- return IrInstSrcIdFromBytes;
-}
-
static constexpr IrInstSrcId ir_inst_id(IrInstSrcCheckRuntimeScope *) {
return IrInstSrcIdCheckRuntimeScope;
}
@@ -1700,10 +1686,6 @@ static constexpr IrInstGenId ir_inst_id(IrInstGenCast *) {
return IrInstGenIdCast;
}
-static constexpr IrInstGenId ir_inst_id(IrInstGenResizeSlice *) {
- return IrInstGenIdResizeSlice;
-}
-
static constexpr IrInstGenId ir_inst_id(IrInstGenUnreachable *) {
return IrInstGenIdUnreachable;
}
@@ -2759,21 +2741,6 @@ static IrInstGen *ir_build_var_decl_gen(IrAnalyze *ira, IrInst *source_instructi
return &inst->base;
}
-static IrInstGen *ir_build_resize_slice(IrAnalyze *ira, IrInst *source_instruction,
- IrInstGen *operand, ZigType *ty, IrInstGen *result_loc)
-{
- IrInstGenResizeSlice *instruction = ir_build_inst_gen(&ira->new_irb,
- source_instruction->scope, source_instruction->source_node);
- instruction->base.value->type = ty;
- instruction->operand = operand;
- instruction->result_loc = result_loc;
-
- ir_ref_inst_gen(operand, ira->new_irb.current_basic_block);
- if (result_loc != nullptr) ir_ref_inst_gen(result_loc, ira->new_irb.current_basic_block);
-
- return &instruction->base;
-}
-
static IrInstSrc *ir_build_export(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
IrInstSrc *target, IrInstSrc *options)
{
@@ -3540,32 +3507,6 @@ static IrInstSrc *ir_build_err_set_cast(IrBuilderSrc *irb, Scope *scope, AstNode
return &instruction->base;
}
-static IrInstSrc *ir_build_to_bytes(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *target,
- ResultLoc *result_loc)
-{
- IrInstSrcToBytes *instruction = ir_build_instruction(irb, scope, source_node);
- instruction->target = target;
- instruction->result_loc = result_loc;
-
- ir_ref_instruction(target, irb->current_basic_block);
-
- return &instruction->base;
-}
-
-static IrInstSrc *ir_build_from_bytes(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
- IrInstSrc *dest_child_type, IrInstSrc *target, ResultLoc *result_loc)
-{
- IrInstSrcFromBytes *instruction = ir_build_instruction(irb, scope, source_node);
- instruction->dest_child_type = dest_child_type;
- instruction->target = target;
- instruction->result_loc = result_loc;
-
- ir_ref_instruction(dest_child_type, irb->current_basic_block);
- ir_ref_instruction(target, irb->current_basic_block);
-
- return &instruction->base;
-}
-
static IrInstSrc *ir_build_int_to_float(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
IrInstSrc *dest_type, IrInstSrc *target)
{
@@ -6597,31 +6538,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
IrInstSrc *result = ir_build_err_set_cast(irb, scope, node, arg0_value, arg1_value);
return ir_lval_wrap(irb, scope, result, lval, result_loc);
}
- case BuiltinFnIdFromBytes:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
- IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
- if (arg1_value == irb->codegen->invalid_inst_src)
- return arg1_value;
-
- IrInstSrc *result = ir_build_from_bytes(irb, scope, node, arg0_value, arg1_value, result_loc);
- return ir_lval_wrap(irb, scope, result, lval, result_loc);
- }
- case BuiltinFnIdToBytes:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- IrInstSrc *result = ir_build_to_bytes(irb, scope, node, arg0_value, result_loc);
- return ir_lval_wrap(irb, scope, result, lval, result_loc);
- }
case BuiltinFnIdIntToFloat:
{
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
@@ -25489,171 +25405,6 @@ static IrInstGen *ir_analyze_instruction_err_set_cast(IrAnalyze *ira, IrInstSrcE
return ir_analyze_err_set_cast(ira, &instruction->base.base, target, dest_type);
}
-static IrInstGen *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstSrcFromBytes *instruction) {
- Error err;
-
- ZigType *dest_child_type = ir_resolve_type(ira, instruction->dest_child_type->child);
- if (type_is_invalid(dest_child_type))
- return ira->codegen->invalid_inst_gen;
-
- IrInstGen *target = instruction->target->child;
- if (type_is_invalid(target->value->type))
- return ira->codegen->invalid_inst_gen;
-
- bool src_ptr_const;
- bool src_ptr_volatile;
- uint32_t src_ptr_align;
- if (target->value->type->id == ZigTypeIdPointer) {
- src_ptr_const = target->value->type->data.pointer.is_const;
- src_ptr_volatile = target->value->type->data.pointer.is_volatile;
-
- if ((err = resolve_ptr_align(ira, target->value->type, &src_ptr_align)))
- return ira->codegen->invalid_inst_gen;
- } else if (is_slice(target->value->type)) {
- ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry;
- src_ptr_const = src_ptr_type->data.pointer.is_const;
- src_ptr_volatile = src_ptr_type->data.pointer.is_volatile;
-
- if ((err = resolve_ptr_align(ira, src_ptr_type, &src_ptr_align)))
- return ira->codegen->invalid_inst_gen;
- } else {
- src_ptr_const = true;
- src_ptr_volatile = false;
-
- if ((err = type_resolve(ira->codegen, target->value->type, ResolveStatusAlignmentKnown)))
- return ira->codegen->invalid_inst_gen;
-
- src_ptr_align = get_abi_alignment(ira->codegen, target->value->type);
- }
-
- if (src_ptr_align != 0) {
- if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusAlignmentKnown)))
- return ira->codegen->invalid_inst_gen;
- }
-
- ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, dest_child_type,
- src_ptr_const, src_ptr_volatile, PtrLenUnknown,
- src_ptr_align, 0, 0, false);
- ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
-
- ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
- src_ptr_const, src_ptr_volatile, PtrLenUnknown,
- src_ptr_align, 0, 0, false);
- ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
-
- IrInstGen *casted_value = ir_implicit_cast2(ira, &instruction->target->base, target, u8_slice);
- if (type_is_invalid(casted_value->value->type))
- return ira->codegen->invalid_inst_gen;
-
- bool have_known_len = false;
- uint64_t known_len;
-
- if (instr_is_comptime(casted_value)) {
- ZigValue *val = ir_resolve_const(ira, casted_value, UndefBad);
- if (!val)
- return ira->codegen->invalid_inst_gen;
-
- ZigValue *len_val = val->data.x_struct.fields[slice_len_index];
- if (value_is_comptime(len_val)) {
- known_len = bigint_as_u64(&len_val->data.x_bigint);
- have_known_len = true;
- }
- }
-
- IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc,
- dest_slice_type, nullptr, true, true);
- if (result_loc != nullptr && (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable)) {
- return result_loc;
- }
-
- if (target->value->type->id == ZigTypeIdPointer &&
- target->value->type->data.pointer.ptr_len == PtrLenSingle &&
- target->value->type->data.pointer.child_type->id == ZigTypeIdArray)
- {
- known_len = target->value->type->data.pointer.child_type->data.array.len;
- have_known_len = true;
- } else if (casted_value->value->data.rh_slice.id == RuntimeHintSliceIdLen) {
- known_len = casted_value->value->data.rh_slice.len;
- have_known_len = true;
- }
-
- if (have_known_len) {
- if ((err = type_resolve(ira->codegen, dest_child_type, ResolveStatusSizeKnown)))
- return ira->codegen->invalid_inst_gen;
- uint64_t child_type_size = type_size(ira->codegen, dest_child_type);
- uint64_t remainder = known_len % child_type_size;
- if (remainder != 0) {
- ErrorMsg *msg = ir_add_error(ira, &instruction->base.base,
- buf_sprintf("unable to convert [%" ZIG_PRI_u64 "]u8 to %s: size mismatch",
- known_len, buf_ptr(&dest_slice_type->name)));
- add_error_note(ira->codegen, msg, instruction->dest_child_type->base.source_node,
- buf_sprintf("%s has size %" ZIG_PRI_u64 "; remaining bytes: %" ZIG_PRI_u64,
- buf_ptr(&dest_child_type->name), child_type_size, remainder));
- return ira->codegen->invalid_inst_gen;
- }
- }
-
- return ir_build_resize_slice(ira, &instruction->base.base, casted_value, dest_slice_type, result_loc);
-}
-
-static IrInstGen *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstSrcToBytes *instruction) {
- Error err;
-
- IrInstGen *target = instruction->target->child;
- if (type_is_invalid(target->value->type))
- return ira->codegen->invalid_inst_gen;
-
- if (!is_slice(target->value->type)) {
- ir_add_error(ira, &instruction->target->base,
- buf_sprintf("expected slice, found '%s'", buf_ptr(&target->value->type->name)));
- return ira->codegen->invalid_inst_gen;
- }
-
- ZigType *src_ptr_type = target->value->type->data.structure.fields[slice_ptr_index]->type_entry;
-
- uint32_t alignment;
- if ((err = resolve_ptr_align(ira, src_ptr_type, &alignment)))
- return ira->codegen->invalid_inst_gen;
-
- ZigType *dest_ptr_type = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
- src_ptr_type->data.pointer.is_const, src_ptr_type->data.pointer.is_volatile, PtrLenUnknown,
- alignment, 0, 0, false);
- ZigType *dest_slice_type = get_slice_type(ira->codegen, dest_ptr_type);
-
- if (instr_is_comptime(target)) {
- ZigValue *target_val = ir_resolve_const(ira, target, UndefBad);
- if (target_val == nullptr)
- return ira->codegen->invalid_inst_gen;
-
- IrInstGen *result = ir_const(ira, &instruction->base.base, dest_slice_type);
- result->value->data.x_struct.fields = alloc_const_vals_ptrs(ira->codegen, 2);
-
- ZigValue *ptr_val = result->value->data.x_struct.fields[slice_ptr_index];
- ZigValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index];
- copy_const_val(ira->codegen, ptr_val, target_ptr_val);
- ptr_val->type = dest_ptr_type;
-
- ZigValue *len_val = result->value->data.x_struct.fields[slice_len_index];
- len_val->special = ConstValSpecialStatic;
- len_val->type = ira->codegen->builtin_types.entry_usize;
- ZigValue *target_len_val = target_val->data.x_struct.fields[slice_len_index];
- ZigType *elem_type = src_ptr_type->data.pointer.child_type;
- BigInt elem_size_bigint;
- bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type));
- bigint_mul(&len_val->data.x_bigint, &target_len_val->data.x_bigint, &elem_size_bigint);
-
- return result;
- }
-
- IrInstGen *result_loc = ir_resolve_result(ira, &instruction->base.base, instruction->result_loc,
- dest_slice_type, nullptr, true, true);
- if (type_is_invalid(result_loc->value->type) || result_loc->value->type->id == ZigTypeIdUnreachable) {
- return result_loc;
- }
-
- return ir_build_resize_slice(ira, &instruction->base.base, target, dest_slice_type, result_loc);
-}
-
static Error resolve_ptr_align(IrAnalyze *ira, ZigType *ty, uint32_t *result_align) {
Error err;
@@ -29783,10 +29534,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
return ir_analyze_instruction_float_cast(ira, (IrInstSrcFloatCast *)instruction);
case IrInstSrcIdErrSetCast:
return ir_analyze_instruction_err_set_cast(ira, (IrInstSrcErrSetCast *)instruction);
- case IrInstSrcIdFromBytes:
- return ir_analyze_instruction_from_bytes(ira, (IrInstSrcFromBytes *)instruction);
- case IrInstSrcIdToBytes:
- return ir_analyze_instruction_to_bytes(ira, (IrInstSrcToBytes *)instruction);
case IrInstSrcIdIntToFloat:
return ir_analyze_instruction_int_to_float(ira, (IrInstSrcIntToFloat *)instruction);
case IrInstSrcIdFloatToInt:
@@ -30113,7 +29860,6 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {
case IrInstGenIdCmpxchg:
case IrInstGenIdAssertZero:
case IrInstGenIdAssertNonNull:
- case IrInstGenIdResizeSlice:
case IrInstGenIdPtrOfArrayToSlice:
case IrInstGenIdSlice:
case IrInstGenIdOptionalWrap:
@@ -30339,8 +30085,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
case IrInstSrcIdIntToFloat:
case IrInstSrcIdFloatToInt:
case IrInstSrcIdBoolToInt:
- case IrInstSrcIdFromBytes:
- case IrInstSrcIdToBytes:
case IrInstSrcIdEnumToInt:
case IrInstSrcIdHasDecl:
case IrInstSrcIdAlloca:
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index c0a127dd16..6d04db6168 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -307,10 +307,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcAddImplicitReturnType";
case IrInstSrcIdErrSetCast:
return "SrcErrSetCast";
- case IrInstSrcIdToBytes:
- return "SrcToBytes";
- case IrInstSrcIdFromBytes:
- return "SrcFromBytes";
case IrInstSrcIdCheckRuntimeScope:
return "SrcCheckRuntimeScope";
case IrInstSrcIdHasDecl:
@@ -383,8 +379,6 @@ const char* ir_inst_gen_type_str(IrInstGenId id) {
return "GenReturn";
case IrInstGenIdCast:
return "GenCast";
- case IrInstGenIdResizeSlice:
- return "GenResizeSlice";
case IrInstGenIdUnreachable:
return "GenUnreachable";
case IrInstGenIdAsm:
@@ -1644,20 +1638,6 @@ static void ir_print_err_set_cast(IrPrintSrc *irp, IrInstSrcErrSetCast *instruct
fprintf(irp->f, ")");
}
-static void ir_print_from_bytes(IrPrintSrc *irp, IrInstSrcFromBytes *instruction) {
- fprintf(irp->f, "@bytesToSlice(");
- ir_print_other_inst_src(irp, instruction->dest_child_type);
- fprintf(irp->f, ", ");
- ir_print_other_inst_src(irp, instruction->target);
- fprintf(irp->f, ")");
-}
-
-static void ir_print_to_bytes(IrPrintSrc *irp, IrInstSrcToBytes *instruction) {
- fprintf(irp->f, "@sliceToBytes(");
- ir_print_other_inst_src(irp, instruction->target);
- fprintf(irp->f, ")");
-}
-
static void ir_print_int_to_float(IrPrintSrc *irp, IrInstSrcIntToFloat *instruction) {
fprintf(irp->f, "@intToFloat(");
ir_print_other_inst_src(irp, instruction->dest_type);
@@ -2142,13 +2122,6 @@ static void ir_print_assert_non_null(IrPrintGen *irp, IrInstGenAssertNonNull *in
fprintf(irp->f, ")");
}
-static void ir_print_resize_slice(IrPrintGen *irp, IrInstGenResizeSlice *instruction) {
- fprintf(irp->f, "@resizeSlice(");
- ir_print_other_inst_gen(irp, instruction->operand);
- fprintf(irp->f, ")result=");
- ir_print_other_inst_gen(irp, instruction->result_loc);
-}
-
static void ir_print_alloca_src(IrPrintSrc *irp, IrInstSrcAlloca *instruction) {
fprintf(irp->f, "Alloca(align=");
ir_print_other_inst_src(irp, instruction->align);
@@ -2793,12 +2766,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdErrSetCast:
ir_print_err_set_cast(irp, (IrInstSrcErrSetCast *)instruction);
break;
- case IrInstSrcIdFromBytes:
- ir_print_from_bytes(irp, (IrInstSrcFromBytes *)instruction);
- break;
- case IrInstSrcIdToBytes:
- ir_print_to_bytes(irp, (IrInstSrcToBytes *)instruction);
- break;
case IrInstSrcIdIntToFloat:
ir_print_int_to_float(irp, (IrInstSrcIntToFloat *)instruction);
break;
@@ -3273,9 +3240,6 @@ static void ir_print_inst_gen(IrPrintGen *irp, IrInstGen *instruction, bool trai
case IrInstGenIdAssertNonNull:
ir_print_assert_non_null(irp, (IrInstGenAssertNonNull *)instruction);
break;
- case IrInstGenIdResizeSlice:
- ir_print_resize_slice(irp, (IrInstGenResizeSlice *)instruction);
- break;
case IrInstGenIdAlloca:
ir_print_alloca_gen(irp, (IrInstGenAlloca *)instruction);
break;
--
cgit v1.2.3
From 3458fb891d8c7072a9bff6a32db9f3105ab72aa4 Mon Sep 17 00:00:00 2001
From: Vexu
Date: Mon, 24 Feb 2020 23:21:11 +0200
Subject: remove `@typeId`, `@memberCount`, `@memberName` and `@memberType`
from the compiler
---
doc/langref.html.in | 84 ++--------------
src/all_types.hpp | 34 -------
src/codegen.cpp | 4 -
src/ir.cpp | 282 ----------------------------------------------------
src/ir_print.cpp | 48 ---------
5 files changed, 8 insertions(+), 444 deletions(-)
(limited to 'src/ir_print.cpp')
diff --git a/doc/langref.html.in b/doc/langref.html.in
index 4ac9cf47e0..d186e68451 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -2810,14 +2810,10 @@ test "@TagType" {
assert(@TagType(Small) == u2);
}
-// @memberCount tells how many fields an enum has:
-test "@memberCount" {
- assert(@memberCount(Small) == 4);
-}
-
-// @memberName tells the name of a field in an enum:
-test "@memberName" {
- assert(mem.eql(u8, @memberName(Small, 1), "Two"));
+// @typeInfo tells us the field count and the fields name:
+test "@typeInfo" {
+ assert(@typeInfo(Small).Enum.fields.len == 4);
+ assert(mem.eql(u8, @typeInfo(Small).Enum.fields[0].name, "Two"));
}
// @tagName gives a []const u8 representation of an enum value:
@@ -2825,7 +2821,7 @@ test "@tagName" {
assert(mem.eql(u8, @tagName(Small.Three), "Three"));
}
{#code_end#}
- {#see_also|@memberName|@memberCount|@tagName|@sizeOf#}
+ {#see_also|@typeInfo|@tagName|@sizeOf#}
{#header_open|extern enum#}
@@ -6816,7 +6812,7 @@ async fn func(y: *i32) void {
Asserts that {#syntax#}@sizeOf(@TypeOf(value)) == @sizeOf(DestType){#endsyntax#}.
- Asserts that {#syntax#}@typeId(DestType) != @import("builtin").TypeId.Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.
+ Asserts that {#syntax#}@typeInfo(DestType) != .Pointer{#endsyntax#}. Use {#syntax#}@ptrCast{#endsyntax#} or {#syntax#}@intToPtr{#endsyntax#} if you need this.
Can be used for these things for example:
@@ -7269,7 +7265,7 @@ test "main" {
Floored division. Rounds toward negative infinity. For unsigned integers it is
the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
- {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
+ {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
- {#syntax#}@divFloor(-5, 3) == -2{#endsyntax#}
@@ -7283,7 +7279,7 @@ test "main" {
Truncated division. Rounds toward zero. For unsigned integers it is
the same as {#syntax#}numerator / denominator{#endsyntax#}. Caller guarantees {#syntax#}denominator != 0{#endsyntax#} and
- {#syntax#}!(@typeId(T) == builtin.TypeId.Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
+ {#syntax#}!(@typeInfo(T) == .Int and T.is_signed and numerator == std.math.minInt(T) and denominator == -1){#endsyntax#}.
- {#syntax#}@divTrunc(-5, 3) == -1{#endsyntax#}
@@ -7679,33 +7675,6 @@ test "@hasDecl" {
{#header_close#}
- {#header_open|@memberCount#}
- {#syntax#}@memberCount(comptime T: type) comptime_int{#endsyntax#}
-
- This function returns the number of members in a struct, enum, or union type.
-
-
- The result is a compile time constant.
-
-
- It does not include functions, variables, or constants.
-
- {#header_close#}
- {#header_open|@memberName#}
- {#syntax#}@memberName(comptime T: type, comptime index: usize) [N]u8{#endsyntax#}
- Returns the field name of a struct, union, or enum.
-
- The result is a compile time constant.
-
-
- It does not include functions, variables, or constants.
-
- {#header_close#}
- {#header_open|@memberType#}
- {#syntax#}@memberType(comptime T: type, comptime index: usize) type{#endsyntax#}
- Returns the field type of a struct or union.
- {#header_close#}
-
{#header_open|@memcpy#}
{#syntax#}@memcpy(noalias dest: [*]u8, noalias source: [*]const u8, byte_count: usize){#endsyntax#}
@@ -8401,43 +8370,6 @@ test "integer truncation" {
{#link|struct#}
{#header_close#}
-
- {#header_open|@typeId#}
- {#syntax#}@typeId(comptime T: type) @import("builtin").TypeId{#endsyntax#}
-
- Returns which kind of type something is. Possible values:
-
- {#code_begin|syntax#}
-pub const TypeId = enum {
- Type,
- Void,
- Bool,
- NoReturn,
- Int,
- Float,
- Pointer,
- Array,
- Struct,
- ComptimeFloat,
- ComptimeInt,
- Undefined,
- Null,
- Optional,
- ErrorUnion,
- ErrorSet,
- Enum,
- Union,
- Fn,
- BoundFn,
- Opaque,
- Frame,
- AnyFrame,
- Vector,
- EnumLiteral,
-};
- {#code_end#}
- {#header_close#}
-
{#header_open|@typeInfo#}
{#syntax#}@typeInfo(comptime T: type) @import("std").builtin.TypeInfo{#endsyntax#}
diff --git a/src/all_types.hpp b/src/all_types.hpp
index 117a0004f0..9f20d176bf 100644
--- a/src/all_types.hpp
+++ b/src/all_types.hpp
@@ -1695,9 +1695,6 @@ enum BuiltinFnId {
BuiltinFnIdMemset,
BuiltinFnIdSizeof,
BuiltinFnIdAlignOf,
- BuiltinFnIdMemberCount,
- BuiltinFnIdMemberType,
- BuiltinFnIdMemberName,
BuiltinFnIdField,
BuiltinFnIdTypeInfo,
BuiltinFnIdType,
@@ -1777,7 +1774,6 @@ enum BuiltinFnId {
BuiltinFnIdBitOffsetOf,
BuiltinFnIdNewStackCall,
BuiltinFnIdAsyncCall,
- BuiltinFnIdTypeId,
BuiltinFnIdShlExact,
BuiltinFnIdShrExact,
BuiltinFnIdSetEvalBranchQuota,
@@ -2638,9 +2634,6 @@ enum IrInstSrcId {
IrInstSrcIdMemset,
IrInstSrcIdMemcpy,
IrInstSrcIdSlice,
- IrInstSrcIdMemberCount,
- IrInstSrcIdMemberType,
- IrInstSrcIdMemberName,
IrInstSrcIdBreakpoint,
IrInstSrcIdReturnAddress,
IrInstSrcIdFrameAddress,
@@ -2677,7 +2670,6 @@ enum IrInstSrcId {
IrInstSrcIdTypeInfo,
IrInstSrcIdType,
IrInstSrcIdHasField,
- IrInstSrcIdTypeId,
IrInstSrcIdSetEvalBranchQuota,
IrInstSrcIdPtrType,
IrInstSrcIdAlignCast,
@@ -3715,26 +3707,6 @@ struct IrInstGenSlice {
bool safety_check_on;
};
-struct IrInstSrcMemberCount {
- IrInstSrc base;
-
- IrInstSrc *container;
-};
-
-struct IrInstSrcMemberType {
- IrInstSrc base;
-
- IrInstSrc *container_type;
- IrInstSrc *member_index;
-};
-
-struct IrInstSrcMemberName {
- IrInstSrc base;
-
- IrInstSrc *container_type;
- IrInstSrc *member_index;
-};
-
struct IrInstSrcBreakpoint {
IrInstSrc base;
};
@@ -4142,12 +4114,6 @@ struct IrInstSrcHasField {
IrInstSrc *field_name;
};
-struct IrInstSrcTypeId {
- IrInstSrc base;
-
- IrInstSrc *type_value;
-};
-
struct IrInstSrcSetEvalBranchQuota {
IrInstSrc base;
diff --git a/src/codegen.cpp b/src/codegen.cpp
index 12293cd9b3..c6ee153573 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -8152,9 +8152,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdMemset, "memset", 3);
create_builtin_fn(g, BuiltinFnIdSizeof, "sizeOf", 1);
create_builtin_fn(g, BuiltinFnIdAlignOf, "alignOf", 1);
- create_builtin_fn(g, BuiltinFnIdMemberCount, "memberCount", 1);
- create_builtin_fn(g, BuiltinFnIdMemberType, "memberType", 2);
- create_builtin_fn(g, BuiltinFnIdMemberName, "memberName", 2);
create_builtin_fn(g, BuiltinFnIdField, "field", 2);
create_builtin_fn(g, BuiltinFnIdTypeInfo, "typeInfo", 1);
create_builtin_fn(g, BuiltinFnIdType, "Type", 1);
@@ -8231,7 +8228,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdMulAdd, "mulAdd", 4);
create_builtin_fn(g, BuiltinFnIdNewStackCall, "newStackCall", SIZE_MAX);
create_builtin_fn(g, BuiltinFnIdAsyncCall, "asyncCall", SIZE_MAX);
- create_builtin_fn(g, BuiltinFnIdTypeId, "typeId", 1);
create_builtin_fn(g, BuiltinFnIdShlExact, "shlExact", 2);
create_builtin_fn(g, BuiltinFnIdShrExact, "shrExact", 2);
create_builtin_fn(g, BuiltinFnIdSetEvalBranchQuota, "setEvalBranchQuota", 1);
diff --git a/src/ir.cpp b/src/ir.cpp
index 80fef04496..6646d0ed55 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -405,12 +405,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdSlice:
return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstSrcIdMemberCount:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstSrcIdMemberType:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstSrcIdMemberName:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdBreakpoint:
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdReturnAddress:
@@ -477,8 +471,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdHasField:
return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstSrcIdTypeId:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdSetEvalBranchQuota:
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdAlignCast:
@@ -1325,18 +1317,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcSlice *) {
return IrInstSrcIdSlice;
}
-static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberCount *) {
- return IrInstSrcIdMemberCount;
-}
-
-static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberType *) {
- return IrInstSrcIdMemberType;
-}
-
-static constexpr IrInstSrcId ir_inst_id(IrInstSrcMemberName *) {
- return IrInstSrcIdMemberName;
-}
-
static constexpr IrInstSrcId ir_inst_id(IrInstSrcBreakpoint *) {
return IrInstSrcIdBreakpoint;
}
@@ -1481,10 +1461,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcHasField *) {
return IrInstSrcIdHasField;
}
-static constexpr IrInstSrcId ir_inst_id(IrInstSrcTypeId *) {
- return IrInstSrcIdTypeId;
-}
-
static constexpr IrInstSrcId ir_inst_id(IrInstSrcSetEvalBranchQuota *) {
return IrInstSrcIdSetEvalBranchQuota;
}
@@ -3749,41 +3725,6 @@ static IrInstGen *ir_build_slice_gen(IrAnalyze *ira, IrInst *source_instruction,
return &instruction->base;
}
-static IrInstSrc *ir_build_member_count(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *container) {
- IrInstSrcMemberCount *instruction = ir_build_instruction(irb, scope, source_node);
- instruction->container = container;
-
- ir_ref_instruction(container, irb->current_basic_block);
-
- return &instruction->base;
-}
-
-static IrInstSrc *ir_build_member_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
- IrInstSrc *container_type, IrInstSrc *member_index)
-{
- IrInstSrcMemberType *instruction = ir_build_instruction(irb, scope, source_node);
- instruction->container_type = container_type;
- instruction->member_index = member_index;
-
- ir_ref_instruction(container_type, irb->current_basic_block);
- ir_ref_instruction(member_index, irb->current_basic_block);
-
- return &instruction->base;
-}
-
-static IrInstSrc *ir_build_member_name(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
- IrInstSrc *container_type, IrInstSrc *member_index)
-{
- IrInstSrcMemberName *instruction = ir_build_instruction(irb, scope, source_node);
- instruction->container_type = container_type;
- instruction->member_index = member_index;
-
- ir_ref_instruction(container_type, irb->current_basic_block);
- ir_ref_instruction(member_index, irb->current_basic_block);
-
- return &instruction->base;
-}
-
static IrInstSrc *ir_build_breakpoint(IrBuilderSrc *irb, Scope *scope, AstNode *source_node) {
IrInstSrcBreakpoint *instruction = ir_build_instruction(irb, scope, source_node);
return &instruction->base;
@@ -4458,15 +4399,6 @@ static IrInstSrc *ir_build_type(IrBuilderSrc *irb, Scope *scope, AstNode *source
return &instruction->base;
}
-static IrInstSrc *ir_build_type_id(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *type_value) {
- IrInstSrcTypeId *instruction = ir_build_instruction(irb, scope, source_node);
- instruction->type_value = type_value;
-
- ir_ref_instruction(type_value, irb->current_basic_block);
-
- return &instruction->base;
-}
-
static IrInstSrc *ir_build_set_eval_branch_quota(IrBuilderSrc *irb, Scope *scope, AstNode *source_node,
IrInstSrc *new_quota)
{
@@ -6710,48 +6642,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
IrInstSrc *ir_memset = ir_build_memset_src(irb, scope, node, arg0_value, arg1_value, arg2_value);
return ir_lval_wrap(irb, scope, ir_memset, lval, result_loc);
}
- case BuiltinFnIdMemberCount:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- IrInstSrc *member_count = ir_build_member_count(irb, scope, node, arg0_value);
- return ir_lval_wrap(irb, scope, member_count, lval, result_loc);
- }
- case BuiltinFnIdMemberType:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
- IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
- if (arg1_value == irb->codegen->invalid_inst_src)
- return arg1_value;
-
-
- IrInstSrc *member_type = ir_build_member_type(irb, scope, node, arg0_value, arg1_value);
- return ir_lval_wrap(irb, scope, member_type, lval, result_loc);
- }
- case BuiltinFnIdMemberName:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
- IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
- if (arg1_value == irb->codegen->invalid_inst_src)
- return arg1_value;
-
-
- IrInstSrc *member_name = ir_build_member_name(irb, scope, node, arg0_value, arg1_value);
- return ir_lval_wrap(irb, scope, member_name, lval, result_loc);
- }
case BuiltinFnIdField:
{
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
@@ -7109,16 +6999,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
}
case BuiltinFnIdAsyncCall:
return ir_gen_async_call(irb, scope, nullptr, node, lval, result_loc);
- case BuiltinFnIdTypeId:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- IrInstSrc *type_id = ir_build_type_id(irb, scope, node, arg0_value);
- return ir_lval_wrap(irb, scope, type_id, lval, result_loc);
- }
case BuiltinFnIdShlExact:
{
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
@@ -24795,19 +24675,6 @@ static IrInstGen *ir_analyze_instruction_type(IrAnalyze *ira, IrInstSrcType *ins
return ir_const_type(ira, &instruction->base.base, type);
}
-static IrInstGen *ir_analyze_instruction_type_id(IrAnalyze *ira, IrInstSrcTypeId *instruction) {
- IrInstGen *type_value = instruction->type_value->child;
- ZigType *type_entry = ir_resolve_type(ira, type_value);
- if (type_is_invalid(type_entry))
- return ira->codegen->invalid_inst_gen;
-
- ZigType *result_type = get_builtin_type(ira->codegen, "TypeId");
-
- IrInstGen *result = ir_const(ira, &instruction->base.base, result_type);
- bigint_init_unsigned(&result->value->data.x_enum_tag, type_id_index(type_entry));
- return result;
-}
-
static IrInstGen *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
IrInstSrcSetEvalBranchQuota *instruction)
{
@@ -26445,143 +26312,6 @@ static IrInstGen *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstSrcSlice *i
ptr_ptr, casted_start, end, instruction->safety_check_on, result_loc);
}
-static IrInstGen *ir_analyze_instruction_member_count(IrAnalyze *ira, IrInstSrcMemberCount *instruction) {
- Error err;
- IrInstGen *container = instruction->container->child;
- if (type_is_invalid(container->value->type))
- return ira->codegen->invalid_inst_gen;
- ZigType *container_type = ir_resolve_type(ira, container);
-
- if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown)))
- return ira->codegen->invalid_inst_gen;
-
- uint64_t result;
- if (type_is_invalid(container_type)) {
- return ira->codegen->invalid_inst_gen;
- } else if (container_type->id == ZigTypeIdEnum) {
- result = container_type->data.enumeration.src_field_count;
- } else if (container_type->id == ZigTypeIdStruct) {
- result = container_type->data.structure.src_field_count;
- } else if (container_type->id == ZigTypeIdUnion) {
- result = container_type->data.unionation.src_field_count;
- } else if (container_type->id == ZigTypeIdErrorSet) {
- if (!resolve_inferred_error_set(ira->codegen, container_type, instruction->base.base.source_node)) {
- return ira->codegen->invalid_inst_gen;
- }
- if (type_is_global_error_set(container_type)) {
- ir_add_error(ira, &instruction->base.base, buf_sprintf("global error set member count not available at comptime"));
- return ira->codegen->invalid_inst_gen;
- }
- result = container_type->data.error_set.err_count;
- } else {
- ir_add_error(ira, &instruction->base.base, buf_sprintf("no value count available for type '%s'", buf_ptr(&container_type->name)));
- return ira->codegen->invalid_inst_gen;
- }
-
- return ir_const_unsigned(ira, &instruction->base.base, result);
-}
-
-static IrInstGen *ir_analyze_instruction_member_type(IrAnalyze *ira, IrInstSrcMemberType *instruction) {
- Error err;
- IrInstGen *container_type_value = instruction->container_type->child;
- ZigType *container_type = ir_resolve_type(ira, container_type_value);
- if (type_is_invalid(container_type))
- return ira->codegen->invalid_inst_gen;
-
- if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown)))
- return ira->codegen->invalid_inst_gen;
-
-
- uint64_t member_index;
- IrInstGen *index_value = instruction->member_index->child;
- if (!ir_resolve_usize(ira, index_value, &member_index))
- return ira->codegen->invalid_inst_gen;
-
- if (container_type->id == ZigTypeIdStruct) {
- if (member_index >= container_type->data.structure.src_field_count) {
- ir_add_error(ira, &index_value->base,
- buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members",
- member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count));
- return ira->codegen->invalid_inst_gen;
- }
- TypeStructField *field = container_type->data.structure.fields[member_index];
-
- return ir_const_type(ira, &instruction->base.base, field->type_entry);
- } else if (container_type->id == ZigTypeIdUnion) {
- if (member_index >= container_type->data.unionation.src_field_count) {
- ir_add_error(ira, &index_value->base,
- buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members",
- member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count));
- return ira->codegen->invalid_inst_gen;
- }
- TypeUnionField *field = &container_type->data.unionation.fields[member_index];
-
- return ir_const_type(ira, &instruction->base.base, field->type_entry);
- } else {
- ir_add_error(ira, &container_type_value->base,
- buf_sprintf("type '%s' does not support @memberType", buf_ptr(&container_type->name)));
- return ira->codegen->invalid_inst_gen;
- }
-}
-
-static IrInstGen *ir_analyze_instruction_member_name(IrAnalyze *ira, IrInstSrcMemberName *instruction) {
- Error err;
- IrInstGen *container_type_value = instruction->container_type->child;
- ZigType *container_type = ir_resolve_type(ira, container_type_value);
- if (type_is_invalid(container_type))
- return ira->codegen->invalid_inst_gen;
-
- if ((err = type_resolve(ira->codegen, container_type, ResolveStatusSizeKnown)))
- return ira->codegen->invalid_inst_gen;
-
- uint64_t member_index;
- IrInstGen *index_value = instruction->member_index->child;
- if (!ir_resolve_usize(ira, index_value, &member_index))
- return ira->codegen->invalid_inst_gen;
-
- if (container_type->id == ZigTypeIdStruct) {
- if (member_index >= container_type->data.structure.src_field_count) {
- ir_add_error(ira, &index_value->base,
- buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members",
- member_index, buf_ptr(&container_type->name), container_type->data.structure.src_field_count));
- return ira->codegen->invalid_inst_gen;
- }
- TypeStructField *field = container_type->data.structure.fields[member_index];
-
- IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr);
- init_const_str_lit(ira->codegen, result->value, field->name);
- return result;
- } else if (container_type->id == ZigTypeIdEnum) {
- if (member_index >= container_type->data.enumeration.src_field_count) {
- ir_add_error(ira, &index_value->base,
- buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members",
- member_index, buf_ptr(&container_type->name), container_type->data.enumeration.src_field_count));
- return ira->codegen->invalid_inst_gen;
- }
- TypeEnumField *field = &container_type->data.enumeration.fields[member_index];
-
- IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr);
- init_const_str_lit(ira->codegen, result->value, field->name);
- return result;
- } else if (container_type->id == ZigTypeIdUnion) {
- if (member_index >= container_type->data.unionation.src_field_count) {
- ir_add_error(ira, &index_value->base,
- buf_sprintf("member index %" ZIG_PRI_u64 " out of bounds; '%s' has %" PRIu32 " members",
- member_index, buf_ptr(&container_type->name), container_type->data.unionation.src_field_count));
- return ira->codegen->invalid_inst_gen;
- }
- TypeUnionField *field = &container_type->data.unionation.fields[member_index];
-
- IrInstGen *result = ir_const(ira, &instruction->base.base, nullptr);
- init_const_str_lit(ira->codegen, result->value, field->name);
- return result;
- } else {
- ir_add_error(ira, &container_type_value->base,
- buf_sprintf("type '%s' does not support @memberName", buf_ptr(&container_type->name)));
- return ira->codegen->invalid_inst_gen;
- }
-}
-
static IrInstGen *ir_analyze_instruction_has_field(IrAnalyze *ira, IrInstSrcHasField *instruction) {
Error err;
ZigType *container_type = ir_resolve_type(ira, instruction->container_type->child);
@@ -29556,12 +29286,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
return ir_analyze_instruction_memcpy(ira, (IrInstSrcMemcpy *)instruction);
case IrInstSrcIdSlice:
return ir_analyze_instruction_slice(ira, (IrInstSrcSlice *)instruction);
- case IrInstSrcIdMemberCount:
- return ir_analyze_instruction_member_count(ira, (IrInstSrcMemberCount *)instruction);
- case IrInstSrcIdMemberType:
- return ir_analyze_instruction_member_type(ira, (IrInstSrcMemberType *)instruction);
- case IrInstSrcIdMemberName:
- return ir_analyze_instruction_member_name(ira, (IrInstSrcMemberName *)instruction);
case IrInstSrcIdBreakpoint:
return ir_analyze_instruction_breakpoint(ira, (IrInstSrcBreakpoint *)instruction);
case IrInstSrcIdReturnAddress:
@@ -29616,8 +29340,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
return ir_analyze_instruction_type(ira, (IrInstSrcType *)instruction);
case IrInstSrcIdHasField:
return ir_analyze_instruction_has_field(ira, (IrInstSrcHasField *) instruction);
- case IrInstSrcIdTypeId:
- return ir_analyze_instruction_type_id(ira, (IrInstSrcTypeId *)instruction);
case IrInstSrcIdSetEvalBranchQuota:
return ir_analyze_instruction_set_eval_branch_quota(ira, (IrInstSrcSetEvalBranchQuota *)instruction);
case IrInstSrcIdPtrType:
@@ -30038,9 +29760,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
case IrInstSrcIdSplat:
case IrInstSrcIdBoolNot:
case IrInstSrcIdSlice:
- case IrInstSrcIdMemberCount:
- case IrInstSrcIdMemberType:
- case IrInstSrcIdMemberName:
case IrInstSrcIdAlignOf:
case IrInstSrcIdReturnAddress:
case IrInstSrcIdFrameAddress:
@@ -30067,7 +29786,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
case IrInstSrcIdTypeInfo:
case IrInstSrcIdType:
case IrInstSrcIdHasField:
- case IrInstSrcIdTypeId:
case IrInstSrcIdAlignCast:
case IrInstSrcIdImplicitCast:
case IrInstSrcIdResolveResult:
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 6d04db6168..4f87ff832d 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -191,12 +191,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcMemcpy";
case IrInstSrcIdSlice:
return "SrcSlice";
- case IrInstSrcIdMemberCount:
- return "SrcMemberCount";
- case IrInstSrcIdMemberType:
- return "SrcMemberType";
- case IrInstSrcIdMemberName:
- return "SrcMemberName";
case IrInstSrcIdBreakpoint:
return "SrcBreakpoint";
case IrInstSrcIdReturnAddress:
@@ -269,8 +263,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcType";
case IrInstSrcIdHasField:
return "SrcHasField";
- case IrInstSrcIdTypeId:
- return "SrcTypeId";
case IrInstSrcIdSetEvalBranchQuota:
return "SrcSetEvalBranchQuota";
case IrInstSrcIdPtrType:
@@ -1784,28 +1776,6 @@ static void ir_print_slice_gen(IrPrintGen *irp, IrInstGenSlice *instruction) {
ir_print_other_inst_gen(irp, instruction->result_loc);
}
-static void ir_print_member_count(IrPrintSrc *irp, IrInstSrcMemberCount *instruction) {
- fprintf(irp->f, "@memberCount(");
- ir_print_other_inst_src(irp, instruction->container);
- fprintf(irp->f, ")");
-}
-
-static void ir_print_member_type(IrPrintSrc *irp, IrInstSrcMemberType *instruction) {
- fprintf(irp->f, "@memberType(");
- ir_print_other_inst_src(irp, instruction->container_type);
- fprintf(irp->f, ", ");
- ir_print_other_inst_src(irp, instruction->member_index);
- fprintf(irp->f, ")");
-}
-
-static void ir_print_member_name(IrPrintSrc *irp, IrInstSrcMemberName *instruction) {
- fprintf(irp->f, "@memberName(");
- ir_print_other_inst_src(irp, instruction->container_type);
- fprintf(irp->f, ", ");
- ir_print_other_inst_src(irp, instruction->member_index);
- fprintf(irp->f, ")");
-}
-
static void ir_print_breakpoint(IrPrintSrc *irp, IrInstSrcBreakpoint *instruction) {
fprintf(irp->f, "@breakpoint()");
}
@@ -2279,12 +2249,6 @@ static void ir_print_has_field(IrPrintSrc *irp, IrInstSrcHasField *instruction)
fprintf(irp->f, ")");
}
-static void ir_print_type_id(IrPrintSrc *irp, IrInstSrcTypeId *instruction) {
- fprintf(irp->f, "@typeId(");
- ir_print_other_inst_src(irp, instruction->type_value);
- fprintf(irp->f, ")");
-}
-
static void ir_print_set_eval_branch_quota(IrPrintSrc *irp, IrInstSrcSetEvalBranchQuota *instruction) {
fprintf(irp->f, "@setEvalBranchQuota(");
ir_print_other_inst_src(irp, instruction->new_quota);
@@ -2799,15 +2763,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdSlice:
ir_print_slice_src(irp, (IrInstSrcSlice *)instruction);
break;
- case IrInstSrcIdMemberCount:
- ir_print_member_count(irp, (IrInstSrcMemberCount *)instruction);
- break;
- case IrInstSrcIdMemberType:
- ir_print_member_type(irp, (IrInstSrcMemberType *)instruction);
- break;
- case IrInstSrcIdMemberName:
- ir_print_member_name(irp, (IrInstSrcMemberName *)instruction);
- break;
case IrInstSrcIdBreakpoint:
ir_print_breakpoint(irp, (IrInstSrcBreakpoint *)instruction);
break;
@@ -2907,9 +2862,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdHasField:
ir_print_has_field(irp, (IrInstSrcHasField *)instruction);
break;
- case IrInstSrcIdTypeId:
- ir_print_type_id(irp, (IrInstSrcTypeId *)instruction);
- break;
case IrInstSrcIdSetEvalBranchQuota:
ir_print_set_eval_branch_quota(irp, (IrInstSrcSetEvalBranchQuota *)instruction);
break;
--
cgit v1.2.3
From d56115ef4189a7716d9371ef87df9124a61f5ab1 Mon Sep 17 00:00:00 2001
From: Vexu
Date: Mon, 24 Feb 2020 23:50:02 +0200
Subject: remove `@IntType` and `@ArgType` (mostly) from the compiler
---
doc/langref.html.in | 4 +--
src/all_types.hpp | 10 --------
src/codegen.cpp | 2 --
src/ir.cpp | 66 -------------------------------------------------
src/ir_print.cpp | 13 ----------
test/compile_errors.zig | 1 -
6 files changed, 2 insertions(+), 94 deletions(-)
(limited to 'src/ir_print.cpp')
diff --git a/doc/langref.html.in b/doc/langref.html.in
index 55b8d82476..e244d69e25 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -2810,10 +2810,10 @@ test "@TagType" {
assert(@TagType(Small) == u2);
}
-// @typeInfo tells us the field count and the fields name:
+// @typeInfo tells us the field count and the fields names:
test "@typeInfo" {
assert(@typeInfo(Small).Enum.fields.len == 4);
- assert(mem.eql(u8, @typeInfo(Small).Enum.fields[0].name, "Two"));
+ assert(mem.eql(u8, @typeInfo(Small).Enum.fields[1].name, "Two"));
}
// @tagName gives a []const u8 representation of an enum value:
diff --git a/src/all_types.hpp b/src/all_types.hpp
index 9f20d176bf..022a34038e 100644
--- a/src/all_types.hpp
+++ b/src/all_types.hpp
@@ -1754,7 +1754,6 @@ enum BuiltinFnId {
BuiltinFnIdIntToErr,
BuiltinFnIdEnumToInt,
BuiltinFnIdIntToEnum,
- BuiltinFnIdIntType,
BuiltinFnIdVectorType,
BuiltinFnIdShuffle,
BuiltinFnIdSplat,
@@ -1781,7 +1780,6 @@ enum BuiltinFnId {
BuiltinFnIdOpaqueType,
BuiltinFnIdThis,
BuiltinFnIdSetAlignStack,
- BuiltinFnIdArgType,
BuiltinFnIdExport,
BuiltinFnIdErrorReturnTrace,
BuiltinFnIdAtomicRmw,
@@ -2626,7 +2624,6 @@ enum IrInstSrcId {
IrInstSrcIdIntToFloat,
IrInstSrcIdFloatToInt,
IrInstSrcIdBoolToInt,
- IrInstSrcIdIntType,
IrInstSrcIdVectorType,
IrInstSrcIdShuffleVector,
IrInstSrcIdSplat,
@@ -3628,13 +3625,6 @@ struct IrInstSrcBoolToInt {
IrInstSrc *target;
};
-struct IrInstSrcIntType {
- IrInstSrc base;
-
- IrInstSrc *is_signed;
- IrInstSrc *bit_count;
-};
-
struct IrInstSrcVectorType {
IrInstSrc base;
diff --git a/src/codegen.cpp b/src/codegen.cpp
index c6ee153573..f9d2566da7 100644
--- a/src/codegen.cpp
+++ b/src/codegen.cpp
@@ -8189,7 +8189,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdIntToEnum, "intToEnum", 2);
create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1);
create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX);
- create_builtin_fn(g, BuiltinFnIdIntType, "IntType", 2); // TODO rename to Int
create_builtin_fn(g, BuiltinFnIdVectorType, "Vector", 2);
create_builtin_fn(g, BuiltinFnIdShuffle, "shuffle", 4);
create_builtin_fn(g, BuiltinFnIdSplat, "splat", 2);
@@ -8234,7 +8233,6 @@ static void define_builtin_fns(CodeGen *g) {
create_builtin_fn(g, BuiltinFnIdAlignCast, "alignCast", 2);
create_builtin_fn(g, BuiltinFnIdOpaqueType, "OpaqueType", 0);
create_builtin_fn(g, BuiltinFnIdSetAlignStack, "setAlignStack", 1);
- create_builtin_fn(g, BuiltinFnIdArgType, "ArgType", 2);
create_builtin_fn(g, BuiltinFnIdExport, "export", 2);
create_builtin_fn(g, BuiltinFnIdErrorReturnTrace, "errorReturnTrace", 0);
create_builtin_fn(g, BuiltinFnIdAtomicRmw, "atomicRmw", 5);
diff --git a/src/ir.cpp b/src/ir.cpp
index 6646d0ed55..80b8c93abd 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -389,8 +389,6 @@ static void destroy_instruction_src(IrInstSrc *inst) {
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdBoolToInt:
return heap::c_allocator.destroy(reinterpret_cast(inst));
- case IrInstSrcIdIntType:
- return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdVectorType:
return heap::c_allocator.destroy(reinterpret_cast(inst));
case IrInstSrcIdShuffleVector:
@@ -1285,10 +1283,6 @@ static constexpr IrInstSrcId ir_inst_id(IrInstSrcBoolToInt *) {
return IrInstSrcIdBoolToInt;
}
-static constexpr IrInstSrcId ir_inst_id(IrInstSrcIntType *) {
- return IrInstSrcIdIntType;
-}
-
static constexpr IrInstSrcId ir_inst_id(IrInstSrcVectorType *) {
return IrInstSrcIdVectorType;
}
@@ -3518,19 +3512,6 @@ static IrInstSrc *ir_build_bool_to_int(IrBuilderSrc *irb, Scope *scope, AstNode
return &instruction->base;
}
-static IrInstSrc *ir_build_int_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *is_signed,
- IrInstSrc *bit_count)
-{
- IrInstSrcIntType *instruction = ir_build_instruction(irb, scope, source_node);
- instruction->is_signed = is_signed;
- instruction->bit_count = bit_count;
-
- ir_ref_instruction(is_signed, irb->current_basic_block);
- ir_ref_instruction(bit_count, irb->current_basic_block);
-
- return &instruction->base;
-}
-
static IrInstSrc *ir_build_vector_type(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, IrInstSrc *len,
IrInstSrc *elem_type)
{
@@ -6530,21 +6511,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
IrInstSrc *result = ir_build_bool_to_int(irb, scope, node, arg0_value);
return ir_lval_wrap(irb, scope, result, lval, result_loc);
}
- case BuiltinFnIdIntType:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
- IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
- if (arg1_value == irb->codegen->invalid_inst_src)
- return arg1_value;
-
- IrInstSrc *int_type = ir_build_int_type(irb, scope, node, arg0_value, arg1_value);
- return ir_lval_wrap(irb, scope, int_type, lval, result_loc);
- }
case BuiltinFnIdVectorType:
{
AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
@@ -7074,21 +7040,6 @@ static IrInstSrc *ir_gen_builtin_fn_call(IrBuilderSrc *irb, Scope *scope, AstNod
IrInstSrc *set_align_stack = ir_build_set_align_stack(irb, scope, node, arg0_value);
return ir_lval_wrap(irb, scope, set_align_stack, lval, result_loc);
}
- case BuiltinFnIdArgType:
- {
- AstNode *arg0_node = node->data.fn_call_expr.params.at(0);
- IrInstSrc *arg0_value = ir_gen_node(irb, arg0_node, scope);
- if (arg0_value == irb->codegen->invalid_inst_src)
- return arg0_value;
-
- AstNode *arg1_node = node->data.fn_call_expr.params.at(1);
- IrInstSrc *arg1_value = ir_gen_node(irb, arg1_node, scope);
- if (arg1_value == irb->codegen->invalid_inst_src)
- return arg1_value;
-
- IrInstSrc *arg_type = ir_build_arg_type(irb, scope, node, arg0_value, arg1_value, false);
- return ir_lval_wrap(irb, scope, arg_type, lval, result_loc);
- }
case BuiltinFnIdExport:
{
// Cast the options parameter to the options type
@@ -25385,20 +25336,6 @@ static IrInstGen *ir_analyze_instruction_bool_to_int(IrAnalyze *ira, IrInstSrcBo
return ir_resolve_cast(ira, &instruction->base.base, target, u1_type, CastOpBoolToInt);
}
-static IrInstGen *ir_analyze_instruction_int_type(IrAnalyze *ira, IrInstSrcIntType *instruction) {
- IrInstGen *is_signed_value = instruction->is_signed->child;
- bool is_signed;
- if (!ir_resolve_bool(ira, is_signed_value, &is_signed))
- return ira->codegen->invalid_inst_gen;
-
- IrInstGen *bit_count_value = instruction->bit_count->child;
- uint64_t bit_count;
- if (!ir_resolve_unsigned(ira, bit_count_value, ira->codegen->builtin_types.entry_u16, &bit_count))
- return ira->codegen->invalid_inst_gen;
-
- return ir_const_type(ira, &instruction->base.base, get_int_type(ira->codegen, is_signed, (uint32_t)bit_count));
-}
-
static IrInstGen *ir_analyze_instruction_vector_type(IrAnalyze *ira, IrInstSrcVectorType *instruction) {
uint64_t len;
if (!ir_resolve_unsigned(ira, instruction->len->child, ira->codegen->builtin_types.entry_u32, &len))
@@ -29270,8 +29207,6 @@ static IrInstGen *ir_analyze_instruction_base(IrAnalyze *ira, IrInstSrc *instruc
return ir_analyze_instruction_float_to_int(ira, (IrInstSrcFloatToInt *)instruction);
case IrInstSrcIdBoolToInt:
return ir_analyze_instruction_bool_to_int(ira, (IrInstSrcBoolToInt *)instruction);
- case IrInstSrcIdIntType:
- return ir_analyze_instruction_int_type(ira, (IrInstSrcIntType *)instruction);
case IrInstSrcIdVectorType:
return ir_analyze_instruction_vector_type(ira, (IrInstSrcVectorType *)instruction);
case IrInstSrcIdShuffleVector:
@@ -29754,7 +29689,6 @@ bool ir_inst_src_has_side_effects(IrInstSrc *instruction) {
case IrInstSrcIdRef:
case IrInstSrcIdEmbedFile:
case IrInstSrcIdTruncate:
- case IrInstSrcIdIntType:
case IrInstSrcIdVectorType:
case IrInstSrcIdShuffleVector:
case IrInstSrcIdSplat:
diff --git a/src/ir_print.cpp b/src/ir_print.cpp
index 4f87ff832d..1cfe904660 100644
--- a/src/ir_print.cpp
+++ b/src/ir_print.cpp
@@ -179,8 +179,6 @@ const char* ir_inst_src_type_str(IrInstSrcId id) {
return "SrcFloatToInt";
case IrInstSrcIdBoolToInt:
return "SrcBoolToInt";
- case IrInstSrcIdIntType:
- return "SrcIntType";
case IrInstSrcIdVectorType:
return "SrcVectorType";
case IrInstSrcIdBoolNot:
@@ -1652,14 +1650,6 @@ static void ir_print_bool_to_int(IrPrintSrc *irp, IrInstSrcBoolToInt *instructio
fprintf(irp->f, ")");
}
-static void ir_print_int_type(IrPrintSrc *irp, IrInstSrcIntType *instruction) {
- fprintf(irp->f, "@IntType(");
- ir_print_other_inst_src(irp, instruction->is_signed);
- fprintf(irp->f, ", ");
- ir_print_other_inst_src(irp, instruction->bit_count);
- fprintf(irp->f, ")");
-}
-
static void ir_print_vector_type(IrPrintSrc *irp, IrInstSrcVectorType *instruction) {
fprintf(irp->f, "@Vector(");
ir_print_other_inst_src(irp, instruction->len);
@@ -2739,9 +2729,6 @@ static void ir_print_inst_src(IrPrintSrc *irp, IrInstSrc *instruction, bool trai
case IrInstSrcIdBoolToInt:
ir_print_bool_to_int(irp, (IrInstSrcBoolToInt *)instruction);
break;
- case IrInstSrcIdIntType:
- ir_print_int_type(irp, (IrInstSrcIntType *)instruction);
- break;
case IrInstSrcIdVectorType:
ir_print_vector_type(irp, (IrInstSrcVectorType *)instruction);
break;
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index eb1f68e163..56df006e82 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -1902,7 +1902,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
\\ var x: i65536 = 1;
\\}
, &[_][]const u8{
- "tmp.zig:2:31: error: integer value 65536 cannot be coerced to type 'u16'",
"tmp.zig:5:12: error: primitive integer type 'i65536' exceeds maximum bit width of 65535",
});
--
cgit v1.2.3