@@ -924,15 +924,18 @@ checkPPCMathOperationsRange(llvm::StringRef name) {
924
924
925
925
// Helper functions for vector element ordering.
926
926
bool PPCIntrinsicLibrary::isBEVecElemOrderOnLE () {
927
- return (Fortran::evaluate::isHostLittleEndian &&
927
+ const auto triple{fir::getTargetTriple (builder.getModule ())};
928
+ return (triple.isLittleEndian () &&
928
929
converter->getLoweringOptions ().getNoPPCNativeVecElemOrder ());
929
930
}
930
931
bool PPCIntrinsicLibrary::isNativeVecElemOrderOnLE () {
931
- return (Fortran::evaluate::isHostLittleEndian &&
932
+ const auto triple{fir::getTargetTriple (builder.getModule ())};
933
+ return (triple.isLittleEndian () &&
932
934
!converter->getLoweringOptions ().getNoPPCNativeVecElemOrder ());
933
935
}
934
936
bool PPCIntrinsicLibrary::changeVecElemOrder () {
935
- return (Fortran::evaluate::isHostLittleEndian !=
937
+ const auto triple{fir::getTargetTriple (builder.getModule ())};
938
+ return (triple.isLittleEndian () !=
936
939
converter->getLoweringOptions ().getNoPPCNativeVecElemOrder ());
937
940
}
938
941
@@ -2205,12 +2208,19 @@ PPCIntrinsicLibrary::genVecShift(mlir::Type resultType,
2205
2208
shiftVal = shiftVal << 2 ;
2206
2209
shiftVal &= 0xF ;
2207
2210
llvm::SmallVector<int64_t , 16 > mask;
2208
- for (int i = 16 ; i < 32 ; ++i)
2209
- mask.push_back (i - shiftVal);
2210
-
2211
- // Shuffle with mask
2212
- shftRes = builder.create <mlir::vector::ShuffleOp>(loc, mlirVecArgs[1 ],
2213
- mlirVecArgs[0 ], mask);
2211
+ // Shuffle with mask based on the endianness
2212
+ const auto triple{fir::getTargetTriple (builder.getModule ())};
2213
+ if (triple.isLittleEndian ()) {
2214
+ for (int i = 16 ; i < 32 ; ++i)
2215
+ mask.push_back (i - shiftVal);
2216
+ shftRes = builder.create <mlir::vector::ShuffleOp>(loc, mlirVecArgs[1 ],
2217
+ mlirVecArgs[0 ], mask);
2218
+ } else {
2219
+ for (int i = 0 ; i < 16 ; ++i)
2220
+ mask.push_back (i + shiftVal);
2221
+ shftRes = builder.create <mlir::vector::ShuffleOp>(loc, mlirVecArgs[0 ],
2222
+ mlirVecArgs[1 ], mask);
2223
+ }
2214
2224
2215
2225
// Bitcast to the original type
2216
2226
if (shftRes.getType () != mlirTyArgs[0 ])
@@ -2593,7 +2603,8 @@ void PPCIntrinsicLibrary::genMmaIntr(llvm::ArrayRef<fir::ExtendedValue> args) {
2593
2603
} else if (HandlerOp == MMAHandlerOp::SubToFuncReverseArgOnLE) {
2594
2604
// Reverse argument order on little-endian target only.
2595
2605
// The reversal does not depend on the setting of non-native-order option.
2596
- if (Fortran::evaluate::isHostLittleEndian) {
2606
+ const auto triple{fir::getTargetTriple (builder.getModule ())};
2607
+ if (triple.isLittleEndian ()) {
2597
2608
// Load the arguments in reverse order.
2598
2609
argStart = args.size () - 1 ;
2599
2610
// The first argument becomes function result. Stop at the second
0 commit comments