Skip to content

Commit

Permalink
Merge pull request #6990 from dylanjtuttle/renameCodeGeneratorVariables
Browse files Browse the repository at this point in the history
Rename code generator variables
  • Loading branch information
0xdaryl authored Jun 6, 2023
2 parents de1b809 + 771b334 commit d573db5
Show file tree
Hide file tree
Showing 23 changed files with 407 additions and 407 deletions.
42 changes: 21 additions & 21 deletions compiler/aarch64/codegen/ARM64SystemLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,18 +517,18 @@ TR::ARM64SystemLinkage::createPrologue(TR::Instruction *cursor)
void
TR::ARM64SystemLinkage::createPrologue(TR::Instruction *cursor, List<TR::ParameterSymbol> &parmList)
{
TR::CodeGenerator *codeGen = cg();
TR::Machine *machine = codeGen->machine();
TR::CodeGenerator *cg = this->cg();
TR::Machine *machine = cg->machine();
TR::ResolvedMethodSymbol *bodySymbol = comp()->getJittedMethodSymbol();
const TR::ARM64LinkageProperties& properties = getProperties();
TR::RealRegister *sp = machine->getRealRegister(properties.getStackPointerRegister());
TR::Node *firstNode = comp()->getStartTree()->getNode();

// allocate stack space
uint32_t frameSize = (uint32_t)codeGen->getFrameSizeInBytes();
uint32_t frameSize = (uint32_t)cg->getFrameSizeInBytes();
if (constantIsUnsignedImm12(frameSize))
{
cursor = generateTrg1Src1ImmInstruction(codeGen, TR::InstOpCode::subimmx, firstNode, sp, sp, frameSize, cursor);
cursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::subimmx, firstNode, sp, sp, frameSize, cursor);
}
else
{
Expand All @@ -538,8 +538,8 @@ TR::ARM64SystemLinkage::createPrologue(TR::Instruction *cursor, List<TR::Paramet
// save link register (x30)
if (machine->getLinkRegisterKilled())
{
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(codeGen, sp, 0);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::strimmx, firstNode, stackSlot, machine->getRealRegister(TR::RealRegister::x30), cursor);
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(cg, sp, 0);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::strimmx, firstNode, stackSlot, machine->getRealRegister(TR::RealRegister::x30), cursor);
}

// save callee-saved registers
Expand All @@ -549,8 +549,8 @@ TR::ARM64SystemLinkage::createPrologue(TR::Instruction *cursor, List<TR::Paramet
TR::RealRegister *rr = machine->getRealRegister((TR::RealRegister::RegNum)r);
if (rr->getHasBeenAssignedInMethod())
{
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(codeGen, sp, offset);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::strimmx, firstNode, stackSlot, rr, cursor);
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(cg, sp, offset);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::strimmx, firstNode, stackSlot, rr, cursor);
offset += 8;
}
}
Expand All @@ -559,8 +559,8 @@ TR::ARM64SystemLinkage::createPrologue(TR::Instruction *cursor, List<TR::Paramet
TR::RealRegister *rr = machine->getRealRegister((TR::RealRegister::RegNum)r);
if (rr->getHasBeenAssignedInMethod())
{
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(codeGen, sp, offset);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::vstrimmq, firstNode, stackSlot, rr, cursor);
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(cg, sp, offset);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::vstrimmq, firstNode, stackSlot, rr, cursor);
offset += 16;
}
}
Expand All @@ -571,9 +571,9 @@ TR::ARM64SystemLinkage::createPrologue(TR::Instruction *cursor, List<TR::Paramet
void
TR::ARM64SystemLinkage::createEpilogue(TR::Instruction *cursor)
{
TR::CodeGenerator *codeGen = cg();
TR::CodeGenerator *cg = this->cg();
const TR::ARM64LinkageProperties& properties = getProperties();
TR::Machine *machine = codeGen->machine();
TR::Machine *machine = cg->machine();
TR::Node *lastNode = cursor->getNode();
TR::ResolvedMethodSymbol *bodySymbol = comp()->getJittedMethodSymbol();
TR::RealRegister *sp = machine->getRealRegister(properties.getStackPointerRegister());
Expand All @@ -585,8 +585,8 @@ TR::ARM64SystemLinkage::createEpilogue(TR::Instruction *cursor)
TR::RealRegister *rr = machine->getRealRegister((TR::RealRegister::RegNum)r);
if (rr->getHasBeenAssignedInMethod())
{
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(codeGen, sp, offset);
cursor = generateTrg1MemInstruction(cg(), TR::InstOpCode::ldrimmx, lastNode, rr, stackSlot, cursor);
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(cg, sp, offset);
cursor = generateTrg1MemInstruction(this->cg(), TR::InstOpCode::ldrimmx, lastNode, rr, stackSlot, cursor);
offset += 8;
}
}
Expand All @@ -595,8 +595,8 @@ TR::ARM64SystemLinkage::createEpilogue(TR::Instruction *cursor)
TR::RealRegister *rr = machine->getRealRegister((TR::RealRegister::RegNum)r);
if (rr->getHasBeenAssignedInMethod())
{
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(codeGen, sp, offset);
cursor = generateTrg1MemInstruction(cg(), TR::InstOpCode::vldrimmq, lastNode, rr, stackSlot, cursor);
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(cg, sp, offset);
cursor = generateTrg1MemInstruction(this->cg(), TR::InstOpCode::vldrimmq, lastNode, rr, stackSlot, cursor);
offset += 16;
}
}
Expand All @@ -605,23 +605,23 @@ TR::ARM64SystemLinkage::createEpilogue(TR::Instruction *cursor)
TR::RealRegister *lr = machine->getRealRegister(TR::RealRegister::lr);
if (machine->getLinkRegisterKilled())
{
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(codeGen, sp, 0);
cursor = generateTrg1MemInstruction(cg(), TR::InstOpCode::ldrimmx, lastNode, lr, stackSlot, cursor);
TR::MemoryReference *stackSlot = TR::MemoryReference::createWithDisplacement(cg, sp, 0);
cursor = generateTrg1MemInstruction(this->cg(), TR::InstOpCode::ldrimmx, lastNode, lr, stackSlot, cursor);
}

