This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add a table for extension implications.
ClosedPublic

Authored by craig.topper on Dec 13 2021, 1:09 PM.

Details

Summary

This a proof of concept for a suggestion I proposed in D108694.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 13 2021, 1:09 PM
craig.topper requested review of this revision.Dec 13 2021, 1:09 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2021, 1:09 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
eopXD added a comment.Dec 13 2021, 5:38 PM

LGTM. I will apply it onto D108694.

eopXD accepted this revision.Dec 13 2021, 5:38 PM
This revision is now accepted and ready to land.Dec 13 2021, 5:38 PM
eopXD added inline comments.Dec 13 2021, 7:11 PM
llvm/lib/Support/RISCVISAInfo.cpp
698

Will the variables with underscore violate the naming conventions in LLVM?

craig.topper added inline comments.Dec 13 2021, 7:30 PM
llvm/lib/Support/RISCVISAInfo.cpp
698

Yeah. Maybe I should use ImpliedExtsV and ImpliedExtsZfh so that a capital letter is against the ImpliedExts part for readability?

eopXD added a comment.Dec 13 2021, 7:35 PM

Sorry I accepted this without giving a closer look.
Some comments added :-)

llvm/lib/Support/RISCVISAInfo.cpp
730–738

I think this won't cover recursive dependencies?
Additionally, Calling addExtension will invalidate the range of Exts.
Maybe the "work list way" I did on the zvl patch is more correct than this single for loop?

733

Does this mean the ImpliedExts have to have extensions sorted in lexicological order? If so adding the zvl extension would look like: (I think it looks strange in my opinion, but no big problem though

static constexpr ImpliedExtsEntry ImpliedExts[] = {
    {"v", ImpliedExtsV},
    {"zfh", ImpliedExtsZfh},
    {"zvl64b", ImpliedExtsZvl64b},
    {"zvl1024b", ImpliedExtsZvl1024b},
    {"zvl128b", ImpliedExtsZvl128b},
    {"zvl16384b", ImpliedExtsZvl16384b},
    {"zvl2048b", ImpliedExtsZvl2048b},
    {"zvl256b", ImpliedExtsZvl256b},
    {"zvl32768b", ImpliedExtsZvl32768b},
    {"zvl4096b", ImpliedExtsZvl4096b},
    {"zvl512b", ImpliedExtsZvl512b},
    {"zvl65536b", ImpliedExtsZvl65536b},
    {"zvl8192b", ImpliedExtsZvl8192b},
};
craig.topper added inline comments.Dec 13 2021, 7:43 PM
llvm/lib/Support/RISCVISAInfo.cpp
733

Yes. It is unfortunate that they have to be ordered like that. I should also add a check to verify the table is sorted to prevent mistakes.

Add is_sorted check. Add operator< to the ImpliedFeatures struct
Remove underscore from array names.

clang-format

craig.topper requested review of this revision.Dec 13 2021, 9:38 PM
eopXD accepted this revision.Dec 13 2021, 10:03 PM

Looks good. Thank you for the patch!

This revision is now accepted and ready to land.Dec 13 2021, 10:03 PM
eopXD added inline comments.Dec 14 2021, 1:38 AM
llvm/lib/Support/RISCVISAInfo.cpp
730–738

The comment don't need to be addressed. It is a problem D108694 will deal with,

This revision was landed with ongoing or failed builds.Dec 14 2021, 9:30 AM
This revision was automatically updated to reflect the committed changes.

This does not build with gcc5 apparently: https://lab.llvm.org/staging/#/builders/190/builds/2632

llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char*)"v"' from 'const char*' to 'llvm::StringLiteral'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char**)(& ImpliedExtsV)' from 'const char**' to 'llvm::ArrayRef<const char*>'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char*)"zfh"' from 'const char*' to 'llvm::StringLiteral'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char**)(& ImpliedExtsZfh)' from 'const char**' to 'llvm::ArrayRef<const char*>'
craig.topper added a comment.EditedDec 14 2021, 9:36 PM

This does not build with gcc5 apparently: https://lab.llvm.org/staging/#/builders/190/builds/2632

llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char*)"v"' from 'const char*' to 'llvm::StringLiteral'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char**)(& ImpliedExtsV)' from 'const char**' to 'llvm::ArrayRef<const char*>'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char*)"zfh"' from 'const char*' to 'llvm::StringLiteral'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char**)(& ImpliedExtsZfh)' from 'const char**' to 'llvm::ArrayRef<const char*>'

Thanks. I seem to remember something about gcc 5.x and constexprs before. I’ll take a look

This does not build with gcc5 apparently: https://lab.llvm.org/staging/#/builders/190/builds/2632

llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char*)"v"' from 'const char*' to 'llvm::StringLiteral'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char**)(& ImpliedExtsV)' from 'const char**' to 'llvm::ArrayRef<const char*>'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char*)"zfh"' from 'const char*' to 'llvm::StringLiteral'
llvm/lib/Support/RISCVISAInfo.cpp:715:1: error: could not convert '(const char**)(& ImpliedExtsZfh)' from 'const char**' to 'llvm::ArrayRef<const char*>'

Thanks. I seem to remember something about gcc 5.x and constexprs before. I’ll take a look

We might just need more curly braces.