mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-30 19:55:11 +00:00
Fix it so llvm-objdump -arch does accept x86 and x86-64 as valid arch names.
PR12731. Patch by Meador Inge! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156444 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
acc472a4fe
commit
9ed9e5d0f9
@ -510,6 +510,21 @@ namespace llvm {
|
|||||||
static const Target *lookupTarget(const std::string &Triple,
|
static const Target *lookupTarget(const std::string &Triple,
|
||||||
std::string &Error);
|
std::string &Error);
|
||||||
|
|
||||||
|
/// lookupTarget - Lookup a target based on an architecture name
|
||||||
|
/// and a target triple. If the architecture name is non-empty,
|
||||||
|
/// then the lookup is done by architecture. Otherwise, the target
|
||||||
|
/// triple is used.
|
||||||
|
///
|
||||||
|
/// \param ArchName - The architecture to use for finding a target.
|
||||||
|
/// \param TheTriple - The triple to use for finding a target. The
|
||||||
|
/// triple is updated with canonical architecture name if a lookup
|
||||||
|
/// by architecture is done.
|
||||||
|
/// \param Error - On failure, an error string describing why no target was
|
||||||
|
/// found.
|
||||||
|
static const Target *lookupTarget(const std::string &ArchName,
|
||||||
|
Triple &TheTriple,
|
||||||
|
std::string &Error);
|
||||||
|
|
||||||
/// getClosestTargetForJIT - Pick the best target that is compatible with
|
/// getClosestTargetForJIT - Pick the best target that is compatible with
|
||||||
/// the current host. If no close target can be found, this returns null
|
/// the current host. If no close target can be found, this returns null
|
||||||
/// and sets the Error string to a reason.
|
/// and sets the Error string to a reason.
|
||||||
|
@ -23,6 +23,47 @@ TargetRegistry::iterator TargetRegistry::begin() {
|
|||||||
return iterator(FirstTarget);
|
return iterator(FirstTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Target *TargetRegistry::lookupTarget(const std::string &ArchName,
|
||||||
|
Triple &TheTriple,
|
||||||
|
std::string &Error) {
|
||||||
|
// Allocate target machine. First, check whether the user has explicitly
|
||||||
|
// specified an architecture to compile for. If so we have to look it up by
|
||||||
|
// name, because it might be a backend that has no mapping to a target triple.
|
||||||
|
const Target *TheTarget = 0;
|
||||||
|
if (!ArchName.empty()) {
|
||||||
|
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
||||||
|
ie = TargetRegistry::end(); it != ie; ++it) {
|
||||||
|
if (ArchName == it->getName()) {
|
||||||
|
TheTarget = &*it;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TheTarget) {
|
||||||
|
Error = "error: invalid target '" + ArchName + "'.\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adjust the triple to match (if known), otherwise stick with the
|
||||||
|
// given triple.
|
||||||
|
Triple::ArchType Type = Triple::getArchTypeForLLVMName(ArchName);
|
||||||
|
if (Type != Triple::UnknownArch)
|
||||||
|
TheTriple.setArch(Type);
|
||||||
|
} else {
|
||||||
|
// Get the target specific parser.
|
||||||
|
std::string TempError;
|
||||||
|
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), TempError);
|
||||||
|
if (TheTarget == 0) {
|
||||||
|
Error = ": error: unable to get target for '"
|
||||||
|
+ TheTriple.getTriple()
|
||||||
|
+ "', see --version and --triple.\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TheTarget;
|
||||||
|
}
|
||||||
|
|
||||||
const Target *TargetRegistry::lookupTarget(const std::string &TT,
|
const Target *TargetRegistry::lookupTarget(const std::string &TT,
|
||||||
std::string &Error) {
|
std::string &Error) {
|
||||||
// Provide special warning when no targets are initialized.
|
// Provide special warning when no targets are initialized.
|
||||||
|
@ -366,42 +366,18 @@ int main(int argc, char **argv) {
|
|||||||
if (!TargetTriple.empty())
|
if (!TargetTriple.empty())
|
||||||
mod.setTargetTriple(Triple::normalize(TargetTriple));
|
mod.setTargetTriple(Triple::normalize(TargetTriple));
|
||||||
|
|
||||||
|
// Figure out the target triple.
|
||||||
Triple TheTriple(mod.getTargetTriple());
|
Triple TheTriple(mod.getTargetTriple());
|
||||||
if (TheTriple.getTriple().empty())
|
if (TheTriple.getTriple().empty())
|
||||||
TheTriple.setTriple(sys::getDefaultTargetTriple());
|
TheTriple.setTriple(sys::getDefaultTargetTriple());
|
||||||
|
|
||||||
// Allocate target machine. First, check whether the user has explicitly
|
// Get the target specific parser.
|
||||||
// specified an architecture to compile for. If so we have to look it up by
|
std::string Error;
|
||||||
// name, because it might be a backend that has no mapping to a target triple.
|
const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
|
||||||
const Target *TheTarget = 0;
|
Error);
|
||||||
if (!MArch.empty()) {
|
if (!TheTarget) {
|
||||||
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
errs() << argv[0] << ": " << Error;
|
||||||
ie = TargetRegistry::end(); it != ie; ++it) {
|
return 1;
|
||||||
if (MArch == it->getName()) {
|
|
||||||
TheTarget = &*it;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TheTarget) {
|
|
||||||
errs() << argv[0] << ": error: invalid target '" << MArch << "'.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust the triple to match (if known), otherwise stick with the
|
|
||||||
// module/host triple.
|
|
||||||
Triple::ArchType Type = Triple::getArchTypeForLLVMName(MArch);
|
|
||||||
if (Type != Triple::UnknownArch)
|
|
||||||
TheTriple.setArch(Type);
|
|
||||||
} else {
|
|
||||||
std::string Err;
|
|
||||||
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Err);
|
|
||||||
if (TheTarget == 0) {
|
|
||||||
errs() << argv[0] << ": error auto-selecting target for module '"
|
|
||||||
<< Err << "'. Please use the -march option to explicitly "
|
|
||||||
<< "pick a target.\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Package up features to be passed to target/subtarget
|
// Package up features to be passed to target/subtarget
|
||||||
|
@ -180,38 +180,16 @@ static const Target *GetTarget(const char *ProgName) {
|
|||||||
TripleName = sys::getDefaultTargetTriple();
|
TripleName = sys::getDefaultTargetTriple();
|
||||||
Triple TheTriple(Triple::normalize(TripleName));
|
Triple TheTriple(Triple::normalize(TripleName));
|
||||||
|
|
||||||
const Target *TheTarget = 0;
|
// Get the target specific parser.
|
||||||
if (!ArchName.empty()) {
|
std::string Error;
|
||||||
for (TargetRegistry::iterator it = TargetRegistry::begin(),
|
const Target *TheTarget = TargetRegistry::lookupTarget(ArchName, TheTriple,
|
||||||
ie = TargetRegistry::end(); it != ie; ++it) {
|
Error);
|
||||||
if (ArchName == it->getName()) {
|
if (!TheTarget) {
|
||||||
TheTarget = &*it;
|
errs() << ProgName << ": " << Error;
|
||||||
break;
|
return 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TheTarget) {
|
|
||||||
errs() << ProgName << ": error: invalid target '" << ArchName << "'.\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust the triple to match (if known), otherwise stick with the
|
|
||||||
// module/host triple.
|
|
||||||
Triple::ArchType Type = Triple::getArchTypeForLLVMName(ArchName);
|
|
||||||
if (Type != Triple::UnknownArch)
|
|
||||||
TheTriple.setArch(Type);
|
|
||||||
} else {
|
|
||||||
// Get the target specific parser.
|
|
||||||
std::string Error;
|
|
||||||
TheTarget = TargetRegistry::lookupTarget(TheTriple.getTriple(), Error);
|
|
||||||
if (TheTarget == 0) {
|
|
||||||
errs() << ProgName << ": error: unable to get target for '"
|
|
||||||
<< TheTriple.getTriple()
|
|
||||||
<< "', see --version and --triple.\n";
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the triple name and return the found target.
|
||||||
TripleName = TheTriple.getTriple();
|
TripleName = TheTriple.getTriple();
|
||||||
return TheTarget;
|
return TheTarget;
|
||||||
}
|
}
|
||||||
|
@ -106,27 +106,25 @@ static bool error(error_code ec) {
|
|||||||
|
|
||||||
static const Target *GetTarget(const ObjectFile *Obj = NULL) {
|
static const Target *GetTarget(const ObjectFile *Obj = NULL) {
|
||||||
// Figure out the target triple.
|
// Figure out the target triple.
|
||||||
llvm::Triple TT("unknown-unknown-unknown");
|
llvm::Triple TheTriple("unknown-unknown-unknown");
|
||||||
if (TripleName.empty()) {
|
if (TripleName.empty()) {
|
||||||
if (Obj)
|
if (Obj)
|
||||||
TT.setArch(Triple::ArchType(Obj->getArch()));
|
TheTriple.setArch(Triple::ArchType(Obj->getArch()));
|
||||||
} else
|
} else
|
||||||
TT.setTriple(Triple::normalize(TripleName));
|
TheTriple.setTriple(Triple::normalize(TripleName));
|
||||||
|
|
||||||
if (!ArchName.empty())
|
|
||||||
TT.setArchName(ArchName);
|
|
||||||
|
|
||||||
TripleName = TT.str();
|
|
||||||
|
|
||||||
// Get the target specific parser.
|
// Get the target specific parser.
|
||||||
std::string Error;
|
std::string Error;
|
||||||
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
|
const Target *TheTarget = TargetRegistry::lookupTarget(ArchName, TheTriple,
|
||||||
if (TheTarget)
|
Error);
|
||||||
return TheTarget;
|
if (!TheTarget) {
|
||||||
|
errs() << ToolName << ": " << Error;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
errs() << ToolName << ": error: unable to get target for '" << TripleName
|
// Update the triple name and return the found target.
|
||||||
<< "', see --version and --triple.\n";
|
TripleName = TheTriple.getTriple();
|
||||||
return 0;
|
return TheTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void llvm::StringRefMemoryObject::anchor() { }
|
void llvm::StringRefMemoryObject::anchor() { }
|
||||||
|
Loading…
Reference in New Issue
Block a user