diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-27 19:57:19 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-27 19:57:19 -0800 |
commit | 81afe65c6fa734101c96dc99ec10b1aed3f43602 (patch) | |
tree | 7af4be660811c17f77cefe25c9be2b7df36df980 | |
parent | 9a21bed266588de64040a9ec3b3dafa912eb4c6a (diff) |
CPPBackend => JSBackend
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rwxr-xr-x | configure | 5 | ||||
-rw-r--r-- | lib/Target/CppBackend/CMakeLists.txt | 6 | ||||
-rw-r--r-- | lib/Target/CppBackend/LLVMBuild.txt | 29 | ||||
-rw-r--r-- | lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp | 28 | ||||
-rw-r--r-- | lib/Target/CppBackend/readme.txt | 1 | ||||
-rw-r--r-- | lib/Target/JSBackend/CMakeLists.txt | 6 | ||||
-rw-r--r-- | lib/Target/JSBackend/CallHandlers.h (renamed from lib/Target/CppBackend/CallHandlers.h) | 26 | ||||
-rw-r--r-- | lib/Target/JSBackend/JSBackend.cpp (renamed from lib/Target/CppBackend/CPPBackend.cpp) | 48 | ||||
-rw-r--r-- | lib/Target/JSBackend/JSTargetMachine.h (renamed from lib/Target/CppBackend/CPPTargetMachine.h) | 25 | ||||
-rw-r--r-- | lib/Target/JSBackend/LLVMBuild.txt | 31 | ||||
-rw-r--r-- | lib/Target/JSBackend/Makefile (renamed from lib/Target/CppBackend/Makefile) | 6 | ||||
-rw-r--r-- | lib/Target/JSBackend/OptPasses.h (renamed from lib/Target/CppBackend/OptPasses.h) | 4 | ||||
-rw-r--r-- | lib/Target/JSBackend/Relooper.cpp (renamed from lib/Target/CppBackend/Relooper.cpp) | 0 | ||||
-rw-r--r-- | lib/Target/JSBackend/Relooper.h (renamed from lib/Target/CppBackend/Relooper.h) | 0 | ||||
-rw-r--r-- | lib/Target/JSBackend/SimplifyAllocas.cpp (renamed from lib/Target/CppBackend/SimplifyAllocas.cpp) | 4 | ||||
-rw-r--r-- | lib/Target/JSBackend/TargetInfo/CMakeLists.txt (renamed from lib/Target/CppBackend/TargetInfo/CMakeLists.txt) | 4 | ||||
-rw-r--r-- | lib/Target/JSBackend/TargetInfo/CppBackendTargetInfo.cpp | 28 | ||||
-rw-r--r-- | lib/Target/JSBackend/TargetInfo/LLVMBuild.txt (renamed from lib/Target/CppBackend/TargetInfo/LLVMBuild.txt) | 12 | ||||
-rw-r--r-- | lib/Target/JSBackend/TargetInfo/Makefile (renamed from lib/Target/CppBackend/TargetInfo/Makefile) | 6 | ||||
-rw-r--r-- | lib/Target/LLVMBuild.txt | 2 | ||||
-rwxr-xr-x | projects/sample/configure | 3 |
22 files changed, 141 insertions, 134 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index fffdf9b87b..2918aeb86a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,7 @@ set(LLVM_ALL_TARGETS ARM CppBackend Hexagon + JSBackend Mips MBlaze MSP430 @@ -1445,7 +1445,7 @@ Optional Features: --enable-targets Build specific host targets: all or target1,target2,... Valid targets are: host, x86, x86_64, sparc, powerpc, arm, aarch64, mips, hexagon, - xcore, msp430, nvptx, systemz, and cpp (default=all) + xcore, msp430, nvptx, systemz, js, and cpp (default=all) --enable-experimental-targets Build experimental host targets: disable or target1,target2,... (default=disable) @@ -5641,7 +5641,7 @@ if test "$enableval" = host-only ; then enableval=host fi case "$enableval" in - all) TARGETS_TO_BUILD="X86 Sparc PowerPC AArch64 ARM Mips XCore MSP430 CppBackend MBlaze NVPTX Hexagon SystemZ" ;; + all) TARGETS_TO_BUILD="X86 Sparc PowerPC AArch64 ARM Mips XCore MSP430 CppBackend JSBackend MBlaze NVPTX Hexagon SystemZ" ;; *)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do case "$a_target" in x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;; @@ -5657,6 +5657,7 @@ case "$enableval" in xcore) TARGETS_TO_BUILD="XCore $TARGETS_TO_BUILD" ;; msp430) TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;; cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;; + js) TARGETS_TO_BUILD="JSBackend $TARGETS_TO_BUILD" ;; hexagon) TARGETS_TO_BUILD="Hexagon $TARGETS_TO_BUILD" ;; mblaze) TARGETS_TO_BUILD="MBlaze $TARGETS_TO_BUILD" ;; nvptx) TARGETS_TO_BUILD="NVPTX $TARGETS_TO_BUILD" ;; diff --git a/lib/Target/CppBackend/CMakeLists.txt b/lib/Target/CppBackend/CMakeLists.txt deleted file mode 100644 index 7e138b2695..0000000000 --- a/lib/Target/CppBackend/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_llvm_target(CppBackendCodeGen - CPPBackend.cpp - Relooper.cpp - ) - -add_subdirectory(TargetInfo) diff --git a/lib/Target/CppBackend/LLVMBuild.txt b/lib/Target/CppBackend/LLVMBuild.txt index 122b5e7502..139597f9cb 100644 --- a/lib/Target/CppBackend/LLVMBuild.txt +++ b/lib/Target/CppBackend/LLVMBuild.txt @@ -1,31 +1,2 @@ -;===- ./lib/Target/CppBackend/LLVMBuild.txt --------------------*- Conf -*--===; -; -; The LLVM Compiler Infrastructure -; -; This file is distributed under the University of Illinois Open Source -; License. See LICENSE.TXT for details. -; -;===------------------------------------------------------------------------===; -; -; This is an LLVMBuild description file for the components in this subdirectory. -; -; For more information on the LLVMBuild system, please see: -; -; http://llvm.org/docs/LLVMBuild.html -; -;===------------------------------------------------------------------------===; -[common] -subdirectories = TargetInfo -[component_0] -type = TargetGroup -name = CppBackend -parent = Target - -[component_1] -type = Library -name = CppBackendCodeGen -parent = CppBackend -required_libraries = Core CppBackendInfo Support Target -add_to_library_groups = CppBackend diff --git a/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp b/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp deleted file mode 100644 index 339b36105c..0000000000 --- a/lib/Target/CppBackend/TargetInfo/CppBackendTargetInfo.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===-- CppBackendTargetInfo.cpp - CppBackend Target Implementation -------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CPPTargetMachine.h" -#include "llvm/IR/Module.h" -#include "llvm/Support/TargetRegistry.h" -using namespace llvm; - -Target llvm::TheCppBackendTarget; - -static unsigned CppBackend_TripleMatchQuality(const std::string &TT) { - // This class always works, but shouldn't be the default in most cases. - return 1; -} - -extern "C" void LLVMInitializeCppBackendTargetInfo() { - TargetRegistry::RegisterTarget(TheCppBackendTarget, "js", - "JavaScript backend", - &CppBackend_TripleMatchQuality); -} - -extern "C" void LLVMInitializeCppBackendTargetMC() {} diff --git a/lib/Target/CppBackend/readme.txt b/lib/Target/CppBackend/readme.txt new file mode 100644 index 0000000000..aa482b2fd4 --- /dev/null +++ b/lib/Target/CppBackend/readme.txt @@ -0,0 +1 @@ +TODO: restore old cpp backend to here diff --git a/lib/Target/JSBackend/CMakeLists.txt b/lib/Target/JSBackend/CMakeLists.txt new file mode 100644 index 0000000000..9d38665eeb --- /dev/null +++ b/lib/Target/JSBackend/CMakeLists.txt @@ -0,0 +1,6 @@ +add_llvm_target(JSBackendCodeGen + JSBackend.cpp + Relooper.cpp + ) + +add_subdirectory(TargetInfo) diff --git a/lib/Target/CppBackend/CallHandlers.h b/lib/Target/JSBackend/CallHandlers.h index d23fa7e9b9..0bd7e191cb 100644 --- a/lib/Target/CppBackend/CallHandlers.h +++ b/lib/Target/JSBackend/CallHandlers.h @@ -37,13 +37,13 @@ DEF_CALL_HANDLER(__default__, { text += ")"; Type *RT = CI->getType(); if (!RT->isVoidTy()) { - text = getAssign(getCppName(CI), RT) + getCast(text, RT, ASM_NONSPECIFIC); + text = getAssign(getJSName(CI), RT) + getCast(text, RT, ASM_NONSPECIFIC); } return text; }) DEF_CALL_HANDLER(getHigh32, { - return getAssign(getCppName(CI), CI->getType()) + "tempRet0"; + return getAssign(getJSName(CI), CI->getType()) + "tempRet0"; }) DEF_CALL_HANDLER(setHigh32, { @@ -51,48 +51,48 @@ DEF_CALL_HANDLER(setHigh32, { }) DEF_CALL_HANDLER(FPtoILow, { - return getAssign(getCppName(CI), CI->getType()) + "(~~" + getValueAsStr(CI->getArgOperand(0)) + ")>>>0"; + return getAssign(getJSName(CI), CI->getType()) + "(~~" + getValueAsStr(CI->getArgOperand(0)) + ")>>>0"; }) DEF_CALL_HANDLER(FPtoIHigh, { std::string Input = getValueAsStr(CI->getArgOperand(0)); - return getAssign(getCppName(CI), CI->getType()) + "+Math_abs(" + Input + ") >= +1 ? " + Input + " > +0 ? (Math_min(+Math_floor(" + Input + " / +4294967296), +4294967295) | 0) >>> 0 : ~~+Math_ceil((" + Input + " - +(~~" + Input + " >>> 0)) / +4294967296) >>> 0 : 0"; + return getAssign(getJSName(CI), CI->getType()) + "+Math_abs(" + Input + ") >= +1 ? " + Input + " > +0 ? (Math_min(+Math_floor(" + Input + " / +4294967296), +4294967295) | 0) >>> 0 : ~~+Math_ceil((" + Input + " - +(~~" + Input + " >>> 0)) / +4294967296) >>> 0 : 0"; }) DEF_CALL_HANDLER(BDtoILow, { - return "HEAPF64[tempDoublePtr>>3] = " + getValueAsStr(CI->getArgOperand(0)) + ";" + getAssign(getCppName(CI), CI->getType()) + "HEAP32[tempDoublePtr>>2]|0"; + return "HEAPF64[tempDoublePtr>>3] = " + getValueAsStr(CI->getArgOperand(0)) + ";" + getAssign(getJSName(CI), CI->getType()) + "HEAP32[tempDoublePtr>>2]|0"; }) DEF_CALL_HANDLER(BDtoIHigh, { - return getAssign(getCppName(CI), CI->getType()) + "HEAP32[tempDoublePtr+4>>2]|0"; + return getAssign(getJSName(CI), CI->getType()) + "HEAP32[tempDoublePtr+4>>2]|0"; }) DEF_CALL_HANDLER(SItoF, { // TODO: fround - return getAssign(getCppName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + + return getAssign(getJSName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + "(+4294967296*(+" + getValueAsCastParenStr(CI->getArgOperand(1), ASM_SIGNED) + "))"; }) DEF_CALL_HANDLER(UItoF, { // TODO: fround - return getAssign(getCppName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + + return getAssign(getJSName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + "(+4294967296*(+" + getValueAsCastParenStr(CI->getArgOperand(1), ASM_UNSIGNED) + "))"; }) DEF_CALL_HANDLER(SItoD, { - return getAssign(getCppName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + + return getAssign(getJSName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + "(+4294967296*(+" + getValueAsCastParenStr(CI->getArgOperand(1), ASM_SIGNED) + "))"; }) DEF_CALL_HANDLER(UItoD, { - return getAssign(getCppName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + + return getAssign(getJSName(CI), CI->getType()) + "(+" + getValueAsCastParenStr(CI->getArgOperand(0), ASM_UNSIGNED) + ") + " + "(+4294967296*(+" + getValueAsCastParenStr(CI->getArgOperand(1), ASM_UNSIGNED) + "))"; }) DEF_CALL_HANDLER(BItoD, { return "HEAP32[tempDoublePtr>>2] = " + getValueAsStr(CI->getArgOperand(0)) + ";" + "HEAP32[tempDoublePtr+4>>2] = " + getValueAsStr(CI->getArgOperand(1)) + ";" + - getAssign(getCppName(CI), CI->getType()) + "+HEAPF64[tempDoublePtr>>3]"; + getAssign(getJSName(CI), CI->getType()) + "+HEAPF64[tempDoublePtr>>3]"; }) DEF_CALL_HANDLER(llvm_nacl_atomic_store_i32, { @@ -115,7 +115,7 @@ DEF_CALL_HANDLER(llvm_memmove_p0i8_p0i8_i32, { }) DEF_CALL_HANDLER(llvm_expect_i32, { - return getAssign(getCppName(CI), CI->getType()) + getValueAsStr(CI->getArgOperand(0)); + return getAssign(getJSName(CI), CI->getType()) + getValueAsStr(CI->getArgOperand(0)); }) DEF_CALL_HANDLER(llvm_dbg_declare, { @@ -713,7 +713,7 @@ void setupCallHandlers() { std::string handleCall(const CallInst *CI) { const Value *CV = CI->getCalledValue(); assert(!isa<InlineAsm>(CV) && "asm() not supported, use EM_ASM() (see emscripten.h)"); - std::string Name = getCppName(CV); + std::string Name = getJSName(CV); if (strcmp(Name.c_str(), "_llvm_dbg_value") == 0) return ""; // ignore this unsigned NumArgs = CI->getNumArgOperands(); CallHandlerMap::iterator CH = CallHandlers->find("___default__"); diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 1253d8a622..656e40753f 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -1,4 +1,4 @@ -//===-- CPPBackend.cpp - Library for converting LLVM code to JS -----===// +//===-- JSBackend.cpp - Library for converting LLVM code to JS -----===// // // The LLVM Compiler Infrastructure // @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -#include "CPPTargetMachine.h" +#include "JSTargetMachine.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" @@ -57,9 +57,9 @@ using namespace llvm; #undef assert #define assert(x) { if (!(x)) dumpfail(#x); } -extern "C" void LLVMInitializeCppBackendTarget() { +extern "C" void LLVMInitializeJSBackendTarget() { // Register the target. - RegisterTargetMachine<CPPTargetMachine> X(TheCppBackendTarget); + RegisterTargetMachine<JSTargetMachine> X(TheJSBackendTarget); } namespace { @@ -191,7 +191,7 @@ namespace { return Ret; } unsigned getFunctionIndex(const Function *F) { - std::string Name = getCppName(F); + std::string Name = getJSName(F); if (IndexedFunctions.find(Name) != IndexedFunctions.end()) return IndexedFunctions[Name]; std::string Sig = getFunctionSignature(F->getFunctionType()); FunctionTable &Table = FunctionTables[Sig]; @@ -258,7 +258,7 @@ namespace { std::string getValueAsParenStr(const Value*); std::string getValueAsCastParenStr(const Value*, AsmCast sign=ASM_SIGNED); - std::string getCppName(const Value* val); + std::string getJSName(const Value* val); std::string getPhiCode(const BasicBlock *From, const BasicBlock *To); @@ -328,7 +328,7 @@ std::string JSWriter::getPhiCode(const BasicBlock *From, const BasicBlock *To) { int index = P->getBasicBlockIndex(From); if (index < 0) continue; // we found it - std::string name = getCppName(P); + std::string name = getJSName(P); assigns[name] = getAssign(name, P->getType()); Value *V = P->getIncomingValue(index); values[name] = V; @@ -371,7 +371,7 @@ std::string JSWriter::getPhiCode(const BasicBlock *From, const BasicBlock *To) { return pre + post; } -std::string JSWriter::getCppName(const Value* val) { +std::string JSWriter::getJSName(const Value* val) { std::string name; ValueMap::iterator I = ValueNames.find(val); if (I != ValueNames.end() && I->first == val) @@ -626,7 +626,7 @@ std::string JSWriter::getStore(const Value *P, const Type *T, const std::string& } std::string JSWriter::getOpName(const Value* V) { // TODO: remove this - return getCppName(V); + return getJSName(V); } std::string JSWriter::getPtrLoad(const Value* Ptr) { @@ -744,7 +744,7 @@ std::string JSWriter::getValueAsStr(const Value* V, AsmCast sign) { if (const Constant *CV = dyn_cast<Constant>(V)) { return getConstant(CV, sign); } else { - return getCppName(V); + return getJSName(V); } } @@ -752,7 +752,7 @@ std::string JSWriter::getValueAsCastStr(const Value* V, AsmCast sign) { if (const Constant *CV = dyn_cast<Constant>(V)) { return getConstant(CV, sign); } else { - return getCast(getCppName(V), V->getType(), sign); + return getCast(getJSName(V), V->getType(), sign); } } @@ -760,7 +760,7 @@ std::string JSWriter::getValueAsParenStr(const Value* V) { if (const Constant *CV = dyn_cast<Constant>(V)) { return getConstant(CV); } else { - return "(" + getCppName(V) + ")"; + return "(" + getJSName(V) + ")"; } } @@ -768,13 +768,13 @@ std::string JSWriter::getValueAsCastParenStr(const Value* V, AsmCast sign) { if (const Constant *CV = dyn_cast<Constant>(V)) { return getConstant(CV, sign); } else { - return "(" + getCast(getCppName(V), V->getType(), sign) + ")"; + return "(" + getCast(getJSName(V), V->getType(), sign) + ")"; } } // generateInstruction - This member is called for each Instruction in a function. void JSWriter::generateInstruction(const Instruction *I, raw_string_ostream& Code) { - std::string iName(getCppName(I)); + std::string iName(getJSName(I)); Type *T = I->getType(); if (T->isIntegerTy() && T->getIntegerBitWidth() > 32) { @@ -1329,13 +1329,13 @@ void JSWriter::printModuleBody() { for (Function::const_arg_iterator AI = I->arg_begin(), AE = I->arg_end(); AI != AE; ++AI) { if (AI != I->arg_begin()) Out << ","; - Out << getCppName(AI); + Out << getJSName(AI); } Out << ") {"; nl(Out); for (Function::const_arg_iterator AI = I->arg_begin(), AE = I->arg_end(); AI != AE; ++AI) { - std::string name = getCppName(AI); + std::string name = getJSName(AI); Out << " " << name << " = " << getCast(name, AI->getType(), ASM_NONSPECIFIC) << ";"; nl(Out); } @@ -1545,7 +1545,7 @@ void JSWriter::parseConstant(const std::string& name, const Constant* CV, bool c if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) { C = CE->getOperand(0); // ignore bitcasts } - GlobalInitializers.push_back(getCppName(C)); + GlobalInitializers.push_back(getJSName(C)); } } } else if (calculate) { @@ -1612,7 +1612,7 @@ void JSWriter::parseConstant(const std::string& name, const Constant* CV, bool c // this is the global static initializer if (calculate) { Value *V = CE->getOperand(0); - GlobalInitializers.push_back(getCppName(V)); + GlobalInitializers.push_back(getJSName(V)); // is the func } } else if (name == "__fini_array_start") { @@ -1722,12 +1722,12 @@ char JSWriter::ID = 0; // External Interface declaration //===----------------------------------------------------------------------===// -bool CPPTargetMachine::addPassesToEmitFile(PassManagerBase &PM, - formatted_raw_ostream &o, - CodeGenFileType FileType, - bool DisableVerify, - AnalysisID StartAfter, - AnalysisID StopAfter) { +bool JSTargetMachine::addPassesToEmitFile(PassManagerBase &PM, + formatted_raw_ostream &o, + CodeGenFileType FileType, + bool DisableVerify, + AnalysisID StartAfter, + AnalysisID StopAfter) { assert(FileType == TargetMachine::CGFT_AssemblyFile); PM.add(createSimplifyAllocasPass()); diff --git a/lib/Target/CppBackend/CPPTargetMachine.h b/lib/Target/JSBackend/JSTargetMachine.h index 477e788ee2..b11533d692 100644 --- a/lib/Target/CppBackend/CPPTargetMachine.h +++ b/lib/Target/JSBackend/JSTargetMachine.h @@ -1,18 +1,19 @@ -//===-- CPPTargetMachine.h - TargetMachine for the C++ backend --*- C++ -*-===// +//===-- JSTargetMachine.h - TargetMachine for the C++ backend --*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // -//===----------------------------------------------------------------------===// +//===---------------------------------------------------------------------===// // -// This file declares the TargetMachine that is used by the C++ backend. +// This file declares the TargetMachine that is used by the JS/asm.js/ +// emscripten backend. // -//===----------------------------------------------------------------------===// +//===---------------------------------------------------------------------===// -#ifndef CPPTARGETMACHINE_H -#define CPPTARGETMACHINE_H +#ifndef JSTARGETMACHINE_H +#define JSTARGETMACHINE_H #include "llvm/IR/DataLayout.h" #include "llvm/Target/TargetMachine.h" @@ -21,11 +22,11 @@ namespace llvm { class formatted_raw_ostream; -struct CPPTargetMachine : public TargetMachine { - CPPTargetMachine(const Target &T, StringRef TT, - StringRef CPU, StringRef FS, const TargetOptions &Options, - Reloc::Model RM, CodeModel::Model CM, - CodeGenOpt::Level OL) +struct JSTargetMachine : public TargetMachine { + JSTargetMachine(const Target &T, StringRef TT, + StringRef CPU, StringRef FS, const TargetOptions &Options, + Reloc::Model RM, CodeModel::Model CM, + CodeGenOpt::Level OL) : TargetMachine(T, TT, CPU, FS, Options) {} virtual bool addPassesToEmitFile(PassManagerBase &PM, @@ -38,7 +39,7 @@ struct CPPTargetMachine : public TargetMachine { virtual const DataLayout *getDataLayout() const { return 0; } }; -extern Target TheCppBackendTarget; +extern Target TheJSBackendTarget; } // End llvm namespace diff --git a/lib/Target/JSBackend/LLVMBuild.txt b/lib/Target/JSBackend/LLVMBuild.txt new file mode 100644 index 0000000000..33b433bfb7 --- /dev/null +++ b/lib/Target/JSBackend/LLVMBuild.txt @@ -0,0 +1,31 @@ +;===- ./lib/Target/JSBackend/LLVMBuild.txt --------------------*- Conf -*--===; +; +; The LLVM Compiler Infrastructure +; +; This file is distributed under the University of Illinois Open Source +; License. See LICENSE.TXT for details. +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; + +[common] +subdirectories = TargetInfo + +[component_0] +type = TargetGroup +name = JSBackend +parent = Target + +[component_1] +type = Library +name = JSBackendCodeGen +parent = JSBackend +required_libraries = Core JSBackendInfo Support Target +add_to_library_groups = JSBackend diff --git a/lib/Target/CppBackend/Makefile b/lib/Target/JSBackend/Makefile index efc7463fda..8a15e7f4c1 100644 --- a/lib/Target/CppBackend/Makefile +++ b/lib/Target/JSBackend/Makefile @@ -1,14 +1,14 @@ -##===- lib/Target/CppBackend/Makefile --- ------------------*- Makefile -*-===## +##===- lib/Target/JSBackend/Makefile --- ------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # # This file is distributed under the University of Illinois Open Source # License. See LICENSE.TXT for details. # -##===----------------------------------------------------------------------===## +##===---------------------------------------------------------------------===## LEVEL = ../../.. -LIBRARYNAME = LLVMCppBackendCodeGen +LIBRARYNAME = LLVMJSBackendCodeGen DIRS = TargetInfo include $(LEVEL)/Makefile.common diff --git a/lib/Target/CppBackend/OptPasses.h b/lib/Target/JSBackend/OptPasses.h index 99f1459462..d976ad226d 100644 --- a/lib/Target/CppBackend/OptPasses.h +++ b/lib/Target/JSBackend/OptPasses.h @@ -1,11 +1,11 @@ -//===-- CPPTargetMachine.h - TargetMachine for the C++ backend --*- C++ -*-===// +//===-- JSTargetMachine.h - TargetMachine for the C++ backend --*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // -//===----------------------------------------------------------------------===// +//===---------------------------------------------------------------------===// #ifndef OPT_PASSES_H #define OPT_PASSES_H diff --git a/lib/Target/CppBackend/Relooper.cpp b/lib/Target/JSBackend/Relooper.cpp index fc7b3ea777..fc7b3ea777 100644 --- a/lib/Target/CppBackend/Relooper.cpp +++ b/lib/Target/JSBackend/Relooper.cpp diff --git a/lib/Target/CppBackend/Relooper.h b/lib/Target/JSBackend/Relooper.h index e78d18e713..e78d18e713 100644 --- a/lib/Target/CppBackend/Relooper.h +++ b/lib/Target/JSBackend/Relooper.h diff --git a/lib/Target/CppBackend/SimplifyAllocas.cpp b/lib/Target/JSBackend/SimplifyAllocas.cpp index 1d4823ec57..2fda6be948 100644 --- a/lib/Target/CppBackend/SimplifyAllocas.cpp +++ b/lib/Target/JSBackend/SimplifyAllocas.cpp @@ -1,11 +1,11 @@ -//===-- CPPTargetMachine.h - TargetMachine for the C++ backend --*- C++ -*-===// +//===-- SimplifyAllocas.cpp - TargetMachine for the C++ backend --*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // -//===----------------------------------------------------------------------===// +//===-----------------------------------------------------------------------===// #include <OptPasses.h> diff --git a/lib/Target/CppBackend/TargetInfo/CMakeLists.txt b/lib/Target/JSBackend/TargetInfo/CMakeLists.txt index f82d72e378..29994eb8f9 100644 --- a/lib/Target/CppBackend/TargetInfo/CMakeLists.txt +++ b/lib/Target/JSBackend/TargetInfo/CMakeLists.txt @@ -1,5 +1,5 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. ) -add_llvm_library(LLVMCppBackendInfo - CppBackendTargetInfo.cpp +add_llvm_library(LLVMJSBackendInfo + JSBackendTargetInfo.cpp ) diff --git a/lib/Target/JSBackend/TargetInfo/CppBackendTargetInfo.cpp b/lib/Target/JSBackend/TargetInfo/CppBackendTargetInfo.cpp new file mode 100644 index 0000000000..cf06eaceea --- /dev/null +++ b/lib/Target/JSBackend/TargetInfo/CppBackendTargetInfo.cpp @@ -0,0 +1,28 @@ +//===-- JSBackendTargetInfo.cpp - JSBackend Target Implementation -------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--------------------------------------------------------------------===// + +#include "JSTargetMachine.h" +#include "llvm/IR/Module.h" +#include "llvm/Support/TargetRegistry.h" +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; +} + +extern "C" void LLVMInitializeJSBackendTargetInfo() { + TargetRegistry::RegisterTarget(TheJSBackendTarget, "js", + "JavaScript (asm.js, emscripten) backend", + &JSBackend_TripleMatchQuality); +} + +extern "C" void LLVMInitializeJSBackendTargetMC() {} diff --git a/lib/Target/CppBackend/TargetInfo/LLVMBuild.txt b/lib/Target/JSBackend/TargetInfo/LLVMBuild.txt index d4dfc3ef04..7320582609 100644 --- a/lib/Target/CppBackend/TargetInfo/LLVMBuild.txt +++ b/lib/Target/JSBackend/TargetInfo/LLVMBuild.txt @@ -1,11 +1,11 @@ -;===- ./lib/Target/CppBackend/TargetInfo/LLVMBuild.txt ---------*- Conf -*--===; +;===- ./lib/Target/JSBackend/TargetInfo/LLVMBuild.txt ---------*- Conf -*--===; ; ; The LLVM Compiler Infrastructure ; ; This file is distributed under the University of Illinois Open Source ; License. See LICENSE.TXT for details. ; -;===------------------------------------------------------------------------===; +;===-----------------------------------------------------------------------===; ; ; This is an LLVMBuild description file for the components in this subdirectory. ; @@ -13,11 +13,11 @@ ; ; http://llvm.org/docs/LLVMBuild.html ; -;===------------------------------------------------------------------------===; +;===-----------------------------------------------------------------------===; [component_0] type = Library -name = CppBackendInfo -parent = CppBackend +name = JSBackendInfo +parent = JSBackend required_libraries = MC Support Target -add_to_library_groups = CppBackend +add_to_library_groups = JSBackend diff --git a/lib/Target/CppBackend/TargetInfo/Makefile b/lib/Target/JSBackend/TargetInfo/Makefile index 6e682838da..45f0230efc 100644 --- a/lib/Target/CppBackend/TargetInfo/Makefile +++ b/lib/Target/JSBackend/TargetInfo/Makefile @@ -1,13 +1,13 @@ -##===- lib/Target/CppBackend/TargetInfo/Makefile -----------*- Makefile -*-===## +##===- lib/Target/JSBackend/TargetInfo/Makefile -----------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # # This file is distributed under the University of Illinois Open Source # License. See LICENSE.TXT for details. # -##===----------------------------------------------------------------------===## +##===---------------------------------------------------------------------===## LEVEL = ../../../.. -LIBRARYNAME = LLVMCppBackendInfo +LIBRARYNAME = LLVMJSBackendInfo # Hack: we need to include 'main' target directory to grab private headers CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/.. diff --git a/lib/Target/LLVMBuild.txt b/lib/Target/LLVMBuild.txt index 1022ae9088..407d8116d3 100644 --- a/lib/Target/LLVMBuild.txt +++ b/lib/Target/LLVMBuild.txt @@ -16,7 +16,7 @@ ;===------------------------------------------------------------------------===; [common] -subdirectories = AArch64 ARM CppBackend Hexagon MBlaze MSP430 NVPTX Mips PowerPC R600 Sparc SystemZ X86 XCore +subdirectories = AArch64 ARM CppBackend Hexagon JSBackend MBlaze MSP430 NVPTX Mips PowerPC R600 Sparc SystemZ X86 XCore ; This is a special group whose required libraries are extended (by llvm-build) ; with the best execution engine (the native JIT, if available, or the diff --git a/projects/sample/configure b/projects/sample/configure index 8484a2ae3c..ed66e1c00b 100755 --- a/projects/sample/configure +++ b/projects/sample/configure @@ -5308,7 +5308,7 @@ if test "$enableval" = host-only ; then enableval=host fi case "$enableval" in - all) TARGETS_TO_BUILD="X86 Sparc PowerPC ARM AArch64 Mips XCore MSP430 Hexagon CppBackend MBlaze NVPTX SystemZ" ;; + all) TARGETS_TO_BUILD="X86 Sparc PowerPC ARM AArch64 Mips XCore MSP430 Hexagon CppBackend JSBackend MBlaze NVPTX SystemZ" ;; *)for a_target in `echo $enableval|sed -e 's/,/ /g' ` ; do case "$a_target" in x86) TARGETS_TO_BUILD="X86 $TARGETS_TO_BUILD" ;; @@ -5322,6 +5322,7 @@ case "$enableval" in msp430) TARGETS_TO_BUILD="MSP430 $TARGETS_TO_BUILD" ;; hexagon) TARGETS_TO_BUILD="Hexagon $TARGETS_TO_BUILD" ;; cpp) TARGETS_TO_BUILD="CppBackend $TARGETS_TO_BUILD" ;; + js) TARGETS_TO_BUILD="JSBackend $TARGETS_TO_BUILD" ;; mblaze) TARGETS_TO_BUILD="MBlaze $TARGETS_TO_BUILD" ;; nvptx) TARGETS_TO_BUILD="NVPTX $TARGETS_TO_BUILD" ;; systemz) TARGETS_TO_BUILD="SystemZ $TARGETS_TO_BUILD" ;; |