rust/src/librustc_codegen_llvm
Mazdak Farrokhzad 62528d86b0
Rollup merge of #66841 - SimonSapin:float_round_unchecked_to, r=rkruppe
Add `{f32,f64}::approx_unchecked_to<Int>` unsafe methods

As discussed in https://github.com/rust-lang/rust/issues/10184

Currently, casting a floating point number to an integer with `as` is Undefined Behavior if the value is out of range. `-Z saturating-float-casts` fixes this soundness hole by making `as` “saturate” to the maximum or minimum value of the integer type (or zero for `NaN`), but has measurable negative performance impact in some benchmarks. There is some consensus in that thread for enabling saturation by default anyway, but provide an `unsafe fn` alternative for users who know through some other mean that their values are in range.

<del>The “fit” wording is copied from https://llvm.org/docs/LangRef.html#fptoui-to-instruction, but I’m not certain what it means exactly. Presumably this is after rounding towards zero, and the doc-test with `i8::MIN` seems to confirm this.</del> Clang presumably uses those LLVM intrinsics to implement C and C++ casts, whose respective standard specify that the value *after truncating to keep its integral part* must be representable in the target type.
2019-12-06 23:26:55 +01:00
..
back Rollup merge of #67033 - cuviper:ValueName2, r=rkruppe 2019-12-07 00:10:02 +09:00
debuginfo Migrate to LLVM{Get,Set}ValueName2 2019-12-04 12:00:28 -08:00
llvm Rollup merge of #67033 - cuviper:ValueName2, r=rkruppe 2019-12-07 00:10:02 +09:00
abi.rs rustc_target: add abi::call::Conv::Rust distinct from Conv::C. 2019-12-03 15:55:21 +02:00
allocator.rs rustc, rustc_passes: don't depend on syntax_expand. 2019-10-27 17:05:57 +01:00
asm.rs reduce size of hir::ExprKind 2019-11-21 01:23:29 +01:00
attributes.rs Use to_option in various places 2019-12-06 12:23:23 +00:00
base.rs Use Symbol for codegen unit names. 2019-10-21 18:30:40 +11:00
build.rs Remove licenses 2018-12-25 21:08:33 -07:00
builder.rs Store ptr_width as u32 on Config 2019-11-24 16:32:07 -05:00
callee.rs rustc_target: add abi::call::Conv::Rust distinct from Conv::C. 2019-12-03 15:55:21 +02:00
Cargo.toml Remove src/llvm-emscripten submodule 2019-10-21 13:05:31 -07:00
common.rs Rename to then_some and then 2019-12-06 12:24:54 +00:00
consts.rs Migrate to LLVM{Get,Set}ValueName2 2019-12-04 12:00:28 -08:00
context.rs rustc: take a PolyFnSig instead of an FnSig in FnAbi::of_fn_ptr. 2019-12-03 15:55:14 +02:00
declare.rs Migrate to LLVM{Get,Set}ValueName2 2019-12-04 12:00:28 -08:00
intrinsic.rs Add {f32,f64}::approx_unchecked_to<Int> unsafe methods 2019-12-06 14:01:05 +01:00
lib.rs Use to_option in various places 2019-12-06 12:23:23 +00:00
llvm_util.rs Rollup merge of #66918 - makotokato:aarch32-crc-crypto, r=petrochenkov 2019-12-02 04:09:06 +01:00
metadata.rs format a bit 2019-07-07 09:32:36 +02:00
mono_item.rs rustc_target: add abi::call::Conv::Rust distinct from Conv::C. 2019-12-03 15:55:21 +02:00
README.md rustc-guide has moved 2018-11-26 15:03:13 -06:00
type_.rs rustc_codegen_ssa: rename FnTypeLlvmExt to FnAbiLlvmExt. 2019-11-03 09:23:50 +02:00
type_of.rs rustc: take a PolyFnSig instead of an FnSig in FnAbi::of_fn_ptr. 2019-12-03 15:55:14 +02:00
va_arg.rs Expose VaListImpl as the Rust equivalent of __va_list_tag and implement Clone for it. 2019-06-17 16:04:49 -07:00
value.rs librustc_codegen_llvm: deny(elided_lifetimes_in_paths) 2019-02-25 08:40:18 +01:00

The codegen crate contains the code to convert from MIR into LLVM IR, and then from LLVM IR into machine code. In general it contains code that runs towards the end of the compilation process.

For more information about how codegen works, see the rustc guide.