// remove space for preserved registers
uint32_t frameSize = codeGen->getFrameSizeInBytes();
uint32_t frameSize = cg->getFrameSizeInBytes();
if (constantIsUnsignedImm12(frameSize))
{
cursor = generateTrg1Src1ImmInstruction(codeGen, TR::InstOpCode::addimmx, lastNode, sp, sp, frameSize, cursor);
cursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::addimmx, lastNode, sp, sp, frameSize, cursor);
}
else
{
TR_UNIMPLEMENTED();
}

// return
cursor = generateRegBranchInstruction(codeGen, TR::InstOpCode::ret, lastNode, lr, cursor);
cursor = generateRegBranchInstruction(cg, TR::InstOpCode::ret, lastNode, lr, cursor);
}


Expand Down
48 changes: 24 additions & 24 deletions compiler/arm/codegen/ARMSystemLinkage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ TR::ARMLinkageProperties& TR::ARMSystemLinkage::getProperties()

void TR::ARMSystemLinkage::createPrologue(TR::Instruction *cursor)
{
TR::CodeGenerator *codeGen = cg();
TR::CodeGenerator *cg = this->cg();
const TR::ARMLinkageProperties& properties = getProperties();
TR::Machine *machine = codeGen->machine();
TR::Machine *machine = cg->machine();
TR::ResolvedMethodSymbol* bodySymbol = comp()->getJittedMethodSymbol();
TR::Node *firstNode = comp()->getStartTree()->getNode();
TR::RealRegister *stackPtr = machine->getRealRegister(properties.getStackPointerRegister());
Expand All @@ -467,12 +467,12 @@ void TR::ARMSystemLinkage::createPrologue(TR::Instruction *cursor)
//
if (comp()->getOption(TR_EntryBreakPoints))
{
cursor = new (trHeapMemory()) TR::Instruction(cursor, TR::InstOpCode::bad, firstNode, cg());
cursor = new (trHeapMemory()) TR::Instruction(cursor, TR::InstOpCode::bad, firstNode, this->cg());
}

// allocate stack space
auto frameSize = codeGen->getFrameSizeInBytes();
cursor = generateTrg1Src1ImmInstruction(codeGen, TR::InstOpCode::sub, firstNode, stackPtr, stackPtr, frameSize, 0, cursor);
auto frameSize = cg->getFrameSizeInBytes();
cursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::sub, firstNode, stackPtr, stackPtr, frameSize, 0, cursor);

// spill argument registers
auto nextIntArgReg = 0;
Expand All @@ -482,7 +482,7 @@ void TR::ARMSystemLinkage::createPrologue(TR::Instruction *cursor)
parameter!=NULL && (nextIntArgReg < getProperties().getNumIntArgRegs() || nextFltArgReg < getProperties().getNumFloatArgRegs());
parameter=parameterIterator.getNext())
{
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, parameter->getParameterOffset(), codeGen);
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, parameter->getParameterOffset(), cg);
switch (parameter->getDataType())
{
case TR::Int8:
Expand All @@ -491,7 +491,7 @@ void TR::ARMSystemLinkage::createPrologue(TR::Instruction *cursor)
case TR::Address:
if (nextIntArgReg < getProperties().getNumIntArgRegs())
{
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::gr0 + nextIntArgReg)), cursor);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::gr0 + nextIntArgReg)), cursor);
nextIntArgReg++;
}
else
Expand All @@ -503,9 +503,9 @@ void TR::ARMSystemLinkage::createPrologue(TR::Instruction *cursor)
nextIntArgReg += nextIntArgReg & 0x1; // round to next even number
if (nextIntArgReg + 1 < getProperties().getNumIntArgRegs())
{
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::gr0 + nextIntArgReg)), cursor);
stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, parameter->getParameterOffset() + 4, codeGen);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::gr0 + nextIntArgReg + 1)), cursor);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::gr0 + nextIntArgReg)), cursor);
stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, parameter->getParameterOffset() + 4, cg);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::gr0 + nextIntArgReg + 1)), cursor);
nextIntArgReg += 2;
}
else
Expand All @@ -519,7 +519,7 @@ void TR::ARMSystemLinkage::createPrologue(TR::Instruction *cursor)
case TR::Double:
if (nextFltArgReg < getProperties().getNumFloatArgRegs())
{
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::fstd, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::fp0 + nextFltArgReg)), cursor);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::fstd, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)(TR::RealRegister::fp0 + nextFltArgReg)), cursor);
nextFltArgReg += 1;
}
else
Expand All @@ -535,43 +535,43 @@ void TR::ARMSystemLinkage::createPrologue(TR::Instruction *cursor)
// save all preserved registers
for (int r = TR::RealRegister::gr4; r <= TR::RealRegister::gr11; ++r)
{
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, (TR::RealRegister::gr11 - r + 1)*4 + bodySymbol->getLocalMappingCursor(), codeGen);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)r), cursor);
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, (TR::RealRegister::gr11 - r + 1)*4 + bodySymbol->getLocalMappingCursor(), cg);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)r), cursor);
}

