[PATCH] D116735: [RISCV] Adjust RISCV data layout by using n32:64 in layout string
Jun Sha via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 6 03:52:57 PST 2022
joshua-arch1 created this revision.
joshua-arch1 added reviewers: asb, frasercrmck, mgrang.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
joshua-arch1 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.
Although i32 type is illegal in llvm back-end, I don't think it necessory to keep consistent for layout string.
In the current version, layout string is "e-m:e-p:64:64-i64:64-i128:128-n64-S128" for 64-bit arch where native integer type is only i64. However, under this circumstance, some middle-end passes like LSRs may be influenced due to the predictor("DL.isLegalInteger") result.
Let's look at line 157-162 in IVUsers.cpp.
- // LSR is not APInt clean, do not touch integers bigger than 64-bits. // Also avoid creating IVs of non-native types. For example, we don't want a // 64-bit IV in 32-bit code just because the loop has one 64-bit cast. uint64_t Width = SE->getTypeSizeInBits(I->getType()); if (Width > 64 || !DL.isLegalInteger(Width)) return false;**
Now I try to use n32:64 in layout string without degression of some other passes that use this info.
https://reviews.llvm.org/D116735
Files:
clang/lib/Basic/Targets/RISCV.h
llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
Index: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
+++ llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
@@ -46,7 +46,7 @@
static StringRef computeDataLayout(const Triple &TT) {
if (TT.isArch64Bit())
- return "e-m:e-p:64:64-i64:64-i128:128-n64-S128";
+ return "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128";
assert(TT.isArch32Bit() && "only RV32 and RV64 are currently supported");
return "e-m:e-p:32:32-i64:64-n32-S128";
}
Index: clang/lib/Basic/Targets/RISCV.h
===================================================================
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -133,7 +133,7 @@
: RISCVTargetInfo(Triple, Opts) {
LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
IntMaxType = Int64Type = SignedLong;
- resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
+ resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n32:64-S128");
}
bool setABI(const std::string &Name) override {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116735.397839.patch
Type: text/x-patch
Size: 1087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220106/f9e5b794/attachment.bin>
More information about the llvm-commits
mailing list