Skip to content

Commit

Permalink
Merge pull request #2515 from mstoodle/jitbuilder_enhance_extensibility
Browse files Browse the repository at this point in the history
Enhance extensibility of JitBuilder classes
  • Loading branch information
0xdaryl authored Jun 27, 2018
2 parents 2335e0e + 902e227 commit 62ce390
Show file tree
Hide file tree
Showing 47 changed files with 3,240 additions and 2,696 deletions.
110 changes: 5 additions & 105 deletions compiler/ilgen/BytecodeBuilder.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corp. and others
* Copyright (c) 2000, 2018 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
Expand All @@ -19,108 +19,10 @@
* 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 BYTECODE_BUILDER_INCL
#define BYTECODE_BUILDER_INCL
#ifndef TR_BYTECODEBUILDER_INCL
#define TR_BYTECODEBUILDER_INCL

#ifndef TR_BYTECODEBUILDER_DEFINED
#define TR_BYTECODEBUILDER_DEFINED
#define PUT_OMR_BYTECODEBUILDER_INTO_TR
#endif // !defined(TR_BYTECODEBUILDER_DEFINED)

#include "ilgen/IlBuilder.hpp"

namespace TR { class BytecodeBuilder; }
namespace TR { class MethodBuilder; }
namespace OMR { class VirtualMachineState; }

namespace OMR
{

class BytecodeBuilder : public TR::IlBuilder
{
public:
TR_ALLOC(TR_Memory::IlGenerator)

BytecodeBuilder(TR::MethodBuilder *methodBuilder, int32_t bcIndex, char *name=NULL);

virtual bool isBytecodeBuilder() { return true; }

/**
* @brief bytecode index for this builder object
*/
int32_t bcIndex() { return _bcIndex; }
virtual int32_t currentByteCodeIndex() { return _bcIndex; } // override from IlGenerator

/* @brief after calling this, all IL nodes created will have this BytecodeBuilder's _bcIndex */
void SetCurrentIlGenerator();

/* The name for this BytecodeBuilder. This can be very helpful for debug output */
char *name() { return _name; }

virtual uint32_t countBlocks();

void AddFallThroughBuilder(TR::BytecodeBuilder *ftb);

void AddSuccessorBuilders(uint32_t numBuilders, ...);
void AddSuccessorBuilder(TR::BytecodeBuilder **b) { AddSuccessorBuilders(1, b); }

OMR::VirtualMachineState *initialVMState() { return _initialVMState; }
OMR::VirtualMachineState *vmState() { return _vmState; }
void setVMState(OMR::VirtualMachineState *vmState) { _vmState = vmState; }

void propagateVMState(OMR::VirtualMachineState *fromVMState);

// The following control flow services are meant to hide the similarly named services
// provided by the IlBuilder class. The reason these implementations exist is to
// automatically manage the propagation of virtual machine states between bytecode
// builders. By using these services, and AddFallthroughBuilder(), users do not have
// to do anything to propagate VM states; it's all just taken care of under the covers.
void Goto(TR::BytecodeBuilder **dest);
void Goto(TR::BytecodeBuilder *dest);
void IfCmpEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpEqualZero(TR::BytecodeBuilder **dest, TR::IlValue *c);
void IfCmpEqualZero(TR::BytecodeBuilder *dest, TR::IlValue *c);
void IfCmpNotEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpNotEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpNotEqualZero(TR::BytecodeBuilder **dest, TR::IlValue *c);
void IfCmpNotEqualZero(TR::BytecodeBuilder *dest, TR::IlValue *c);
void IfCmpLessThan(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpLessThan(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedLessThan(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedLessThan(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpLessOrEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpLessOrEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedLessOrEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedLessOrEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpGreaterThan(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpGreaterThan(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedGreaterThan(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedGreaterThan(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpGreaterOrEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpGreaterOrEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedGreaterOrEqual(TR::BytecodeBuilder **dest, TR::IlValue *v1, TR::IlValue *v2);
void IfCmpUnsignedGreaterOrEqual(TR::BytecodeBuilder *dest, TR::IlValue *v1, TR::IlValue *v2);

protected:
TR::BytecodeBuilder * _fallThroughBuilder;
List<TR::BytecodeBuilder> * _successorBuilders;
int32_t _bcIndex;
char * _name;
OMR::VirtualMachineState * _initialVMState;
OMR::VirtualMachineState * _vmState;

virtual void appendBlock(TR::Block *block = 0, bool addEdge=true);
void addAllSuccessorBuildersToWorklist();
bool connectTrees();
virtual void setHandlerInfo(uint32_t catchType);
void transferVMState(TR::BytecodeBuilder **b);
};

} // namespace OMR


#if defined(PUT_OMR_BYTECODEBUILDER_INTO_TR)
#include "ilgen/OMRBytecodeBuilder.hpp"

namespace TR
{
Expand All @@ -138,6 +40,4 @@ namespace TR

} // namespace TR

#endif // defined(PUT_OMR_BYTECODEBUILDER_INTO_TR)

#endif // !defined(OMR_ILBUILDER_INCL)
#endif // !defined(TR_BYTECODEBUILDER_INCL)
17 changes: 10 additions & 7 deletions compiler/ilgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@

compiler_library(ilgen
${CMAKE_CURRENT_LIST_DIR}/IlGenRequest.cpp
${CMAKE_CURRENT_LIST_DIR}/IlBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/IlValue.cpp
${CMAKE_CURRENT_LIST_DIR}/IlInjector.cpp
${CMAKE_CURRENT_LIST_DIR}/MethodBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/BytecodeBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/TypeDictionary.cpp
${CMAKE_CURRENT_LIST_DIR}/ThunkBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/VirtualMachineOperandStack.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRBytecodeBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRIlBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRIlType.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRIlValue.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRMethodBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRThunkBuilder.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRTypeDictionary.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRVirtualMachineOperandArray.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRVirtualMachineOperandStack.cpp
${CMAKE_CURRENT_LIST_DIR}/OMRVirtualMachineState.cpp
)
Loading

0 comments on commit 62ce390

Please sign in to comment.