about summary refs log tree commit diff
path: root/src/librustc_llvm/lib.rs
AgeCommit message (Collapse)AuthorLines
2016-12-29Fallout from updating bootstrap CargoAlex Crichton-2/+1
2016-12-26PTX supportJorge Aparicio-0/+5
- `--emit=asm --target=nvptx64-nvidia-cuda` can be used to turn a crate into a PTX module (a `.s` file). - intrinsics like `__syncthreads` and `blockIdx.x` are exposed as `"platform-intrinsics"`. - "cabi" has been implemented for the nvptx and nvptx64 architectures. i.e. `extern "C"` works. - a new ABI, `"ptx-kernel"`. That can be used to generate "global" functions. Example: `extern "ptx-kernel" fn kernel() { .. }`. All other functions are "device" functions.
2016-12-26Auto merge of #38314 - japaric:do-not-delete-enable-llvm-backend, r=alexcrichtonbors-0/+6
initial SPARC support ### UPDATE Can now compile `no_std` executables with: ``` $ cargo new --bin app && cd $_ $ edit Cargo.toml && tail -n2 $_ [dependencies] core = { path = "/path/to/rust/src/libcore" } $ edit src/main.rs && cat $_ #![feature(lang_items)] #![no_std] #![no_main] #[no_mangle] pub fn _start() -> ! { loop {} } #[lang = "panic_fmt"] fn panic_fmt() -> ! { loop {} } $ edit sparc-none-elf.json && cat $_ { "arch": "sparc", "data-layout": "E-m:e-p:32:32-i64:64-f128:64-n32-S64", "executables": true, "llvm-target": "sparc", "os": "none", "panic-strategy": "abort", "target-endian": "big", "target-pointer-width": "32" } $ cargo rustc --target sparc-none-elf -- -C linker=sparc-unknown-elf-gcc -C link-args=-nostartfiles $ file target/sparc-none-elf/debug/app app: ELF 32-bit MSB executable, SPARC, version 1 (SYSV), statically linked, not stripped $ sparc-unknown-elf-readelf -h target/sparc-none-elf/debug/app ELF Header: Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: Sparc Version: 0x1 Entry point address: 0x10074 Start of program headers: 52 (bytes into file) Start of section headers: 1188 (bytes into file) Flags: 0x0 Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 2 Size of section headers: 40 (bytes) Number of section headers: 14 Section header string table index: 11 $ sparc-unknown-elf-objdump -Cd target/sparc-none-elf/debug/app target/sparc-none-elf/debug/app: file format elf32-sparc Disassembly of section .text: 00010074 <_start>: 10074: 9d e3 bf 98 save %sp, -104, %sp 10078: 10 80 00 02 b 10080 <_start+0xc> 1007c: 01 00 00 00 nop 10080: 10 80 00 02 b 10088 <_start+0x14> 10084: 01 00 00 00 nop 10088: 10 80 00 00 b 10088 <_start+0x14> 1008c: 01 00 00 00 nop ``` --- Someone wants to attempt launching some Rust [into space](https://www.reddit.com/r/rust/comments/5h76oa/c_interop/) but their platform is based on the SPARCv8 architecture. Let's not block them by enabling LLVM's SPARC backend. Something very important that they'll also need is the "cabi" stuff as they'll be embedding some Rust code into a bigger C application (i.e. heavy use of `extern "C"`). The question there is what name(s) should we use for "target_arch" as the "cabi" implementation [varies according to that parameter](https://github.com/rust-lang/rust/blob/1.13.0/src/librustc_trans/abi.rs#L498-L523). AFAICT, SPARCv8 is a 32-bit architecture and SPARCv9 is a 64-bit architecture. And, LLVM uses `sparc`, `sparcv9` and `sparcel` for [the architecture triple](https://github.com/rust-lang/llvm/blob/ac1c94226e9fa17005ce7e2dd52dd6d1875f3137/include/llvm/ADT/Triple.h#L67-L69) so perhaps we should use `target_arch = "sparc"` (32-bit) and `target_arch = "sparcv9"` (64-bit) as well. r? @alexcrichton This PR only enables this LLVM backend when rustbuild is used. Do I also need to implement this for the old Makefile-based build system? Or are all our nightlies now being generated using rustbuild? cc @brson
2016-12-21Make drop glue for unsized value pass two arguments instead of *(data, meta)Mark Simulacrum-1/+2
2016-12-19enable LLVM's SPARC backendJorge Aparicio-0/+6
2016-12-06Auto merge of #37973 - vadimcn:dllimport, r=alexcrichtonbors-1/+1
Implement RFC 1717 Implement the first two points from #37403. r? @alexcrichton
2016-12-04Auto merge of #37857 - shepmaster:llvm-4.0-dinodes, r=michaelwoeristerbors-0/+4
[LLVM 4.0] Handle new DIFlags enum
2016-12-03Auto merge of #38079 - BurntSushi:attrtarget, r=alexcrichtonbors-4/+4
Add new #[target_feature = "..."] attribute. This commit adds a new attribute that instructs the compiler to emit target specific code for a single function. For example, the following function is permitted to use instructions that are part of SSE 4.2: #[target_feature = "+sse4.2"] fn foo() { ... } In particular, use of this attribute does not require setting the -C target-feature or -C target-cpu options on rustc. This attribute does not have any protections built into it. For example, nothing stops one from calling the above `foo` function on hosts without SSE 4.2 support. Doing so may result in a SIGILL. I've also expanded the x86 target feature whitelist.
2016-12-02[LLVM] Introduce a stable representation of DIFlagsJake Goulding-0/+4
In LLVM 4.0, this enum becomes an actual type-safe enum, which breaks all of the interfaces. Introduce our own copy of the bitflags that we can then safely convert to the LLVM one.
2016-12-01Remove the "linked_from" feature.Vadim Chugunov-1/+1
2016-11-30Update the bootstrap compilerAlex Crichton-2/+2
Now that we've got a beta build, let's use it!
2016-11-29Add new #[target_feature = "..."] attribute.Andrew Gallant-4/+4
This commit adds a new attribute that instructs the compiler to emit target specific code for a single function. For example, the following function is permitted to use instructions that are part of SSE 4.2: #[target_feature = "+sse4.2"] fn foo() { ... } In particular, use of this attribute does not require setting the -C target-feature or -C target-cpu options on rustc. This attribute does not have any protections built into it. For example, nothing stops one from calling the above `foo` function on hosts without SSE 4.2 support. Doing so may result in a SIGILL. This commit also expands the target feature whitelist to include lzcnt, popcnt and sse4a. Namely, lzcnt and popcnt have their own CPUID bits, but were introduced with SSE4.
2016-11-21Restore compatibility with LLVM 3.7 and 3.8Seo Sanghyeon-7/+3
2016-11-19Auto merge of #37831 - rkruppe:llvm-attr-fwdcompat, r=eddybbors-56/+8
[LLVM 4.0] Use llvm::Attribute APIs instead of "raw value" APIs The latter will be removed in LLVM 4.0 (see https://github.com/llvm-mirror/llvm/commit/4a6fc8bacf11d8066da72cf8481467167877ed16). The librustc_llvm API remains mostly unchanged, except that llvm::Attribute is no longer a bitflag but represents only a *single* attribute. The ability to store many attributes in a small number of bits and modify them without interacting with LLVM is only used in rustc_trans::abi and closely related modules, and only attributes for function arguments are considered there. Thus rustc_trans::abi now has its own bit-packed representation of argument attributes, which are translated to rustc_llvm::Attribute when applying the attributes. cc #37609
2016-11-17Use llvm::Attribute API instead of "raw value" APIs, which will be removed ↵Robin Kruppe-56/+8
in LLVM 4.0. The librustc_llvm API remains mostly unchanged, except that llvm::Attribute is no longer a bitflag but represents only a *single* attribute. The ability to store many attributes in a small number of bits and modify them without interacting with LLVM is only used in rustc_trans::abi and closely related modules, and only attributes for function arguments are considered there. Thus rustc_trans::abi now has its own bit-packed representation of argument attributes, which are translated to rustc_llvm::Attribute when applying the attributes.
2016-11-12enable the MSP430 LLVM backendJorge Aparicio-0/+5
to let people experiment with this target out of tree. The MSP430 architecture is used in 16-bit microcontrollers commonly used in Digital Signal Processing applications.
2016-11-10Register and stability check `#[no_link]` crates.Jeffrey Seyfried-0/+1
2016-10-22run rustfmt on librustc_llvm folderSrinivas Reddy Thatiparthy-62/+34
2016-09-30Configure LLVM to use js backendJan-Erik Rediger-0/+4
Initialize the asmjs backend for LLVM
2016-08-26initial support for s390xJorge Aparicio-0/+6
A new target, `s390x-unknown-linux-gnu`, has been added to the compiler and can be used to build no_core/no_std Rust programs. Known limitations: - librustc_trans/cabi_s390x.rs is missing. This means no support for `extern "C" fn`. - No support for this arch in libc. This means std can be cross compiled for this target.
2016-08-03finish type-auditing rustllvmAriel Ben-Yehuda-42/+72
2016-08-03split the FFI part of rustc_llvm to rustc_llvm::ffiAriel Ben-Yehuda-2062/+18
2016-08-03begin auditing the C++ types in RustWrapperAriel Ben-Yehuda-306/+322
2016-08-03audit LLVM C++ types in ArchiveWrapper and PassWrapperAriel Ben-Yehuda-28/+48
2016-08-03remove the ExecutionEngine bindingAriel Ben-Yehuda-9/+0
the code has no tests and will just bitrot by itself. this is a [breaking-change]
2016-07-29llvm: Remove no longer existent LLVMAddTargetData bindingAlex Crichton-3/+0
2016-07-29[LLVM-3.9] Configure PIE at the module level instead of compilation unit levelJan-Erik Rediger-0/+1
This was deleted here[1] which appears to be replaced by this[2] which is a new setPIELevel function on the LLVM module itself. [1]: http://reviews.llvm.org/D19753 [2]: http://reviews.llvm.org/D19671
2016-07-29[LLVM-3.9] Rename custom methods to Rust-specific onesJan-Erik Rediger-3/+3
2016-06-10Remove linking with ARJake Goulding-0/+15
Since we only support LLVM 3.7 and above, we will never need to use the AR linker. Remove the possibility of calling it and all the now-dead code.
2016-04-28Add opt-level options for optimizing for size and minimum size. This attemptsBrandon Edens-0/+9
to mimic the behavior of clang's options Os and Oz.
2016-04-28Make the codegen unit partitioner also emit item declarations.Michael Woerister-1/+1
2016-04-20Auto merge of #31709 - ranma42:target_feature-from-llvm, r=alexcrichtonbors-0/+3
Compute `target_feature` from LLVM This is a work-in-progress fix for #31662. The logic that computes the target features from the command line has been replaced with queries to the `TargetMachine`.
2016-04-15Add initial version of codegen unit partitioning for incremental compilation.Michael Woerister-1/+1
2016-04-09Implement feature extraction from `TargetMachine`Andrea Canciani-0/+3
Add the `LLVMRustHasFeature` function to check whether a `TargetMachine` has a given feature.
2016-03-29Use weak_odr linkage when reusing definitions across codegen unitsBjörn Steinbrink-0/+21
When reuing a definition across codegen units, we obviously cannot use internal linkage, but using external linkage means that we can end up with multiple conflicting definitions of a single symbol across multiple crates. Since the definitions should all be equal semantically, we can use weak_odr linkage to resolve the situation. Fixes #32518
2016-03-26Fix removal of function attributes on ARMBjörn Steinbrink-2/+10
We use a 64bit integer to pass the set of attributes that is to be removed, but the called C function expects a 32bit integer. On most platforms this doesn't cause any problems other than being unable to unset some attributes, but on ARM even the lower 32bit aren't handled correctly because the 64bit value is passed in different registers, so the C function actually sees random garbage. So we need to fix the relevant functions to use 32bit integers instead. Additionally we need an implementation that actually accepts 64bit integers because some attributes can only be unset that way. Fixes #32360
2016-03-18Add intrinsics for float arithmetic with `fast` flag enabledUlrik Sverdrup-0/+1
`fast` a.k.a UnsafeAlgebra is the flag for enabling all "unsafe" (according to llvm) float optimizations. See LangRef for more information http://llvm.org/docs/LangRef.html#fast-math-flags Providing these operations with less precise associativity rules (for example) is useful to numerical applications. For example, the summation loop: let sum = 0.; for element in data { sum += *element; } Using the default floating point semantics, this loop expresses the floats must be added in a sequence, one after another. This constraint is usually completely unintended, and it means that no autovectorization is possible.
2016-03-17trans: Apply all attributes through FnType.Eduard Burtescu-49/+6
2016-03-17trans: Use llvm::Attributes directly in ArgTy.Eduard Burtescu-1/+1
2016-03-17rustc_llvm: An AttrBuilder that's not completely wasteful.Eduard Burtescu-61/+74
2016-03-17rustc_llvm: Update the Attribute bitflags and remove OtherAttribute.Eduard Burtescu-40/+25
2016-03-17trans: Use fmt::Debug for debugging instead of ad-hoc methods.Eduard Burtescu-0/+1
2016-02-24Implement filling drop in MIRSimonas Kazlauskas-0/+2
Hopefully the author caught all the cases. For the mir_dynamic_drops_3 test case the ratio of memsets to other instructions is 12%. On the other hand we actually do not double drop for at least the test cases provided anymore in MIR.
2016-02-22Auto merge of #30969 - Amanieu:extended_atomic_cmpxchg, r=alexcrichtonbors-1/+2
This is an implementation of rust-lang/rfcs#1443.
2016-02-18Add intrinsics for compare_exchange and compare_exchange_weakAmanieu d'Antras-1/+2
2016-02-18Remove unnecessary explicit lifetime bounds.Corey Farwell-2/+2
These explicit lifetimes can be ommitted because of lifetime elision rules. Instances were found using rust-clippy.
2016-02-11rustc_llvm: Tweak how initialization is performedAlex Crichton-78/+39
Refactor a bit to have less repetition and #[cfg] and try to bury it all inside of a macro.
2016-02-11bootstrap: Add directives to not double-link libsAlex Crichton-0/+4
Have all Cargo-built crates pass `--cfg cargobuild` and then add appropriate `#[cfg]` definitions to all crates to avoid linking anything if this is passed. This should help allow libstd to compile with both the makefiles and with Cargo.
2016-02-08Remove old #[allow(trivial_casts)] annotationsAlex Crichton-1/+0
These were added a long time ago but we long since switched the lint back to allow-by-default, so these annotations shouldn't be necessary.
2016-01-29trans: Reimplement unwinding on MSVCAlex Crichton-14/+78
This commit transitions the compiler to using the new exception handling instructions in LLVM for implementing unwinding for MSVC. This affects both 32 and 64-bit MSVC as they're both now using SEH-based strategies. In terms of standard library support, lots more details about how SEH unwinding is implemented can be found in the commits. In terms of trans, this change necessitated a few modifications: * Branches were added to detect when the old landingpad instruction is used or the new cleanuppad instruction is used to `trans::cleanup`. * The return value from `cleanuppad` is not stored in an `alloca` (because it cannot be). * Each block in trans now has an `Option<LandingPad>` instead of `is_lpad: bool` for indicating whether it's in a landing pad or not. The new exception handling intrinsics require that on MSVC each `call` inside of a landing pad is annotated with which landing pad that it's in. This change to the basic block means that whenever a `call` or `invoke` instruction is generated we know whether to annotate it as part of a cleanuppad or not. * Lots of modifications were made to the instruction builders to construct the new instructions as well as pass the tagging information for the call/invoke instructions. * The translation of the `try` intrinsics for MSVC has been overhauled to use the new `catchpad` instruction. The filter function is now also a rustc-generated function instead of a purely libstd-defined function. The libstd definition still exists, it just has a stable ABI across architectures and leaves some of the really weird implementation details to the compiler (e.g. the `localescape` and `localrecover` intrinsics).