diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-08-24 15:57:44 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 15:57:44 -0400 |
| commit | 2a96209c4060bbf8a41fbe34e687a7a4741d2fe1 (patch) | |
| tree | 11594b42c723162c304f5cbce7259c856718458b /src/Sema.zig | |
| parent | 80b8294bccdbdf3bc0dd9248676e5c9718354125 (diff) | |
| parent | 7b14d614d91df7b9b5d802f34bf628293fc714f0 (diff) | |
| download | zig-2a96209c4060bbf8a41fbe34e687a7a4741d2fe1.tar.gz zig-2a96209c4060bbf8a41fbe34e687a7a4741d2fe1.zip | |
Merge pull request #12574 from Vexu/remove-bit-op-type-param
stage2+stage1: remove type parameter from bit builtins
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index 4f558ccae4..51208c445a 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -13043,7 +13043,7 @@ fn analyzePtrArithmetic( // The resulting pointer is aligned to the lcd between the offset (an // arbitrary number) and the alignment factor (always a power of two, // non zero). - const new_align = @as(u32, 1) << @intCast(u5, @ctz(u64, addend | ptr_info.@"align")); + const new_align = @as(u32, 1) << @intCast(u5, @ctz(addend | ptr_info.@"align")); break :t try Type.ptr(sema.arena, sema.mod, .{ .pointee_type = ptr_info.pointee_type, @@ -17792,7 +17792,7 @@ fn zirBitCount( ) CompileError!Air.Inst.Ref { const inst_data = sema.code.instructions.items(.data)[inst].un_node; const src = inst_data.src(); - const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; + const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; const operand = try sema.resolveInst(inst_data.operand); const operand_ty = sema.typeOf(operand); _ = try checkIntOrVector(sema, block, operand, operand_src); @@ -17844,17 +17844,16 @@ fn zirBitCount( fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { const inst_data = sema.code.instructions.items(.data)[inst].un_node; const src = inst_data.src(); - const ty_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; - const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; + const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; const operand = try sema.resolveInst(inst_data.operand); const operand_ty = sema.typeOf(operand); - const scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); + const scalar_ty = try sema.checkIntOrVector(block, operand, operand_src); const target = sema.mod.getTarget(); const bits = scalar_ty.intInfo(target).bits; if (bits % 8 != 0) { return sema.fail( block, - ty_src, + operand_src, "@byteSwap requires the number of bits to be evenly divisible by 8, but {} has {} bits", .{ scalar_ty.fmt(sema.mod), bits }, ); @@ -17865,7 +17864,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai } switch (operand_ty.zigTypeTag()) { - .Int, .ComptimeInt => { + .Int => { const runtime_src = if (try sema.resolveMaybeUndefVal(block, operand_src, operand)) |val| { if (val.isUndef()) return sema.addConstUndef(operand_ty); const result_val = try val.byteSwap(operand_ty, target, sema.arena); @@ -17903,7 +17902,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai fn zirBitReverse(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref { const inst_data = sema.code.instructions.items(.data)[inst].un_node; const src = inst_data.src(); - const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; + const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node }; const operand = try sema.resolveInst(inst_data.operand); const operand_ty = sema.typeOf(operand); _ = try sema.checkIntOrVectorAllowComptime(block, operand_ty, operand_src); @@ -21683,7 +21682,7 @@ fn structFieldPtrByIndex( const elem_size_bits = ptr_ty_data.pointee_type.bitSize(target); if (elem_size_bytes * 8 == elem_size_bits) { const byte_offset = ptr_ty_data.bit_offset / 8; - const new_align = @as(u32, 1) << @intCast(u5, @ctz(u64, byte_offset | parent_align)); + const new_align = @as(u32, 1) << @intCast(u5, @ctz(byte_offset | parent_align)); ptr_ty_data.bit_offset = 0; ptr_ty_data.host_size = 0; ptr_ty_data.@"align" = new_align; @@ -30455,7 +30454,7 @@ fn elemPtrType(sema: *Sema, ptr_ty: Type, offset: ?usize) !Type { // The resulting pointer is aligned to the lcd between the offset (an // arbitrary number) and the alignment factor (always a power of two, // non zero). - const new_align = @as(u32, 1) << @intCast(u5, @ctz(u64, addend | ptr_info.@"align")); + const new_align = @as(u32, 1) << @intCast(u5, @ctz(addend | ptr_info.@"align")); break :a new_align; }; return try Type.ptr(sema.arena, sema.mod, .{ |
