Skip to content

Feat: Restructure code & manage Packages #4

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 42 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
bf82b36
Create tech stack docs (techstack.yml and techstack.md) (#1)
stack-file[bot] Jan 20, 2024
101213b
Merge branch 'master' of github.com:mrLSD/llvm-codegen
mrLSD Sep 6, 2021
47fa270
Extend Context functions
mrLSD Sep 7, 2021
40c75f7
Context API completed. Updated readme
mrLSD Sep 7, 2021
f9b3d2c
Updated Library properties. Renamed dir structure
mrLSD Sep 19, 2021
b3e1018
Refactoring for LLVM-Core module
mrLSD Sep 19, 2021
6759dc7
Added Core module
mrLSD Sep 20, 2021
1a36aba
Added LLVMOpcode. Changed LLVMTypeKind
mrLSD Sep 23, 2021
9015a8c
Extend Types with: Linkage, Visibility, UnnamedAddr, DLLStorageClass,…
mrLSD Sep 24, 2021
f03ee96
Extend types with: DiagnosticSeverity, AtomicRMWBinOp, AtomicOrdering…
mrLSD Sep 26, 2021
21ad776
Added Types: attributes
mrLSD Sep 28, 2021
169d1de
Added Constants
mrLSD Sep 30, 2021
f20adb8
Scalar constants
mrLSD Oct 1, 2021
7ce4e17
Scalar constants - extend
mrLSD Oct 3, 2021
21f4aef
Added CompositeConstant
mrLSD Oct 4, 2021
86c3973
Extend: CompositeConstant
mrLSD Oct 5, 2021
2ae6d13
Added constant expressions
mrLSD Oct 7, 2021
3ed76ed
Extend ConstantExpressions
mrLSD Oct 7, 2021
8e59019
Update to LLVM-18
mrLSD Oct 13, 2021
514aadb
Update CI
mrLSD Oct 11, 2021
ffac36d
Update CI
mrLSD Oct 12, 2021
c8ccd2d
Update CI
mrLSD Oct 12, 2021
8051752
Update CI
mrLSD Oct 15, 2021
74953ef
Update CI
mrLSD Oct 15, 2021
7e193db
Update CI
mrLSD Oct 15, 2021
dee9045
Update CI
mrLSD Oct 15, 2021
03b1e5f
Update CI
mrLSD Oct 15, 2021
1c3523c
Remove: Value constant expressions
mrLSD Oct 16, 2021
3a5e369
Refactored Package LLVM config
mrLSD Oct 17, 2021
503e134
Added LLVM-18
mrLSD Oct 17, 2021
2b9ee1c
Remove utils, and updated CI
mrLSD Oct 18, 2021
b11616f
Update README
mrLSD Oct 18, 2021
28627f8
Update README
mrLSD Oct 18, 2021
7c12785
Extend Modules
mrLSD Oct 19, 2021
c43e751
Update Package.swift conditional config
mrLSD Oct 20, 2021
7b72ed6
Update CI conditional build
mrLSD Oct 21, 2021
4b5c322
Restructure project and extend README
mrLSD Jul 17, 2024
2c3a082
Exnted Module with Flag and Metadata funcitons
mrLSD Oct 22, 2021
0157b3d
Extend README
mrLSD Jul 22, 2024
647e0c7
Merge pull request #2 from mrLSD/feat/extend-module
mrLSD Jul 23, 2024
fe59e51
Merge branch 'master' into feat/restructure
mrLSD Jul 23, 2024
93ed8fe
Merge branch 'master' into feat/restructure
mrLSD Oct 25, 2021
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
10 changes: 5 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func getTargets() -> [Target] {
let llvmTarget: Target = .target(
name: "LLVM",
dependencies: ["CLLVM"],
path: "llvm-api/LLVM",
// path: "llvm-api/LLVM",
cSettings: [
.unsafeFlags(cFlags),
],
Expand All @@ -103,13 +103,13 @@ func getTargets() -> [Target] {
} else {
let customSystemLibrary: Target = .systemLibrary(
name: "CLLVM",
path: "llvm-api/CLLVM",
pkgConfig: "cllvm"
// path: "llvm-api/CLLVM",
pkgConfig: "llvm"
)
let llvmTarget: Target = .target(
name: "LLVM",
dependencies: ["CLLVM"],
path: "llvm-api/LLVM"
dependencies: ["CLLVM"]
// path: "llvm-api/LLVM"
)
return [customSystemLibrary, llvmTarget]
}
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ brew install llvm
- [x] v17.0
- [x] v18.0

### XCode support

To develop correctly with XCode it's necessary to generate package-config: `llvm.pc`:
- `sh utils/llvm-pkg.swift` - will generate package config and copy to your default `pkg-config` path.

After that XCode should correctly recognize LLVM headers path, and can build project.

### Troubleshooting

Expand All @@ -108,6 +114,9 @@ llc --version
brew info llvm
```

- **conditional build**: `Package.swift` supports conditional builds:
- for CLI build: `CLI_BUILD swift build` - it get's LLVM veriabels form Environment sets.
- `swift build` - if presented `llvm.pc` package config
- To get more insights take a look current project [Github CI config](.github/workflows/swift.yaml).

### LICENS: [MIT](LICENSE)
39 changes: 39 additions & 0 deletions Source/CLLVM/bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// bridge.h
// llvm-codegen
//
// Created by Evgeny Ukhanov on 22/12/2023.
//

#ifndef bridge_h
#define bridge_h

#include <llvm-c/Transforms/PassBuilder.h>
#include <llvm-c/Analysis.h>
#include <llvm-c/BitReader.h>
#include <llvm-c/BitWriter.h>
#include <llvm-c/Comdat.h>
#include <llvm-c/Core.h>
#include <llvm-c/DataTypes.h>
#include <llvm-c/DebugInfo.h>
#include <llvm-c/Disassembler.h>
#include <llvm-c/DisassemblerTypes.h>
#include <llvm-c/Error.h>
#include <llvm-c/ErrorHandling.h>
#include <llvm-c/ExecutionEngine.h>
#include <llvm-c/ExternC.h>
#include <llvm-c/IRReader.h>
#include <llvm-c/LLJIT.h>
#include <llvm-c/Linker.h>
#include <llvm-c/Object.h>
#include <llvm-c/Orc.h>
#include <llvm-c/OrcEE.h>
#include <llvm-c/Remarks.h>
#include <llvm-c/Support.h>
#include <llvm-c/Target.h>
#include <llvm-c/TargetMachine.h>
#include <llvm-c/Types.h>
#include <llvm-c/blake3.h>
#include <llvm-c/lto.h>

#endif /* bridge_h */
11 changes: 11 additions & 0 deletions Source/CLLVM/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// module.modulemap
// llvm-codegen
//
// Created by Evgeny Ukhanov on 22/12/2023.
//

module CLLVM [system] {
header "bridge.h"
export *
}
64 changes: 64 additions & 0 deletions Source/LLVM/Core/AddressSpace.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import CLLVM

/// An address space is an identifier for a target-specific range of address values. An address space is a
/// fundamental part of the type of a pointer value and the type of operations that manipulate memory.
///
/// LLVM affords a default address space (numbered zero) and places a number of assumptions on pointer
/// values within that address space:
/// - The pointer must have a fixed integral value
/// - The null pointer has a bit-value of 0
///
/// These assumptions are not guaranteed to hold in any other address space. In particular, a target may
/// allow pointers in non-default address spaces to have *non-integral* types. Non-integral pointer types
/// represent pointers that have an unspecified bitwise representation; that is, the integral representation may
/// be target dependent or have an unstable value. Further, outside of the default address space, it is not
/// always the case that the `null` pointer value, especially as returned by
/// `constPointerNull()` has a bit value of 0. e.g. A non-default address space may use
/// an offset-based or segment-based addressing mode in which 0 is a valid, addressable pointer value.
///
/// Target-Level Address Space Overrides
/// ====================================
///
/// A target may choose to override the default address space for code, data, and local allocations through the
/// data layout string. This has multiple uses. For example, the address space of an `alloca` is *only*
/// configurable via the data layout string, because it is a target-dependent property. There are also
/// use-cases for overriding language standards e.g. the C standard requires the address-of operator applied
/// to values on the stack to result in a pointer in the default address space. However, many OpenCL-based
/// targets consider the stack to be a private region, and place such pointers in a non-default address space.
///
/// Care must be taken when interacting with these non-standard targets. The IR printer currently does not
/// print anything when the default address space is attached to an instruction or value, and values will still
/// report being assigned to that space. However, these values are still subject to the backend's interpretation
/// of the data layout string overrides and as such may not always reside in the default address space when
/// it comes time to codegen them.
///
/// Restrictions
/// ============
///
/// There are currently a number of artificial restrictions on values and operations that have non-default
/// address spaces:
/// - A `bitcast` between two pointer values residing in different address spaces, even if those two
/// values have the same size, is always an illegal operation. Use an `addrspacecast` instead or
/// always use `buildPointerCast()` to get the correct operation.
/// - The so-called "null pointer" has a bit value that may differ from address space to address space. This
/// exposes bugs in optimizer passes and lowerings that did not consider this possibility.
/// - A pointer value may not necessarily "round-trip" when converted between address spaces, even if
/// annotated `nonnull` and `dereferenceable`. This is especially true of non-integral pointer types.
/// - Though the zero address space is the default, many backends and some errant passes interpret this to
/// mean a "lack of address space" and may miscompile code with pointers in mixed address spaces.
/// - A number of intriniscs that operate on memory currently do not support a non-default address space.
/// - The address space is ultimately an integer value and in theory an address space identifier may take on
/// any value. In practice, LLVM guarantees only 24 bits of precision, though higher address space
/// identifiers may succeed in being properly represented.
public struct AddressSpace: Equatable {
let rawValue: UInt32

/// LLVM's default address space.
public static let zero = AddressSpace(0)

/// Creates and initializes an address space with the given identifier.
/// - Parameter identifier: The raw, integral address space identifier.
public init(_ identifier: UInt32) {
rawValue = identifier
}
}
Loading
Loading