Skip to content
Closed
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
46 changes: 0 additions & 46 deletions .github/actions/build-swift-project-macos/action.yml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/actions/checkout-swift-headers/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Checkout Swift Headers
description: |
This action checks-out certain header files from the swiftlang/swift
repository.

inputs:
path:
description: Relative path under $GITHUB_WORKSPACE to place the repository
required: true
swift-version-major:
description: The Swift toolchain major version.
required: true
swift-version-minor:
description: The Swift toolchain minor version.
required: true

runs:
using: "composite"
steps:
- uses: actions/checkout@v4
with:
repository: swiftlang/swift
path: ${{ inputs.path }}
ref: release/${{ inputs.swift-version-major }}.${{ inputs.swift-version-minor }}
sparse-checkout: |
include/swift
stdlib/include
stdlib/public/SwiftShims
stdlib/public/runtime/MetadataAllocatorTags.def
- name: Write CMakeConfig.h file
run: |
cat > include/swift/Runtime/CMakeConfig.h << EOF
#ifndef SWIFT_RUNTIME_CMAKECONFIG_H
#define SWIFT_RUNTIME_CMAKECONFIG_H
#define SWIFT_VERSION_MAJOR "${SWIFT_VERSION_MAJOR}"
#define SWIFT_VERSION_MINOR "${SWIFT_VERSION_MINOR}"
#endif
EOF
shell: bash
working-directory: ${{ inputs.path }}
env:
SWIFT_VERSION_MAJOR: ${{ inputs.swift-version-major }}
SWIFT_VERSION_MINOR: ${{ inputs.swift-version-minor }}
14 changes: 9 additions & 5 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/checkout-swift-headers
with:
path: Compute
- uses: ./Compute/.github/actions/build-swift-project-macos
with:
checkout-scheme: release/6.2
path: Checkouts/swift
swift-version-major: 6
swift-version-minor: 2
- name: Build
run: swift build
working-directory: ./Compute
- name: Test
run: |
swift test --filter UtilitiesTests
swift test --filter ComputeLayoutDescriptorTests
swift test --filter ComputeTests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
# Swift
.build
.swiftpm

# Dependencies
Checkouts
18 changes: 7 additions & 11 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import PackageDescription

let swiftProjectPath = "\(Context.packageDirectory)/../swift-project"
let swiftCheckoutPath = "\(Context.packageDirectory)/Checkouts/swift"

