[llvm] [TableGen] Sign extend constants based on size for EmitIntegerMatcher. (PR #104550)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 23:34:52 PDT 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/104550
I'm planning to add a getSignedConstant to SelectionDAG and use it for EmitInteger in SelectionDAGISel which already uses int64_t. getSignedConstant will verify that the constant has the correct number of significant bits for the VT.
This patch ensures that tablegen emits constants in this form.
It does reduce X86GenDAGISel.inc by a few bytes.
>From 9d1ea3f14a57ab120d94c29186507a1cabc66e3a Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 15 Aug 2024 23:19:34 -0700
Subject: [PATCH] [TableGen] Sign extend constants based on size for
EmitIntegerMatcher.
I'm planning to add a getSignedConstant to SelectionDAG and use it
for EmitInteger in SelectionDAGISel which already uses int64_t.
getSignedConstant will verify that the constant has the correct number
of significant bits for the VT.
This patch ensures that tablegen emits constants in this form.
---
llvm/utils/TableGen/Common/DAGISelMatcher.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/utils/TableGen/Common/DAGISelMatcher.h b/llvm/utils/TableGen/Common/DAGISelMatcher.h
index f4ababcd4be68a..81a5e3e050f272 100644
--- a/llvm/utils/TableGen/Common/DAGISelMatcher.h
+++ b/llvm/utils/TableGen/Common/DAGISelMatcher.h
@@ -836,7 +836,8 @@ class EmitIntegerMatcher : public Matcher {
public:
EmitIntegerMatcher(int64_t val, MVT::SimpleValueType vt)
- : Matcher(EmitInteger), Val(val), VT(vt) {}
+ : Matcher(EmitInteger), Val(SignExtend64(val, MVT(vt).getSizeInBits())),
+ VT(vt) {}
int64_t getValue() const { return Val; }
MVT::SimpleValueType getVT() const { return VT; }
More information about the llvm-commits
mailing list