@@ -273,10 +273,54 @@ mlirLocationFileLineColRangeGet(MlirContext context, MlirStringRef filename,
273
273
startLine, startCol, endLine, endCol)));
274
274
}
275
275
276
+ MlirIdentifier mlirLocationFileLineColRangeGetFilename (MlirLocation location) {
277
+ return wrap ((llvm::cast<FileLineColRange>(unwrap (location)).getFilename ()));
278
+ }
279
+
280
+ unsigned mlirLocationFileLineColRangeGetStartLine (MlirLocation location) {
281
+ return llvm::cast<FileLineColRange>(unwrap (location)).getStartLine ();
282
+ }
283
+
284
+ unsigned mlirLocationFileLineColRangeGetStartColumn (MlirLocation location) {
285
+ return llvm::cast<FileLineColRange>(unwrap (location)).getStartColumn ();
286
+ }
287
+
288
+ unsigned mlirLocationFileLineColRangeGetEndLine (MlirLocation location) {
289
+ return llvm::cast<FileLineColRange>(unwrap (location)).getEndLine ();
290
+ }
291
+
292
+ unsigned mlirLocationFileLineColRangeGetEndColumn (MlirLocation location) {
293
+ return llvm::cast<FileLineColRange>(unwrap (location)).getEndColumn ();
294
+ }
295
+
296
+ MlirTypeID mlirLocationFileLineColRangeGetTypeID () {
297
+ return wrap (FileLineColRange::getTypeID ());
298
+ }
299
+
300
+ bool mlirLocationisAFileLineColRange (MlirLocation location) {
301
+ return isa<FileLineColRange>(unwrap (location));
302
+ }
303
+
276
304
MlirLocation mlirLocationCallSiteGet (MlirLocation callee, MlirLocation caller) {
277
305
return wrap (Location (CallSiteLoc::get (unwrap (callee), unwrap (caller))));
278
306
}
279
307
308
+ MlirLocation mlirLocationCallSiteGetCallee (MlirLocation location) {
309
+ return wrap (Location (llvm::cast<CallSiteLoc>(unwrap (location)).getCallee ()));
310
+ }
311
+
312
+ MlirLocation mlirLocationCallSiteGetCaller (MlirLocation location) {
313
+ return wrap (Location (llvm::cast<CallSiteLoc>(unwrap (location)).getCaller ()));
314
+ }
315
+
316
+ MlirTypeID mlirLocationCallSiteGetTypeID () {
317
+ return wrap (CallSiteLoc::getTypeID ());
318
+ }
319
+
320
+ bool mlirLocationisACallSite (MlirLocation location) {
321
+ return isa<CallSiteLoc>(unwrap (location));
322
+ }
323
+
280
324
MlirLocation mlirLocationFusedGet (MlirContext ctx, intptr_t nLocations,
281
325
MlirLocation const *locations,
282
326
MlirAttribute metadata) {
@@ -285,6 +329,30 @@ MlirLocation mlirLocationFusedGet(MlirContext ctx, intptr_t nLocations,
285
329
return wrap (FusedLoc::get (unwrappedLocs, unwrap (metadata), unwrap (ctx)));
286
330
}
287
331
332
+ void mlirLocationFusedGetLocations (MlirLocation location,
333
+ MlirLocation **locationsCPtr,
334
+ unsigned *nLocations) {
335
+ llvm::ArrayRef<Location> locationsArrRef =
336
+ llvm::cast<FusedLoc>(unwrap (location)).getLocations ();
337
+ assert (!locationsArrRef.empty () && " expected non-empty locations" );
338
+ SmallVector<MlirLocation> *locationsVec =
339
+ new SmallVector<MlirLocation>(locationsArrRef.size ());
340
+ for (auto [i, location] : llvm::enumerate (locationsArrRef))
341
+ locationsVec->operator [](i) = wrap (location);
342
+ *nLocations = locationsVec->size ();
343
+ *locationsCPtr = locationsVec->data ();
344
+ }
345
+
346
+ MlirAttribute mlirLocationFusedGetMetadata (MlirLocation location) {
347
+ return wrap (llvm::cast<FusedLoc>(unwrap (location)).getMetadata ());
348
+ }
349
+
350
+ MlirTypeID mlirLocationFusedGetTypeID () { return wrap (FusedLoc::getTypeID ()); }
351
+
352
+ bool mlirLocationisAFused (MlirLocation location) {
353
+ return isa<FusedLoc>(unwrap (location));
354
+ }
355
+
288
356
MlirLocation mlirLocationNameGet (MlirContext context, MlirStringRef name,
289
357
MlirLocation childLoc) {
290
358
if (mlirLocationIsNull (childLoc))
@@ -294,6 +362,20 @@ MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name,
294
362
StringAttr::get (unwrap (context), unwrap (name)), unwrap (childLoc))));
295
363
}
296
364
365
+ MlirIdentifier mlirLocationNameGetName (MlirLocation location) {
366
+ return wrap ((llvm::cast<NameLoc>(unwrap (location)).getName ()));
367
+ }
368
+
369
+ MlirLocation mlirLocationNameGetChildLoc (MlirLocation location) {
370
+ return wrap (Location (llvm::cast<NameLoc>(unwrap (location)).getChildLoc ()));
371
+ }
372
+
373
+ MlirTypeID mlirLocationNameGetTypeID () { return wrap (NameLoc::getTypeID ()); }
374
+
375
+ bool mlirLocationisAName (MlirLocation location) {
376
+ return isa<NameLoc>(unwrap (location));
377
+ }
378
+
297
379
MlirLocation mlirLocationUnknownGet (MlirContext context) {
298
380
return wrap (Location (UnknownLoc::get (unwrap (context))));
299
381
}
0 commit comments