As what has been mentioned in D137517, this patch is to simplify
processors definitions in RISCV.td. We don't have to specify march
string since we can generate it from target features.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp | ||
---|---|---|
60 | I think you should reference here the pieces of the standard that describe the rules for building the March string. | |
61 | Do you need this variable? it is used only once... | |
68 | I think you can avoid constructing a std::string here? | |
71 | Please avoid auto if the type cannot be deducted from the context. | |
76 | Do we need this variable? It is used only once... | |
77 | You could use StringRef and then check MArch.empty() in line 70. |
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp | ||
---|---|---|
77 | getMArch() returns std::string, if I change type of MArch from std::string to StringRef, it would be: if (MArch.empty()) MArch = StringRef(getMArch(XLen, Rec)); The string will be destroyed and cause errors like https://buildkite.com/llvm-project/premerge-checks/builds/130218. |
LGTM, with some minor observations:
- You say The disadvantage is that the generated march string is too tedious.. That does seems to imply that autogenerating the string is not a good idea? I'd remove it from the commit message.
- I am still thinking you should reference the bits of the RISCV specs that describe how to create MArch out of the features.
Thank you!
Francesco
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp | ||
---|---|---|
69 | Nit - maybe if you set std::vector<StringRef> FeatureVector; you can avoid the .str() in here? | |
72 | Nit: maybe alias the type in the body of the function? using ISAInfoTy = llvm::Expected<std::unique_ptr<RISCVISAInfo>>; ISAInfoTy ISAInfo = ... |
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp | ||
---|---|---|
69 | I'm afraid not, because we expect std::vector<std::string> in llvm::RISCVISAInfo::parseFeatures. |
LGTM, Ilike this improvement, it's further simplified the step of adding a new CPU info.
Nit: link to the specific version, or mention the version.