@@ -79,10 +79,10 @@ namespace {
79
79
constexpr WarningCollector* kNoWarningCollector = nullptr ;
80
80
81
81
// Returns a status that indicates an error in the IR conversion process.
82
- absl::Status ConversionErrorStatus (const std::optional<Span>& span,
83
- std::string_view message) {
82
+ absl::Status IrConversionErrorStatus (const std::optional<Span>& span,
83
+ std::string_view message) {
84
84
return absl::InternalError (
85
- absl::StrFormat (" ConversionError : %s %s" ,
85
+ absl::StrFormat (" IrConversionError : %s %s" ,
86
86
span ? span->ToString () : " <no span>" , message));
87
87
}
88
88
@@ -805,10 +805,12 @@ absl::Status FunctionConverter::HandleBuiltinCheckedCast(
805
805
806
806
if (dynamic_cast <ArrayType*>(output_type.get ()) != nullptr ||
807
807
dynamic_cast <ArrayType*>(input_type.get ()) != nullptr ) {
808
- return absl::UnimplementedError (
809
- absl::StrFormat (" ConversionError: CheckedCast to and from arrays (%s) "
810
- " is not currently supported for IR conversion." ,
811
- node->span ().ToString ()));
808
+ return IrConversionErrorStatus (
809
+ node->span (),
810
+ absl::StrFormat (" CheckedCast to and from array "
811
+ " is not currently supported for IR conversion; "
812
+ " attempted checked cast from: %s to: %s" ,
813
+ input_type->ToString (), output_type->ToString ()));
812
814
}
813
815
814
816
// TODO(tedhong): 2023-05-22 Add verilog assertion that cast has not
@@ -864,7 +866,7 @@ absl::Status FunctionConverter::HandleBuiltinWideningCast(
864
866
absl::Status FunctionConverter::HandleMatch (const Match* node) {
865
867
if (node->arms ().empty () ||
866
868
!node->arms ().back ()->patterns ()[0 ]->IsIrrefutable ()) {
867
- return ConversionErrorStatus (
869
+ return IrConversionErrorStatus (
868
870
node->span (),
869
871
" Only matches with trailing irrefutable patterns (i.e. `_ => ...`) "
870
872
" are currently supported for IR conversion." );
@@ -945,10 +947,10 @@ absl::Status FunctionConverter::HandleMatch(const Match* node) {
945
947
});
946
948
MatchArm* default_arm = node->arms ().back ();
947
949
if (default_arm->patterns ().size () != 1 ) {
948
- return absl::UnimplementedError (
949
- absl::StrFormat ( " ConversionError: %s Multiple patterns in default arm "
950
- " is not currently supported for IR conversion. " ,
951
- node-> span (). ToString ()) );
950
+ return IrConversionErrorStatus (
951
+ node-> span (),
952
+ " Multiple patterns in default arm "
953
+ " is not currently supported for IR conversion. " );
952
954
}
953
955
XLS_RETURN_IF_ERROR (
954
956
HandleMatcher (default_arm->patterns ()[0 ],
@@ -986,11 +988,12 @@ absl::Status FunctionConverter::HandleMatch(const Match* node) {
986
988
absl::StatusOr<FunctionConverter::RangeData> FunctionConverter::GetRangeData (
987
989
const Expr* iterable) {
988
990
auto error = [&] {
989
- return absl::InvalidArgumentError (
990
- absl::StrFormat (" ConversionError: %s iterable (%s) "
991
+ return IrConversionErrorStatus (
992
+ iterable->span (),
993
+ absl::StrFormat (" iterable `%s` "
991
994
" must be bits-typed, constexpr, and its start must be "
992
995
" less than or equal to its limit." ,
993
- iterable->span (). ToString (), iterable-> ToString ()));
996
+ iterable->ToString ()));
994
997
};
995
998
996
999
// Easy case first: using the `..` range operator.
@@ -1825,10 +1828,11 @@ absl::Status FunctionConverter::HandleInvocation(const Invocation* node) {
1825
1828
};
1826
1829
auto it = map.find (called_name);
1827
1830
if (it == map.end ()) {
1828
- return absl::InvalidArgumentError (
1829
- absl::StrFormat (" ConversionError: %s Could not find name for "
1830
- " invocation: %s; available: [%s]" ,
1831
- node->span ().ToString (), called_name,
1831
+ return IrConversionErrorStatus (
1832
+ node->span (),
1833
+ absl::StrFormat (" Could not find name for "
1834
+ " invocation: `%s`; available: [%s]" ,
1835
+ called_name,
1832
1836
absl::StrJoin (module_->GetFunctionNames (), " , " )));
1833
1837
}
1834
1838
XLS_RETURN_IF_ERROR (accept_args ().status ());
@@ -3174,7 +3178,7 @@ absl::StatusOr<std::unique_ptr<ConcreteType>> FunctionConverter::ResolveType(
3174
3178
XLS_RET_CHECK (current_type_info_ != nullptr );
3175
3179
std::optional<const ConcreteType*> t = current_type_info_->GetItem (node);
3176
3180
if (!t.has_value ()) {
3177
- return ConversionErrorStatus (
3181
+ return IrConversionErrorStatus (
3178
3182
node->GetSpan (),
3179
3183
absl::StrFormat (" Failed to convert IR because type was missing for AST "
3180
3184
" node: %s (kind: %s)" ,
0 commit comments