[llvm] [RISCV][MC] Implement ISA mapping symbols (PR #67541)
Joe Faulls via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 12 03:09:32 PST 2024
================
@@ -66,6 +86,69 @@ void RISCVTargetELFStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
void RISCVTargetELFStreamer::emitTextAttribute(unsigned Attribute,
StringRef String) {
getStreamer().setAttributeItem(Attribute, String, /*OverwriteExisting=*/true);
+ if (Attribute == RISCVAttrs::ARCH)
+ setArchString(String);
+}
+
+void RISCVTargetELFStreamer::emitDirectiveOptionArch(
+ ArrayRef<RISCVOptionArchArg> Args) {
+ if (Args.size() == 1) {
+ RISCVOptionArchArg Arg = Args[0];
+ if (Arg.Type == RISCVOptionArchArgType::Full) {
+ // If there is a full arch string, then just set the arch string and
+ // return. It is illegal to have more than one argument with this option.
+ setArchString(Arg.Value);
+ return;
+ }
+ }
+
+ auto ParseResult = RISCVISAInfo::parseArchString(ISAString, false);
+ if (!ParseResult) {
+ std::string Buffer;
+ raw_string_ostream OutputErrMsg(Buffer);
+ handleAllErrors(ParseResult.takeError(), [&](llvm::StringError &ErrMsg) {
+ OutputErrMsg << "invalid arch name '" << ISAString << "', "
+ << ErrMsg.getMessage();
+ });
+ return;
+ }
+ auto &ISAInfo = *ParseResult;
+ std::vector<std::string> NewFeatures = ISAInfo->toFeatureVector();
+ for (RISCVOptionArchArg Arg : Args) {
+ switch (Arg.Type) {
+ case RISCVOptionArchArgType::Minus:
+ NewFeatures.push_back("-" + Arg.Value);
+ break;
+ case RISCVOptionArchArgType::Plus:
+ NewFeatures.push_back("+" + Arg.Value);
+ break;
+ case RISCVOptionArchArgType::Full:
+ // This is special cased at the beginning of this function.
+ // It is illegal to have more than one argument for this option.
+ llvm_unreachable("Improperly formed arch option");
+ break;
----------------
joe-img wrote:
done
https://github.com/llvm/llvm-project/pull/67541
More information about the llvm-commits
mailing list