Skip to content

Commit 5a55205

Browse files
imaihalRiver707
authored andcommitted
[mlir] Fixed dynamic operand storage on big-endian machines.
Many tests fails by D101969 (https://reviews.llvm.org/D101969) on big-endian machines. This patch changes bit order of TrailingOperandStorage in big-endian machines. This patch works on System Z (Triple = "s390x-ibm-linux", CPU = "z14"). Signed-off-by: Haruki Imai <imaihal@jp.ibm.com> Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D104225
1 parent 07481b3 commit 5a55205

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

mlir/include/mlir/IR/OperationSupport.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,11 @@ namespace detail {
484484
/// This class contains the information for a trailing operand storage.
485485
struct TrailingOperandStorage final
486486
: public llvm::TrailingObjects<TrailingOperandStorage, OpOperand> {
487+
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
488+
TrailingOperandStorage() : numOperands(0), capacity(0), reserved(0) {}
489+
#else
487490
TrailingOperandStorage() : reserved(0), capacity(0), numOperands(0) {}
491+
#endif
488492
~TrailingOperandStorage() {
489493
for (auto &operand : getOperands())
490494
operand.~OpOperand();
@@ -495,12 +499,21 @@ struct TrailingOperandStorage final
495499
return {getTrailingObjects<OpOperand>(), numOperands};
496500
}
497501

502+
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
503+
/// The number of operands within the storage.
504+
unsigned numOperands;
505+
/// The total capacity number of operands that the storage can hold.
506+
unsigned capacity : 31;
507+
/// We reserve a range of bits for use by the operand storage.
508+
unsigned reserved : 1;
509+
#else
498510
/// We reserve a range of bits for use by the operand storage.
499511
unsigned reserved : 1;
500512
/// The total capacity number of operands that the storage can hold.
501513
unsigned capacity : 31;
502514
/// The number of operands within the storage.
503515
unsigned numOperands;
516+
#endif
504517
};
505518

506519
/// This class handles the management of operation operands. Operands are

0 commit comments

Comments
 (0)