mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-13 08:25:27 +00:00
Remove DOS line endings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167968 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1,80 +1,80 @@
|
|||||||
//===---- ObjectBuffer.h - Utility class to wrap object image memory -----===//
|
//===---- ObjectBuffer.h - Utility class to wrap object image memory -----===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
// This file is distributed under the University of Illinois Open Source
|
// This file is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file declares a wrapper class to hold the memory into which an
|
// This file declares a wrapper class to hold the memory into which an
|
||||||
// object will be generated.
|
// object will be generated.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
|
#ifndef LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
|
||||||
#define LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
|
#define LLVM_EXECUTIONENGINE_OBJECTBUFFER_H
|
||||||
|
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/ADT/OwningPtr.h"
|
#include "llvm/ADT/OwningPtr.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
/// ObjectBuffer - This class acts as a container for the memory buffer used during
|
/// ObjectBuffer - This class acts as a container for the memory buffer used during
|
||||||
/// generation and loading of executable objects using MCJIT and RuntimeDyld. The
|
/// generation and loading of executable objects using MCJIT and RuntimeDyld. The
|
||||||
/// underlying memory for the object will be owned by the ObjectBuffer instance
|
/// underlying memory for the object will be owned by the ObjectBuffer instance
|
||||||
/// throughout its lifetime. The getMemBuffer() method provides a way to create a
|
/// throughout its lifetime. The getMemBuffer() method provides a way to create a
|
||||||
/// MemoryBuffer wrapper object instance to be owned by other classes (such as
|
/// MemoryBuffer wrapper object instance to be owned by other classes (such as
|
||||||
/// ObjectFile) as needed, but the MemoryBuffer instance returned does not own the
|
/// ObjectFile) as needed, but the MemoryBuffer instance returned does not own the
|
||||||
/// actual memory it points to.
|
/// actual memory it points to.
|
||||||
class ObjectBuffer {
|
class ObjectBuffer {
|
||||||
public:
|
public:
|
||||||
ObjectBuffer() {}
|
ObjectBuffer() {}
|
||||||
ObjectBuffer(MemoryBuffer* Buf) : Buffer(Buf) {}
|
ObjectBuffer(MemoryBuffer* Buf) : Buffer(Buf) {}
|
||||||
virtual ~ObjectBuffer() {}
|
virtual ~ObjectBuffer() {}
|
||||||
|
|
||||||
/// getMemBuffer - Like MemoryBuffer::getMemBuffer() this function
|
/// getMemBuffer - Like MemoryBuffer::getMemBuffer() this function
|
||||||
/// returns a pointer to an object that is owned by the caller. However,
|
/// returns a pointer to an object that is owned by the caller. However,
|
||||||
/// the caller does not take ownership of the underlying memory.
|
/// the caller does not take ownership of the underlying memory.
|
||||||
MemoryBuffer *getMemBuffer() const {
|
MemoryBuffer *getMemBuffer() const {
|
||||||
return MemoryBuffer::getMemBuffer(Buffer->getBuffer(), "", false);
|
return MemoryBuffer::getMemBuffer(Buffer->getBuffer(), "", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *getBufferStart() const { return Buffer->getBufferStart(); }
|
const char *getBufferStart() const { return Buffer->getBufferStart(); }
|
||||||
size_t getBufferSize() const { return Buffer->getBufferSize(); }
|
size_t getBufferSize() const { return Buffer->getBufferSize(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// The memory contained in an ObjectBuffer
|
// The memory contained in an ObjectBuffer
|
||||||
OwningPtr<MemoryBuffer> Buffer;
|
OwningPtr<MemoryBuffer> Buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ObjectBufferStream - This class encapsulates the SmallVector and
|
/// ObjectBufferStream - This class encapsulates the SmallVector and
|
||||||
/// raw_svector_ostream needed to generate an object using MC code emission
|
/// raw_svector_ostream needed to generate an object using MC code emission
|
||||||
/// while providing a common ObjectBuffer interface for access to the
|
/// while providing a common ObjectBuffer interface for access to the
|
||||||
/// memory once the object has been generated.
|
/// memory once the object has been generated.
|
||||||
class ObjectBufferStream : public ObjectBuffer {
|
class ObjectBufferStream : public ObjectBuffer {
|
||||||
public:
|
public:
|
||||||
ObjectBufferStream() : OS(SV) {}
|
ObjectBufferStream() : OS(SV) {}
|
||||||
virtual ~ObjectBufferStream() {}
|
virtual ~ObjectBufferStream() {}
|
||||||
|
|
||||||
raw_ostream &getOStream() { return OS; }
|
raw_ostream &getOStream() { return OS; }
|
||||||
void flush()
|
void flush()
|
||||||
{
|
{
|
||||||
OS.flush();
|
OS.flush();
|
||||||
|
|
||||||
// Make the data accessible via the ObjectBuffer::Buffer
|
// Make the data accessible via the ObjectBuffer::Buffer
|
||||||
Buffer.reset(MemoryBuffer::getMemBuffer(StringRef(SV.data(), SV.size()),
|
Buffer.reset(MemoryBuffer::getMemBuffer(StringRef(SV.data(), SV.size()),
|
||||||
"",
|
"",
|
||||||
false));
|
false));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SmallVector<char, 4096> SV; // Working buffer into which we JIT.
|
SmallVector<char, 4096> SV; // Working buffer into which we JIT.
|
||||||
raw_svector_ostream OS; // streaming wrapper
|
raw_svector_ostream OS; // streaming wrapper
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,61 +1,61 @@
|
|||||||
//===---- ObjectImage.h - Format independent executuable object image -----===//
|
//===---- ObjectImage.h - Format independent executuable object image -----===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
// This file is distributed under the University of Illinois Open Source
|
// This file is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file declares a file format independent ObjectImage class.
|
// This file declares a file format independent ObjectImage class.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef LLVM_EXECUTIONENGINE_OBJECTIMAGE_H
|
#ifndef LLVM_EXECUTIONENGINE_OBJECTIMAGE_H
|
||||||
#define LLVM_EXECUTIONENGINE_OBJECTIMAGE_H
|
#define LLVM_EXECUTIONENGINE_OBJECTIMAGE_H
|
||||||
|
|
||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
#include "llvm/ExecutionEngine/ObjectBuffer.h"
|
#include "llvm/ExecutionEngine/ObjectBuffer.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
|
||||||
/// ObjectImage - A container class that represents an ObjectFile that has been
|
/// ObjectImage - A container class that represents an ObjectFile that has been
|
||||||
/// or is in the process of being loaded into memory for execution.
|
/// or is in the process of being loaded into memory for execution.
|
||||||
class ObjectImage {
|
class ObjectImage {
|
||||||
ObjectImage() LLVM_DELETED_FUNCTION;
|
ObjectImage() LLVM_DELETED_FUNCTION;
|
||||||
ObjectImage(const ObjectImage &other) LLVM_DELETED_FUNCTION;
|
ObjectImage(const ObjectImage &other) LLVM_DELETED_FUNCTION;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
OwningPtr<ObjectBuffer> Buffer;
|
OwningPtr<ObjectBuffer> Buffer;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ObjectImage(ObjectBuffer *Input) : Buffer(Input) {}
|
ObjectImage(ObjectBuffer *Input) : Buffer(Input) {}
|
||||||
virtual ~ObjectImage() {}
|
virtual ~ObjectImage() {}
|
||||||
|
|
||||||
virtual object::symbol_iterator begin_symbols() const = 0;
|
virtual object::symbol_iterator begin_symbols() const = 0;
|
||||||
virtual object::symbol_iterator end_symbols() const = 0;
|
virtual object::symbol_iterator end_symbols() const = 0;
|
||||||
|
|
||||||
virtual object::section_iterator begin_sections() const = 0;
|
virtual object::section_iterator begin_sections() const = 0;
|
||||||
virtual object::section_iterator end_sections() const = 0;
|
virtual object::section_iterator end_sections() const = 0;
|
||||||
|
|
||||||
virtual /* Triple::ArchType */ unsigned getArch() const = 0;
|
virtual /* Triple::ArchType */ unsigned getArch() const = 0;
|
||||||
|
|
||||||
// Subclasses can override these methods to update the image with loaded
|
// Subclasses can override these methods to update the image with loaded
|
||||||
// addresses for sections and common symbols
|
// addresses for sections and common symbols
|
||||||
virtual void updateSectionAddress(const object::SectionRef &Sec,
|
virtual void updateSectionAddress(const object::SectionRef &Sec,
|
||||||
uint64_t Addr) = 0;
|
uint64_t Addr) = 0;
|
||||||
virtual void updateSymbolAddress(const object::SymbolRef &Sym,
|
virtual void updateSymbolAddress(const object::SymbolRef &Sym,
|
||||||
uint64_t Addr) = 0;
|
uint64_t Addr) = 0;
|
||||||
|
|
||||||
virtual StringRef getData() const = 0;
|
virtual StringRef getData() const = 0;
|
||||||
|
|
||||||
// Subclasses can override these methods to provide JIT debugging support
|
// Subclasses can override these methods to provide JIT debugging support
|
||||||
virtual void registerWithDebugger() = 0;
|
virtual void registerWithDebugger() = 0;
|
||||||
virtual void deregisterWithDebugger() = 0;
|
virtual void deregisterWithDebugger() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
||||||
#endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H
|
#endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H
|
||||||
|
|
||||||
|
@@ -1,76 +1,76 @@
|
|||||||
//===-- ObjectImageCommon.h - Format independent executuable object image -===//
|
//===-- ObjectImageCommon.h - Format independent executuable object image -===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
// This file is distributed under the University of Illinois Open Source
|
// This file is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// This file declares a file format independent ObjectImage class.
|
// This file declares a file format independent ObjectImage class.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#ifndef LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
|
#ifndef LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
|
||||||
#define LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
|
#define LLVM_RUNTIMEDYLD_OBJECTIMAGECOMMON_H
|
||||||
|
|
||||||
#include "llvm/Object/ObjectFile.h"
|
#include "llvm/Object/ObjectFile.h"
|
||||||
#include "llvm/ExecutionEngine/ObjectImage.h"
|
#include "llvm/ExecutionEngine/ObjectImage.h"
|
||||||
#include "llvm/ExecutionEngine/ObjectBuffer.h"
|
#include "llvm/ExecutionEngine/ObjectBuffer.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class ObjectImageCommon : public ObjectImage {
|
class ObjectImageCommon : public ObjectImage {
|
||||||
ObjectImageCommon(); // = delete
|
ObjectImageCommon(); // = delete
|
||||||
ObjectImageCommon(const ObjectImageCommon &other); // = delete
|
ObjectImageCommon(const ObjectImageCommon &other); // = delete
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
object::ObjectFile *ObjFile;
|
object::ObjectFile *ObjFile;
|
||||||
|
|
||||||
// This form of the constructor allows subclasses to use
|
// This form of the constructor allows subclasses to use
|
||||||
// format-specific subclasses of ObjectFile directly
|
// format-specific subclasses of ObjectFile directly
|
||||||
ObjectImageCommon(ObjectBuffer *Input, object::ObjectFile *Obj)
|
ObjectImageCommon(ObjectBuffer *Input, object::ObjectFile *Obj)
|
||||||
: ObjectImage(Input), // saves Input as Buffer and takes ownership
|
: ObjectImage(Input), // saves Input as Buffer and takes ownership
|
||||||
ObjFile(Obj)
|
ObjFile(Obj)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ObjectImageCommon(ObjectBuffer* Input)
|
ObjectImageCommon(ObjectBuffer* Input)
|
||||||
: ObjectImage(Input) // saves Input as Buffer and takes ownership
|
: ObjectImage(Input) // saves Input as Buffer and takes ownership
|
||||||
{
|
{
|
||||||
ObjFile = object::ObjectFile::createObjectFile(Buffer->getMemBuffer());
|
ObjFile = object::ObjectFile::createObjectFile(Buffer->getMemBuffer());
|
||||||
}
|
}
|
||||||
virtual ~ObjectImageCommon() { delete ObjFile; }
|
virtual ~ObjectImageCommon() { delete ObjFile; }
|
||||||
|
|
||||||
virtual object::symbol_iterator begin_symbols() const
|
virtual object::symbol_iterator begin_symbols() const
|
||||||
{ return ObjFile->begin_symbols(); }
|
{ return ObjFile->begin_symbols(); }
|
||||||
virtual object::symbol_iterator end_symbols() const
|
virtual object::symbol_iterator end_symbols() const
|
||||||
{ return ObjFile->end_symbols(); }
|
{ return ObjFile->end_symbols(); }
|
||||||
|
|
||||||
virtual object::section_iterator begin_sections() const
|
virtual object::section_iterator begin_sections() const
|
||||||
{ return ObjFile->begin_sections(); }
|
{ return ObjFile->begin_sections(); }
|
||||||
virtual object::section_iterator end_sections() const
|
virtual object::section_iterator end_sections() const
|
||||||
{ return ObjFile->end_sections(); }
|
{ return ObjFile->end_sections(); }
|
||||||
|
|
||||||
virtual /* Triple::ArchType */ unsigned getArch() const
|
virtual /* Triple::ArchType */ unsigned getArch() const
|
||||||
{ return ObjFile->getArch(); }
|
{ return ObjFile->getArch(); }
|
||||||
|
|
||||||
virtual StringRef getData() const { return ObjFile->getData(); }
|
virtual StringRef getData() const { return ObjFile->getData(); }
|
||||||
|
|
||||||
// Subclasses can override these methods to update the image with loaded
|
// Subclasses can override these methods to update the image with loaded
|
||||||
// addresses for sections and common symbols
|
// addresses for sections and common symbols
|
||||||
virtual void updateSectionAddress(const object::SectionRef &Sec,
|
virtual void updateSectionAddress(const object::SectionRef &Sec,
|
||||||
uint64_t Addr) {}
|
uint64_t Addr) {}
|
||||||
virtual void updateSymbolAddress(const object::SymbolRef &Sym, uint64_t Addr)
|
virtual void updateSymbolAddress(const object::SymbolRef &Sym, uint64_t Addr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Subclasses can override these methods to provide JIT debugging support
|
// Subclasses can override these methods to provide JIT debugging support
|
||||||
virtual void registerWithDebugger() {}
|
virtual void registerWithDebugger() {}
|
||||||
virtual void deregisterWithDebugger() {}
|
virtual void deregisterWithDebugger() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
||||||
#endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H
|
#endif // LLVM_RUNTIMEDYLD_OBJECT_IMAGE_H
|
||||||
|
|
||||||
|
@@ -1,67 +1,67 @@
|
|||||||
# RUN: llvm-mc --disassemble %s -triple=mips64-unknown-linux | FileCheck %s
|
# RUN: llvm-mc --disassemble %s -triple=mips64-unknown-linux | FileCheck %s
|
||||||
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
||||||
# CHECK: daddiu $11, $26, 31949
|
# CHECK: daddiu $11, $26, 31949
|
||||||
0x67 0x4b 0x7c 0xcd
|
0x67 0x4b 0x7c 0xcd
|
||||||
|
|
||||||
# CHECK: daddu $26, $1, $11
|
# CHECK: daddu $26, $1, $11
|
||||||
0x00 0x2b 0xd0 0x2d
|
0x00 0x2b 0xd0 0x2d
|
||||||
|
|
||||||
# CHECK: ddiv $zero, $26, $22
|
# CHECK: ddiv $zero, $26, $22
|
||||||
0x03 0x56 0x00 0x1e
|
0x03 0x56 0x00 0x1e
|
||||||
|
|
||||||
# CHECK: ddivu $zero, $9, $24
|
# CHECK: ddivu $zero, $9, $24
|
||||||
0x01 0x38 0x00 0x1f
|
0x01 0x38 0x00 0x1f
|
||||||
|
|
||||||
# CHECK: dmfc1 $2, $f14
|
# CHECK: dmfc1 $2, $f14
|
||||||
0x44 0x22 0x70 0x00
|
0x44 0x22 0x70 0x00
|
||||||
|
|
||||||
# CHECK: dmtc1 $23, $f5
|
# CHECK: dmtc1 $23, $f5
|
||||||
0x44 0xb7 0x28 0x00
|
0x44 0xb7 0x28 0x00
|
||||||
|
|
||||||
# CHECK: dmult $11, $26
|
# CHECK: dmult $11, $26
|
||||||
0x01 0x7a 0x00 0x1c
|
0x01 0x7a 0x00 0x1c
|
||||||
|
|
||||||
# CHECK: dmultu $23, $13
|
# CHECK: dmultu $23, $13
|
||||||
0x02 0xed 0x00 0x1d
|
0x02 0xed 0x00 0x1d
|
||||||
|
|
||||||
# CHECK: dsll $3, $24, 17
|
# CHECK: dsll $3, $24, 17
|
||||||
0x00 0x18 0x1c 0x78
|
0x00 0x18 0x1c 0x78
|
||||||
|
|
||||||
# CHECK: dsllv $gp, $27, $24
|
# CHECK: dsllv $gp, $27, $24
|
||||||
0x03 0x1b 0xe0 0x14
|
0x03 0x1b 0xe0 0x14
|
||||||
|
|
||||||
# CHECK: dsra $1, $1, 30
|
# CHECK: dsra $1, $1, 30
|
||||||
0x00 0x01 0x0f 0xbb
|
0x00 0x01 0x0f 0xbb
|
||||||
|
|
||||||
# CHECK: dsrav $1, $1, $fp
|
# CHECK: dsrav $1, $1, $fp
|
||||||
0x03 0xc1 0x08 0x17
|
0x03 0xc1 0x08 0x17
|
||||||
|
|
||||||
# CHECK: dsrl $10, $gp, 24
|
# CHECK: dsrl $10, $gp, 24
|
||||||
0x00 0x1c 0x56 0x3a
|
0x00 0x1c 0x56 0x3a
|
||||||
|
|
||||||
# CHECK: dsrlv $gp, $10, $23
|
# CHECK: dsrlv $gp, $10, $23
|
||||||
0x02 0xea 0xe0 0x16
|
0x02 0xea 0xe0 0x16
|
||||||
|
|
||||||
# CHECK: dsubu $gp, $27, $24
|
# CHECK: dsubu $gp, $27, $24
|
||||||
0x03 0x78 0xe0 0x2f
|
0x03 0x78 0xe0 0x2f
|
||||||
|
|
||||||
# CHECK: lw $27, -15155($1)
|
# CHECK: lw $27, -15155($1)
|
||||||
0x8c 0x3b 0xc4 0xcd
|
0x8c 0x3b 0xc4 0xcd
|
||||||
|
|
||||||
# CHECK: lui $1, 1
|
# CHECK: lui $1, 1
|
||||||
0x3c 0x01 0x00 0x01
|
0x3c 0x01 0x00 0x01
|
||||||
|
|
||||||
# CHECK: lwu $3, -1746($3)
|
# CHECK: lwu $3, -1746($3)
|
||||||
0x9c 0x63 0xf9 0x2e
|
0x9c 0x63 0xf9 0x2e
|
||||||
|
|
||||||
# CHECK: lui $ra, 1
|
# CHECK: lui $ra, 1
|
||||||
0x3c 0x1f 0x00 0x01
|
0x3c 0x1f 0x00 0x01
|
||||||
|
|
||||||
# CHECK: sw $26, -15159($1)
|
# CHECK: sw $26, -15159($1)
|
||||||
0xac 0x3a 0xc4 0xc9
|
0xac 0x3a 0xc4 0xc9
|
||||||
|
|
||||||
# CHECK: ld $26, 3958($zero)
|
# CHECK: ld $26, 3958($zero)
|
||||||
0xdc 0x1a 0x0f 0x76
|
0xdc 0x1a 0x0f 0x76
|
||||||
|
|
||||||
# CHECK: sd $6, 17767($zero)
|
# CHECK: sd $6, 17767($zero)
|
||||||
0xfc 0x06 0x45 0x67
|
0xfc 0x06 0x45 0x67
|
||||||
|
@@ -1,67 +1,67 @@
|
|||||||
# RUN: llvm-mc --disassemble %s -triple=mips64el-unknown-linux | FileCheck %s
|
# RUN: llvm-mc --disassemble %s -triple=mips64el-unknown-linux | FileCheck %s
|
||||||
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
||||||
# CHECK: daddiu $11, $26, 31949
|
# CHECK: daddiu $11, $26, 31949
|
||||||
0xcd 0x7c 0x4b 0x67
|
0xcd 0x7c 0x4b 0x67
|
||||||
|
|
||||||
# CHECK: daddu $26, $1, $11
|
# CHECK: daddu $26, $1, $11
|
||||||
0x2d 0xd0 0x2b 0x00
|
0x2d 0xd0 0x2b 0x00
|
||||||
|
|
||||||
# CHECK: ddiv $zero, $26, $22
|
# CHECK: ddiv $zero, $26, $22
|
||||||
0x1e 0x00 0x56 0x03
|
0x1e 0x00 0x56 0x03
|
||||||
|
|
||||||
# CHECK: ddivu $zero, $9, $24
|
# CHECK: ddivu $zero, $9, $24
|
||||||
0x1f 0x00 0x38 0x01
|
0x1f 0x00 0x38 0x01
|
||||||
|
|
||||||
# CHECK: dmfc1 $2, $f14
|
# CHECK: dmfc1 $2, $f14
|
||||||
0x00 0x70 0x22 0x44
|
0x00 0x70 0x22 0x44
|
||||||
|
|
||||||
# CHECK: dmtc1 $23, $f5
|
# CHECK: dmtc1 $23, $f5
|
||||||
0x00 0x28 0xb7 0x44
|
0x00 0x28 0xb7 0x44
|
||||||
|
|
||||||
# CHECK: dmult $11, $26
|
# CHECK: dmult $11, $26
|
||||||
0x1c 0x00 0x7a 0x01
|
0x1c 0x00 0x7a 0x01
|
||||||
|
|
||||||
# CHECK: dmultu $23, $13
|
# CHECK: dmultu $23, $13
|
||||||
0x1d 0x00 0xed 0x02
|
0x1d 0x00 0xed 0x02
|
||||||
|
|
||||||
# CHECK: dsll $3, $24, 17
|
# CHECK: dsll $3, $24, 17
|
||||||
0x78 0x1c 0x18 0x00
|
0x78 0x1c 0x18 0x00
|
||||||
|
|
||||||
# CHECK: dsllv $gp, $27, $24
|
# CHECK: dsllv $gp, $27, $24
|
||||||
0x14 0xe0 0x1b 0x03
|
0x14 0xe0 0x1b 0x03
|
||||||
|
|
||||||
# CHECK: dsra $1, $1, 30
|
# CHECK: dsra $1, $1, 30
|
||||||
0xbb 0x0f 0x01 0x00
|
0xbb 0x0f 0x01 0x00
|
||||||
|
|
||||||
# CHECK: dsrav $1, $1, $fp
|
# CHECK: dsrav $1, $1, $fp
|
||||||
0x17 0x08 0xc1 0x03
|
0x17 0x08 0xc1 0x03
|
||||||
|
|
||||||
# CHECK: dsrl $10, $gp, 24
|
# CHECK: dsrl $10, $gp, 24
|
||||||
0x3a 0x56 0x1c 0x00
|
0x3a 0x56 0x1c 0x00
|
||||||
|
|
||||||
# CHECK: dsrlv $gp, $10, $23
|
# CHECK: dsrlv $gp, $10, $23
|
||||||
0x16 0xe0 0xea 0x02
|
0x16 0xe0 0xea 0x02
|
||||||
|
|
||||||
# CHECK: dsubu $gp, $27, $24
|
# CHECK: dsubu $gp, $27, $24
|
||||||
0x2f 0xe0 0x78 0x03
|
0x2f 0xe0 0x78 0x03
|
||||||
|
|
||||||
# CHECK: lw $27, -15155($1)
|
# CHECK: lw $27, -15155($1)
|
||||||
0xcd 0xc4 0x3b 0x8c
|
0xcd 0xc4 0x3b 0x8c
|
||||||
|
|
||||||
# CHECK: lui $1, 1
|
# CHECK: lui $1, 1
|
||||||
0x01 0x00 0x01 0x3c
|
0x01 0x00 0x01 0x3c
|
||||||
|
|
||||||
# CHECK: lwu $3, -1746($3)
|
# CHECK: lwu $3, -1746($3)
|
||||||
0x2e 0xf9 0x63 0x9c
|
0x2e 0xf9 0x63 0x9c
|
||||||
|
|
||||||
# CHECK: lui $ra, 1
|
# CHECK: lui $ra, 1
|
||||||
0x01 0x00 0x1f 0x3c
|
0x01 0x00 0x1f 0x3c
|
||||||
|
|
||||||
# CHECK: sw $26, -15159($1)
|
# CHECK: sw $26, -15159($1)
|
||||||
0xc9 0xc4 0x3a 0xac
|
0xc9 0xc4 0x3a 0xac
|
||||||
|
|
||||||
# CHECK: ld $26, 3958($zero)
|
# CHECK: ld $26, 3958($zero)
|
||||||
0x76 0x0f 0x1a 0xdc
|
0x76 0x0f 0x1a 0xdc
|
||||||
|
|
||||||
# CHECK: sd $6, 17767($zero)
|
# CHECK: sd $6, 17767($zero)
|
||||||
0x67 0x45 0x06 0xfc
|
0x67 0x45 0x06 0xfc
|
||||||
|
@@ -1,91 +1,91 @@
|
|||||||
# RUN: llvm-mc --disassemble %s -triple=mips64-unknown-linux -mattr +mips64r2 | FileCheck %s
|
# RUN: llvm-mc --disassemble %s -triple=mips64-unknown-linux -mattr +mips64r2 | FileCheck %s
|
||||||
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
||||||
# CHECK: daddiu $11, $26, 31949
|
# CHECK: daddiu $11, $26, 31949
|
||||||
0x67 0x4b 0x7c 0xcd
|
0x67 0x4b 0x7c 0xcd
|
||||||
|
|
||||||
# CHECK: daddu $26, $1, $11
|
# CHECK: daddu $26, $1, $11
|
||||||
0x00 0x2b 0xd0 0x2d
|
0x00 0x2b 0xd0 0x2d
|
||||||
|
|
||||||
# CHECK: ddiv $zero, $26, $22
|
# CHECK: ddiv $zero, $26, $22
|
||||||
0x03 0x56 0x00 0x1e
|
0x03 0x56 0x00 0x1e
|
||||||
|
|
||||||
# CHECK: ddivu $zero, $9, $24
|
# CHECK: ddivu $zero, $9, $24
|
||||||
0x01 0x38 0x00 0x1f
|
0x01 0x38 0x00 0x1f
|
||||||
|
|
||||||
# CHECK: dmfc1 $2, $f14
|
# CHECK: dmfc1 $2, $f14
|
||||||
0x44 0x22 0x70 0x00
|
0x44 0x22 0x70 0x00
|
||||||
|
|
||||||
# CHECK: dmtc1 $23, $f5
|
# CHECK: dmtc1 $23, $f5
|
||||||
0x44 0xb7 0x28 0x00
|
0x44 0xb7 0x28 0x00
|
||||||
|
|
||||||
# CHECK: dmult $11, $26
|
# CHECK: dmult $11, $26
|
||||||
0x01 0x7a 0x00 0x1c
|
0x01 0x7a 0x00 0x1c
|
||||||
|
|
||||||
# CHECK: dmultu $23, $13
|
# CHECK: dmultu $23, $13
|
||||||
0x02 0xed 0x00 0x1d
|
0x02 0xed 0x00 0x1d
|
||||||
|
|
||||||
# CHECK: dsll $3, $24, 17
|
# CHECK: dsll $3, $24, 17
|
||||||
0x00 0x18 0x1c 0x78
|
0x00 0x18 0x1c 0x78
|
||||||
|
|
||||||
# CHECK: dsllv $gp, $27, $24
|
# CHECK: dsllv $gp, $27, $24
|
||||||
0x03 0x1b 0xe0 0x14
|
0x03 0x1b 0xe0 0x14
|
||||||
|
|
||||||
# CHECK: dsra $1, $1, 30
|
# CHECK: dsra $1, $1, 30
|
||||||
0x00 0x01 0x0f 0xbb
|
0x00 0x01 0x0f 0xbb
|
||||||
|
|
||||||
# CHECK: dsrav $1, $1, $fp
|
# CHECK: dsrav $1, $1, $fp
|
||||||
0x03 0xc1 0x08 0x17
|
0x03 0xc1 0x08 0x17
|
||||||
|
|
||||||
# CHECK: dsrl $10, $gp, 24
|
# CHECK: dsrl $10, $gp, 24
|
||||||
0x00 0x1c 0x56 0x3a
|
0x00 0x1c 0x56 0x3a
|
||||||
|
|
||||||
# CHECK: dsrlv $gp, $10, $23
|
# CHECK: dsrlv $gp, $10, $23
|
||||||
0x02 0xea 0xe0 0x16
|
0x02 0xea 0xe0 0x16
|
||||||
|
|
||||||
# CHECK: dsubu $gp, $27, $24
|
# CHECK: dsubu $gp, $27, $24
|
||||||
0x03 0x78 0xe0 0x2f
|
0x03 0x78 0xe0 0x2f
|
||||||
|
|
||||||
# CHECK: lw $27, -15155($1)
|
# CHECK: lw $27, -15155($1)
|
||||||
0x8c 0x3b 0xc4 0xcd
|
0x8c 0x3b 0xc4 0xcd
|
||||||
|
|
||||||
# CHECK: lui $1, 1
|
# CHECK: lui $1, 1
|
||||||
0x3c 0x01 0x00 0x01
|
0x3c 0x01 0x00 0x01
|
||||||
|
|
||||||
# CHECK: lwu $3, -1746($3)
|
# CHECK: lwu $3, -1746($3)
|
||||||
0x9c 0x63 0xf9 0x2e
|
0x9c 0x63 0xf9 0x2e
|
||||||
|
|
||||||
# CHECK: lui $ra, 1
|
# CHECK: lui $ra, 1
|
||||||
0x3c 0x1f 0x00 0x01
|
0x3c 0x1f 0x00 0x01
|
||||||
|
|
||||||
# CHECK: sw $26, -15159($1)
|
# CHECK: sw $26, -15159($1)
|
||||||
0xac 0x3a 0xc4 0xc9
|
0xac 0x3a 0xc4 0xc9
|
||||||
|
|
||||||
# CHECK: ld $26, 3958($zero)
|
# CHECK: ld $26, 3958($zero)
|
||||||
0xdc 0x1a 0x0f 0x76
|
0xdc 0x1a 0x0f 0x76
|
||||||
|
|
||||||
# CHECK: sd $6, 17767($zero)
|
# CHECK: sd $6, 17767($zero)
|
||||||
0xfc 0x06 0x45 0x67
|
0xfc 0x06 0x45 0x67
|
||||||
|
|
||||||
# CHECK: dclo $9, $24
|
# CHECK: dclo $9, $24
|
||||||
0x73 0x09 0x48 0x25
|
0x73 0x09 0x48 0x25
|
||||||
|
|
||||||
# CHECK: dclz $26, $9
|
# CHECK: dclz $26, $9
|
||||||
0x71 0x3a 0xd0 0x24
|
0x71 0x3a 0xd0 0x24
|
||||||
|
|
||||||
# CHECK: dext $7, $gp, 29, 31
|
# CHECK: dext $7, $gp, 29, 31
|
||||||
0x7f 0x87 0xf7 0x43
|
0x7f 0x87 0xf7 0x43
|
||||||
|
|
||||||
# CHECK: dins $20, $gp, 15, 1
|
# CHECK: dins $20, $gp, 15, 1
|
||||||
0x7f 0x94 0x7b 0xc7
|
0x7f 0x94 0x7b 0xc7
|
||||||
|
|
||||||
# CHECK: dsbh $7, $gp
|
# CHECK: dsbh $7, $gp
|
||||||
0x7c 0x1c 0x38 0xa4
|
0x7c 0x1c 0x38 0xa4
|
||||||
|
|
||||||
# CHECK: dshd $3, $14
|
# CHECK: dshd $3, $14
|
||||||
0x7c 0x0e 0x19 0x64
|
0x7c 0x0e 0x19 0x64
|
||||||
|
|
||||||
# CHECK: drotr $20, $27, 6
|
# CHECK: drotr $20, $27, 6
|
||||||
0x00 0x3b 0xa1 0xba
|
0x00 0x3b 0xa1 0xba
|
||||||
|
|
||||||
# CHECK: drotrv $24, $23, $5
|
# CHECK: drotrv $24, $23, $5
|
||||||
0x00 0xb7 0xc0 0x56
|
0x00 0xb7 0xc0 0x56
|
||||||
|
@@ -1,91 +1,91 @@
|
|||||||
# RUN: llvm-mc --disassemble %s -triple=mips64el-unknown-linux -mattr +mips64r2 | FileCheck %s
|
# RUN: llvm-mc --disassemble %s -triple=mips64el-unknown-linux -mattr +mips64r2 | FileCheck %s
|
||||||
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
# CHECK: .section __TEXT,__text,regular,pure_instructions
|
||||||
# CHECK: daddiu $11, $26, 31949
|
# CHECK: daddiu $11, $26, 31949
|
||||||
0xcd 0x7c 0x4b 0x67
|
0xcd 0x7c 0x4b 0x67
|
||||||
|
|
||||||
# CHECK: daddu $26, $1, $11
|
# CHECK: daddu $26, $1, $11
|
||||||
0x2d 0xd0 0x2b 0x00
|
0x2d 0xd0 0x2b 0x00
|
||||||
|
|
||||||
# CHECK: ddiv $zero, $26, $22
|
# CHECK: ddiv $zero, $26, $22
|
||||||
0x1e 0x00 0x56 0x03
|
0x1e 0x00 0x56 0x03
|
||||||
|
|
||||||
# CHECK: ddivu $zero, $9, $24
|
# CHECK: ddivu $zero, $9, $24
|
||||||
0x1f 0x00 0x38 0x01
|
0x1f 0x00 0x38 0x01
|
||||||
|
|
||||||
# CHECK: dmfc1 $2, $f14
|
# CHECK: dmfc1 $2, $f14
|
||||||
0x00 0x70 0x22 0x44
|
0x00 0x70 0x22 0x44
|
||||||
|
|
||||||
# CHECK: dmtc1 $23, $f5
|
# CHECK: dmtc1 $23, $f5
|
||||||
0x00 0x28 0xb7 0x44
|
0x00 0x28 0xb7 0x44
|
||||||
|
|
||||||
# CHECK: dmult $11, $26
|
# CHECK: dmult $11, $26
|
||||||
0x1c 0x00 0x7a 0x01
|
0x1c 0x00 0x7a 0x01
|
||||||
|
|
||||||
# CHECK: dmultu $23, $13
|
# CHECK: dmultu $23, $13
|
||||||
0x1d 0x00 0xed 0x02
|
0x1d 0x00 0xed 0x02
|
||||||
|
|
||||||
# CHECK: dsll $3, $24, 17
|
# CHECK: dsll $3, $24, 17
|
||||||
0x78 0x1c 0x18 0x00
|
0x78 0x1c 0x18 0x00
|
||||||
|
|
||||||
# CHECK: dsllv $gp, $27, $24
|
# CHECK: dsllv $gp, $27, $24
|
||||||
0x14 0xe0 0x1b 0x03
|
0x14 0xe0 0x1b 0x03
|
||||||
|
|
||||||
# CHECK: dsra $1, $1, 30
|
# CHECK: dsra $1, $1, 30
|
||||||
0xbb 0x0f 0x01 0x00
|
0xbb 0x0f 0x01 0x00
|
||||||
|
|
||||||
# CHECK: dsrav $1, $1, $fp
|
# CHECK: dsrav $1, $1, $fp
|
||||||
0x17 0x08 0xc1 0x03
|
0x17 0x08 0xc1 0x03
|
||||||
|
|
||||||
# CHECK: dsrl $10, $gp, 24
|
# CHECK: dsrl $10, $gp, 24
|
||||||
0x3a 0x56 0x1c 0x00
|
0x3a 0x56 0x1c 0x00
|
||||||
|
|
||||||
# CHECK: dsrlv $gp, $10, $23
|
# CHECK: dsrlv $gp, $10, $23
|
||||||
0x16 0xe0 0xea 0x02
|
0x16 0xe0 0xea 0x02
|
||||||
|
|
||||||
# CHECK: dsubu $gp, $27, $24
|
# CHECK: dsubu $gp, $27, $24
|
||||||
0x2f 0xe0 0x78 0x03
|
0x2f 0xe0 0x78 0x03
|
||||||
|
|
||||||
# CHECK: lw $27, -15155($1)
|
# CHECK: lw $27, -15155($1)
|
||||||
0xcd 0xc4 0x3b 0x8c
|
0xcd 0xc4 0x3b 0x8c
|
||||||
|
|
||||||
# CHECK: lui $1, 1
|
# CHECK: lui $1, 1
|
||||||
0x01 0x00 0x01 0x3c
|
0x01 0x00 0x01 0x3c
|
||||||
|
|
||||||
# CHECK: lwu $3, -1746($3)
|
# CHECK: lwu $3, -1746($3)
|
||||||
0x2e 0xf9 0x63 0x9c
|
0x2e 0xf9 0x63 0x9c
|
||||||
|
|
||||||
# CHECK: lui $ra, 1
|
# CHECK: lui $ra, 1
|
||||||
0x01 0x00 0x1f 0x3c
|
0x01 0x00 0x1f 0x3c
|
||||||
|
|
||||||
# CHECK: sw $26, -15159($1)
|
# CHECK: sw $26, -15159($1)
|
||||||
0xc9 0xc4 0x3a 0xac
|
0xc9 0xc4 0x3a 0xac
|
||||||
|
|
||||||
# CHECK: ld $26, 3958($zero)
|
# CHECK: ld $26, 3958($zero)
|
||||||
0x76 0x0f 0x1a 0xdc
|
0x76 0x0f 0x1a 0xdc
|
||||||
|
|
||||||
# CHECK: sd $6, 17767($zero)
|
# CHECK: sd $6, 17767($zero)
|
||||||
0x67 0x45 0x06 0xfc
|
0x67 0x45 0x06 0xfc
|
||||||
|
|
||||||
# CHECK: dclo $9, $24
|
# CHECK: dclo $9, $24
|
||||||
0x25 0x48 0x09 0x73
|
0x25 0x48 0x09 0x73
|
||||||
|
|
||||||
# CHECK: dclz $26, $9
|
# CHECK: dclz $26, $9
|
||||||
0x24 0xd0 0x3a 0x71
|
0x24 0xd0 0x3a 0x71
|
||||||
|
|
||||||
# CHECK: dext $7, $gp, 29, 31
|
# CHECK: dext $7, $gp, 29, 31
|
||||||
0x43 0xf7 0x87 0x7f
|
0x43 0xf7 0x87 0x7f
|
||||||
|
|
||||||
# CHECK: dins $20, $gp, 15, 1
|
# CHECK: dins $20, $gp, 15, 1
|
||||||
0xc7 0x7b 0x94 0x7f
|
0xc7 0x7b 0x94 0x7f
|
||||||
|
|
||||||
# CHECK: dsbh $7, $gp
|
# CHECK: dsbh $7, $gp
|
||||||
0xa4 0x38 0x1c 0x7c
|
0xa4 0x38 0x1c 0x7c
|
||||||
|
|
||||||
# CHECK: dshd $3, $14
|
# CHECK: dshd $3, $14
|
||||||
0x64 0x19 0x0e 0x7c
|
0x64 0x19 0x0e 0x7c
|
||||||
|
|
||||||
# CHECK: drotr $20, $27, 6
|
# CHECK: drotr $20, $27, 6
|
||||||
0xba 0xa1 0x3b 0x00
|
0xba 0xa1 0x3b 0x00
|
||||||
|
|
||||||
# CHECK: drotrv $24, $23, $5
|
# CHECK: drotrv $24, $23, $5
|
||||||
0x56 0xc0 0xb7 0x00
|
0x56 0xc0 0xb7 0x00
|
||||||
|
@@ -1,24 +1,24 @@
|
|||||||
; RUN: opt < %s -instcombine -S | FileCheck %s
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||||
|
|
||||||
define void @entry() nounwind {
|
define void @entry() nounwind {
|
||||||
entry:
|
entry:
|
||||||
br label %for.cond
|
br label %for.cond
|
||||||
|
|
||||||
for.cond:
|
for.cond:
|
||||||
%local = phi <1 x i32> [ <i32 0>, %entry ], [ %phi2, %cond.end47 ]
|
%local = phi <1 x i32> [ <i32 0>, %entry ], [ %phi2, %cond.end47 ]
|
||||||
; CHECK: sub <1 x i32> <i32 92>, %local
|
; CHECK: sub <1 x i32> <i32 92>, %local
|
||||||
%phi3 = sub <1 x i32> zeroinitializer, %local
|
%phi3 = sub <1 x i32> zeroinitializer, %local
|
||||||
br label %cond.end
|
br label %cond.end
|
||||||
|
|
||||||
cond.false:
|
cond.false:
|
||||||
br label %cond.end
|
br label %cond.end
|
||||||
|
|
||||||
cond.end:
|
cond.end:
|
||||||
%cond = phi <1 x i32> [ %phi3, %for.cond ], [ undef, %cond.false ]
|
%cond = phi <1 x i32> [ %phi3, %for.cond ], [ undef, %cond.false ]
|
||||||
br label %cond.end47
|
br label %cond.end47
|
||||||
|
|
||||||
cond.end47:
|
cond.end47:
|
||||||
%sum = add <1 x i32> %cond, <i32 92>
|
%sum = add <1 x i32> %cond, <i32 92>
|
||||||
%phi2 = sub <1 x i32> zeroinitializer, %sum
|
%phi2 = sub <1 x i32> zeroinitializer, %sum
|
||||||
br label %for.cond
|
br label %for.cond
|
||||||
}
|
}
|
||||||
|
@@ -1,356 +1,356 @@
|
|||||||
//===- llvm/unittest/Support/AllocatorTest.cpp - BumpPtrAllocator tests ---===//
|
//===- llvm/unittest/Support/AllocatorTest.cpp - BumpPtrAllocator tests ---===//
|
||||||
//
|
//
|
||||||
// The LLVM Compiler Infrastructure
|
// The LLVM Compiler Infrastructure
|
||||||
//
|
//
|
||||||
// This file is distributed under the University of Illinois Open Source
|
// This file is distributed under the University of Illinois Open Source
|
||||||
// License. See LICENSE.TXT for details.
|
// License. See LICENSE.TXT for details.
|
||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Support/Memory.h"
|
#include "llvm/Support/Memory.h"
|
||||||
#include "llvm/Support/Process.h"
|
#include "llvm/Support/Process.h"
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace sys;
|
using namespace sys;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class MappedMemoryTest : public ::testing::TestWithParam<unsigned> {
|
class MappedMemoryTest : public ::testing::TestWithParam<unsigned> {
|
||||||
public:
|
public:
|
||||||
MappedMemoryTest() {
|
MappedMemoryTest() {
|
||||||
Flags = GetParam();
|
Flags = GetParam();
|
||||||
PageSize = sys::Process::GetPageSize();
|
PageSize = sys::Process::GetPageSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Adds RW flags to permit testing of the resulting memory
|
// Adds RW flags to permit testing of the resulting memory
|
||||||
unsigned getTestableEquivalent(unsigned RequestedFlags) {
|
unsigned getTestableEquivalent(unsigned RequestedFlags) {
|
||||||
switch (RequestedFlags) {
|
switch (RequestedFlags) {
|
||||||
case Memory::MF_READ:
|
case Memory::MF_READ:
|
||||||
case Memory::MF_WRITE:
|
case Memory::MF_WRITE:
|
||||||
case Memory::MF_READ|Memory::MF_WRITE:
|
case Memory::MF_READ|Memory::MF_WRITE:
|
||||||
return Memory::MF_READ|Memory::MF_WRITE;
|
return Memory::MF_READ|Memory::MF_WRITE;
|
||||||
case Memory::MF_READ|Memory::MF_EXEC:
|
case Memory::MF_READ|Memory::MF_EXEC:
|
||||||
case Memory::MF_READ|Memory::MF_WRITE|Memory::MF_EXEC:
|
case Memory::MF_READ|Memory::MF_WRITE|Memory::MF_EXEC:
|
||||||
case Memory::MF_EXEC:
|
case Memory::MF_EXEC:
|
||||||
return Memory::MF_READ|Memory::MF_WRITE|Memory::MF_EXEC;
|
return Memory::MF_READ|Memory::MF_WRITE|Memory::MF_EXEC;
|
||||||
}
|
}
|
||||||
// Default in case values are added to the enum, as required by some compilers
|
// Default in case values are added to the enum, as required by some compilers
|
||||||
return Memory::MF_READ|Memory::MF_WRITE;
|
return Memory::MF_READ|Memory::MF_WRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the memory blocks overlap
|
// Returns true if the memory blocks overlap
|
||||||
bool doesOverlap(MemoryBlock M1, MemoryBlock M2) {
|
bool doesOverlap(MemoryBlock M1, MemoryBlock M2) {
|
||||||
if (M1.base() == M2.base())
|
if (M1.base() == M2.base())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (M1.base() > M2.base())
|
if (M1.base() > M2.base())
|
||||||
return (unsigned char *)M2.base() + M2.size() > M1.base();
|
return (unsigned char *)M2.base() + M2.size() > M1.base();
|
||||||
|
|
||||||
return (unsigned char *)M1.base() + M1.size() > M2.base();
|
return (unsigned char *)M1.base() + M1.size() > M2.base();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned Flags;
|
unsigned Flags;
|
||||||
size_t PageSize;
|
size_t PageSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, AllocAndRelease) {
|
TEST_P(MappedMemoryTest, AllocAndRelease) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(sizeof(int), M1.size());
|
EXPECT_LE(sizeof(int), M1.size());
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
|
TEST_P(MappedMemoryTest, MultipleAllocAndRelease) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC);
|
MemoryBlock M2 = Memory::allocateMappedMemory(64, 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC);
|
MemoryBlock M3 = Memory::allocateMappedMemory(32, 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(16U, M1.size());
|
EXPECT_LE(16U, M1.size());
|
||||||
EXPECT_NE((void*)0, M2.base());
|
EXPECT_NE((void*)0, M2.base());
|
||||||
EXPECT_LE(64U, M2.size());
|
EXPECT_LE(64U, M2.size());
|
||||||
EXPECT_NE((void*)0, M3.base());
|
EXPECT_NE((void*)0, M3.base());
|
||||||
EXPECT_LE(32U, M3.size());
|
EXPECT_LE(32U, M3.size());
|
||||||
|
|
||||||
EXPECT_FALSE(doesOverlap(M1, M2));
|
EXPECT_FALSE(doesOverlap(M1, M2));
|
||||||
EXPECT_FALSE(doesOverlap(M2, M3));
|
EXPECT_FALSE(doesOverlap(M2, M3));
|
||||||
EXPECT_FALSE(doesOverlap(M1, M3));
|
EXPECT_FALSE(doesOverlap(M1, M3));
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
||||||
MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
EXPECT_NE((void*)0, M4.base());
|
EXPECT_NE((void*)0, M4.base());
|
||||||
EXPECT_LE(16U, M4.size());
|
EXPECT_LE(16U, M4.size());
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, BasicWrite) {
|
TEST_P(MappedMemoryTest, BasicWrite) {
|
||||||
// This test applies only to writeable combinations
|
// This test applies only to writeable combinations
|
||||||
if (Flags && !(Flags & Memory::MF_WRITE))
|
if (Flags && !(Flags & Memory::MF_WRITE))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(sizeof(int), M1.size());
|
EXPECT_LE(sizeof(int), M1.size());
|
||||||
|
|
||||||
int *a = (int*)M1.base();
|
int *a = (int*)M1.base();
|
||||||
*a = 1;
|
*a = 1;
|
||||||
EXPECT_EQ(1, *a);
|
EXPECT_EQ(1, *a);
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, MultipleWrite) {
|
TEST_P(MappedMemoryTest, MultipleWrite) {
|
||||||
// This test applies only to writeable combinations
|
// This test applies only to writeable combinations
|
||||||
if (Flags && !(Flags & Memory::MF_WRITE))
|
if (Flags && !(Flags & Memory::MF_WRITE))
|
||||||
return;
|
return;
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
|
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
|
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_FALSE(doesOverlap(M1, M2));
|
EXPECT_FALSE(doesOverlap(M1, M2));
|
||||||
EXPECT_FALSE(doesOverlap(M2, M3));
|
EXPECT_FALSE(doesOverlap(M2, M3));
|
||||||
EXPECT_FALSE(doesOverlap(M1, M3));
|
EXPECT_FALSE(doesOverlap(M1, M3));
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(1U * sizeof(int), M1.size());
|
EXPECT_LE(1U * sizeof(int), M1.size());
|
||||||
EXPECT_NE((void*)0, M2.base());
|
EXPECT_NE((void*)0, M2.base());
|
||||||
EXPECT_LE(8U * sizeof(int), M2.size());
|
EXPECT_LE(8U * sizeof(int), M2.size());
|
||||||
EXPECT_NE((void*)0, M3.base());
|
EXPECT_NE((void*)0, M3.base());
|
||||||
EXPECT_LE(4U * sizeof(int), M3.size());
|
EXPECT_LE(4U * sizeof(int), M3.size());
|
||||||
|
|
||||||
int *x = (int*)M1.base();
|
int *x = (int*)M1.base();
|
||||||
*x = 1;
|
*x = 1;
|
||||||
|
|
||||||
int *y = (int*)M2.base();
|
int *y = (int*)M2.base();
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
y[i] = i;
|
y[i] = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int *z = (int*)M3.base();
|
int *z = (int*)M3.base();
|
||||||
*z = 42;
|
*z = 42;
|
||||||
|
|
||||||
EXPECT_EQ(1, *x);
|
EXPECT_EQ(1, *x);
|
||||||
EXPECT_EQ(7, y[7]);
|
EXPECT_EQ(7, y[7]);
|
||||||
EXPECT_EQ(42, *z);
|
EXPECT_EQ(42, *z);
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
||||||
|
|
||||||
MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC);
|
MemoryBlock M4 = Memory::allocateMappedMemory(64 * sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
EXPECT_NE((void*)0, M4.base());
|
EXPECT_NE((void*)0, M4.base());
|
||||||
EXPECT_LE(64U * sizeof(int), M4.size());
|
EXPECT_LE(64U * sizeof(int), M4.size());
|
||||||
x = (int*)M4.base();
|
x = (int*)M4.base();
|
||||||
*x = 4;
|
*x = 4;
|
||||||
EXPECT_EQ(4, *x);
|
EXPECT_EQ(4, *x);
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
|
||||||
|
|
||||||
// Verify that M2 remains unaffected by other activity
|
// Verify that M2 remains unaffected by other activity
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
EXPECT_EQ(i, y[i]);
|
EXPECT_EQ(i, y[i]);
|
||||||
}
|
}
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, EnabledWrite) {
|
TEST_P(MappedMemoryTest, EnabledWrite) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(2 * sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
|
MemoryBlock M2 = Memory::allocateMappedMemory(8 * sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
|
MemoryBlock M3 = Memory::allocateMappedMemory(4 * sizeof(int), 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(2U * sizeof(int), M1.size());
|
EXPECT_LE(2U * sizeof(int), M1.size());
|
||||||
EXPECT_NE((void*)0, M2.base());
|
EXPECT_NE((void*)0, M2.base());
|
||||||
EXPECT_LE(8U * sizeof(int), M2.size());
|
EXPECT_LE(8U * sizeof(int), M2.size());
|
||||||
EXPECT_NE((void*)0, M3.base());
|
EXPECT_NE((void*)0, M3.base());
|
||||||
EXPECT_LE(4U * sizeof(int), M3.size());
|
EXPECT_LE(4U * sizeof(int), M3.size());
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::protectMappedMemory(M1, getTestableEquivalent(Flags)));
|
EXPECT_FALSE(Memory::protectMappedMemory(M1, getTestableEquivalent(Flags)));
|
||||||
EXPECT_FALSE(Memory::protectMappedMemory(M2, getTestableEquivalent(Flags)));
|
EXPECT_FALSE(Memory::protectMappedMemory(M2, getTestableEquivalent(Flags)));
|
||||||
EXPECT_FALSE(Memory::protectMappedMemory(M3, getTestableEquivalent(Flags)));
|
EXPECT_FALSE(Memory::protectMappedMemory(M3, getTestableEquivalent(Flags)));
|
||||||
|
|
||||||
EXPECT_FALSE(doesOverlap(M1, M2));
|
EXPECT_FALSE(doesOverlap(M1, M2));
|
||||||
EXPECT_FALSE(doesOverlap(M2, M3));
|
EXPECT_FALSE(doesOverlap(M2, M3));
|
||||||
EXPECT_FALSE(doesOverlap(M1, M3));
|
EXPECT_FALSE(doesOverlap(M1, M3));
|
||||||
|
|
||||||
int *x = (int*)M1.base();
|
int *x = (int*)M1.base();
|
||||||
*x = 1;
|
*x = 1;
|
||||||
int *y = (int*)M2.base();
|
int *y = (int*)M2.base();
|
||||||
for (unsigned int i = 0; i < 8; i++) {
|
for (unsigned int i = 0; i < 8; i++) {
|
||||||
y[i] = i;
|
y[i] = i;
|
||||||
}
|
}
|
||||||
int *z = (int*)M3.base();
|
int *z = (int*)M3.base();
|
||||||
*z = 42;
|
*z = 42;
|
||||||
|
|
||||||
EXPECT_EQ(1, *x);
|
EXPECT_EQ(1, *x);
|
||||||
EXPECT_EQ(7, y[7]);
|
EXPECT_EQ(7, y[7]);
|
||||||
EXPECT_EQ(42, *z);
|
EXPECT_EQ(42, *z);
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
||||||
EXPECT_EQ(6, y[6]);
|
EXPECT_EQ(6, y[6]);
|
||||||
|
|
||||||
MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
MemoryBlock M4 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
EXPECT_NE((void*)0, M4.base());
|
EXPECT_NE((void*)0, M4.base());
|
||||||
EXPECT_LE(16U, M4.size());
|
EXPECT_LE(16U, M4.size());
|
||||||
EXPECT_EQ(error_code::success(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
|
EXPECT_EQ(error_code::success(), Memory::protectMappedMemory(M4, getTestableEquivalent(Flags)));
|
||||||
x = (int*)M4.base();
|
x = (int*)M4.base();
|
||||||
*x = 4;
|
*x = 4;
|
||||||
EXPECT_EQ(4, *x);
|
EXPECT_EQ(4, *x);
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M4));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, SuccessiveNear) {
|
TEST_P(MappedMemoryTest, SuccessiveNear) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(16, 0, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC);
|
MemoryBlock M2 = Memory::allocateMappedMemory(64, &M1, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC);
|
MemoryBlock M3 = Memory::allocateMappedMemory(32, &M2, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(16U, M1.size());
|
EXPECT_LE(16U, M1.size());
|
||||||
EXPECT_NE((void*)0, M2.base());
|
EXPECT_NE((void*)0, M2.base());
|
||||||
EXPECT_LE(64U, M2.size());
|
EXPECT_LE(64U, M2.size());
|
||||||
EXPECT_NE((void*)0, M3.base());
|
EXPECT_NE((void*)0, M3.base());
|
||||||
EXPECT_LE(32U, M3.size());
|
EXPECT_LE(32U, M3.size());
|
||||||
|
|
||||||
EXPECT_FALSE(doesOverlap(M1, M2));
|
EXPECT_FALSE(doesOverlap(M1, M2));
|
||||||
EXPECT_FALSE(doesOverlap(M2, M3));
|
EXPECT_FALSE(doesOverlap(M2, M3));
|
||||||
EXPECT_FALSE(doesOverlap(M1, M3));
|
EXPECT_FALSE(doesOverlap(M1, M3));
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, DuplicateNear) {
|
TEST_P(MappedMemoryTest, DuplicateNear) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock Near((void*)(3*PageSize), 16);
|
MemoryBlock Near((void*)(3*PageSize), 16);
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
|
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
|
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(16U, M1.size());
|
EXPECT_LE(16U, M1.size());
|
||||||
EXPECT_NE((void*)0, M2.base());
|
EXPECT_NE((void*)0, M2.base());
|
||||||
EXPECT_LE(64U, M2.size());
|
EXPECT_LE(64U, M2.size());
|
||||||
EXPECT_NE((void*)0, M3.base());
|
EXPECT_NE((void*)0, M3.base());
|
||||||
EXPECT_LE(32U, M3.size());
|
EXPECT_LE(32U, M3.size());
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, ZeroNear) {
|
TEST_P(MappedMemoryTest, ZeroNear) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock Near(0, 0);
|
MemoryBlock Near(0, 0);
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
|
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
|
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(16U, M1.size());
|
EXPECT_LE(16U, M1.size());
|
||||||
EXPECT_NE((void*)0, M2.base());
|
EXPECT_NE((void*)0, M2.base());
|
||||||
EXPECT_LE(64U, M2.size());
|
EXPECT_LE(64U, M2.size());
|
||||||
EXPECT_NE((void*)0, M3.base());
|
EXPECT_NE((void*)0, M3.base());
|
||||||
EXPECT_LE(32U, M3.size());
|
EXPECT_LE(32U, M3.size());
|
||||||
|
|
||||||
EXPECT_FALSE(doesOverlap(M1, M2));
|
EXPECT_FALSE(doesOverlap(M1, M2));
|
||||||
EXPECT_FALSE(doesOverlap(M2, M3));
|
EXPECT_FALSE(doesOverlap(M2, M3));
|
||||||
EXPECT_FALSE(doesOverlap(M1, M3));
|
EXPECT_FALSE(doesOverlap(M1, M3));
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, ZeroSizeNear) {
|
TEST_P(MappedMemoryTest, ZeroSizeNear) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock Near((void*)(4*PageSize), 0);
|
MemoryBlock Near((void*)(4*PageSize), 0);
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(16, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
|
MemoryBlock M2 = Memory::allocateMappedMemory(64, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
|
MemoryBlock M3 = Memory::allocateMappedMemory(32, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(16U, M1.size());
|
EXPECT_LE(16U, M1.size());
|
||||||
EXPECT_NE((void*)0, M2.base());
|
EXPECT_NE((void*)0, M2.base());
|
||||||
EXPECT_LE(64U, M2.size());
|
EXPECT_LE(64U, M2.size());
|
||||||
EXPECT_NE((void*)0, M3.base());
|
EXPECT_NE((void*)0, M3.base());
|
||||||
EXPECT_LE(32U, M3.size());
|
EXPECT_LE(32U, M3.size());
|
||||||
|
|
||||||
EXPECT_FALSE(doesOverlap(M1, M2));
|
EXPECT_FALSE(doesOverlap(M1, M2));
|
||||||
EXPECT_FALSE(doesOverlap(M2, M3));
|
EXPECT_FALSE(doesOverlap(M2, M3));
|
||||||
EXPECT_FALSE(doesOverlap(M1, M3));
|
EXPECT_FALSE(doesOverlap(M1, M3));
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M3));
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M2));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(MappedMemoryTest, UnalignedNear) {
|
TEST_P(MappedMemoryTest, UnalignedNear) {
|
||||||
error_code EC;
|
error_code EC;
|
||||||
MemoryBlock Near((void*)(2*PageSize+5), 0);
|
MemoryBlock Near((void*)(2*PageSize+5), 0);
|
||||||
MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC);
|
MemoryBlock M1 = Memory::allocateMappedMemory(15, &Near, Flags, EC);
|
||||||
EXPECT_EQ(error_code::success(), EC);
|
EXPECT_EQ(error_code::success(), EC);
|
||||||
|
|
||||||
EXPECT_NE((void*)0, M1.base());
|
EXPECT_NE((void*)0, M1.base());
|
||||||
EXPECT_LE(sizeof(int), M1.size());
|
EXPECT_LE(sizeof(int), M1.size());
|
||||||
|
|
||||||
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
EXPECT_FALSE(Memory::releaseMappedMemory(M1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that Memory::MF_WRITE is not supported exclusively across
|
// Note that Memory::MF_WRITE is not supported exclusively across
|
||||||
// operating systems and architectures and can imply MF_READ|MF_WRITE
|
// operating systems and architectures and can imply MF_READ|MF_WRITE
|
||||||
unsigned MemoryFlags[] = {
|
unsigned MemoryFlags[] = {
|
||||||
Memory::MF_READ,
|
Memory::MF_READ,
|
||||||
Memory::MF_WRITE,
|
Memory::MF_WRITE,
|
||||||
Memory::MF_READ|Memory::MF_WRITE,
|
Memory::MF_READ|Memory::MF_WRITE,
|
||||||
Memory::MF_EXEC,
|
Memory::MF_EXEC,
|
||||||
Memory::MF_READ|Memory::MF_EXEC,
|
Memory::MF_READ|Memory::MF_EXEC,
|
||||||
Memory::MF_READ|Memory::MF_WRITE|Memory::MF_EXEC
|
Memory::MF_READ|Memory::MF_WRITE|Memory::MF_EXEC
|
||||||
};
|
};
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(AllocationTests,
|
INSTANTIATE_TEST_CASE_P(AllocationTests,
|
||||||
MappedMemoryTest,
|
MappedMemoryTest,
|
||||||
::testing::ValuesIn(MemoryFlags));
|
::testing::ValuesIn(MemoryFlags));
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
Reference in New Issue
Block a user