aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2024-09-27 10:47:29 +0200
committerMarc Poulhiès <dkm@gcc.gnu.org>2024-11-04 16:57:54 +0100
commitccd17b28e9bb9bd49676000c12e471a512c3a7cd (patch)
treebe411f46d962a00f60bf664aa1e7fbf82879f84d
parentc9328cb4b106a6b9afe3359e0287ece496b8e277 (diff)
downloadgcc-ccd17b28e9bb9bd49676000c12e471a512c3a7cd.zip
gcc-ccd17b28e9bb9bd49676000c12e471a512c3a7cd.tar.gz
gcc-ccd17b28e9bb9bd49676000c12e471a512c3a7cd.tar.bz2
ada: Resolve intrinsic operators without homonyms
Intrinsic operators are resolved by rewriting into a corresponding operator from the Standard package. Traversing homonyms just to find the corresponding operator was not particularly efficient; also, for the binary "-" it was finding the unary "-". There appears to be no difference in compiler behavior, but the new code should be more efficient and finding the correct operator seems to make more sense. gcc/ada/ChangeLog: * sem_res.adb (Resolve_Intrinsic_Operator) (Resolve_Intrinsic_Unary_Operator): Replace traversals of homonyms with a direct lookup.
-rw-r--r--gcc/ada/sem_res.adb47
1 files changed, 37 insertions, 10 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 0abdeee..2ea1ae4 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -9885,11 +9885,30 @@ package body Sem_Res is
return;
end if;
- Op := Entity (N);
- while Scope (Op) /= Standard_Standard loop
- Op := Homonym (Op);
- pragma Assert (Present (Op));
- end loop;
+ case N_Binary_Op'(Nkind (N)) is
+ when N_Op_Add =>
+ Op := Standard_Op_Add;
+ when N_Op_Expon =>
+ Op := Standard_Op_Expon;
+ when N_Op_Subtract =>
+ Op := Standard_Op_Subtract;
+ when N_Op_Divide =>
+ Op := Standard_Op_Divide;
+ when N_Op_Mod =>
+ Op := Standard_Op_Mod;
+ when N_Op_Multiply =>
+ Op := Standard_Op_Multiply;
+ when N_Op_Rem =>
+ Op := Standard_Op_Rem;
+
+ -- Non-arithmetic operators are handled elsewhere
+
+ when N_Op_Boolean
+ | N_Op_Concat
+ | N_Op_Shift
+ =>
+ raise Program_Error;
+ end case;
Set_Entity (N, Op);
Set_Is_Overloaded (N, False);
@@ -9979,11 +9998,19 @@ package body Sem_Res is
return;
end if;
- Op := Entity (N);
- while Scope (Op) /= Standard_Standard loop
- Op := Homonym (Op);
- pragma Assert (Present (Op));
- end loop;
+ case N_Unary_Op'(Nkind (N)) is
+ when N_Op_Abs =>
+ Op := Standard_Op_Abs;
+ when N_Op_Minus =>
+ Op := Standard_Op_Minus;
+ when N_Op_Plus =>
+ Op := Standard_Op_Plus;
+
+ -- Non-arithmetic operators are handled elsewhere
+
+ when N_Op_Not =>
+ raise Program_Error;
+ end case;
Set_Entity (N, Op);