diff --git a/README.md b/README.md index d9ef33d1..443f2ef3 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,22 @@ build. Once you do that, you can add LLVMSwift as a dependency for your own Swift compiler projects! +### Installation without Swift Package Manager + +We really recommend using SwiftPM with LLVMSwift, but if your project is +structured in such a way that makes using SwiftPM impractical or impossible, +you can still use LLVMSwift by passing the `-DNO_SWIFTPM` to swift when +compiling. + +- Xcode: + - Add this repository as a git submodule + - Add the files in `Sources/` to your Xcode project. + - Under `Other Swift Flags`, add `-DNO_SWIFTPM`. + - Under `Library Search Paths` add the output of `llvm-config --libdir` + - Under `Header Search Paths` add the output of `llvm-config --includedir` + - Under `Link Target with Libraries` drag in + `/path/to/your/llvm/lib/libLLVM.dylib` + This project is used by [Trill](https://github.com/harlanhaskins/trill) for all its code generation. diff --git a/Sources/LLVM/Alias.swift b/Sources/LLVM/Alias.swift index b186846f..c90d480f 100644 --- a/Sources/LLVM/Alias.swift +++ b/Sources/LLVM/Alias.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// An `Alias` represents a global alias in an LLVM module - a new symbol and /// corresponding metadata for an existing position diff --git a/Sources/LLVM/ArrayType.swift b/Sources/LLVM/ArrayType.swift index 04eca4bf..9d3ab61f 100644 --- a/Sources/LLVM/ArrayType.swift +++ b/Sources/LLVM/ArrayType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `ArrayType` is a very simple derived type that arranges elements /// sequentially in memory. `ArrayType` requires a size (number of elements) and diff --git a/Sources/LLVM/BasicBlock.swift b/Sources/LLVM/BasicBlock.swift index e035e1a0..93be9bc3 100644 --- a/Sources/LLVM/BasicBlock.swift +++ b/Sources/LLVM/BasicBlock.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A `BasicBlock` represents a basic block in an LLVM IR program. A basic /// block contains a sequence of instructions, a pointer to its parent block and diff --git a/Sources/LLVM/FloatType.swift b/Sources/LLVM/FloatType.swift index 78201e03..9e1d2f7f 100644 --- a/Sources/LLVM/FloatType.swift +++ b/Sources/LLVM/FloatType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `FloatType` enumerates representations of a floating value of a particular /// bit width and semantics. diff --git a/Sources/LLVM/Function.swift b/Sources/LLVM/Function.swift index 0cbcbc0c..d38de2cb 100644 --- a/Sources/LLVM/Function.swift +++ b/Sources/LLVM/Function.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// Enumerates the calling conventions supported by LLVM. /// diff --git a/Sources/LLVM/FunctionType.swift b/Sources/LLVM/FunctionType.swift index 8d88e81b..acc9cc3b 100644 --- a/Sources/LLVM/FunctionType.swift +++ b/Sources/LLVM/FunctionType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `FunctionType` represents a function's type signature. It consists of a /// return type and a list of formal parameter types. The return type of a diff --git a/Sources/LLVM/Global.swift b/Sources/LLVM/Global.swift index 6225d505..1d0fcd1b 100644 --- a/Sources/LLVM/Global.swift +++ b/Sources/LLVM/Global.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A `Global` represents a region of memory allocated at compile time instead /// of at runtime. A global variable must either have an initializer, or make diff --git a/Sources/LLVM/IRBuilder.swift b/Sources/LLVM/IRBuilder.swift index e07ef987..a1a0a44d 100644 --- a/Sources/LLVM/IRBuilder.swift +++ b/Sources/LLVM/IRBuilder.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// Species the behavior that should occur on overflow during mathematical /// operations. diff --git a/Sources/LLVM/IRGlobal.swift b/Sources/LLVM/IRGlobal.swift index 66a01400..59be0d30 100644 --- a/Sources/LLVM/IRGlobal.swift +++ b/Sources/LLVM/IRGlobal.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// An `IRGlobal` is a value, alias, or function that exists at the top level of /// an LLVM module. diff --git a/Sources/LLVM/IRType.swift b/Sources/LLVM/IRType.swift index 3ed96354..1fb9693f 100644 --- a/Sources/LLVM/IRType.swift +++ b/Sources/LLVM/IRType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// An `IRType` is a type that is capable of lowering itself to an `LLVMTypeRef` /// object for use with LLVM's C API. diff --git a/Sources/LLVM/IRValue+Kinds.swift b/Sources/LLVM/IRValue+Kinds.swift index ae7967cf..8168c091 100644 --- a/Sources/LLVM/IRValue+Kinds.swift +++ b/Sources/LLVM/IRValue+Kinds.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif // Automatically generated from the macros in llvm/Core.h diff --git a/Sources/LLVM/IRValue.swift b/Sources/LLVM/IRValue.swift index 76be97c7..2aa739a8 100644 --- a/Sources/LLVM/IRValue.swift +++ b/Sources/LLVM/IRValue.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// An `IRValue` is a type that is capable of lowering itself to an /// `LLVMValueRef` object for use with LLVM's C API. diff --git a/Sources/LLVM/Initialization.swift b/Sources/LLVM/Initialization.swift index 51b65545..652e7784 100644 --- a/Sources/LLVM/Initialization.swift +++ b/Sources/LLVM/Initialization.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// Lazy static initializer that calls LLVM initialization functions only once. let llvmInitializer: Void = { diff --git a/Sources/LLVM/Instruction.swift b/Sources/LLVM/Instruction.swift index 7febf71e..f7987c80 100644 --- a/Sources/LLVM/Instruction.swift +++ b/Sources/LLVM/Instruction.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// An `Instruction` represents an instruction residing in a basic block. public struct Instruction: IRValue { diff --git a/Sources/LLVM/IntType.swift b/Sources/LLVM/IntType.swift index aa20a533..b7f88eae 100644 --- a/Sources/LLVM/IntType.swift +++ b/Sources/LLVM/IntType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// The `IntType` represents an integral value of a specified bit width. /// diff --git a/Sources/LLVM/JIT.swift b/Sources/LLVM/JIT.swift index 3e130fd3..cb7ef9c7 100644 --- a/Sources/LLVM/JIT.swift +++ b/Sources/LLVM/JIT.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// JITError represents the different kinds of errors the JIT compiler can /// throw. diff --git a/Sources/LLVM/LabelType.swift b/Sources/LLVM/LabelType.swift index 4c9a96ca..c3518b82 100644 --- a/Sources/LLVM/LabelType.swift +++ b/Sources/LLVM/LabelType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `LabelType` represents code labels. public struct LabelType: IRType { diff --git a/Sources/LLVM/Linkage.swift b/Sources/LLVM/Linkage.swift index 7a59f357..49839ede 100644 --- a/Sources/LLVM/Linkage.swift +++ b/Sources/LLVM/Linkage.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `Visibility` enumerates available visibility styles. public enum Visibility { diff --git a/Sources/LLVM/MemoryBuffer.swift b/Sources/LLVM/MemoryBuffer.swift index 28d6ef7e..cbea7a21 100644 --- a/Sources/LLVM/MemoryBuffer.swift +++ b/Sources/LLVM/MemoryBuffer.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// Enumerates the possible failures that can be thrown initializing /// a MemoryBuffer. diff --git a/Sources/LLVM/MetadataType.swift b/Sources/LLVM/MetadataType.swift index 27c168b8..3fc03731 100644 --- a/Sources/LLVM/MetadataType.swift +++ b/Sources/LLVM/MetadataType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// The `MetadataType` type represents embedded metadata. No derived types may /// be created from metadata except for function arguments. diff --git a/Sources/LLVM/Module.swift b/Sources/LLVM/Module.swift index dbf93d98..26a6a7b3 100644 --- a/Sources/LLVM/Module.swift +++ b/Sources/LLVM/Module.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A `Context` represents execution states for the core LLVM IR system. public class Context { diff --git a/Sources/LLVM/OpCode.swift b/Sources/LLVM/OpCode.swift index bdb71bc3..ac2c1867 100644 --- a/Sources/LLVM/OpCode.swift +++ b/Sources/LLVM/OpCode.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// Enumerates the opcodes of instructions available in the LLVM IR language. /// diff --git a/Sources/LLVM/PassManager.swift b/Sources/LLVM/PassManager.swift index 5919c158..d04fdaa8 100644 --- a/Sources/LLVM/PassManager.swift +++ b/Sources/LLVM/PassManager.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A subset of supported LLVM IR optimizer passes. public enum FunctionPass { diff --git a/Sources/LLVM/PhiNode.swift b/Sources/LLVM/PhiNode.swift index e099899c..e04b9e73 100644 --- a/Sources/LLVM/PhiNode.swift +++ b/Sources/LLVM/PhiNode.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A `PhiNode` object represents a PHI node. /// diff --git a/Sources/LLVM/PointerType.swift b/Sources/LLVM/PointerType.swift index 08a7949a..a1a5d397 100644 --- a/Sources/LLVM/PointerType.swift +++ b/Sources/LLVM/PointerType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `PointerType` is used to specify memory locations. Pointers are commonly /// used to reference objects in memory. diff --git a/Sources/LLVM/StructType.swift b/Sources/LLVM/StructType.swift index 3ee8c95b..39c5bdea 100644 --- a/Sources/LLVM/StructType.swift +++ b/Sources/LLVM/StructType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `StructType` is used to represent a collection of data members together in /// memory. The elements of a structure may be any type that has a size. diff --git a/Sources/LLVM/Switch.swift b/Sources/LLVM/Switch.swift index 313cff9a..ccb77561 100644 --- a/Sources/LLVM/Switch.swift +++ b/Sources/LLVM/Switch.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A `Switch` represents a `switch` instruction. A `switch` instruction /// defines a jump table of values and destination basic blocks to pass the flow diff --git a/Sources/LLVM/TargetData.swift b/Sources/LLVM/TargetData.swift index dcb25633..eeca2d4e 100644 --- a/Sources/LLVM/TargetData.swift +++ b/Sources/LLVM/TargetData.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A `TargetData` encapsulates information about the data requirements of a /// particular target architecture and can be used to retrieve information about diff --git a/Sources/LLVM/TargetMachine.swift b/Sources/LLVM/TargetMachine.swift index 679401e6..257f1b43 100644 --- a/Sources/LLVM/TargetMachine.swift +++ b/Sources/LLVM/TargetMachine.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// The supported types of files codegen can produce. public enum CodegenFileType { diff --git a/Sources/LLVM/TokenType.swift b/Sources/LLVM/TokenType.swift index 3c112fd2..0895655c 100644 --- a/Sources/LLVM/TokenType.swift +++ b/Sources/LLVM/TokenType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `TokenType` is used when a value is associated with an instruction but all /// uses of the value must not attempt to introspect or obscure it. As such, it diff --git a/Sources/LLVM/Use.swift b/Sources/LLVM/Use.swift index c92884f2..8cebf4bb 100644 --- a/Sources/LLVM/Use.swift +++ b/Sources/LLVM/Use.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `Use` represents an iterator over the uses and users of a particular value /// in an LLVM program. diff --git a/Sources/LLVM/VectorType.swift b/Sources/LLVM/VectorType.swift index e6cba45b..4a47c409 100644 --- a/Sources/LLVM/VectorType.swift +++ b/Sources/LLVM/VectorType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// A `VectorType` is a simple derived type that represents a vector of /// elements. `VectorType`s are used when multiple primitive data are operated diff --git a/Sources/LLVM/VoidType.swift b/Sources/LLVM/VoidType.swift index ef7f5bc5..ad4a02c0 100644 --- a/Sources/LLVM/VoidType.swift +++ b/Sources/LLVM/VoidType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// The `Void` type represents any value and has no size. public struct VoidType: IRType { diff --git a/Sources/LLVM/X86MMXType.swift b/Sources/LLVM/X86MMXType.swift index 79f8c9be..624c8a94 100644 --- a/Sources/LLVM/X86MMXType.swift +++ b/Sources/LLVM/X86MMXType.swift @@ -1,4 +1,6 @@ +#if !NO_SWIFTPM import cllvm +#endif /// `X86MMXType` represents a value held in an MMX register on an x86 machine. ///