Chromium Code Reviews| Index: src/PNaClTranslator.cpp |
| diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp |
| index b74de0a999f908813535bfab8189e582ed05557f..8a7d4c8da59d50b30b2c2fd03ea4734b693fbdcc 100644 |
| --- a/src/PNaClTranslator.cpp |
| +++ b/src/PNaClTranslator.cpp |
| @@ -13,13 +13,11 @@ |
| //===----------------------------------------------------------------------===// |
| #include "llvm/ADT/SmallString.h" |
| -#include "llvm/Analysis/NaCl/PNaClABIProps.h" |
| #include "llvm/Bitcode/NaCl/NaClBitcodeDecoders.h" |
| #include "llvm/Bitcode/NaCl/NaClBitcodeHeader.h" |
| #include "llvm/Bitcode/NaCl/NaClBitcodeParser.h" |
| #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" |
| #include "llvm/IR/Constants.h" |
| -#include "llvm/IR/DataLayout.h" |
| #include "llvm/IR/LLVMContext.h" |
| #include "llvm/IR/Module.h" |
| #include "llvm/Support/Format.h" |
| @@ -175,11 +173,10 @@ public: |
| NaClBitcodeHeader &Header, NaClBitstreamCursor &Cursor, |
| bool &ErrorStatus) |
| : NaClBitcodeParser(Cursor), Translator(Translator), |
| - Mod(new Module(InputName, getGlobalContext())), DL(PNaClDataLayout), |
| + Mod(new Module(InputName, getGlobalContext())), |
| Header(Header), TypeConverter(Mod->getContext()), |
| ErrorStatus(ErrorStatus), NumErrors(0), NumFunctionIds(0), |
| NumFunctionBlocks(0), BlockParser(nullptr) { |
| - Mod->setDataLayout(PNaClDataLayout); |
| setErrStream(Translator.getContext()->getStrDump()); |
| } |
| @@ -204,8 +201,6 @@ public: |
| /// Returns the LLVM module associated with the translation. |
| Module *getModule() const { return Mod.get(); } |
| - const DataLayout &getDataLayout() const { return DL; } |
| - |
| /// Returns the number of bytes in the bitcode header. |
| size_t getHeaderSize() const { return Header.getHeaderSize(); } |
| @@ -405,8 +400,6 @@ private: |
| Ice::Translator &Translator; |
| // The parsed module. |
| std::unique_ptr<Module> Mod; |
| - // The data layout to use. |
| - DataLayout DL; |
| // The bitcode header. |
| NaClBitcodeHeader &Header; |
| // Converter between LLVM and ICE types. |
| @@ -1442,13 +1435,11 @@ private: |
| // Checks if loading/storing a value of type Ty is allowed for |
| // the given Alignment. Otherwise generates an error message and |
| // returns false. |
| - bool isValidLoadStoreAlignment(unsigned Alignment, Ice::Type Ty, |
| + bool isValidLoadStoreAlignment(size_t Alignment, Ice::Type Ty, |
|
Jim Stichnoth
2014/12/08 23:14:47
If you change the type of Alignment, should you al
Karl
2014/12/09 21:20:45
Done.
|
| const char *InstructionName) { |
| if (!isValidLoadStoreType(Ty, InstructionName)) |
| return false; |
| - if (PNaClABIProps::isAllowedAlignment(&Context->getDataLayout(), Alignment, |
| - Context->convertToLLVMType(Ty))) |
| - return true; |
| + if (isAllowedAlignment(Alignment, Ty)) return true; |
|
Jim Stichnoth
2014/12/08 23:14:47
return on separate line (i.e., make format-diff)
Karl
2014/12/09 21:20:45
Done.
|
| std::string Buffer; |
| raw_string_ostream StrBuf(Buffer); |
| StrBuf << InstructionName << " " << Ty << "*: not allowed for alignment " |
| @@ -1457,6 +1448,14 @@ private: |
| return false; |
| } |
| + // Defines if the given alignment is valid for the given type. Simplified |
| + // version of PNaClABIProps::isAllowedAlignment, based on API's offered |
| + // for Ice::Type. |
| + bool isAllowedAlignment(size_t Alignment, Ice::Type Ty) { |
|
Jim Stichnoth
2014/12/08 23:14:47
Can this be const?
Karl
2014/12/09 21:20:45
Done.
|
| + return Alignment == typeAlignInBytes(Ty) || |
|
Jim Stichnoth
2014/12/08 23:14:47
This implementation doesn't seem to match the orig
Karl
2014/12/09 21:20:45
This code doesn't match the comment (which is out
Jim Stichnoth
2014/12/09 21:48:24
Thanks, my world-view is restored. :)
|
| + (Alignment == 1 && !isVectorType(Ty)); |
| + } |
| + |
| // Types of errors that can occur for insertelement and extractelement |
| // instructions. |
| enum VectorIndexCheckValue { |