| author | |
| committer | |
| log | 6577f52614e21dc43ccc2eb9ab80eeaa4fde9cd4 |
| tree | 1c204760b6e6e9351a1018909059686eb1ac66fa |
| parent | e1efd4d3c22cad89ed89ea152c92b1c3260ddb8a |
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 { | ... | @@ -7464,18 +7464,16 @@ pub const FuncGen = struct { |
| 7464 | const llvm_inst_ty = try o.lowerType(inst_ty); | 7464 | const llvm_inst_ty = try o.lowerType(inst_ty); |
| 7465 | const results = try fg.wip.callIntrinsic(intrinsic, &.{llvm_inst_ty}, &.{ lhs, rhs }, ""); | 7465 | const results = try fg.wip.callIntrinsic(intrinsic, &.{llvm_inst_ty}, &.{ lhs, rhs }, ""); |
| 7466 | 7466 | ||
| 7467 | const overflow_bit = try fg.wip.extractValue(results, &.{1}, ""); | 7467 | const overflow_bits = try fg.wip.extractValue(results, &.{1}, ""); |
| 7468 | const scalar_overflow_bit = if (llvm_inst_ty.isVector(&o.builder)) | 7468 | const overflow_bits_ty = overflow_bits.typeOfWip(&fg.wip); |
| 7469 | (try fg.wip.unimplemented(.i1, "")).finish( | 7469 | const overflow_bit = if (overflow_bits_ty.isVector(&o.builder)) |
| 7470 | fg.builder.buildOrReduce(overflow_bit.toLlvm(&fg.wip)), | 7470 | try fg.wip.callIntrinsic(.@"vector.reduce.or", &.{overflow_bits_ty}, &.{overflow_bits}, "") |
| 7471 | &fg.wip, | ||
| 7472 | ) | ||
| 7473 | else | 7471 | else |
| 7474 | overflow_bit; | 7472 | overflow_bits; |
| 7475 | 7473 | ||
| 7476 | const fail_block = try fg.wip.block(1, "OverflowFail"); | 7474 | const fail_block = try fg.wip.block(1, "OverflowFail"); |
| 7477 | const ok_block = try fg.wip.block(1, "OverflowOk"); | 7475 | 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); |
| 7479 | 7477 | ||
| 7480 | fg.wip.cursor = .{ .block = fail_block }; | 7478 | fg.wip.cursor = .{ .block = fail_block }; |
| 7481 | try fg.buildSimplePanic(.integer_overflow); | 7479 | try fg.buildSimplePanic(.integer_overflow); |
| ... | @@ -9643,72 +9641,53 @@ pub const FuncGen = struct { | ... | @@ -9643,72 +9641,53 @@ pub const FuncGen = struct { |
| 9643 | const reduce = self.air.instructions.items(.data)[inst].reduce; | 9641 | const reduce = self.air.instructions.items(.data)[inst].reduce; |
| 9644 | const operand = try self.resolveInst(reduce.operand); | 9642 | const operand = try self.resolveInst(reduce.operand); |
| 9645 | const operand_ty = self.typeOf(reduce.operand); | 9643 | const operand_ty = self.typeOf(reduce.operand); |
| 9644 | const llvm_operand_ty = try o.lowerType(operand_ty); | ||
| 9646 | const scalar_ty = self.typeOfIndex(inst); | 9645 | const scalar_ty = self.typeOfIndex(inst); |
| 9647 | const llvm_scalar_ty = try o.lowerType(scalar_ty); | 9646 | const llvm_scalar_ty = try o.lowerType(scalar_ty); |
| 9648 | 9647 | ||
| 9649 | switch (reduce.operation) { | 9648 | switch (reduce.operation) { |
| 9650 | .And => return (try self.wip.unimplemented(llvm_scalar_ty, "")) | 9649 | .And, .Or, .Xor => return self.wip.callIntrinsic(switch (reduce.operation) { |
| 9651 | .finish(self.builder.buildAndReduce(operand.toLlvm(&self.wip)), &self.wip), | 9650 | .And => .@"vector.reduce.and", |
| 9652 | .Or => return (try self.wip.unimplemented(llvm_scalar_ty, "")) | 9651 | .Or => .@"vector.reduce.or", |
| 9653 | .finish(self.builder.buildOrReduce(operand.toLlvm(&self.wip)), &self.wip), | 9652 | .Xor => .@"vector.reduce.xor", |
| 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 | }, | ||
| 9668 | else => unreachable, | 9653 | else => unreachable, |
| 9669 | }, | 9654 | }, &.{llvm_operand_ty}, &.{operand}, ""), |
| 9670 | .Max => switch (scalar_ty.zigTypeTag(mod)) { | 9655 | .Min, .Max => switch (scalar_ty.zigTypeTag(mod)) { |
| 9671 | .Int => return (try self.wip.unimplemented(llvm_scalar_ty, "")).finish( | 9656 | .Int => return self.wip.callIntrinsic(switch (reduce.operation) { |
| 9672 | self.builder.buildIntMaxReduce( | 9657 | .Min => if (scalar_ty.isSignedInt(mod)) |
| 9673 | operand.toLlvm(&self.wip), | 9658 | .@"vector.reduce.smin" |
| 9674 | scalar_ty.isSignedInt(mod), | 9659 | else |
| 9675 | ), | 9660 | .@"vector.reduce.umin", |
| 9676 | &self.wip, | 9661 | .Max => if (scalar_ty.isSignedInt(mod)) |
| 9677 | ), | 9662 | .@"vector.reduce.smax" |
| 9678 | .Float => if (intrinsicsAllowed(scalar_ty, target)) { | 9663 | else |
| 9679 | return (try self.wip.unimplemented(llvm_scalar_ty, "")) | 9664 | .@"vector.reduce.umax", |
| 9680 | .finish(self.builder.buildFPMaxReduce(operand.toLlvm(&self.wip)), &self.wip); | 9665 | else => unreachable, |
| 9681 | }, | 9666 | }, &.{llvm_operand_ty}, &.{operand}, ""), |
| 9682 | else => unreachable, | 9667 | .Float => if (intrinsicsAllowed(scalar_ty, target)) |
| 9683 | }, | 9668 | return self.wip.callIntrinsic(switch (reduce.operation) { |
| 9684 | .Add => switch (scalar_ty.zigTypeTag(mod)) { | 9669 | .Min => .@"vector.reduce.fmin", |
| 9685 | .Int => return (try self.wip.unimplemented(llvm_scalar_ty, "")) | 9670 | .Max => .@"vector.reduce.fmax", |
| 9686 | .finish(self.builder.buildAddReduce(operand.toLlvm(&self.wip)), &self.wip), | 9671 | else => unreachable, |
| 9687 | .Float => if (intrinsicsAllowed(scalar_ty, target)) { | 9672 | }, &.{llvm_operand_ty}, &.{operand}, ""), |
| 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 | }, | ||
| 9697 | else => unreachable, | 9673 | else => unreachable, |
| 9698 | }, | 9674 | }, |
| 9699 | .Mul => switch (scalar_ty.zigTypeTag(mod)) { | 9675 | .Add, .Mul => switch (scalar_ty.zigTypeTag(mod)) { |
| 9700 | .Int => return (try self.wip.unimplemented(llvm_scalar_ty, "")) | 9676 | .Int => return self.wip.callIntrinsic(switch (reduce.operation) { |
| 9701 | .finish(self.builder.buildMulReduce(operand.toLlvm(&self.wip)), &self.wip), | 9677 | .Add => .@"vector.reduce.add", |
| 9702 | .Float => if (intrinsicsAllowed(scalar_ty, target)) { | 9678 | .Mul => .@"vector.reduce.mul", |
| 9703 | const neutral_value = try o.builder.fpConst(llvm_scalar_ty, 1.0); | 9679 | else => unreachable, |
| 9704 | return (try self.wip.unimplemented(llvm_scalar_ty, "")).finish( | 9680 | }, &.{llvm_operand_ty}, &.{operand}, ""), |
| 9705 | self.builder.buildFPMulReduce( | 9681 | .Float => if (intrinsicsAllowed(scalar_ty, target)) |
| 9706 | neutral_value.toLlvm(&o.builder), | 9682 | return self.wip.callIntrinsic(switch (reduce.operation) { |
| 9707 | operand.toLlvm(&self.wip), | 9683 | .Add => .@"vector.reduce.fadd", |
| 9708 | ), | 9684 | .Mul => .@"vector.reduce.fmul", |
| 9709 | &self.wip, | 9685 | else => unreachable, |
| 9710 | ); | 9686 | }, &.{llvm_operand_ty}, &.{ switch (reduce.operation) { |
| 9711 | }, | 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 }, ""), | ||
| 9712 | else => unreachable, | 9691 | else => unreachable, |
| 9713 | }, | 9692 | }, |
| 9714 | } | 9693 | } |
src/codegen/llvm/Builder.zig+162-17| ... | @@ -2472,12 +2472,13 @@ pub const Intrinsic = enum { | ... | @@ -2472,12 +2472,13 @@ pub const Intrinsic = enum { |
| 2472 | 2472 | ||
| 2473 | const Kind = union(enum) { | 2473 | const Kind = union(enum) { |
| 2474 | type: Type, | 2474 | type: Type, |
| 2475 | change_scalar: struct { | 2475 | overloaded, |
| 2476 | matches: u8, | ||
| 2477 | matches_scalar: u8, | ||
| 2478 | matches_changed_scalar: struct { | ||
| 2476 | index: u8, | 2479 | index: u8, |
| 2477 | scalar: Type, | 2480 | scalar: Type, |
| 2478 | }, | 2481 | }, |
| 2479 | overloaded, | ||
| 2480 | matches: u8, | ||
| 2481 | }; | 2482 | }; |
| 2482 | }; | 2483 | }; |
| 2483 | }; | 2484 | }; |
| ... | @@ -2921,7 +2922,7 @@ pub const Intrinsic = enum { | ... | @@ -2921,7 +2922,7 @@ pub const Intrinsic = enum { |
| 2921 | .ret_len = 2, | 2922 | .ret_len = 2, |
| 2922 | .params = &.{ | 2923 | .params = &.{ |
| 2923 | .{ .kind = .overloaded }, | 2924 | .{ .kind = .overloaded }, |
| 2924 | .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } }, | 2925 | .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } }, |
| 2925 | .{ .kind = .{ .matches = 0 } }, | 2926 | .{ .kind = .{ .matches = 0 } }, |
| 2926 | .{ .kind = .{ .matches = 0 } }, | 2927 | .{ .kind = .{ .matches = 0 } }, |
| 2927 | }, | 2928 | }, |
| ... | @@ -2931,7 +2932,7 @@ pub const Intrinsic = enum { | ... | @@ -2931,7 +2932,7 @@ pub const Intrinsic = enum { |
| 2931 | .ret_len = 2, | 2932 | .ret_len = 2, |
| 2932 | .params = &.{ | 2933 | .params = &.{ |
| 2933 | .{ .kind = .overloaded }, | 2934 | .{ .kind = .overloaded }, |
| 2934 | .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } }, | 2935 | .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } }, |
| 2935 | .{ .kind = .{ .matches = 0 } }, | 2936 | .{ .kind = .{ .matches = 0 } }, |
| 2936 | .{ .kind = .{ .matches = 0 } }, | 2937 | .{ .kind = .{ .matches = 0 } }, |
| 2937 | }, | 2938 | }, |
| ... | @@ -2941,7 +2942,7 @@ pub const Intrinsic = enum { | ... | @@ -2941,7 +2942,7 @@ pub const Intrinsic = enum { |
| 2941 | .ret_len = 2, | 2942 | .ret_len = 2, |
| 2942 | .params = &.{ | 2943 | .params = &.{ |
| 2943 | .{ .kind = .overloaded }, | 2944 | .{ .kind = .overloaded }, |
| 2944 | .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } }, | 2945 | .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } }, |
| 2945 | .{ .kind = .{ .matches = 0 } }, | 2946 | .{ .kind = .{ .matches = 0 } }, |
| 2946 | .{ .kind = .{ .matches = 0 } }, | 2947 | .{ .kind = .{ .matches = 0 } }, |
| 2947 | }, | 2948 | }, |
| ... | @@ -2951,7 +2952,7 @@ pub const Intrinsic = enum { | ... | @@ -2951,7 +2952,7 @@ pub const Intrinsic = enum { |
| 2951 | .ret_len = 2, | 2952 | .ret_len = 2, |
| 2952 | .params = &.{ | 2953 | .params = &.{ |
| 2953 | .{ .kind = .overloaded }, | 2954 | .{ .kind = .overloaded }, |
| 2954 | .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } }, | 2955 | .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } }, |
| 2955 | .{ .kind = .{ .matches = 0 } }, | 2956 | .{ .kind = .{ .matches = 0 } }, |
| 2956 | .{ .kind = .{ .matches = 0 } }, | 2957 | .{ .kind = .{ .matches = 0 } }, |
| 2957 | }, | 2958 | }, |
| ... | @@ -2961,7 +2962,7 @@ pub const Intrinsic = enum { | ... | @@ -2961,7 +2962,7 @@ pub const Intrinsic = enum { |
| 2961 | .ret_len = 2, | 2962 | .ret_len = 2, |
| 2962 | .params = &.{ | 2963 | .params = &.{ |
| 2963 | .{ .kind = .overloaded }, | 2964 | .{ .kind = .overloaded }, |
| 2964 | .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } }, | 2965 | .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } }, |
| 2965 | .{ .kind = .{ .matches = 0 } }, | 2966 | .{ .kind = .{ .matches = 0 } }, |
| 2966 | .{ .kind = .{ .matches = 0 } }, | 2967 | .{ .kind = .{ .matches = 0 } }, |
| 2967 | }, | 2968 | }, |
| ... | @@ -2971,7 +2972,7 @@ pub const Intrinsic = enum { | ... | @@ -2971,7 +2972,7 @@ pub const Intrinsic = enum { |
| 2971 | .ret_len = 2, | 2972 | .ret_len = 2, |
| 2972 | .params = &.{ | 2973 | .params = &.{ |
| 2973 | .{ .kind = .overloaded }, | 2974 | .{ .kind = .overloaded }, |
| 2974 | .{ .kind = .{ .change_scalar = .{ .index = 0, .scalar = .i1 } } }, | 2975 | .{ .kind = .{ .matches_changed_scalar = .{ .index = 0, .scalar = .i1 } } }, |
| 2975 | .{ .kind = .{ .matches = 0 } }, | 2976 | .{ .kind = .{ .matches = 0 } }, |
| 2976 | .{ .kind = .{ .matches = 0 } }, | 2977 | .{ .kind = .{ .matches = 0 } }, |
| 2977 | }, | 2978 | }, |
| ... | @@ -3114,6 +3115,148 @@ pub const Intrinsic = enum { | ... | @@ -3114,6 +3115,148 @@ pub const Intrinsic = enum { |
| 3114 | .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .willreturn, .{ .memory = Attribute.Memory.all(.none) } }, | 3115 | .attrs = &.{ .nocallback, .nofree, .nosync, .nounwind, .willreturn, .{ .memory = Attribute.Memory.all(.none) } }, |
| 3115 | }, | 3116 | }, |
| 3116 | 3117 | ||
| 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 | |||
| 3117 | .trap = .{ | 3260 | .trap = .{ |
| 3118 | .ret_len = 0, | 3261 | .ret_len = 0, |
| 3119 | .params = &.{}, | 3262 | .params = &.{}, |
| ... | @@ -7742,18 +7885,11 @@ pub fn getIntrinsic( | ... | @@ -7742,18 +7885,11 @@ pub fn getIntrinsic( |
| 7742 | for (0.., param_types, signature.params) |param_index, *param_type, signature_param| { | 7885 | for (0.., param_types, signature.params) |param_index, *param_type, signature_param| { |
| 7743 | switch (signature_param.kind) { | 7886 | switch (signature_param.kind) { |
| 7744 | .type => |ty| param_type.* = ty, | 7887 | .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 | }, | ||
| 7749 | .overloaded => { | 7888 | .overloaded => { |
| 7750 | param_type.* = overload[overload_index]; | 7889 | param_type.* = overload[overload_index]; |
| 7751 | overload_index += 1; | 7890 | overload_index += 1; |
| 7752 | }, | 7891 | }, |
| 7753 | .matches => |index| { | 7892 | .matches, .matches_scalar, .matches_changed_scalar => {}, |
| 7754 | assert(index < param_index); | ||
| 7755 | param_type.* = param_types[index]; | ||
| 7756 | }, | ||
| 7757 | } | 7893 | } |
| 7758 | function_attributes[ | 7894 | function_attributes[ |
| 7759 | if (param_index < signature.ret_len) | 7895 | if (param_index < signature.ret_len) |
| ... | @@ -7763,6 +7899,15 @@ pub fn getIntrinsic( | ... | @@ -7763,6 +7899,15 @@ pub fn getIntrinsic( |
| 7763 | ] = try attributes.get(signature_param.attrs); | 7899 | ] = try attributes.get(signature_param.attrs); |
| 7764 | } | 7900 | } |
| 7765 | assert(overload_index == overload.len); | 7901 | 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 | } | ||
| 7766 | 7911 | ||
| 7767 | const function_index = | 7912 | const function_index = |
| 7768 | try self.addFunction(try self.fnType(switch (signature.ret_len) { | 7913 | try self.addFunction(try self.fnType(switch (signature.ret_len) { |
src/codegen/llvm/bindings.zig-33| ... | @@ -993,39 +993,6 @@ pub const Builder = opaque { | ... | @@ -993,39 +993,6 @@ pub const Builder = opaque { |
| 993 | pub const buildShuffleVector = LLVMBuildShuffleVector; | 993 | pub const buildShuffleVector = LLVMBuildShuffleVector; |
| 994 | extern fn LLVMBuildShuffleVector(*Builder, V1: *Value, V2: *Value, Mask: *Value, Name: [*:0]const u8) *Value; | 994 | extern fn LLVMBuildShuffleVector(*Builder, V1: *Value, V2: *Value, Mask: *Value, Name: [*:0]const u8) *Value; |
| 995 | 995 | ||
| 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 | |||
| 1029 | pub const setFastMath = ZigLLVMSetFastMath; | 996 | pub const setFastMath = ZigLLVMSetFastMath; |
| 1030 | extern fn ZigLLVMSetFastMath(B: *Builder, on_state: bool) void; | 997 | extern fn ZigLLVMSetFastMath(B: *Builder, on_state: bool) void; |
| 1031 | 998 |
src/zig_llvm.cpp-44| ... | @@ -1134,50 +1134,6 @@ bool ZigLLDLinkWasm(int argc, const char **argv, bool can_exit_early, bool disab | ... | @@ -1134,50 +1134,6 @@ bool ZigLLDLinkWasm(int argc, const char **argv, bool can_exit_early, bool disab |
| 1134 | return lld::wasm::link(args, llvm::outs(), llvm::errs(), can_exit_early, disable_output); | 1134 | return lld::wasm::link(args, llvm::outs(), llvm::errs(), can_exit_early, disable_output); |
| 1135 | } | 1135 | } |
| 1136 | 1136 | ||
| 1137 | LLVMValueRef ZigLLVMBuildAndReduce(LLVMBuilderRef B, LLVMValueRef Val) { | ||
| 1138 | return wrap(unwrap(B)->CreateAndReduce(unwrap(Val))); | ||
| 1139 | } | ||
| 1140 | |||
| 1141 | LLVMValueRef ZigLLVMBuildOrReduce(LLVMBuilderRef B, LLVMValueRef Val) { | ||
| 1142 | return wrap(unwrap(B)->CreateOrReduce(unwrap(Val))); | ||
| 1143 | } | ||
| 1144 | |||
| 1145 | LLVMValueRef ZigLLVMBuildXorReduce(LLVMBuilderRef B, LLVMValueRef Val) { | ||
| 1146 | return wrap(unwrap(B)->CreateXorReduce(unwrap(Val))); | ||
| 1147 | } | ||
| 1148 | |||
| 1149 | LLVMValueRef ZigLLVMBuildIntMaxReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed) { | ||
| 1150 | return wrap(unwrap(B)->CreateIntMaxReduce(unwrap(Val), is_signed)); | ||
| 1151 | } | ||
| 1152 | |||
| 1153 | LLVMValueRef ZigLLVMBuildIntMinReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed) { | ||
| 1154 | return wrap(unwrap(B)->CreateIntMinReduce(unwrap(Val), is_signed)); | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | LLVMValueRef ZigLLVMBuildFPMaxReduce(LLVMBuilderRef B, LLVMValueRef Val) { | ||
| 1158 | return wrap(unwrap(B)->CreateFPMaxReduce(unwrap(Val))); | ||
| 1159 | } | ||
| 1160 | |||
| 1161 | LLVMValueRef ZigLLVMBuildFPMinReduce(LLVMBuilderRef B, LLVMValueRef Val) { | ||
| 1162 | return wrap(unwrap(B)->CreateFPMinReduce(unwrap(Val))); | ||
| 1163 | } | ||
| 1164 | |||
| 1165 | LLVMValueRef ZigLLVMBuildAddReduce(LLVMBuilderRef B, LLVMValueRef Val) { | ||
| 1166 | return wrap(unwrap(B)->CreateAddReduce(unwrap(Val))); | ||
| 1167 | } | ||
| 1168 | |||
| 1169 | LLVMValueRef ZigLLVMBuildMulReduce(LLVMBuilderRef B, LLVMValueRef Val) { | ||
| 1170 | return wrap(unwrap(B)->CreateMulReduce(unwrap(Val))); | ||
| 1171 | } | ||
| 1172 | |||
| 1173 | LLVMValueRef ZigLLVMBuildFPAddReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val) { | ||
| 1174 | return wrap(unwrap(B)->CreateFAddReduce(unwrap(Acc), unwrap(Val))); | ||
| 1175 | } | ||
| 1176 | |||
| 1177 | LLVMValueRef ZigLLVMBuildFPMulReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val) { | ||
| 1178 | return wrap(unwrap(B)->CreateFMulReduce(unwrap(Acc), unwrap(Val))); | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | void ZigLLVMTakeName(LLVMValueRef new_owner, LLVMValueRef victim) { | 1137 | void ZigLLVMTakeName(LLVMValueRef new_owner, LLVMValueRef victim) { |
| 1182 | unwrap(new_owner)->takeName(unwrap(victim)); | 1138 | unwrap(new_owner)->takeName(unwrap(victim)); |
| 1183 | } | 1139 | } |
src/zig_llvm.h-12| ... | @@ -497,18 +497,6 @@ enum ZigLLVM_ObjectFormatType { | ... | @@ -497,18 +497,6 @@ enum ZigLLVM_ObjectFormatType { |
| 497 | ZigLLVM_XCOFF, | 497 | ZigLLVM_XCOFF, |
| 498 | }; | 498 | }; |
| 499 | 499 | ||
| 500 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildAndReduce(LLVMBuilderRef B, LLVMValueRef Val); | ||
| 501 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildOrReduce(LLVMBuilderRef B, LLVMValueRef Val); | ||
| 502 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildXorReduce(LLVMBuilderRef B, LLVMValueRef Val); | ||
| 503 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildIntMaxReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed); | ||
| 504 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildIntMinReduce(LLVMBuilderRef B, LLVMValueRef Val, bool is_signed); | ||
| 505 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPMaxReduce(LLVMBuilderRef B, LLVMValueRef Val); | ||
| 506 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPMinReduce(LLVMBuilderRef B, LLVMValueRef Val); | ||
| 507 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildAddReduce(LLVMBuilderRef B, LLVMValueRef Val); | ||
| 508 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildMulReduce(LLVMBuilderRef B, LLVMValueRef Val); | ||
| 509 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPAddReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val); | ||
| 510 | ZIG_EXTERN_C LLVMValueRef ZigLLVMBuildFPMulReduce(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Val); | ||
| 511 | |||
| 512 | ZIG_EXTERN_C void ZigLLVMTakeName(LLVMValueRef new_owner, LLVMValueRef victim); | 500 | ZIG_EXTERN_C void ZigLLVMTakeName(LLVMValueRef new_owner, LLVMValueRef victim); |
| 513 | 501 | ||
| 514 | #define ZigLLVM_DIFlags_Zero 0U | 502 | #define ZigLLVM_DIFlags_Zero 0U |