Skip to content

[SystemZ] Use the same PatFrag for all "insert imm" fragments (NFC) #119962

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2024

Conversation

s-barannikov
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Dec 14, 2024

@llvm/pr-subscribers-backend-systemz

Author: Sergei Barannikov (s-barannikov)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/119962.diff

1 Files Affected:

  • (modified) llvm/lib/Target/SystemZ/SystemZOperators.td (+12-17)
diff --git a/llvm/lib/Target/SystemZ/SystemZOperators.td b/llvm/lib/Target/SystemZ/SystemZOperators.td
index 6439c82d26ff5c..c084c1ee581a9c 100644
--- a/llvm/lib/Target/SystemZ/SystemZOperators.td
+++ b/llvm/lib/Target/SystemZ/SystemZOperators.td
@@ -757,23 +757,18 @@ defm block_or  : block_op<or>;
 defm block_xor : block_op<xor>;
 
 // Insertions.
-def inserti8 : PatFrag<(ops node:$src1, node:$src2),
-                       (or (and node:$src1, -256), node:$src2)>;
-
-class inserti16<int mask> : PatFrag<(ops node:$src1, node:$src2),
-                                    (or (and node:$src1, mask), node:$src2)>;
-
-def insertll   : inserti16<0xffff0000>;
-def insertlh   : inserti16<0x0000ffff>;
-def insertll64 : inserti16<0xffffffffffff0000>;
-def insertlh64 : inserti16<0xffffffff0000ffff>;
-def inserthl64 : inserti16<0xffff0000ffffffff>;
-def inserthh64 : inserti16<0x0000ffffffffffff>;
-
-def insertlf : PatFrag<(ops node:$src1, node:$src2),
-                       (or (and node:$src1, 0xffffffff00000000), node:$src2)>;
-def inserthf : PatFrag<(ops node:$src1, node:$src2),
-                       (or (and node:$src1, 0x00000000ffffffff), node:$src2)>;
+class insert_imm<int mask> : PatFrag<(ops node:$src1, node:$src2),
+                                     (or (and node:$src1, mask), node:$src2)>;
+
+def inserti8   : insert_imm<0xff00>;
+def insertll   : insert_imm<0xffff0000>;
+def insertlh   : insert_imm<0x0000ffff>;
+def insertll64 : insert_imm<0xffffffffffff0000>;
+def insertlh64 : insert_imm<0xffffffff0000ffff>;
+def inserthl64 : insert_imm<0xffff0000ffffffff>;
+def inserthh64 : insert_imm<0x0000ffffffffffff>;
+def insertlf   : insert_imm<0xffffffff00000000>;
+def inserthf   : insert_imm<0x00000000ffffffff>;
 
 // ORs that can be treated as insertions.
 def or_as_inserti8 : PatFrag<(ops node:$src1, node:$src2),

@s-barannikov s-barannikov force-pushed the tablegen/systemz-insert-imm branch from 8c74cc0 to 0fe5fa7 Compare December 14, 2024 12:05
class insert_imm<int mask> : PatFrag<(ops node:$src1, node:$src2),
(or (and node:$src1, mask), node:$src2)>;

def inserti8 : insert_imm<-256>;
Copy link
Contributor Author

@s-barannikov s-barannikov Dec 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be written as 0xffffffffffffff00, but not 0xffffff00 since it is used in 64-bit patterns too. I didn't spend much time investigating.

Copy link
Member

@uweigand uweigand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@s-barannikov s-barannikov merged commit c084921 into llvm:main Dec 14, 2024
8 checks passed
@s-barannikov s-barannikov deleted the tablegen/systemz-insert-imm branch December 14, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants