diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | lib/IR/Module.cpp | 1 | ||||
-rw-r--r-- | lib/Target/JSBackend/JSBackend.cpp | 10 | ||||
-rw-r--r-- | lib/Target/LLVMBuild.txt | 4 | ||||
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 20 | ||||
-rw-r--r-- | lib/Transforms/NaCl/ResolvePNaClIntrinsics.cpp | 2 |
6 files changed, 34 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2918aeb86a..10954c67dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,12 +73,12 @@ set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin) set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples) set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" ) +# TODO Add CppBackend back once it's restored. XXX Emscripten set(LLVM_ALL_TARGETS AArch64 ARM - CppBackend - Hexagon JSBackend + Hexagon Mips MBlaze MSP430 diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index 4cb93d1fe6..dd2c691951 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -24,6 +24,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ErrorHandling.h" // @LOCALMOD +#include "llvm/Support/raw_ostream.h" // XXX Emscripten TODO: Move to PNacl upstream. #include <algorithm> #include <cstdarg> #include <cstdlib> diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 984015fffa..11482d2bcd 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -44,6 +44,10 @@ using namespace llvm; #include <OptPasses.h> #include <Relooper.h> +#ifdef _MSC_VER +#define snprintf _snprintf +#endif + #define dump(x) fprintf(stderr, x "\n") #define dumpv(x, ...) fprintf(stderr, x "\n", __VA_ARGS__) #define dumpfail(x) { fprintf(stderr, x "\n"); fprintf(stderr, "%s : %d\n", __FILE__, __LINE__); report_fatal_error("fail"); } @@ -965,6 +969,10 @@ bool JSWriter::generateSIMDInstruction(const std::string &iName, const Instructi return false; } +uint64_t LSBMask(unsigned numBits) { + return numBits >= 64 ? 0xFFFFFFFFFFFFFFFFULL : (1ULL << numBits) - 1; +} + // generateInstruction - This member is called for each Instruction in a function. void JSWriter::generateInstruction(const Instruction *I, raw_string_ostream& Code) { std::string iName(getJSName(I)); @@ -1208,7 +1216,7 @@ void JSWriter::generateInstruction(const Instruction *I, raw_string_ostream& Cod case Instruction::Trunc: { //unsigned inBits = V->getType()->getIntegerBitWidth(); unsigned outBits = I->getType()->getIntegerBitWidth(); - Code << getValueAsStr(I->getOperand(0)) + "&" + utostr(pow(2, outBits)-1); + Code << getValueAsStr(I->getOperand(0)) + "&" + utostr(LSBMask(outBits)); break; } case Instruction::SExt: { diff --git a/lib/Target/LLVMBuild.txt b/lib/Target/LLVMBuild.txt index 407d8116d3..76462f47fa 100644 --- a/lib/Target/LLVMBuild.txt +++ b/lib/Target/LLVMBuild.txt @@ -15,8 +15,10 @@ ; ;===------------------------------------------------------------------------===; +; TODO Add CppBackend back once it's restored. XXX Emscripten + [common] -subdirectories = AArch64 ARM CppBackend Hexagon JSBackend MBlaze MSP430 NVPTX Mips PowerPC R600 Sparc SystemZ X86 XCore +subdirectories = AArch64 ARM 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/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp index 40ad6b6cbf..f56932dec4 100644 --- a/lib/Transforms/NaCl/ExpandI64.cpp +++ b/lib/Transforms/NaCl/ExpandI64.cpp @@ -163,6 +163,15 @@ void ExpandI64::ensureLegalFunc(Function *F) { FunctionType *FT = F->getFunctionType(); int Num = FT->getNumParams(); + + // XXX Emscripten TODO: Move this fix to PNacl upstream. + // Allocate small names on stack, large ones on heap. + // This is because on VS2010, arrays on the stack must + // be compile-time constant sized. (no C99 dynamic-length array support) + const int StackSize = 256; + char StackArray[StackSize]; + char *AllocArray = 0; + for (int i = -1; i < Num; i++) { Type *T = i == -1 ? FT->getReturnType() : FT->getParamType(i); if (isIllegal(T)) { @@ -170,12 +179,19 @@ void ExpandI64::ensureLegalFunc(Function *F) { std::string Name = NF->getName(); if (strncmp(Name.c_str(), "llvm.", 5) == 0) { // this is an intrinsic, and we are changing its signature, which will annoy LLVM, so rename - char NewName[Name.size()+1]; + const size_t len = Name.size()+1; + char *NewName; + if (len > StackSize) + NewName = AllocArray = new char[len]; + else + NewName = StackArray; const char *CName = Name.c_str(); - for (unsigned i = 0; i < Name.size()+1; i++) { + for (unsigned i = 0; i < len; i++) { NewName[i] = CName[i] != '.' ? CName[i] : '_'; } NF->setName(NewName); + delete[] AllocArray; + AllocArray = 0; } // Move and update arguments for (Function::arg_iterator Arg = F->arg_begin(), E = F->arg_end(), NewArg = NF->arg_begin(); diff --git a/lib/Transforms/NaCl/ResolvePNaClIntrinsics.cpp b/lib/Transforms/NaCl/ResolvePNaClIntrinsics.cpp index 428caef2b5..d58b70d4d0 100644 --- a/lib/Transforms/NaCl/ResolvePNaClIntrinsics.cpp +++ b/lib/Transforms/NaCl/ResolvePNaClIntrinsics.cpp @@ -185,7 +185,7 @@ struct IsLockFreeToConstant { } # elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) // Continue. -# elif defined(__mips__) +# elif defined(__mips__) || defined(_M_IX86) // XXX Emscripten TODO: Move this fix to PNacl upstream. MaxLockFreeByteSize = 4; # else # error "Unknown architecture" |