[llvm] [GlobalISel] Change MatchTable entries to 1 byte each (PR #74429)
Wang Pengcheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 5 20:23:53 PST 2023
================
@@ -172,33 +226,66 @@ MatchTableRecord MatchTable::Opcode(StringRef Opcode, int IndentAdjust) {
MatchTableRecord::MTRF_CommaFollows | ExtraFlags);
}
-MatchTableRecord MatchTable::NamedValue(StringRef NamedValue) {
- return MatchTableRecord(std::nullopt, NamedValue, 1,
+MatchTableRecord MatchTable::NamedValue(unsigned NumBytes,
+ StringRef NamedValue) {
+ return MatchTableRecord(std::nullopt, NamedValue, NumBytes,
MatchTableRecord::MTRF_CommaFollows);
}
-MatchTableRecord MatchTable::NamedValue(StringRef NamedValue,
+MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef NamedValue,
int64_t RawValue) {
- return MatchTableRecord(std::nullopt, NamedValue, 1,
+ return MatchTableRecord(std::nullopt, NamedValue, NumBytes,
MatchTableRecord::MTRF_CommaFollows, RawValue);
}
-MatchTableRecord MatchTable::NamedValue(StringRef Namespace,
+MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
StringRef NamedValue) {
return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),
- 1, MatchTableRecord::MTRF_CommaFollows);
+ NumBytes, MatchTableRecord::MTRF_CommaFollows);
}
-MatchTableRecord MatchTable::NamedValue(StringRef Namespace,
+MatchTableRecord MatchTable::NamedValue(unsigned NumBytes, StringRef Namespace,
StringRef NamedValue,
int64_t RawValue) {
return MatchTableRecord(std::nullopt, (Namespace + "::" + NamedValue).str(),
- 1, MatchTableRecord::MTRF_CommaFollows, RawValue);
+ NumBytes, MatchTableRecord::MTRF_CommaFollows,
+ RawValue);
+}
+
+MatchTableRecord MatchTable::IntValue(unsigned NumBytes, int64_t IntValue) {
+ assert(isUIntN(NumBytes * 8, IntValue) || isIntN(NumBytes * 8, IntValue));
+ auto Str = llvm::to_string(IntValue);
+ if (NumBytes == 1 && IntValue < 0)
+ Str = "uint8_t(" + Str + ")";
+ // TODO: Could optimize this directly to save the compiler some work when
+ // building the file
+ return MatchTableRecord(std::nullopt, Str, NumBytes,
+ MatchTableRecord::MTRF_CommaFollows);
}
-MatchTableRecord MatchTable::IntValue(int64_t IntValue) {
- return MatchTableRecord(std::nullopt, llvm::to_string(IntValue), 1,
- MatchTableRecord::MTRF_CommaFollows);
+MatchTableRecord MatchTable::ULEB128Value(uint64_t IntValue) {
+ uint8_t Buffer[16];
----------------
wangpc-pp wrote:
The maximum output bytes would be 10 I think.
https://github.com/llvm/llvm-project/pull/74429
More information about the llvm-commits
mailing list