Skip to content

Commit

Permalink
Move CodeGenerator object into base of OMRLinkage
Browse files Browse the repository at this point in the history
Each architecture requires and caches the CodeGenerator object in its
own specialization.  Cache the object in the base class to share
functionality.

Signed-off-by: Daryl Maier <[email protected]>
  • Loading branch information
0xdaryl committed Apr 15, 2019
1 parent de6fc95 commit 51bf2be
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 32 deletions.
11 changes: 2 additions & 9 deletions compiler/aarch64/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2018 IBM Corp. and others
* Copyright (c) 2018, 2019 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 Down Expand Up @@ -272,15 +272,11 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
{
public:

/**
* @brief Constructor
*/
Linkage () : OMR::Linkage() {}
/**
* @brief Constructor
* @param[in] cg : CodeGenerator
*/
Linkage (TR::CodeGenerator *cg) : _cg(cg) {}
Linkage (TR::CodeGenerator *cg) : OMR::Linkage(cg) {}

/**
* @brief Parameter has to be on stack or not
Expand Down Expand Up @@ -426,9 +422,6 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
*/
TR_StackMemory trStackMemory();

protected:

TR::CodeGenerator*_cg;
};
} // ARM64
} // TR
Expand Down
8 changes: 2 additions & 6 deletions compiler/arm/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2016 IBM Corp. and others
* Copyright (c) 2000, 2019 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 Down Expand Up @@ -294,7 +294,7 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
{
public:

Linkage (TR::CodeGenerator *cg) : _cg(cg) {}
Linkage (TR::CodeGenerator *cg) : OMR::Linkage(cg) {}

virtual bool hasToBeOnStack(TR::ParameterSymbol *parm);
virtual void mapStack(TR::ResolvedMethodSymbol *method);
Expand Down Expand Up @@ -351,10 +351,6 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
TR::Register* &vftReg,
TR_LinkageConventions conventions,
bool isVirtualOrJNI);

protected:

TR::CodeGenerator*_cg;
};
}
}
Expand Down
7 changes: 5 additions & 2 deletions compiler/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace OMR { typedef OMR::Linkage LinkageConnector; }

class TR_BitVector;
namespace TR { class AutomaticSymbol; }
namespace TR { class Compilation; }
namespace TR { class CodeGenerator; }
namespace TR { class Linkage; }
namespace TR { class Instruction; }
namespace TR { class Node; }
Expand All @@ -63,7 +63,7 @@ class OMR_EXTENSIBLE Linkage

TR_ALLOC(TR_Memory::Linkage)

Linkage() { }
Linkage(TR::CodeGenerator *cg) : _cg(cg) { }

virtual void createPrologue(TR::Instruction *cursor) = 0;
virtual void createEpilogue(TR::Instruction *cursor) = 0;
Expand All @@ -87,6 +87,9 @@ class OMR_EXTENSIBLE Linkage

virtual TR_RegisterKinds argumentRegisterKind(TR::Node *argumentNode);

protected:

TR::CodeGenerator *_cg;
};
}

Expand Down
8 changes: 1 addition & 7 deletions compiler/p/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,7 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
{
public:

Linkage () : OMR::Linkage() {}

Linkage (TR::CodeGenerator *cg) : _cg(cg) {}
Linkage (TR::CodeGenerator *cg) : OMR::Linkage(cg) {}

virtual bool hasToBeOnStack(TR::ParameterSymbol *parm);
virtual void mapStack(TR::ResolvedMethodSymbol *method);
Expand Down Expand Up @@ -445,10 +443,6 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
virtual uintptr_t calculateParameterRegisterOffset(uintptr_t o, TR::ParameterSymbol& p) { return o; }

TR_ReturnInfo getReturnInfoFromReturnType(TR::DataType);

protected:

TR::CodeGenerator*_cg;
};
}
}
Expand Down
3 changes: 1 addition & 2 deletions compiler/x/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage

protected:

Linkage(TR::CodeGenerator *cg) : _cg(cg), _minimumFirstInstructionSize(0)
Linkage(TR::CodeGenerator *cg) : OMR::Linkage(cg), _minimumFirstInstructionSize(0)
{
// Initialize the movOp table based on preferred load instructions for this target.
//
Expand Down Expand Up @@ -443,7 +443,6 @@ class OMR_EXTENSIBLE Linkage : public OMR::Linkage
private:

static TR_X86OpCodes _movOpcodes[NumMovOperandTypes][NumMovDataTypes];
TR::CodeGenerator* _cg;
uint8_t _minimumFirstInstructionSize;

};
Expand Down
8 changes: 4 additions & 4 deletions compiler/z/codegen/OMRLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ static int32_t getFirstMaskedBit(int16_t mask); ///< formward reference
////////////////////////////////////////////////////////////////////////////////

OMR::Z::Linkage::Linkage(TR::CodeGenerator * codeGen)
: OMR::Linkage(),
_codeGen(codeGen), _explicitLinkageType(TR_S390LinkageDefault), _linkageType(TR_None), _stackSizeCheckNeeded(true), _raContextSaveNeeded(true),
: OMR::Linkage(codeGen),
_explicitLinkageType(TR_S390LinkageDefault), _linkageType(TR_None), _stackSizeCheckNeeded(true), _raContextSaveNeeded(true),
_integerReturnRegister(TR::RealRegister::NoReg),
_floatReturnRegister(TR::RealRegister::NoReg),
_doubleReturnRegister(TR::RealRegister::NoReg),
Expand Down Expand Up @@ -141,8 +141,8 @@ OMR::Z::Linkage::Linkage(TR::CodeGenerator * codeGen)
* Even though this method is common, its implementation is machine-specific.
*/
OMR::Z::Linkage::Linkage(TR::CodeGenerator * codeGen,TR_S390LinkageConventions elc, TR_LinkageConventions lc)
: OMR::Linkage(),
_codeGen(codeGen), _explicitLinkageType(elc), _linkageType(lc), _stackSizeCheckNeeded(true), _raContextSaveNeeded(true),
: OMR::Linkage(codeGen),
_explicitLinkageType(elc), _linkageType(lc), _stackSizeCheckNeeded(true), _raContextSaveNeeded(true),
_integerReturnRegister(TR::RealRegister::NoReg),
_floatReturnRegister(TR::RealRegister::NoReg),
_doubleReturnRegister(TR::RealRegister::NoReg),
Expand Down
3 changes: 1 addition & 2 deletions compiler/z/codegen/OMRLinkage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ enum TR_DispatchType
virtual int32_t setupLiteralPoolRegister(TR::Snippet *firstSnippet) { return -1; }

// Just for convenience
TR::CodeGenerator * cg() { return _codeGen; }
TR::CodeGenerator * cg() { return _cg; }
TR::Compilation * comp();
TR_FrontEnd * fe();

Expand Down Expand Up @@ -631,7 +631,6 @@ enum TR_DispatchType

enum FrameType _frameType;

TR::CodeGenerator * _codeGen;
TR::Instruction * _lastPrologueInstr;
TR::Instruction * _firstPrologueInstr;
};
Expand Down

0 comments on commit 51bf2be

Please sign in to comment.