Skip to content

Make the naming of underlying builtin for FP + Vector match Integer. #15430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions stdlib/public/SDK/simd/simd.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ cardinal = { 2:'two', 3:'three', 4:'four'}
@_alignment(${vecsize})
public struct ${vectype} {

public var _vector: Builtin.${llvm_vectype}
public var _value: Builtin.${llvm_vectype}

% for i in xrange(count):
public var ${component[i]} : ${scalar} {
@_transparent
get {
let elt = Builtin.${extractelement}(_vector,
let elt = Builtin.${extractelement}(_value,
(${i} as Int32)._value)

return ${scalar}(_bits: elt)
return ${scalar}(elt)
}
@_transparent
set {
_vector = Builtin.${insertelement}(_vector,
_value = Builtin.${insertelement}(_value,
newValue._value,
(${i} as Int32)._value)
}
Expand All @@ -68,8 +68,8 @@ public struct ${vectype} {
public init() { self.init(0) }

@_transparent
public init(_bits: Builtin.${llvm_vectype}) {
_vector = _bits
public init(_ _value: Builtin.${llvm_vectype}) {
self._value = _value
}

/// Initialize a vector with the specified elements.
Expand All @@ -81,7 +81,7 @@ public struct ${vectype} {
${component[i]}._value,
(${i} as Int32)._value)
% end
_vector = v
_value = v
}

/// Initialize a vector with the specified elements.
Expand Down Expand Up @@ -113,15 +113,15 @@ public struct ${vectype} {
get {
_precondition(index >= 0, "Vector index out of range")
_precondition(index < ${count}, "Vector index out of range")
let elt = Builtin.${extractelement}(_vector,
let elt = Builtin.${extractelement}(_value,
Int32(index)._value)
return ${scalar}(_bits: elt)
return ${scalar}(elt)
}
@_transparent
set(value) {
_precondition(index >= 0, "Vector index out of range")
_precondition(index < ${count}, "Vector index out of range")
_vector = Builtin.${insertelement}(_vector,
_value = Builtin.${insertelement}(_value,
value._value,
Int32(index)._value)
}
Expand Down Expand Up @@ -183,15 +183,13 @@ extension ${vectype} {
/// Vector (elementwise) sum of `lhs` and `rhs`.
@_transparent
public static func ${wrap}+(lhs: ${vectype}, rhs: ${vectype}) -> ${vectype} {
return ${vectype}(_bits:
Builtin.${prefix}add_${llvm_vectype}(lhs._vector, rhs._vector))
return ${vectype}(Builtin.${prefix}add_${llvm_vectype}(lhs._value, rhs._value))
}

/// Vector (elementwise) difference of `lhs` and `rhs`.
@_transparent
public static func ${wrap}-(lhs: ${vectype}, rhs: ${vectype}) -> ${vectype} {
return ${vectype}(_bits:
Builtin.${prefix}sub_${llvm_vectype}(lhs._vector, rhs._vector))
return ${vectype}(Builtin.${prefix}sub_${llvm_vectype}(lhs._value, rhs._value))
}

/// Negation of `rhs`.
Expand All @@ -204,8 +202,7 @@ extension ${vectype} {
/// vector product).
@_transparent
public static func ${wrap}*(lhs: ${vectype}, rhs: ${vectype}) -> ${vectype} {
return ${vectype}(_bits:
Builtin.${prefix}mul_${llvm_vectype}(lhs._vector, rhs._vector))
return ${vectype}(Builtin.${prefix}mul_${llvm_vectype}(lhs._value, rhs._value))
}

/// Scalar-Vector product.
Expand All @@ -223,8 +220,7 @@ extension ${vectype} {
/// Elementwise quotient of `lhs` and `rhs`.
@_transparent
public static func /(lhs: ${vectype}, rhs: ${vectype}) -> ${vectype} {
return ${vectype}(_bits:
Builtin.${divide}_${llvm_vectype}(lhs._vector, rhs._vector))
return ${vectype}(Builtin.${divide}_${llvm_vectype}(lhs._value, rhs._value))
}

/// Divide vector by scalar.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/BuiltinMath.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def TypedUnaryIntrinsicFunctions():
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public func _${ufunc}(_ x: ${T}) -> ${T} {
return ${T}(_bits: Builtin.int_${ufunc}_FPIEEE${bits}(x._value))
return ${T}(Builtin.int_${ufunc}_FPIEEE${bits}(x._value))
}
% if bits == 80:
#endif
Expand Down
22 changes: 11 additions & 11 deletions stdlib/public/core/FloatingPointTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public struct ${Self} {
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public // @testable
init(_bits v: Builtin.FPIEEE${bits}) {
self._value = v
init(_ _value: Builtin.FPIEEE${bits}) {
self._value = _value
}
}

Expand Down Expand Up @@ -214,7 +214,7 @@ extension ${Self}: BinaryFloatingPoint {
/// - Parameter bitPattern: The integer encoding of a `${Self}` instance.
@_inlineable // FIXME(sil-serialize-all)
public init(bitPattern: UInt${bits}) {
self.init(_bits: Builtin.bitcast_Int${bits}_FPIEEE${bits}(bitPattern._value))
self.init(Builtin.bitcast_Int${bits}_FPIEEE${bits}(bitPattern._value))
}

/// The sign of the floating-point value.
Expand Down Expand Up @@ -1449,7 +1449,7 @@ extension ${Self} : _ExpressibleByBuiltinIntegerLiteral, ExpressibleByIntegerLit
@_transparent
public
init(_builtinIntegerLiteral value: Builtin.Int${builtinIntLiteralBits}){
self = ${Self}(_bits: Builtin.itofp_with_overflow_Int${builtinIntLiteralBits}_FPIEEE${bits}(value))
self = ${Self}(Builtin.itofp_with_overflow_Int${builtinIntLiteralBits}_FPIEEE${bits}(value))
}

/// Creates a new value from the given integer literal.
Expand All @@ -1468,7 +1468,7 @@ extension ${Self} : _ExpressibleByBuiltinIntegerLiteral, ExpressibleByIntegerLit
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public init(integerLiteral value: Int64) {
self = ${Self}(_bits: Builtin.sitofp_Int64_FPIEEE${bits}(value._value))
self = ${Self}(Builtin.sitofp_Int64_FPIEEE${bits}(value._value))
}
}

Expand All @@ -1483,9 +1483,9 @@ extension ${Self} : _ExpressibleByBuiltinFloatLiteral {
public
init(_builtinFloatLiteral value: Builtin.FPIEEE${builtinFloatLiteralBits}) {
% if bits == builtinFloatLiteralBits:
self = ${Self}(_bits: value)
self = ${Self}(value)
% elif bits < builtinFloatLiteralBits:
self = ${Self}(_bits: Builtin.fptrunc_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
self = ${Self}(Builtin.fptrunc_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
% else:
// FIXME: This is actually losing precision <rdar://problem/14073102>.
self = ${Self}(Builtin.fpext_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
Expand All @@ -1503,10 +1503,10 @@ extension ${Self} : _ExpressibleByBuiltinFloatLiteral {
public
init(_builtinFloatLiteral value: Builtin.FPIEEE${builtinFloatLiteralBits}) {
% if bits == builtinFloatLiteralBits:
self = ${Self}(_bits: value)
self = ${Self}(value)
% elif bits < builtinFloatLiteralBits:
// FIXME: This can result in double rounding errors (SR-7124).
self = ${Self}(_bits: Builtin.fptrunc_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
self = ${Self}(Builtin.fptrunc_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
% else:
// FIXME: This is actually losing precision <rdar://problem/14073102>.
self = ${Self}(Builtin.fpext_FPIEEE${builtinFloatLiteralBits}_FPIEEE${bits}(value))
Expand Down Expand Up @@ -1569,15 +1569,15 @@ extension ${Self} {
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public var magnitude: ${Self} {
return ${Self}(_bits: Builtin.int_fabs_FPIEEE${bits}(_value))
return ${Self}(Builtin.int_fabs_FPIEEE${bits}(_value))
}
}

extension ${Self} {
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public static prefix func - (x: ${Self}) -> ${Self} {
return ${Self}(_bits: Builtin.fneg_FPIEEE${bits}(x._value))
return ${Self}(Builtin.fneg_FPIEEE${bits}(x._value))
}
}

Expand Down
8 changes: 0 additions & 8 deletions stdlib/public/core/Integers.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -3290,14 +3290,6 @@ ${assignmentOperatorComment('%', True)}
self._value = _value
}

// FIXME(integers): in order to remove this, the simd.swift.gyb should be
// updated
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public init(_bits: Builtin.Int${bits}) {
self._value = _bits
}

% for x in binaryBitwise:
${assignmentOperatorComment(x.operator, True)}
@_inlineable // FIXME(sil-serialize-all)
Expand Down
2 changes: 1 addition & 1 deletion test/DebugInfo/vector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public struct float2 {
get {
let elt = Builtin.extractelement_Vec2xFPIEEE32_Int32(_vector,
Int32(index)._value)
return Float(_bits: elt)
return Float(elt)
}
}
}
2 changes: 1 addition & 1 deletion test/stdlib/FloatingPoint.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension Float80 {
Builtin.zextOrBitCast_Int64_Int80((64 as Int64)._value))
result = Builtin.or_Int80(
result, Builtin.zextOrBitCast_Int64_Int80(bitPattern.significand._value))
self = Float80(_bits: Builtin.bitcast_Int80_FPIEEE80(result))
self = Float80(Builtin.bitcast_Int80_FPIEEE80(result))
}
}

Expand Down