// save link register (r14)
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, bodySymbol->getLocalMappingCursor(), codeGen);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister(TR::RealRegister::gr14), cursor);
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, bodySymbol->getLocalMappingCursor(), cg);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::str, firstNode, stackSlot, machine->getRealRegister(TR::RealRegister::gr14), cursor);
}

void TR::ARMSystemLinkage::createEpilogue(TR::Instruction *cursor)
{
TR::CodeGenerator *codeGen = cg();
TR::CodeGenerator *cg = this->cg();
const TR::ARMLinkageProperties& properties = getProperties();
TR::Machine *machine = codeGen->machine();
TR::Machine *machine = cg->machine();
TR::Node *lastNode = cursor->getNode();
TR::ResolvedMethodSymbol* bodySymbol = comp()->getJittedMethodSymbol();
TR::RealRegister *stackPtr = machine->getRealRegister(properties.getStackPointerRegister());

// restore link register (r14)
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, bodySymbol->getLocalMappingCursor(), codeGen);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::ldr, lastNode, stackSlot, machine->getRealRegister(TR::RealRegister::gr14), cursor);
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, bodySymbol->getLocalMappingCursor(), cg);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::ldr, lastNode, stackSlot, machine->getRealRegister(TR::RealRegister::gr14), cursor);

// restore all preserved registers
for (int r = TR::RealRegister::gr4; r <= TR::RealRegister::gr11; ++r)
{
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, (TR::RealRegister::gr11 - r + 1)*4 + bodySymbol->getLocalMappingCursor(), codeGen);
cursor = generateMemSrc1Instruction(cg(), TR::InstOpCode::ldr, lastNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)r), cursor);
auto *stackSlot = new (trHeapMemory()) TR::MemoryReference(stackPtr, (TR::RealRegister::gr11 - r + 1)*4 + bodySymbol->getLocalMappingCursor(), cg);
cursor = generateMemSrc1Instruction(this->cg(), TR::InstOpCode::ldr, lastNode, stackSlot, machine->getRealRegister((TR::RealRegister::RegNum)r), cursor);
}

// remove space for preserved registers
auto frameSize = codeGen->getFrameSizeInBytes();
cursor = generateTrg1Src1ImmInstruction(codeGen, TR::InstOpCode::add, lastNode, stackPtr, stackPtr, frameSize, 0, cursor);
auto frameSize = cg->getFrameSizeInBytes();
cursor = generateTrg1Src1ImmInstruction(cg, TR::InstOpCode::add, lastNode, stackPtr, stackPtr, frameSize, 0, cursor);

// return using `mov r15, r14`
TR::RealRegister *gr14 = machine->getRealRegister(TR::RealRegister::gr14);
TR::RealRegister *gr15 = machine->getRealRegister(TR::RealRegister::gr15);
cursor = generateTrg1Src1Instruction(codeGen, TR::InstOpCode::mov, lastNode, gr15, gr14, cursor);
cursor = generateTrg1Src1Instruction(cg, TR::InstOpCode::mov, lastNode, gr15, gr14, cursor);
}

TR::MemoryReference *TR::ARMSystemLinkage::getOutgoingArgumentMemRef(int32_t totalSize,
Expand Down
2 changes: 1 addition & 1 deletion compiler/arm/codegen/ARMSystemLinkage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ARMSystemLinkage : public TR::Linkage

public:

ARMSystemLinkage(TR::CodeGenerator *codeGen);
ARMSystemLinkage(TR::CodeGenerator *cg);

virtual uint32_t getRightToLeft();
virtual void mapStack(TR::ResolvedMethodSymbol *method);
Expand Down
2 changes: 1 addition & 1 deletion compiler/arm/codegen/OMRCodeGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace TR { class Register; }
extern TR::Instruction *armLoadConstant(TR::Node *node,
int32_t value,
TR::Register *targetRegister,
TR::CodeGenerator *codeGen,
TR::CodeGenerator *cg,
TR::Instruction *cursor=NULL);

extern TR::Instruction *loadAddressConstantInSnippet(TR::CodeGenerator *cg,
Expand Down
Loading

0 comments on commit d573db5

Please sign in to comment.