-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests for the Power binary encoder (#4721)
Add unit tests for the Power binary encoder
- Loading branch information
Showing
6 changed files
with
3,090 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
############################################################################### | ||
# Copyright (c) 2020, 2020 IBM Corp. and others | ||
# | ||
# This program and the accompanying materials are made available under | ||
# the terms of the Eclipse Public License 2.0 which accompanies this | ||
# distribution and is available at http://eclipse.org/legal/epl-2.0 | ||
# or the Apache License, Version 2.0 which accompanies this distribution | ||
# and is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
# | ||
# This Source Code may also be made available under the following Secondary | ||
# Licenses when the conditions for such availability set forth in the | ||
# Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, | ||
# version 2 with the GNU Classpath Exception [1] and GNU General Public | ||
# License, version 2 with the OpenJDK Assembly Exception [2]. | ||
# | ||
# [1] https://www.gnu.org/software/classpath/license.html | ||
# [2] http://openjdk.java.net/legal/assembly-exception.html | ||
# | ||
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception | ||
############################################################################### | ||
|
||
cmake_minimum_required(VERSION 3.2 FATAL_ERROR) | ||
|
||
project(compunittest LANGUAGES C CXX) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
set(COMPCGTEST_FILES | ||
main.cpp | ||
) | ||
|
||
if(OMR_ARCH_POWER) | ||
list(APPEND COMPCGTEST_FILES | ||
p/BinaryEncoder.cpp | ||
) | ||
endif() | ||
|
||
add_executable(compunittest ${COMPCGTEST_FILES}) | ||
|
||
# For the time being, link against Tril even though we don't really need Tril itself. This is done | ||
# to avoid needing to duplicate the boilerplate in Tril's CMakeLists.txt. | ||
target_link_libraries(compunittest | ||
omrGtestGlue | ||
tril | ||
) | ||
|
||
set_property(TARGET compunittest PROPERTY FOLDER fvtest) | ||
|
||
add_test( | ||
NAME compunittest | ||
COMMAND compunittest --gtest_color=yes --gtest_output=xml:${CMAKE_CURRENT_BINARY_DIR}/compunittest-results.xml | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020, 2020 IBM Corp. and others | ||
* | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which accompanies this | ||
* distribution and is available at http://eclipse.org/legal/epl-2.0 | ||
* or the Apache License, Version 2.0 which accompanies this distribution | ||
* and is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception [1] and GNU General Public | ||
* License, version 2 with the OpenJDK Assembly Exception [2]. | ||
* | ||
* [1] https://www.gnu.org/software/classpath/license.html | ||
* [2] http://openjdk.java.net/legal/assembly-exception.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception | ||
*******************************************************************************/ | ||
|
||
#ifndef CODEGENTEST_HPP | ||
#define CODEGENTEST_HPP | ||
|
||
#include <gtest/gtest.h> | ||
#include <exception> | ||
|
||
#include "Jit.hpp" | ||
#include "codegen/CodeGenerator.hpp" | ||
#include "compile/Compilation.hpp" | ||
#include "env/ConcreteFE.hpp" | ||
#include "env/SystemSegmentProvider.hpp" | ||
#include "ilgen/IlGenRequest.hpp" | ||
#include "ilgen/IlGeneratorMethodDetails.hpp" | ||
#include "ilgen/TypeDictionary.hpp" | ||
|
||
#include "codegen/CodeGenerator_inlines.hpp" | ||
#include "compile/Compilation_inlines.hpp" | ||
#include "ilgen/IlGeneratorMethodDetails_inlines.hpp" | ||
|
||
namespace TRTest { | ||
|
||
class NullIlGenRequest : public TR::IlGenRequest { | ||
TR::IlGeneratorMethodDetails _details; | ||
|
||
public: | ||
NullIlGenRequest() : TR::IlGenRequest(_details) {} | ||
|
||
virtual TR_IlGenerator *getIlGenerator( | ||
TR::ResolvedMethodSymbol *methodSymbol, | ||
TR_FrontEnd *fe, | ||
TR::Compilation *comp, | ||
TR::SymbolReferenceTable *symRefTab | ||
) { | ||
throw std::runtime_error("The mock JIT environment does not support calling TR::IlGenRequest::getIlGenerator"); | ||
} | ||
|
||
virtual void print(TR_FrontEnd *fe, TR::FILE *file, const char *suffix) {} | ||
}; | ||
|
||
class JitInitializer { | ||
public: | ||
JitInitializer() { | ||
initializeJit(); | ||
} | ||
|
||
~JitInitializer() { | ||
shutdownJit(); | ||
} | ||
}; | ||
|
||
class CodeGenTest : public ::testing::Test { | ||
JitInitializer _jitInit; | ||
|
||
TR::RawAllocator _rawAllocator; | ||
TR::SystemSegmentProvider _segmentProvider; | ||
TR::Region _dispatchRegion; | ||
TR_Memory _trMemory; | ||
|
||
TR::TypeDictionary _types; | ||
|
||
TR::Options _options; | ||
NullIlGenRequest _ilGenRequest; | ||
TR::ResolvedMethod _method; | ||
TR::Compilation _comp; | ||
public: | ||
CodeGenTest() : | ||
_jitInit(), | ||
_rawAllocator(), | ||
_segmentProvider(1 << 16, _rawAllocator), | ||
_dispatchRegion(_segmentProvider, _rawAllocator), | ||
_trMemory(*OMR::FrontEnd::singleton().persistentMemory(), _dispatchRegion), | ||
_types(), | ||
_options(), | ||
_ilGenRequest(), | ||
_method("compunittest", "0", "test", 0, NULL, _types.NoType, NULL, NULL), | ||
_comp(0, NULL, &OMR::FrontEnd::singleton(), &_method, _ilGenRequest, _options, _dispatchRegion, &_trMemory, TR_OptimizationPlan::alloc(warm)) { | ||
} | ||
|
||
TR::CodeGenerator* cg() { return _comp.cg(); } | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2020, 2020 IBM Corp. and others | ||
* | ||
* This program and the accompanying materials are made available under | ||
* the terms of the Eclipse Public License 2.0 which accompanies this | ||
* distribution and is available at http://eclipse.org/legal/epl-2.0 | ||
* or the Apache License, Version 2.0 which accompanies this distribution | ||
* and is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the | ||
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, | ||
* version 2 with the GNU Classpath Exception [1] and GNU General Public | ||
* License, version 2 with the OpenJDK Assembly Exception [2]. | ||
* | ||
* [1] https://www.gnu.org/software/classpath/license.html | ||
* [2] http://openjdk.java.net/legal/assembly-exception.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception | ||
*******************************************************************************/ | ||
|
||
#include "omrTest.h" | ||
|
||
extern "C" { | ||
int omr_main_entry(int argc, char **argv, char **envp); | ||
} | ||
|
||
int omr_main_entry(int argc, char **argv, char **envp) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
OMREventListener::setDefaultTestListener(); | ||
return RUN_ALL_TESTS(); | ||
} |
Oops, something went wrong.