Skip to content

Commit

Permalink
Check for feature with pre-interned symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
CryZe committed Jul 2, 2020
1 parent 94cd4f1 commit b249029
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
17 changes: 8 additions & 9 deletions src/librustc_codegen_llvm/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::def_id::DefId;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::sym;
use rustc_target::abi::{self, Align, Size};
use rustc_target::spec::{HasTargetSpec, Target};
use std::borrow::Cow;
Expand Down Expand Up @@ -478,7 +479,11 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
let llptr = self.struct_gep(place.llval, i as u64);
let load = self.load(llptr, align);
scalar_load_metadata(self, load, scalar);
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
if scalar.is_bool() {
self.trunc(load, self.type_i1())
} else {
load
}
};

OperandValue::Pair(
Expand Down Expand Up @@ -654,10 +659,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {

fn fptoui_sat(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> Option<&'ll Value> {
if self.sess().target.target.arch == "wasm32"
&& self
.sess()
.target_features
.contains(&rustc_span::symbol::Symbol::intern("nontrapping-fptoint"))
&& self.sess().target_features.contains(&sym::wasm_nontrapping_fptoint)
{
let src_ty = self.cx.val_ty(val);
let float_width = self.cx.float_width(src_ty);
Expand All @@ -679,10 +681,7 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {

fn fptosi_sat(&mut self, val: &'ll Value, dest_ty: &'ll Type) -> Option<&'ll Value> {
if self.sess().target.target.arch == "wasm32"
&& self
.sess()
.target_features
.contains(&rustc_span::symbol::Symbol::intern("nontrapping-fptoint"))
&& self.sess().target_features.contains(&sym::wasm_nontrapping_fptoint)
{
let src_ty = self.cx.val_ty(val);
let float_width = self.cx.float_width(src_ty);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ const RISCV_WHITELIST: &[(&str, Option<Symbol>)] = &[
const WASM_WHITELIST: &[(&str, Option<Symbol>)] = &[
("simd128", Some(sym::wasm_target_feature)),
("atomics", Some(sym::wasm_target_feature)),
("nontrapping-fptoint", Some(sym::wasm_target_feature)), // TODO: Maybe None?
("nontrapping-fptoint", Some(sym::wasm_target_feature)),
];

/// When rustdoc is running, provide a list of all known features so that all their respective
Expand Down
1 change: 1 addition & 0 deletions src/librustc_span/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,7 @@ symbols! {
warn,
wasm_import_module,
wasm_target_feature,
wasm_nontrapping_fptoint: "nontrapping-fptoint",
while_let,
windows,
windows_subsystem,
Expand Down

0 comments on commit b249029

Please sign in to comment.