authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-07 05:24:14-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-08-08 21:32:50-04:00
log6577f52614e21dc43ccc2eb9ab80eeaa4fde9cd4
tree1c204760b6e6e9351a1018909059686eb1ac66fa
parente1efd4d3c22cad89ed89ea152c92b1c3260ddb8a

llvm: convert vector reduction intrinsics

Scratch that thing I said about one pass. :)

5 files changed, 208 insertions(+), 173 deletions(-)

src/codegen/llvm.zig+46-67
......@@ -7464,18 +7464,16 @@ pub const FuncGen = struct {
74647464 const llvm_inst_ty = try o.lowerType(inst_ty);
74657465 const results = try fg.wip.callIntrinsic(intrinsic, &.{llvm_inst_ty}, &.{ lhs, rhs }, "");
74667466
7467 const overflow_bit = try fg.wip.extractValue(results, &.{1}, "");
7468 const scalar_overflow_bit = if (llvm_inst_ty.isVector(&o.builder))
7469 (try fg.wip.unimplemented(.i1, "")).finish(
7470 fg.builder.buildOrReduce(overflow_bit.toLlvm(&fg.wip)),
7471 &fg.wip,
7472 )
7467 const overflow_bits = try fg.wip.extractValue(results, &.{1}, "");
7468 const overflow_bits_ty = overflow_bits.typeOfWip(&fg.wip);
7469 const overflow_bit = if (overflow_bits_ty.isVector(&o.builder))
7470 try fg.wip.callIntrinsic(.@"vector.reduce.or", &.{overflow_bits_ty}, &.{overflow_bits}, "")
74737471 else
7474 overflow_bit;
7472 overflow_bits;
74757473
74767474 const fail_block = try fg.wip.block(1, "OverflowFail");
74777475 const ok_block = try fg.wip.block(1, "OverflowOk");
7478 _ = try fg.wip.brCond(scalar_overflow_bit, fail_block, ok_block);
7476 _ = try fg.wip.brCond(overflow_bit, fail_block, ok_block);
74797477
74807478 fg.wip.cursor = .{ .block = fail_block };
74817479 try fg.buildSimplePanic(.integer_overflow);
......@@ -9643,72 +9641,53 @@ pub const FuncGen = struct {
96439641 const reduce = self.air.instructions.items(.data)[inst].reduce;
96449642 const operand = try self.resolveInst(reduce.operand);
96459643 const operand_ty = self.typeOf(reduce.operand);
9644 const llvm_operand_ty = try o.lowerType(operand_ty);
96469645 const scalar_ty = self.typeOfIndex(inst);
96479646 const llvm_scalar_ty = try o.lowerType(scalar_ty);
96489647
96499648 switch (reduce.operation) {
9650 .And => return (try self.wip.unimplemented(llvm_scalar_ty, ""))
9651 .finish(self.builder.buildAndReduce(operand.toLlvm(&self.wip)), &self.wip),
9652 .Or => return (try self.wip.unimplemented(llvm_scalar_ty, ""))
9653 .finish(self.builder.buildOrReduce(operand.toLlvm(&self.wip)), &self.wip),
9654 .Xor => return (try self.wip.unimplemented(llvm_scalar_ty, ""))
9655 .finish(self.builder.buildXorReduce(operand.toLlvm(&self.wip)), &self.wip),
9656 .Min => switch (scalar_ty.zigTypeTag(mod)) {
9657 .Int => return (try self.wip.unimplemented(llvm_scalar_ty, "")).finish(
9658 self.builder.buildIntMinReduce(
9659 operand.toLlvm(&self.wip),
9660 scalar_ty.isSignedInt(mod),
9661 ),
9662 &self.wip,
9663 ),
9664 .Float => if (intrinsicsAllowed(scalar_ty, target)) {
9665 return (try self.wip.unimplemented(llvm_scalar_ty, ""))
9666 .finish(self.builder.buildFPMinReduce(operand.toLlvm(&self.wip)), &self.wip);
9667 },
9649 .And, .Or, .Xor => return self.wip.callIntrinsic(switch (reduce.operation) {
9650 .And => .@"vector.reduce.and",
9651 .Or => .@"vector.reduce.or",
9652 .Xor => .@"vector.reduce.xor",
96689653 else => unreachable,
9669 },
9670 .Max => switch (scalar_ty.zigTypeTag(mod)) {
9671 .Int => return (try self.wip.unimplemented(llvm_scalar_ty, "")).finish(
9672 self.builder.buildIntMaxReduce(
9673 operand.toLlvm(&self.wip),
9674 scalar_ty.isSignedInt(mod),
9675 ),
9676 &self.wip,
9677 ),
9678 .Float => if (intrinsicsAllowed(scalar_ty, target)) {
9679 return (try self.wip.unimplemented(llvm_scalar_ty, ""))
9680 .finish(self.builder.buildFPMaxReduce(operand.toLlvm(&self.wip)), &self.wip);
9681 },
9682 else => unreachable,
9683 },
9684 .Add => switch (scalar_ty.zigTypeTag(mod)) {
9685 .Int => return (try self.wip.unimplemented(llvm_scalar_ty, ""))
9686 .finish(self.builder.buildAddReduce(operand.toLlvm(&self.wip)), &self.wip),
9687 .Float => if (intrinsicsAllowed(scalar_ty, target)) {
9688 const neutral_value = try o.builder.fpConst(llvm_scalar_ty, -0.0);
9689 return (try self.wip.unimplemented(llvm_scalar_ty, "")).finish(
9690 self.builder.buildFPAddReduce(
9691 neutral_value.toLlvm(&o.builder),
9692 operand.toLlvm(&self.wip),
9693 ),
9694 &self.wip,
9695 );
9696 },
9654 }, &.{llvm_operand_ty}, &.{operand}, ""),
9655 .Min, .Max => switch (scalar_ty.zigTypeTag(mod)) {
9656 .Int => return self.wip.callIntrinsic(switch (reduce.operation) {
9657 .Min => if (scalar_ty.isSignedInt(mod))
9658 .@"vector.reduce.smin"
9659 else
9660 .@"vector.reduce.umin",
9661 .Max => if (scalar_ty.isSignedInt(mod))
9662 .@"vector.reduce.smax"
9663 else
9664 .@"vector.reduce.umax",
9665 else => unreachable,
9666 }, &.{llvm_operand_ty}, &.{operand}, ""),
9667 .Float => if (intrinsicsAllowed(scalar_ty, target))
9668 return self.wip.callIntrinsic(switch (reduce.operation) {
9669 .Min => .@"vector.reduce.fmin",
9670 .Max => .@"vector.reduce.fmax",
9671 else => unreachable,
9672 }, &.{llvm_operand_ty}, &.{operand}, ""),
96979673 else => unreachable,
96989674 },
9699 .Mul => switch (scalar_ty.zigTypeTag(mod)) {
9700 .Int => return (try self.wip.unimplemented(llvm_scalar_ty, ""))
9701 .finish(self.builder.buildMulReduce(operand.toLlvm(&self.wip)), &self.wip),
9702 .Float => if (intrinsicsAllowed(scalar_ty, target)) {
9703 const neutral_value = try o.builder.fpConst(llvm_scalar_ty, 1.0);
9704 return (try self.wip.unimplemented(llvm_scalar_ty, "")).finish(
9705 self.builder.buildFPMulReduce(
9706 neutral_value.toLlvm(&o.builder),
9707 operand.toLlvm(&self.wip),
9708 ),
9709 &self.wip,
9710 );
9711 },
9675 .Add, .Mul => switch (scalar_ty.zigTypeTag(mod)) {
9676 .Int => return self.wip.callIntrinsic(switch (reduce.operation) {
9677 .Add => .@"vector.reduce.add",
9678 .Mul => .@"vector.reduce.mul",
9679 else => unreachable,
9680 }, &.{llvm_operand_ty}, &.{operand}, ""),
9681 .Float => if (intrinsicsAllowed(scalar_ty, target))
9682 return self.wip.callIntrinsic(switch (reduce.operation) {
9683 .Add => .@"vector.reduce.fadd",
9684 .Mul => .@"vector.reduce.fmul",
9685 else => unreachable,
9686 }, &.{llvm_operand_ty}, &.{ switch (reduce.operation) {
9687 .Add => try o.builder.fpValue(llvm_scalar_ty, -0.0),
9688 .Mul => try o.builder.fpValue(llvm_scalar_ty, 1.0),
9689 else => unreachable,
9690 }, operand }, ""),
97129691 else => unreachable,
97139692 },
97149693 }
src/codegen/llvm/Builder.zig+162-17
......@@ -2472,12 +2472,13 @@ pub const Intrinsic = enum {
24722472
24732473 const Kind = union(enum) {
24742474 type: Type,
2475 change_scalar: struct {
2475 overloaded,
2476 matches: u8,
2477 matches_scalar: u8,
2478 matches_changed_scalar: struct {
24762479 index: u8,
24772480 scalar: Type,
24782481 },
2479 overloaded,
2480 matches: u8,
24812482 };
24822483 };
24832484 };
......@@ -2921,7 +2922,7 @@ pub const Intrinsic = enum {
29212922 .ret_len = 2,
29222923 .params = &.{
29232924 .{ .kind = .overloaded },
2924 .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } },
2925 .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } },
29252926 .{ .kind = .{ .matches = 0 } },
29262927 .{ .kind = .{ .matches = 0 } },
29272928 },
......@@ -2931,7 +2932,7 @@ pub const Intrinsic = enum {
29312932 .ret_len = 2,
29322933 .params = &.{
29332934 .{ .kind = .overloaded },
2934 .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } },
2935 .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } },
29352936 .{ .kind = .{ .matches = 0 } },
29362937 .{ .kind = .{ .matches = 0 } },
29372938 },
......@@ -2941,7 +2942,7 @@ pub const Intrinsic = enum {
29412942 .ret_len = 2,
29422943 .params = &.{
29432944 .{ .kind = .overloaded },
2944 .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } },
2945 .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } },
29452946 .{ .kind = .{ .matches = 0 } },
29462947 .{ .kind = .{ .matches = 0 } },
29472948 },
......@@ -2951,7 +2952,7 @@ pub const Intrinsic = enum {
29512952 .ret_len = 2,
29522953 .params = &.{
29532954 .{ .kind = .overloaded },
2954 .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } },
2955 .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } },
29552956 .{ .kind = .{ .matches = 0 } },
29562957 .{ .kind = .{ .matches = 0 } },
29572958 },
......@@ -2961,7 +2962,7 @@ pub const Intrinsic = enum {
29612962 .ret_len = 2,
29622963 .params = &.{
29632964 .{ .kind = .overloaded },
2964 .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } },
2965 .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } },
29652966 .{ .kind = .{ .matches = 0 } },
29662967 .{ .kind = .{ .matches = 0 } },
29672968 },
......@@ -2971,7 +2972,7 @@ pub const Intrinsic = enum {
29712972 .ret_len = 2,
29722973 .params = &.{
29732974 .{ .kind = .overloaded },
2974 .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } },
2975 .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } },
29752976 .{ .kind = .{ .matches = 0 } },
29762977 .{ .kind = .{ .matches = 0 } },
29772978 },
......@@ -3114,6 +3115,148 @@ pub const Intrinsic = enum {
31143115 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
31153116 },
31163117
3118 .@"vector.reduce.add" = .{
3119 .ret_len = 1,
3120 .params = &.{
3121 .{ .kind = .{ .matches_scalar = 1 } },
3122 .{ .kind = .overloaded },
3123 },
3124 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3125 },
3126 .@"vector.reduce.fadd" = .{
3127 .ret_len = 1,
3128 .params = &.{
3129 .{ .kind = .{ .matches_scalar = 2 } },
3130 .{ .kind = .{ .matches_scalar = 2 } },
3131 .{ .kind = .overloaded },
3132 },
3133 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3134 },
3135 .@"vector.reduce.mul" = .{
3136 .ret_len = 1,
3137 .params = &.{
3138 .{ .kind = .{ .matches_scalar = 1 } },
3139 .{ .kind = .overloaded },
3140 },
3141 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3142 },
3143 .@"vector.reduce.fmul" = .{
3144 .ret_len = 1,
3145 .params = &.{
3146 .{ .kind = .{ .matches_scalar = 2 } },
3147 .{ .kind = .{ .matches_scalar = 2 } },
3148 .{ .kind = .overloaded },
3149 },
3150 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3151 },
3152 .@"vector.reduce.and" = .{
3153 .ret_len = 1,
3154 .params = &.{
3155 .{ .kind = .{ .matches_scalar = 1 } },
3156 .{ .kind = .overloaded },
3157 },
3158 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3159 },
3160 .@"vector.reduce.or" = .{
3161 .ret_len = 1,
3162 .params = &.{
3163 .{ .kind = .{ .matches_scalar = 1 } },
3164 .{ .kind = .overloaded },
3165 },
3166 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3167 },
3168 .@"vector.reduce.xor" = .{
3169 .ret_len = 1,
3170 .params = &.{
3171 .{ .kind = .{ .matches_scalar = 1 } },
3172 .{ .kind = .overloaded },
3173 },
3174 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3175 },
3176 .@"vector.reduce.smax" = .{
3177 .ret_len = 1,
3178 .params = &.{
3179 .{ .kind = .{ .matches_scalar = 1 } },
3180 .{ .kind = .overloaded },
3181 },
3182 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3183 },
3184 .@"vector.reduce.smin" = .{
3185 .ret_len = 1,
3186 .params = &.{
3187 .{ .kind = .{ .matches_scalar = 1 } },
3188 .{ .kind = .overloaded },
3189 },
3190 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3191 },
3192 .@"vector.reduce.umax" = .{
3193 .ret_len = 1,
3194 .params = &.{
3195 .{ .kind = .{ .matches_scalar = 1 } },
3196 .{ .kind = .overloaded },
3197 },
3198 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3199 },
3200 .@"vector.reduce.umin" = .{
3201 .ret_len = 1,
3202 .params = &.{
3203 .{ .kind = .{ .matches_scalar = 1 } },
3204 .{ .kind = .overloaded },
3205 },
3206 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3207 },
3208 .@"vector.reduce.fmax" = .{
3209 .ret_len = 1,
3210 .params = &.{
3211 .{ .kind = .{ .matches_scalar = 1 } },
3212 .{ .kind = .overloaded },
3213 },
3214 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3215 },
3216 .@"vector.reduce.fmin" = .{
3217 .ret_len = 1,
3218 .params = &.{
3219 .{ .kind = .{ .matches_scalar = 1 } },
3220 .{ .kind = .overloaded },
3221 },
3222 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3223 },
3224 .@"vector.reduce.fmaximum" = .{
3225 .ret_len = 1,
3226 .params = &.{
3227 .{ .kind = .{ .matches_scalar = 1 } },
3228 .{ .kind = .overloaded },
3229 },
3230 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3231 },
3232 .@"vector.reduce.fminimum" = .{
3233 .ret_len = 1,
3234 .params = &.{
3235 .{ .kind = .{ .matches_scalar = 1 } },
3236 .{ .kind = .overloaded },
3237 },
3238 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3239 },
3240 .@"vector.insert" = .{
3241 .ret_len = 1,
3242 .params = &.{
3243 .{ .kind = .overloaded },
3244 .{ .kind = .{ .matches = 0 } },
3245 .{ .kind = .overloaded },
3246 .{ .kind = .{ .type = .i64 } },
3247 },
3248 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3249 },
3250 .@"vector.extract" = .{
3251 .ret_len = 1,
3252 .params = &.{
3253 .{ .kind = .overloaded },
3254 .{ .kind = .overloaded },
3255 .{ .kind = .{ .type = .i64 } },
3256 },
3257 .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .speculatable, .willreturn, .{ .memory = Attribute.Memory.all(.none) } },
3258 },
3259
31173260 .trap = .{
31183261 .ret_len = 0,
31193262 .params = &.{},
......@@ -7742,18 +7885,11 @@ pub fn getIntrinsic(
77427885 for (0.., param_types, signature.params) |param_index, *param_type, signature_param| {
77437886 switch (signature_param.kind) {
77447887 .type => |ty| param_type.* = ty,
7745 .change_scalar => |info| {
7746 assert(info.index < param_index);
7747 param_type.* = try param_types[info.index].changeScalar(info.scalar, self);
7748 },
77497888 .overloaded => {
77507889 param_type.* = overload[overload_index];
77517890 overload_index += 1;
77527891 },
7753 .matches => |index| {
7754 assert(index < param_index);
7755 param_type.* = param_types[index];
7756 },
7892 .matches, .matches_scalar, .matches_changed_scalar => {},
77577893 }
77587894 function_attributes[
77597895 if (param_index < signature.ret_len)
......@@ -7763,6 +7899,15 @@ pub fn getIntrinsic(
77637899 ] = try attributes.get(signature_param.attrs);
77647900 }
77657901 assert(overload_index == overload.len);
7902 for (param_types, signature.params) |*param_type, signature_param| {
7903 param_type.* = switch (signature_param.kind) {
7904 .type, .overloaded => continue,
7905 .matches => |param_index| param_types[param_index],
7906 .matches_scalar => |param_index| param_types[param_index].scalarType(self),
7907 .matches_changed_scalar => |info| try param_types[info.index]
7908 .changeScalar(info.scalar, self),
7909 };
7910 }
77667911
77677912 const function_index =
77687913 try self.addFunction(try self.fnType(switch (signature.ret_len) {
src/codegen/llvm/bindings.zig-33
......@@ -993,39 +993,6 @@ pub const Builder = opaque {
993993 pub const buildShuffleVector = LLVMBuildShuffleVector;
994994 extern fn LLVMBuildShuffleVector(*Builder, V1: *Value, V2: *Value, Mask: *Value, Name: [*:0]const u8) *Value;
995995
996 pub const buildAndReduce = ZigLLVMBuildAndReduce;
997 extern fn ZigLLVMBuildAndReduce(B: *Builder, Val: *Value) *Value;
998
999 pub const buildOrReduce = ZigLLVMBuildOrReduce;
1000 extern fn ZigLLVMBuildOrReduce(B: *Builder, Val: *Value) *Value;
1001
1002 pub const buildXorReduce = ZigLLVMBuildXorReduce;
1003 extern fn ZigLLVMBuildXorReduce(B: *Builder, Val: *Value) *Value;
1004
1005 pub const buildIntMaxReduce = ZigLLVMBuildIntMaxReduce;
1006 extern fn ZigLLVMBuildIntMaxReduce(B: *Builder, Val: *Value, is_signed: bool) *Value;
1007
1008 pub const buildIntMinReduce = ZigLLVMBuildIntMinReduce;
1009 extern fn ZigLLVMBuildIntMinReduce(B: *Builder, Val: *Value, is_signed: bool) *Value;
1010
1011 pub const buildFPMaxReduce = ZigLLVMBuildFPMaxReduce;
1012 extern fn ZigLLVMBuildFPMaxReduce(B: *Builder, Val: *Value) *Value;
1013
1014 pub const buildFPMinReduce = ZigLLVMBuildFPMinReduce;
1015 extern fn ZigLLVMBuildFPMinReduce(B: *Builder, Val: *Value) *Value;
1016
1017 pub const buildAddReduce = ZigLLVMBuildAddReduce;
1018 extern fn ZigLLVMBuildAddReduce(B: *Builder, Val: *Value) *Value;
1019
1020 pub const buildMulReduce = ZigLLVMBuildMulReduce;
1021 extern fn ZigLLVMBuildMulReduce(B: *Builder, Val: *Value) *Value;
1022
1023 pub const buildFPAddReduce = ZigLLVMBuildFPAddReduce;
1024 extern fn ZigLLVMBuildFPAddReduce(B: *Builder, Acc: *Value, Val: *Value) *Value;
1025
1026 pub const buildFPMulReduce = ZigLLVMBuildFPMulReduce;
1027 extern fn ZigLLVMBuildFPMulReduce(B: *Builder, Acc: *Value, Val: *Value) *Value;
1028
1029996 pub const setFastMath = ZigLLVMSetFastMath;
1030997 extern fn ZigLLVMSetFastMath(B: *Builder, on_state: bool) void;
1031998
src/zig_llvm.cpp-44
......@@ -1134,50 +1134,6 @@ bool ZigLLDLinkWasm(int argc, const char **argv, bool can_exit_early, bool disab
11341134 return lld::wasm::link(args, llvm::outs(), llvm::errs(), can_exit_early, disable_output);
11351135}
11361136
1137LLVMValueRef ZigLLVMBuildAndReduce(LLVMBuilderRef B, LLVMValueRef Val) {
1138 return wrap(unwrap(B)->CreateAndReduce(unwrap(Val)));
1139}
1140
1141LLVMValueRef ZigLLVMBuildOrReduce(LLVMBuilderRef B, LLVMValueRef Val) {
1142 return wrap(unwrap(B)->CreateOrReduce(unwrap(Val)));
1143}
1144
1145LLVMValueRef ZigLLVMBuildXorReduce(LLVMBuilderRef B, LLVMValueRef Val) {
1146 return wrap(unwrap(B)->CreateXorReduce(unwrap(Val)));
1147}
1148
1149LLVMValueRef ZigLLVMBuildIntMaxReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed) {
1150 return wrap(unwrap(B)->CreateIntMaxReduce(unwrap(Val), is_signed));
1151}
1152
1153LLVMValueRef ZigLLVMBuildIntMinReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed) {
1154 return wrap(unwrap(B)->CreateIntMinReduce(unwrap(Val), is_signed));
1155}
1156
1157LLVMValueRef ZigLLVMBuildFPMaxReduce(LLVMBuilderRef B, LLVMValueRef Val) {
1158 return wrap(unwrap(B)->CreateFPMaxReduce(unwrap(Val)));
1159}
1160
1161LLVMValueRef ZigLLVMBuildFPMinReduce(LLVMBuilderRef B, LLVMValueRef Val) {
1162 return wrap(unwrap(B)->CreateFPMinReduce(unwrap(Val)));
1163}
1164
1165LLVMValueRef ZigLLVMBuildAddReduce(LLVMBuilderRef B, LLVMValueRef Val) {
1166 return wrap(unwrap(B)->CreateAddReduce(unwrap(Val)));
1167}
1168
1169LLVMValueRef ZigLLVMBuildMulReduce(LLVMBuilderRef B, LLVMValueRef Val) {
1170 return wrap(unwrap(B)->CreateMulReduce(unwrap(Val)));
1171}
1172
1173LLVMValueRef ZigLLVMBuildFPAddReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val) {
1174 return wrap(unwrap(B)->CreateFAddReduce(unwrap(Acc), unwrap(Val)));
1175}
1176
1177LLVMValueRef ZigLLVMBuildFPMulReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val) {
1178 return wrap(unwrap(B)->CreateFMulReduce(unwrap(Acc), unwrap(Val)));
1179}
1180
11811137void ZigLLVMTakeName(LLVMValueRef new_owner, LLVMValueRef victim) {
11821138 unwrap(new_owner)->takeName(unwrap(victim));
11831139}
src/zig_llvm.h-12
......@@ -497,18 +497,6 @@ enum ZigLLVM_ObjectFormatType {
497497 ZigLLVM_XCOFF,
498498};
499499
500ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildAndReduce(LLVMBuilderRef B, LLVMValueRef Val);
501ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildOrReduce(LLVMBuilderRef B, LLVMValueRef Val);
502ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildXorReduce(LLVMBuilderRef B, LLVMValueRef Val);
503ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildIntMaxReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed);
504ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildIntMinReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed);
505ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPMaxReduce(LLVMBuilderRef B, LLVMValueRef Val);
506ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPMinReduce(LLVMBuilderRef B, LLVMValueRef Val);
507ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildAddReduce(LLVMBuilderRef B, LLVMValueRef Val);
508ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildMulReduce(LLVMBuilderRef B, LLVMValueRef Val);
509ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPAddReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val);
510ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPMulReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val);
511
512500ZIG_EXTERN_C void ZigLLVMTakeName(LLVMValueRef new_owner, LLVMValueRef victim);
513501
514502#define ZigLLVM_DIFlags_Zero 0U