mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 11:26:02 +03:00
Add info about registered targets (mimic LLVM tools).
This commit is contained in:
parent
2ae6b3962a
commit
d986d08f37
1 changed files with 19 additions and 17 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
#include "llvm/Support/TargetSelect.h"
|
#include "llvm/Support/TargetSelect.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/MC/SubtargetFeature.h"
|
#include "llvm/MC/SubtargetFeature.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -83,7 +84,13 @@ void printVersion() {
|
||||||
global.ldc_version, global.version, global.llvm_version, global.copyright, global.written);
|
global.ldc_version, global.version, global.llvm_version, global.copyright, global.written);
|
||||||
printf("D Language Documentation: http://d-programming-language.org/index.html\n"
|
printf("D Language Documentation: http://d-programming-language.org/index.html\n"
|
||||||
"LDC Homepage: https://github.com/ldc-developers/ldc\n");
|
"LDC Homepage: https://github.com/ldc-developers/ldc\n");
|
||||||
|
printf("\n");
|
||||||
|
printf(" Default target: %s\n", llvm::sys::getDefaultTargetTriple().c_str());
|
||||||
|
std::string CPU = llvm::sys::getHostCPUName();
|
||||||
|
if (CPU == "generic") CPU = "(unknown)";
|
||||||
|
printf(" Host CPU: %s\n", CPU.c_str());
|
||||||
|
printf("\n");
|
||||||
|
llvm::TargetRegistry::printRegisteredTargetsForVersion();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,6 +217,17 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Initialize LLVM.
|
||||||
|
// Initialize targets first, so that --version shows registered targets.
|
||||||
|
#define LLVM_TARGET(A) \
|
||||||
|
LLVMInitialize##A##TargetInfo(); \
|
||||||
|
LLVMInitialize##A##Target(); \
|
||||||
|
LLVMInitialize##A##AsmPrinter(); \
|
||||||
|
LLVMInitialize##A##AsmParser(); \
|
||||||
|
LLVMInitialize##A##TargetMC();
|
||||||
|
LDC_TARGETS
|
||||||
|
#undef LLVM_TARGET
|
||||||
|
|
||||||
// Handle fixed-up arguments!
|
// Handle fixed-up arguments!
|
||||||
cl::SetVersionPrinter(&printVersion);
|
cl::SetVersionPrinter(&printVersion);
|
||||||
cl::ParseCommandLineOptions(final_args.size(), (char**)&final_args[0], "LLVM-based D Compiler\n", true);
|
cl::ParseCommandLineOptions(final_args.size(), (char**)&final_args[0], "LLVM-based D Compiler\n", true);
|
||||||
|
@ -457,22 +475,6 @@ int main(int argc, char** argv)
|
||||||
std::string triple = global.params.targetTriple;
|
std::string triple = global.params.targetTriple;
|
||||||
|
|
||||||
// Allocate target machine.
|
// Allocate target machine.
|
||||||
|
|
||||||
// first initialize llvm
|
|
||||||
#if 0
|
|
||||||
llvm::InitializeNativeTarget();
|
|
||||||
llvm::InitializeNativeTargetAsmParser();
|
|
||||||
llvm::InitializeNativeTargetAsmPrinter();
|
|
||||||
#endif
|
|
||||||
#define LLVM_TARGET(A) \
|
|
||||||
LLVMInitialize##A##TargetInfo(); \
|
|
||||||
LLVMInitialize##A##Target(); \
|
|
||||||
LLVMInitialize##A##AsmPrinter(); \
|
|
||||||
LLVMInitialize##A##AsmParser(); \
|
|
||||||
LLVMInitialize##A##TargetMC();
|
|
||||||
LDC_TARGETS
|
|
||||||
#undef LLVM_TARGET
|
|
||||||
|
|
||||||
const llvm::Target *theTarget = NULL;
|
const llvm::Target *theTarget = NULL;
|
||||||
// Check whether the user has explicitly specified an architecture to compile for.
|
// Check whether the user has explicitly specified an architecture to compile for.
|
||||||
if (mArch.empty())
|
if (mArch.empty())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue