Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › zig › llvm › Builder › Constant › isZeroInit Public Function isZeroInit Doc Source Public Function std.zig.llvm.Builder.Constant.isZeroInit
pub fn isZeroInit (self : Constant , builder : *const Builder ) bool Params File zig/llvm/Builder.zig: 8655
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694 pub fn isZeroInit (self : Constant , builder : *const Builder ) bool {
switch (self .unwrap ()) {
.constant => |constant | {
const item = builder .constant_items .get (constant );
return switch (item .tag ) {
.positive_integer => {
const extra : *align (@alignOf (std .math .big .Limb )) Integer =
@ptrCast (builder .constant_limbs .items [item .data ..][0 ..Integer .limbs ]);
const limbs = builder .constant_limbs
.items [item .data + Integer .limbs ..][0 ..extra .limbs_len ];
return std .mem .eql (std .math .big .Limb , limbs , &.{0 });
},
.half , .bfloat , .float => item .data == 0 ,
.double => {
const extra = builder .constantExtraData (Constant .Double , item .data );
return extra .lo == 0 and extra .hi == 0 ;
},
.fp128 , .ppc_fp128 => {
const extra = builder .constantExtraData (Constant .Fp128 , item .data );
return extra .lo_lo == 0 and extra .lo_hi == 0 and
extra .hi_lo == 0 and extra .hi_hi == 0 ;
},
.x86_fp80 => {
const extra = builder .constantExtraData (Constant .Fp80 , item .data );
return extra .lo_lo == 0 and extra .lo_hi == 0 and extra .hi == 0 ;
},
.vector => {
var extra = builder .constantExtraDataTrail (Aggregate , item .data );
const len : u32 = @intCast (extra .data .type .aggregateLen (builder ));
const vals = extra .trail .next (len , Constant , builder );
for (vals ) |val | if (!val .isZeroInit (builder )) return false ;
return true ;
},
.null , .zeroinitializer => true ,
else => false ,
};
},
.global => return false ,
}
}