Skip to content

Commit 215bcfc

Browse files
committed
asdf
1 parent 75b6637 commit 215bcfc

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

compiler/rustc_codegen_llvm/src/callee.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
3131
debug!("get_fn({:?}: {:?}) => {}", instance, instance.ty(cx.tcx(), cx.typing_env()), sym);
3232

3333
let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty());
34+
if fn_abi.conv == rustc_abi::CanonAbi::GpuKernel {
35+
dbg!("found gpu fn2!");
36+
} else {
37+
dbg!("asdf2!");
38+
}
3439

3540
let llfn = if let Some(llfn) = cx.get_declared_value(sym) {
3641
llfn
@@ -69,6 +74,11 @@ pub(crate) fn get_fn<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'t
6974
llvm::set_dllimport_storage_class(llfn);
7075
llfn
7176
} else {
77+
//if Some(fn_abi) = fn_abi {
78+
if fn_abi.conv == rustc_abi::CanonAbi::GpuKernel {
79+
dbg!("found gpu fn!");
80+
}
81+
//}
7282
cx.declare_fn(sym, fn_abi, Some(instance))
7383
};
7484
debug!("get_fn: not casting pointer!");

compiler/rustc_codegen_llvm/src/mono_item.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,28 @@ use rustc_hir::def_id::{DefId, LOCAL_CRATE};
55
use rustc_middle::bug;
66
use rustc_middle::mir::mono::Visibility;
77
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv, LayoutOf};
8-
use rustc_middle::ty::{self, Instance, TypeVisitableExt};
8+
use rustc_middle::ty::{self, Ty, TyCtxt,Instance, TypeVisitableExt};
99
use rustc_session::config::CrateType;
1010
use rustc_target::spec::RelocModel;
1111
use tracing::debug;
1212

13+
use rustc_target::callconv::FnAbi;
14+
1315
use crate::context::CodegenCx;
1416
use crate::errors::SymbolAlreadyDefined;
1517
use crate::type_of::LayoutLlvmExt;
1618
use crate::{base, llvm};
1719

20+
fn my_fn_abi<'tcx>(abi: &FnAbi<'tcx, Ty<'tcx>> ) -> FnAbi<'tcx, Ty<'tcx>> {
21+
let mut myABI = abi.clone();
22+
dbg!(&myABI.args);
23+
let val = myABI.clone().args[0].clone();
24+
myABI.args = Box::new([val.clone(), val.clone()]);
25+
dbg!(&myABI.args);
26+
myABI
27+
}
28+
29+
1830
impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
1931
fn predefine_static(
2032
&mut self,
@@ -54,7 +66,14 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
5466
assert!(!instance.args.has_infer());
5567

5668
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
57-
let lldecl = self.declare_fn(symbol_name, fn_abi, Some(instance));
69+
let fn_abi = if fn_abi.conv == rustc_abi::CanonAbi::GpuKernel {
70+
dbg!("found gpu fn!");
71+
my_fn_abi(fn_abi)
72+
} else {
73+
dbg!("asdf!");
74+
fn_abi.clone()
75+
};
76+
let lldecl = self.declare_fn(symbol_name, &fn_abi, Some(instance));
5877
llvm::set_linkage(lldecl, base::linkage_to_llvm(linkage));
5978
let attrs = self.tcx.codegen_instance_attrs(instance.def);
6079
base::set_link_section(lldecl, &attrs);

compiler/rustc_target/src/callconv/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ impl RiscvInterruptKind {
577577
///
578578
/// The signature represented by this type may not match the MIR function signature.
579579
/// Certain attributes, like `#[track_caller]` can introduce additional arguments, which are present in [`FnAbi`], but not in `FnSig`.
580+
/// The std::offload module also adds an addition dyn_ptr argument to the GpuKernel ABI.
580581
/// While this difference is rarely relevant, it should still be kept in mind.
581582
///
582583
/// I will do my best to describe this structure, but these

0 commit comments

Comments
 (0)