[PATCH] D102870: [RFC] CodeGen: Print/parse LLTs in MachineMemOperands
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 8 18:58:37 PDT 2021
arsenm updated this revision to Diff 350758.
arsenm added a comment.
Fix non power of 2 default alignment for weird types
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102870/new/
https://reviews.llvm.org/D102870
Files:
llvm/lib/CodeGen/MIRParser/MIParser.cpp
llvm/lib/CodeGen/MachineOperand.cpp
Index: llvm/lib/CodeGen/MachineOperand.cpp
===================================================================
--- llvm/lib/CodeGen/MachineOperand.cpp
+++ llvm/lib/CodeGen/MachineOperand.cpp
@@ -1113,10 +1113,10 @@
if (getFailureOrdering() != AtomicOrdering::NotAtomic)
OS << toIRString(getFailureOrdering()) << ' ';
- if (getSize() == MemoryLocation::UnknownSize)
- OS << "unknown-size";
+ if (getMemoryType().isValid())
+ OS << '(' << getMemoryType() << ')';
else
- OS << getSize();
+ OS << "unknown-size";
if (const Value *Val = getValue()) {
OS << ((isLoad() && isStore()) ? " on " : isLoad() ? " from " : " into ");
Index: llvm/lib/CodeGen/MIRParser/MIParser.cpp
===================================================================
--- llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -3047,18 +3047,34 @@
if (parseOptionalAtomicOrdering(FailureOrder))
return true;
+ LLT MemoryType;
if (Token.isNot(MIToken::IntegerLiteral) &&
- Token.isNot(MIToken::kw_unknown_size))
- return error("expected the size integer literal or 'unknown-size' after "
+ Token.isNot(MIToken::kw_unknown_size) &&
+ Token.isNot(MIToken::lparen))
+ return error("expected memory LLT, the size integer literal or 'unknown-size' after "
"memory operation");
- uint64_t Size;
+
+ uint64_t Size = MemoryLocation::UnknownSize;
if (Token.is(MIToken::IntegerLiteral)) {
if (getUint64(Size))
return true;
+
+ // Convert from bytes to bits for storage.
+ MemoryType = LLT::scalar(8 * Size);
+ lex();
} else if (Token.is(MIToken::kw_unknown_size)) {
Size = MemoryLocation::UnknownSize;
+ lex();
+ } else {
+ if (expectAndConsume(MIToken::lparen))
+ return true;
+ if (parseLowLevelType(Token.location(), MemoryType))
+ return true;
+ if (expectAndConsume(MIToken::rparen))
+ return true;
+
+ Size = MemoryType.getSizeInBytes();
}
- lex();
MachinePointerInfo Ptr = MachinePointerInfo();
if (Token.is(MIToken::Identifier)) {
@@ -3074,7 +3090,8 @@
if (parseMachinePointerInfo(Ptr))
return true;
}
- unsigned BaseAlignment = (Size != MemoryLocation::UnknownSize ? Size : 1);
+ unsigned BaseAlignment =
+ (Size != MemoryLocation::UnknownSize ? PowerOf2Ceil(Size) : 1);
AAMDNodes AAInfo;
MDNode *Range = nullptr;
while (consumeIfPresent(MIToken::comma)) {
@@ -3121,8 +3138,8 @@
}
if (expectAndConsume(MIToken::rparen))
return true;
- Dest = MF.getMachineMemOperand(Ptr, Flags, Size, Align(BaseAlignment), AAInfo,
- Range, SSID, Order, FailureOrder);
+ Dest = MF.getMachineMemOperand(Ptr, Flags, MemoryType, Align(BaseAlignment),
+ AAInfo, Range, SSID, Order, FailureOrder);
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102870.350758.patch
Type: text/x-patch
Size: 2870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210609/5efc90e1/attachment.bin>
More information about the llvm-commits
mailing list