Skip to content

Commit 6176cf2

Browse files
committed
svae work (ignore commit msgs they aren't foro anyone but myself :)
1 parent 0ca3e7a commit 6176cf2

File tree

6 files changed

+34
-23
lines changed

6 files changed

+34
-23
lines changed

crates/rustc_codegen_nvvm/src/debug_info/create_scope_map.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_middle::ty::{self, Instance, EarlyBinder};
1111
use rustc_session::config::DebugInfo;
1212

1313
use rustc_index::bit_set::BitSet;
14-
use rustc_index::vec::Idx;
1514

1615
use super::metadata::file_metadata;
1716
use super::util::DIB;

crates/rustc_codegen_nvvm/src/debug_info/metadata.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ use rustc_data_structures::fx::FxHashMap;
66
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
77
use rustc_hir::def::CtorKind;
88
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
9-
use rustc_index::Idx;
10-
use rustc_index::vec::{Idx, IndexVec};
9+
use rustc_index::{Idx, IndexVec};
1110
use rustc_middle::mir::{self, GeneratorLayout};
1211
use rustc_middle::ty::layout::{self, IntegerExt, LayoutOf, PrimitiveExt, TyAndLayout};
1312
use rustc_middle::ty::subst::GenericArgKind;
@@ -1677,7 +1676,7 @@ impl<'tcx> VariantInfo<'_, 'tcx> {
16771676
fn field_name(&self, i: usize, cx: &CodegenCx<'_, 'tcx>) -> String {
16781677
let field_name = match *self {
16791678
VariantInfo::Adt(variant) if variant.ctor_kind() != Some(CtorKind::Fn) => {
1680-
Some(variant.fields[Idx::new(i)].ident(cx.tcx).name)
1679+
Some(variant.fields[usize::from_usize(i)].ident(cx.tcx).name)
16811680
}
16821681
VariantInfo::Generator {
16831682
generator_layout,

crates/rustc_codegen_nvvm/src/debug_info/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_codegen_ssa::traits::*;
1111
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
1212
use rustc_data_structures::sync::Lrc;
1313
use rustc_hir::def_id::{DefId, DefIdMap};
14-
use rustc_index::vec::IndexVec;
14+
use rustc_index::IndexVec;
1515
use rustc_middle::mir;
1616
use rustc_middle::ty::layout::HasTyCtxt;
1717
use rustc_middle::ty::subst::{GenericArgKind, SubstsRef};

crates/rustc_codegen_nvvm/src/intrinsic.rs

+21-12
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
322322
_ => bug!(),
323323
};
324324
self.call(
325-
self.type_i1(),None,
325+
self.type_i1(),
326+
None,
326327
None,
327328
expect,
328329
&[
@@ -367,16 +368,23 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
367368
sym::ctlz | sym::cttz => {
368369
let y = self.const_bool(false);
369370
let llfn = self.get_intrinsic(&format!("llvm.{}.i{}", name, width));
370-
self.call(self.type_i1(), None, llfn, &[args[0].immediate(), y], None)
371+
self.call(self.type_i1(), None, None, llfn, &[args[0].immediate(), y], None)
371372
}
372373
sym::ctlz_nonzero | sym::cttz_nonzero => {
373374
let y = self.const_bool(true);
374375
let llvm_name = &format!("llvm.{}.i{}", &name_str[..4], width);
375376
let llfn = self.get_intrinsic(llvm_name);
376-
self.call(self.type_i1(), None,None, llfn, &[args[0].immediate(), y], None)
377+
self.call(
378+
self.type_i1(),
379+
None,
380+
None,
381+
llfn,
382+
&[args[0].immediate(), y],
383+
None,
384+
)
377385
}
378386
sym::ctpop => self.call(
379-
self.type_i1(),
387+
self.type_i1(),None,
380388
None,
381389
self.get_intrinsic(&format!("llvm.ctpop.i{}", width)),
382390
&[args[0].immediate()],
@@ -387,7 +395,7 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
387395
args[0].immediate() // byte swap a u8/i8 is just a no-op
388396
} else {
389397
self.call(
390-
self.type_i1(),
398+
self.type_i1(),None,
391399
None,
392400
self.get_intrinsic(&format!("llvm.bswap.i{}", width)),
393401
&[args[0].immediate()],
@@ -396,7 +404,8 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
396404
}
397405
}
398406
sym::bitreverse => self.call(
399-
self.type_i1(),None,
407+
self.type_i1(),
408+
None,
400409
None,
401410
self.get_intrinsic(&format!("llvm.bitreverse.i{}", width)),
402411
&[args[0].immediate()],
@@ -410,7 +419,7 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
410419
let llvm_name =
411420
&format!("llvm.fsh{}.i{}", if is_left { 'l' } else { 'r' }, width);
412421
let llfn = self.get_intrinsic(llvm_name);
413-
self.call(self.type_i1(), None, llfn, &[val, val, raw_shift], None)
422+
self.call(self.type_i1(), None,None, llfn, &[val, val, raw_shift], None)
414423
}
415424
sym::saturating_add | sym::saturating_sub => {
416425
let is_add = name == sym::saturating_add;
@@ -463,7 +472,7 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
463472
let b_ptr = self.bitcast(b, i8p_ty);
464473
let n = self.const_usize(layout.size().bytes());
465474
let intrinsic = self.get_intrinsic("memcmp");
466-
let cmp = self.call(self.type_i1(), None, intrinsic, &[a_ptr, b_ptr, n], None);
475+
let cmp = self.call(self.type_i1(),None, None, intrinsic, &[a_ptr, b_ptr, n], None);
467476
self.icmp(IntPredicate::IntEQ, cmp, self.const_i32(0))
468477
}
469478
}
@@ -488,7 +497,7 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
488497
fn abort(&mut self) {
489498
trace!("Generate abort call");
490499
let fnname = self.get_intrinsic("llvm.trap");
491-
self.call(self.type_i1(), None, fnname, &[], None);
500+
self.call(self.type_i1(),None, None, fnname, &[], None);
492501
}
493502

494503
fn assume(&mut self, val: Self::Value) {
@@ -501,7 +510,7 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
501510
trace!("Generate expect call with `{:?}`, {}", cond, expected);
502511
let expect = self.get_intrinsic("llvm.expect.i1");
503512
self.call(
504-
self.type_i1(),
513+
self.type_i1(),None,
505514
None,
506515
expect,
507516
&[cond, self.const_bool(expected)],
@@ -526,12 +535,12 @@ impl<'a, 'll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
526535
fn va_start(&mut self, va_list: &'ll Value) -> Self::Value {
527536
trace!("Generate va_start `{:?}`", va_list);
528537
let intrinsic = self.cx().get_intrinsic("llvm.va_start");
529-
self.call(self.type_i1(), None, intrinsic, &[va_list], None)
538+
self.call(self.type_i1(),None, None, intrinsic, &[va_list], None)
530539
}
531540

532541
fn va_end(&mut self, va_list: &'ll Value) -> Self::Value {
533542
trace!("Generate va_end call `{:?}`", va_list);
534543
let intrinsic = self.cx().get_intrinsic("llvm.va_end");
535-
self.call(self.type_i1(), None, intrinsic, &[va_list], None)
544+
self.call(self.type_i1(),None, None, intrinsic, &[va_list], None)
536545
}
537546
}

crates/rustc_codegen_nvvm/src/link.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -160,17 +160,21 @@ fn link_rlib(sess: &Session, codegen_results: &CodegenResults, out_filename: &Pa
160160
| NativeLibKind::RawDylib
161161
| NativeLibKind::LinkArg
162162
| NativeLibKind::Unspecified => continue,
163+
NativeLibKind::WasmImportModule => todo!(),
163164
}
164165
// native libraries in cuda doesnt make much sense, extern functions
165166
// do exist in nvvm for stuff like cuda syscalls and cuda provided functions
166167
// but including libraries doesnt make sense because nvvm would have to translate
167168
// the binary directly to ptx. We might want to add some way of linking in
168169
// ptx files or custom bitcode modules as "libraries" perhaps in the future.
169-
if let Some(name) = lib.name {
170-
sess.err(format!(
171-
"Adding native libraries to rlib is not supported in CUDA: {}",
172-
name
173-
));
170+
match lib.name {
171+
Some(name) => {
172+
sess.err(format!(
173+
"Adding native libraries to rlib is not supported in CUDA: {}",
174+
name
175+
));
176+
}
177+
_ => (),
174178
}
175179
}
176180
trace!("Files linked in rlib:\n{:#?}", file_list);

crates/rustc_codegen_nvvm/src/override_fns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ fn override_libm_function<'ll, 'tcx>(func: Instance<'tcx>, cx: &CodegenCx<'ll, '
5959
let mut bx = Builder::build(cx, start);
6060

6161
let params = llvm::get_params(llfn);
62-
let llcall = bx.call(cx.type_i1(), None, intrinsic, &params, None);
62+
let llcall = bx.call(cx.type_i1(),None, None, intrinsic, &params, None);
6363
bx.ret(llcall);
6464
}

0 commit comments

Comments
 (0)