summaryrefslogtreecommitdiffstats
path: root/mlir
diff options
context:
space:
mode:
authorFeng Liu <fengliuai@google.com>2019-01-23 13:37:35 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 15:33:05 -0700
commitb64998a6b3a8d87bcd7307aa8ba8ea5008d515e4 (patch)
treeebc7b9d5e0d454827441543592cf784f61148040 /mlir
parent1210e92d86c8408846b92b897614b2da94d3b5fd (diff)
downloadbcm5719-llvm-b64998a6b3a8d87bcd7307aa8ba8ea5008d515e4.tar.gz
bcm5719-llvm-b64998a6b3a8d87bcd7307aa8ba8ea5008d515e4.zip
Add a method to construct a CallSiteLoc which represents a stack of locations.
PiperOrigin-RevId: 230592860
Diffstat (limited to 'mlir')
-rw-r--r--mlir/include/mlir/IR/Location.h8
-rw-r--r--mlir/lib/IR/MLIRContext.cpp11
2 files changed, 18 insertions, 1 deletions
diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h
index 9f1e8d2241f..57dcce284c1 100644
--- a/mlir/include/mlir/IR/Location.h
+++ b/mlir/include/mlir/IR/Location.h
@@ -188,7 +188,7 @@ public:
/// Represents a location as call site. "callee" is the concrete location
/// (Unknown/NameLocation/FileLineColLoc) and "caller" points to the caller's
/// location (another CallLocation or a concrete location). Multiple
-/// CallLocations can be chained to form a call stack.
+/// CallSiteLocs can be chained to form a call stack.
class CallSiteLoc : public Location {
public:
using ImplType = detail::CallSiteLocationStorage;
@@ -198,6 +198,12 @@ public:
static CallSiteLoc get(Location callee, Location caller,
MLIRContext *context);
+ /// Return a call site location which represents a name reference in one line
+ /// or a stack of frames. The input frames are ordered from innermost to
+ /// outermost.
+ static CallSiteLoc get(Location name, ArrayRef<Location> frames,
+ MLIRContext *context);
+
/// The concrete location information this object presents.
Location getCallee() const;
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index db736d8f983..69642980677 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -620,6 +620,17 @@ CallSiteLoc CallSiteLoc::get(Location callee, Location caller,
return *existing.first = result;
}
+CallSiteLoc CallSiteLoc::get(Location name, ArrayRef<Location> frames,
+ MLIRContext *context) {
+ assert(!frames.empty() && "required at least 1 frames");
+ auto it = frames.rbegin();
+ Location caller = *it++;
+ for (auto e = frames.rend(); it != e; ++it) {
+ caller = CallSiteLoc::get(*it, caller, context);
+ }
+ return CallSiteLoc::get(name, caller, context);
+}
+
Location FusedLoc::get(ArrayRef<Location> locs, MLIRContext *context) {
return get(locs, Attribute(), context);
}
OpenPOWER on IntegriCloud