var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-algorithms", from: "1.2.0"),
Expand Down Expand Up @@ -51,16 +51,9 @@ extension Target {
"-static",
"-DCOMPILED_WITH_SWIFT",
"-DPURE_BRIDGING_MODE",
"-UIBOutlet", "-UIBAction", "-UIBInspectable",
"-isystem", "\(swiftProjectPath)/swift/include",
"-isystem", "\(swiftProjectPath)/swift/stdlib/public/SwiftShims",
"-isystem", "\(swiftProjectPath)/swift/stdlib/public/runtime",
"-isystem", "\(swiftProjectPath)/llvm-project/llvm/include",
"-isystem", "\(swiftProjectPath)/llvm-project/clang/include",
"-isystem", "\(swiftProjectPath)/build/Default/swift/include",
"-isystem", "\(swiftProjectPath)/build/Default/llvm/include",
"-isystem", "\(swiftProjectPath)/build/Default/llvm/tools/clang/include",
"-DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING",
"-isystem", "\(swiftCheckoutPath)/include",
"-isystem", "\(swiftCheckoutPath)/stdlib/include",
"-isystem", "\(swiftCheckoutPath)/stdlib/public/SwiftShims"
])
] + cxxSettings
)
Expand All @@ -73,6 +66,9 @@ let package = Package(
products: [
.library(name: "Compute", targets: ["Compute"])
],
traits: [
.trait(name: "CompatibilityModeAttributeGraphV6")
],
dependencies: dependencies,
targets: [
.target(
Expand Down
8 changes: 5 additions & 3 deletions Sources/Compute/Attribute/AnyAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension Graph {
_ attribute: AnyAttribute,
type: Metadata,
invalidating: Bool,
modify: (UnsafeMutableRawPointer) -> Void
modify: @escaping (UnsafeMutableRawPointer) -> Void
)

}
Expand All @@ -35,8 +35,10 @@ extension AnyAttribute {
}

public func mutateBody<Body>(as type: Body.Type, invalidating: Bool, _ mutator: (inout Body) -> Void) {
Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in
mutator(&pointer.assumingMemoryBound(to: Body.self).pointee)
withoutActuallyEscaping(mutator) { escapingMutator in
Graph.mutateAttribute(self, type: Metadata(type), invalidating: invalidating) { pointer in
escapingMutator(&pointer.assumingMemoryBound(to: Body.self).pointee)
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion Sources/Compute/Attribute/Attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ public struct Attribute<Value> {
let typeID = graphContext.internAttributeType(
type: Metadata(Body.self)
) {
let bodyType: _AttributeBody.Type
#if CompatibilityModeAttributeGraphV6
bodyType = Body.self
#else
bodyType = flags.contains(.external) ? _External.self : Body.self
#endif
let attributeType =
_AttributeType(
selfType: flags.contains(.external) ? _External.self : Body.self,
selfType: bodyType,
valueType: Value.self,
flags: flags,
update: update()
Expand Down
2 changes: 1 addition & 1 deletion Sources/ComputeCxx/Graph/Graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ void Graph::indirect_attribute_set(data::ptr<IndirectNode> indirect_node, Attrib
}

uint64_t source_subgraph_id = source && !source.is_nil() ? source.subgraph()->subgraph_id() : 0;
indirect_node->modify(WeakAttributeID(source, source_subgraph_id), resolved_source.offset());
indirect_node->modify(WeakAttributeID(source, uint32_t(source_subgraph_id)), resolved_source.offset());
indirect_node->set_traverses_contexts(AttributeID(indirect_node).subgraph()->context_id() !=
source.subgraph()->context_id());

Expand Down
8 changes: 3 additions & 5 deletions Sources/ComputeCxx/Swift/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <CommonCrypto/CommonDigest.h>
#include <CoreFoundation/CFString.h>
#include <SwiftEquatableSupport.h>
#include <swift/Runtime/Casting.h>
#include <swift/Runtime/ExistentialContainer.h>
#include <swift/Runtime/HeapObject.h>
Expand Down Expand Up @@ -273,12 +272,11 @@ const equatable_witness_table *metadata::equatable() const {
if (!nsobject_metadata) {
return nullptr;
}
auto witness_table =
swift_conformsToProtocol(nsobject_metadata, &::swift::equatable_support::EquatableProtocolDescriptor);
auto witness_table = swift_conformsToProtocol(nsobject_metadata, EquatableProtocolDescriptor);
return reinterpret_cast<const equatable_witness_table *>(witness_table);
}();
auto conformance = reinterpret_cast<const equatable_witness_table *>(
swift_conformsToProtocol(this, &::swift::equatable_support::EquatableProtocolDescriptor));
swift_conformsToProtocol(this, &EquatableProtocolDescriptor));
if (conformance == nsobject_conformance) {
return nullptr;
}
Expand All @@ -288,7 +286,7 @@ const equatable_witness_table *metadata::equatable() const {
case ::swift::MetadataKind::Enum:
case ::swift::MetadataKind::Optional:
case ::swift::MetadataKind::Tuple: {
auto witness_table = swift_conformsToProtocol(this, &::swift::equatable_support::EquatableProtocolDescriptor);
auto witness_table = swift_conformsToProtocol(this, &EquatableProtocolDescriptor);
return reinterpret_cast<const equatable_witness_table *>(witness_table);
}
default:
Expand Down
10 changes: 8 additions & 2 deletions Sources/ComputeCxx/Swift/Metadata.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
#pragma once

#include <CoreFoundation/CFBase.h>
#include <SwiftEquatableSupport.h>
#include <swift/Demangling/ManglingMacros.h>
#include <swift/Runtime/Metadata.h>

#include "Comparison/LayoutDescriptor.h"

CF_ASSUME_NONNULL_BEGIN

CF_EXPORT
const void *PROTOCOL_DESCR_SYM(SQ);

namespace AG {
namespace swift {

static constexpr auto &EquatableProtocolDescriptor = PROTOCOL_DESCR_SYM(SQ);

struct equatable_witness_table;

using opaque_value = ::swift::OpaqueValue;
using equatable_witness_table = ::swift::equatable_support::EquatableWitnessTable;

class metadata_visitor;
class context_descriptor;
Expand Down
3 changes: 1 addition & 2 deletions Sources/ComputeCxx/Swift/SwiftShims.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <CoreFoundation/CFBase.h>
#include <CoreFoundation/CFDictionary.h>
#include <CoreFoundation/CFString.h>
#include <SwiftEquatableSupport.h>

#include "ComputeCxx/AGSwiftSupport.h"

Expand All @@ -13,7 +12,7 @@ CF_EXTERN_C_BEGIN

AG_SWIFT_CC(swift)
bool AGDispatchEquatable(const void *lhs_value, const void *rhs_value, const ::swift::Metadata *type,
const ::swift::equatable_support::EquatableWitnessTable *wt);
const AG::swift::equatable_witness_table *wt);

#ifdef __OBJC__
AG_SWIFT_CC(swift)
Expand Down
Loading
Loading