-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm-ifs] Handle more e_machine values for --target #128559
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -200,6 +200,71 @@ uint16_t ELF::convertArchNameToEMachine(StringRef Arch) { | |
.Default(EM_NONE); | ||
} | ||
|
||
uint16_t ELF::convertTripleArchTypeToEMachine(Triple::ArchType ArchType) { | ||
switch (ArchType) { | ||
case Triple::UnknownArch: | ||
default: | ||
return EM_NONE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we leave There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know that every ArchType has an e_machine mapping. If they do, I don't know what they all are. |
||
|
||
case Triple::arm: | ||
case Triple::armeb: | ||
case Triple::thumb: | ||
case Triple::thumbeb: | ||
return EM_ARM; | ||
case Triple::aarch64: | ||
case Triple::aarch64_be: | ||
case Triple::aarch64_32: | ||
return EM_AARCH64; | ||
case Triple::arc: | ||
return EM_ARC; | ||
case Triple::avr: | ||
return EM_AVR; | ||
case Triple::bpfel: | ||
case Triple::bpfeb: | ||
return EM_BPF; | ||
case Triple::csky: | ||
return EM_CSKY; | ||
case Triple::hexagon: | ||
return EM_HEXAGON; | ||
case Triple::loongarch32: | ||
case Triple::loongarch64: | ||
return EM_LOONGARCH; | ||
case Triple::m68k: | ||
return EM_68K; | ||
case Triple::mips: | ||
case Triple::mipsel: | ||
case Triple::mips64: | ||
case Triple::mips64el: | ||
return EM_MIPS; | ||
case Triple::msp430: | ||
return EM_MSP430; | ||
case Triple::ppc: | ||
case Triple::ppcle: | ||
return EM_PPC; | ||
case Triple::ppc64: | ||
case Triple::ppc64le: | ||
return EM_PPC; | ||
case Triple::riscv32: | ||
case Triple::riscv64: | ||
return EM_RISCV; | ||
case Triple::sparc: | ||
case Triple::sparcel: | ||
return EM_SPARC; | ||
case Triple::sparcv9: | ||
return EM_SPARCV9; | ||
case Triple::systemz: | ||
return EM_S390; | ||
case Triple::x86: | ||
return EM_386; | ||
case Triple::x86_64: | ||
return EM_X86_64; | ||
case Triple::xcore: | ||
return EM_XCORE; | ||
case Triple::xtensa: | ||
return EM_XTENSA; | ||
} | ||
} | ||
|
||
/// Convert an ELF's e_machine value into an architecture name. | ||
StringRef ELF::convertEMachineToArchName(uint16_t EMachine) { | ||
switch (EMachine) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if there is a good place to share this - feels like something we would need in the MC layer for the object file emission.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is
ELFObjectFile::getArch()
going in the other direction, with pretty minimal coverage.AFAICT the actual emission is set by each
MCELFObjectTargetWriter
subclass's constructor.I don't really see any straightforward way to share a single source of truth there.