mirror of
https://github.com/intel/llvm.git
synced 2026-02-08 08:57:43 +08:00
These are locations that form a collection of other source locations with an optional metadata attribute.
- Add initial support for print/dump for locations.
Location Printing Examples:
* Unknown : [unknown-location]
* FileLineColLoc : third_party/llvm/llvm/projects/google-mlir/test/TensorFlowLite/legalize.mlir:6:8
* FusedLoc : <"tfl-legalize">[third_party/llvm/llvm/projects/google-mlir/test/TensorFlowLite/legalize.mlir:6:8, third_party/llvm/llvm/projects/google-mlir/test/TensorFlowLite/legalize.mlir:7:8]
- Add diagnostic support for fused locs.
* Prints the first location as the main location and the remaining as "fused from here" notes:
e.g.
third_party/llvm/llvm/projects/google-mlir/test/TensorFlowLite/legalize.mlir:6:8: error: This is an error.
%1 = "tf.add"(%arg0, %0) : (i32, i32) -> i32
^
third_party/llvm/llvm/projects/google-mlir/test/TensorFlowLite/legalize.mlir:7:8: error: Fused from here.
%2 = "tf.relu"(%1) : (i32) -> i32
^
PiperOrigin-RevId: 220835552
49 lines
1.6 KiB
C++
49 lines
1.6 KiB
C++
//===- Location.cpp - MLIR Location Classes -------------------------------===//
|
|
//
|
|
// Copyright 2019 The MLIR Authors.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
// =============================================================================
|
|
|
|
#include "mlir/IR/Location.h"
|
|
#include "LocationDetail.h"
|
|
|
|
using namespace mlir;
|
|
using namespace mlir::detail;
|
|
|
|
Location::Kind Location::getKind() const { return loc->kind; }
|
|
|
|
UnknownLoc::UnknownLoc(Location::ImplType *ptr) : Location(ptr) {}
|
|
|
|
FileLineColLoc::FileLineColLoc(Location::ImplType *ptr) : Location(ptr) {}
|
|
|
|
StringRef FileLineColLoc::getFilename() const {
|
|
return static_cast<ImplType *>(loc)->filename.getRef();
|
|
}
|
|
unsigned FileLineColLoc::getLine() const {
|
|
return static_cast<ImplType *>(loc)->line;
|
|
}
|
|
unsigned FileLineColLoc::getColumn() const {
|
|
return static_cast<ImplType *>(loc)->column;
|
|
}
|
|
|
|
FusedLoc::FusedLoc(Location::ImplType *ptr) : Location(ptr) {}
|
|
|
|
ArrayRef<Location> FusedLoc::getLocations() const {
|
|
return static_cast<ImplType *>(loc)->getLocations();
|
|
}
|
|
|
|
Attribute FusedLoc::getMetadata() const {
|
|
return static_cast<ImplType *>(loc)->metadata;
|
|
}
|