Skip to content

Commit

Permalink
add call_site location (#399)
Browse files Browse the repository at this point in the history
was missing
  • Loading branch information
edg-l authored Jan 15, 2024
1 parent da28b68 commit 18a1619
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions melior/src/ir/location.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use crate::{
utility::print_callback,
};
use mlir_sys::{
mlirLocationEqual, mlirLocationFileLineColGet, mlirLocationFusedGet, mlirLocationGetContext,
mlirLocationNameGet, mlirLocationPrint, mlirLocationUnknownGet, MlirLocation,
mlirLocationCallSiteGet, mlirLocationEqual, mlirLocationFileLineColGet, mlirLocationFusedGet,
mlirLocationGetContext, mlirLocationNameGet, mlirLocationPrint, mlirLocationUnknownGet,
MlirLocation,
};
use std::{
ffi::c_void,
Expand Down Expand Up @@ -57,6 +58,11 @@ impl<'c> Location<'c> {
}
}

/// Creates a call site location.
pub fn call_site(callee: Location, caller: Location) -> Self {
unsafe { Self::from_raw(mlirLocationCallSiteGet(callee.to_raw(), caller.to_raw())) }
}

/// Creates an unknown location.
pub fn unknown(context: &'c Context) -> Self {
unsafe { Self::from_raw(mlirLocationUnknownGet(context.to_raw())) }
Expand Down Expand Up @@ -138,6 +144,13 @@ mod tests {
Location::name(&context, "foo", Location::unknown(&context));
}

#[test]
fn call_site() {
let context = Context::new();

Location::call_site(Location::unknown(&context), Location::unknown(&context));
}

#[test]
fn unknown() {
Location::unknown(&Context::new());
Expand Down

0 comments on commit 18a1619

Please sign in to comment.