Skip to content

Commit 9a05afd

Browse files
committed
Add intrinsic_name to get plain intrinsic name
1 parent 74acabe commit 9a05afd

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

compiler/rustc_smir/src/rustc_smir/context.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,13 @@ impl<'tcx> Context for TablesWrapper<'tcx> {
587587
}
588588
}
589589

590+
fn intrinsic_name(&self, def: InstanceDef) -> Option<Symbol> {
591+
let tables = self.0.borrow_mut();
592+
let instance = tables.instances[def];
593+
let name = tables.tcx.intrinsic(instance.def_id())?;
594+
Some(name.to_string())
595+
}
596+
590597
fn ty_layout(&self, ty: Ty) -> Result<Layout, Error> {
591598
let mut tables = self.0.borrow_mut();
592599
let tcx = tables.tcx;

compiler/stable_mir/src/compiler_interface.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ pub trait Context {
183183
fn vtable_allocation(&self, global_alloc: &GlobalAlloc) -> Option<AllocId>;
184184
fn krate(&self, def_id: DefId) -> Crate;
185185
fn instance_name(&self, def: InstanceDef, trimmed: bool) -> Symbol;
186+
fn intrinsic_name(&self, def: InstanceDef) -> Option<Symbol>;
186187

187188
/// Return information about the target machine.
188189
fn target_info(&self) -> MachineInfo;

compiler/stable_mir/src/mir/mono.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ impl Instance {
9090
with(|context| context.instance_name(self.def, true))
9191
}
9292

93+
pub fn intrinsic_name(&self) -> Option<Symbol> {
94+
with(|context| context.intrinsic_name(self.def))
95+
}
96+
9397
/// Resolve an instance starting from a function definition and generic arguments.
9498
pub fn resolve(def: FnDef, args: &GenericArgs) -> Result<Instance, crate::Error> {
9599
with(|context| {

0 commit comments

Comments
 (0)