diff options
author | Dan Gohman <sunfish@mozilla.com> | 2014-03-04 12:54:43 -0800 |
---|---|---|
committer | Dan Gohman <sunfish@mozilla.com> | 2014-03-04 13:08:47 -0800 |
commit | dc1378e24ff461546f531ec3a6138046b8e9c9ef (patch) | |
tree | 11d7f7e71f144b0c2dfa90a2e1e88a9ae3a6b702 /lib/Target/JSBackend/TargetInfo/JSBackendTargetInfo.cpp | |
parent | 65405351ba0b32a8658c65940e0b65ceb2601ad4 (diff) |
Better integration with the LLVM Target system.
In particular, this is needed to make getOptLevel() work.
Diffstat (limited to 'lib/Target/JSBackend/TargetInfo/JSBackendTargetInfo.cpp')
-rw-r--r-- | lib/Target/JSBackend/TargetInfo/JSBackendTargetInfo.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/Target/JSBackend/TargetInfo/JSBackendTargetInfo.cpp b/lib/Target/JSBackend/TargetInfo/JSBackendTargetInfo.cpp index cf06eaceea..66a3f4d6e8 100644 --- a/lib/Target/JSBackend/TargetInfo/JSBackendTargetInfo.cpp +++ b/lib/Target/JSBackend/TargetInfo/JSBackendTargetInfo.cpp @@ -8,6 +8,7 @@ //===--------------------------------------------------------------------===// #include "JSTargetMachine.h" +#include "MCTargetDesc/JSBackendMCTargetDesc.h" #include "llvm/IR/Module.h" #include "llvm/Support/TargetRegistry.h" using namespace llvm; @@ -15,8 +16,21 @@ using namespace llvm; Target llvm::TheJSBackendTarget; static unsigned JSBackend_TripleMatchQuality(const std::string &TT) { - // This class always works, but shouldn't be the default in most cases. - return 1; + switch (Triple(TT).getArch()) { + case Triple::asmjs: + // That's us! + return 20; + + case Triple::le32: + case Triple::x86: + // For compatibility with older versions of Emscripten, we also basically + // support generating code for le32-unknown-nacl and i386-pc-linux-gnu, + // but we use a low number here so that we're not the default. + return 1; + + default: + return 0; + } } extern "C" void LLVMInitializeJSBackendTargetInfo() { @@ -24,5 +38,3 @@ extern "C" void LLVMInitializeJSBackendTargetInfo() { "JavaScript (asm.js, emscripten) backend", &JSBackend_TripleMatchQuality); } - -extern "C" void LLVMInitializeJSBackendTargetMC() {} |