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
Unit Tests
Event Timeline
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp | ||
---|---|---|
59 | I think you should reference here the pieces of the standard that describe the rules for building the March string. | |
60 | Do you need this variable? it is used only once... | |
67 | I think you can avoid constructing a std::string here? | |
70 | Please avoid auto if the type cannot be deducted from the context. | |
75 | Do we need this variable? It is used only once... | |
76 | You could use StringRef and then check MArch.empty() in line 70. |
llvm/utils/TableGen/RISCVTargetDefEmitter.cpp | ||
---|---|---|
76 | 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 | ||
---|---|---|
68 | Nit - maybe if you set std::vector<StringRef> FeatureVector; you can avoid the .str() in here? | |
71 | 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 | ||
---|---|---|
68 | 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.