Skip to content

Commit

Permalink
Merge pull request #6608 from knn-k/aarch64_binEnc1
Browse files Browse the repository at this point in the history
AArch64: Remove redundant assignments in generateBinaryEncoding()
  • Loading branch information
0xdaryl committed Jul 15, 2022
2 parents 29756eb + 6c3d56e commit d396e45
Showing 1 changed file with 33 additions and 66 deletions.
99 changes: 33 additions & 66 deletions compiler/aarch64/codegen/ARM64BinaryEncoding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
uint8_t *OMR::ARM64::Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
cursor += ARM64_INSTRUCTION_LENGTH;
setBinaryLength(ARM64_INSTRUCTION_LENGTH);
setBinaryEncoding(instructionStart);
Expand All @@ -58,8 +57,7 @@ int32_t OMR::ARM64::Instruction::estimateBinaryLength(int32_t currentEstimate)
uint8_t *TR::ARM64ImmInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertImmediateField(toARM64Cursor(cursor));
cursor += ARM64_INSTRUCTION_LENGTH;
setBinaryLength(ARM64_INSTRUCTION_LENGTH);
Expand All @@ -70,8 +68,7 @@ uint8_t *TR::ARM64ImmInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64RelocatableImmInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertImmediateField((uintptr_t *)cursor);

if (needsAOTRelocation())
Expand Down Expand Up @@ -117,8 +114,7 @@ int32_t TR::ARM64RelocatableImmInstruction::estimateBinaryLength(int32_t current
uint8_t *TR::ARM64ImmSymInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);

if (getOpCodeValue() == TR::InstOpCode::bl)
{
Expand Down Expand Up @@ -268,8 +264,7 @@ int32_t TR::ARM64LabelInstruction::estimateBinaryLength(int32_t currentEstimate)
uint8_t *TR::ARM64ConditionalBranchInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertConditionCodeField(toARM64Cursor(cursor));

TR::LabelSymbol *label = getLabelSymbol();
Expand Down Expand Up @@ -300,8 +295,7 @@ int32_t TR::ARM64ConditionalBranchInstruction::estimateBinaryLength(int32_t curr
uint8_t *TR::ARM64CompareBranchInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertSource1Register(toARM64Cursor(cursor));

TR::LabelSymbol *label = getLabelSymbol();
Expand All @@ -326,8 +320,7 @@ uint8_t *TR::ARM64CompareBranchInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64TestBitBranchInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertSource1Register(toARM64Cursor(cursor));
insertBitposField(toARM64Cursor(cursor));

Expand All @@ -354,8 +347,7 @@ uint8_t *TR::ARM64TestBitBranchInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64RegBranchInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
cursor += ARM64_INSTRUCTION_LENGTH;
setBinaryLength(ARM64_INSTRUCTION_LENGTH);
Expand Down Expand Up @@ -428,8 +420,7 @@ int32_t TR::ARM64AdminInstruction::estimateBinaryLength(int32_t currentEstimate)
uint8_t *TR::ARM64Trg1Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
cursor += ARM64_INSTRUCTION_LENGTH;
setBinaryLength(ARM64_INSTRUCTION_LENGTH);
Expand All @@ -440,8 +431,7 @@ uint8_t *TR::ARM64Trg1Instruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1CondInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertZeroRegister(toARM64Cursor(cursor));
insertConditionCodeField(toARM64Cursor(cursor));
Expand All @@ -454,8 +444,7 @@ uint8_t *TR::ARM64Trg1CondInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1ImmInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertImmediateField(toARM64Cursor(cursor));
cursor += ARM64_INSTRUCTION_LENGTH;
Expand All @@ -467,8 +456,7 @@ uint8_t *TR::ARM64Trg1ImmInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1ImmShiftedInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertImmediateField(toARM64Cursor(cursor));
insertShift(toARM64Cursor(cursor));
Expand All @@ -481,8 +469,7 @@ uint8_t *TR::ARM64Trg1ImmShiftedInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1ImmSymInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));

auto sym = getSymbol();
Expand Down Expand Up @@ -518,8 +505,7 @@ uint8_t *TR::ARM64Trg1ImmSymInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1Src1Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
cursor += ARM64_INSTRUCTION_LENGTH;
Expand All @@ -531,8 +517,7 @@ uint8_t *TR::ARM64Trg1Src1Instruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1ZeroSrc1Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertZeroRegister(toARM64Cursor(cursor));
Expand All @@ -545,8 +530,7 @@ uint8_t *TR::ARM64Trg1ZeroSrc1Instruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1ZeroImmInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertZeroRegister(toARM64Cursor(cursor));
insertImmediateField(toARM64Cursor(cursor));
Expand All @@ -560,8 +544,7 @@ uint8_t *TR::ARM64Trg1ZeroImmInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1Src1ImmInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertImmediateField(toARM64Cursor(cursor));
Expand All @@ -575,8 +558,7 @@ uint8_t *TR::ARM64Trg1Src1ImmInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64ZeroSrc1ImmInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertZeroRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertImmediateField(toARM64Cursor(cursor));
Expand Down Expand Up @@ -613,8 +595,7 @@ uint8_t *TR::ARM64ZeroSrc1ImmInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1Src2Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
Expand All @@ -627,8 +608,7 @@ uint8_t *TR::ARM64Trg1Src2Instruction::generateBinaryEncoding()
uint8_t *TR::ARM64CondTrg1Src2Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
Expand All @@ -642,8 +622,7 @@ uint8_t *TR::ARM64CondTrg1Src2Instruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1Src2ShiftedInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
Expand All @@ -657,8 +636,7 @@ uint8_t *TR::ARM64Trg1Src2ShiftedInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1Src2ExtendedInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
Expand Down Expand Up @@ -709,8 +687,7 @@ uint8_t *TR::ARM64Trg1Src2IndexedElementInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1Src2ZeroInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
Expand All @@ -724,8 +701,7 @@ uint8_t *TR::ARM64Trg1Src2ZeroInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64Trg1Src3Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
Expand All @@ -744,8 +720,7 @@ TR::Instruction *TR::ARM64Trg1MemInstruction::expandInstruction()
uint8_t *TR::ARM64Trg1MemInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg());
setBinaryLength(cursor - instructionStart);
Expand All @@ -768,8 +743,7 @@ TR::Instruction *TR::ARM64MemInstruction::expandInstruction()
uint8_t *TR::ARM64MemInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg());
setBinaryLength(cursor - instructionStart);
setBinaryEncoding(instructionStart);
Expand All @@ -786,8 +760,7 @@ int32_t TR::ARM64MemInstruction::estimateBinaryLength(int32_t currentEstimate)
uint8_t *TR::ARM64MemImmInstruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertImmediateField(toARM64Cursor(cursor));
cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg());
setBinaryLength(cursor - instructionStart);
Expand All @@ -799,8 +772,7 @@ uint8_t *TR::ARM64MemImmInstruction::generateBinaryEncoding()
uint8_t *TR::ARM64MemSrc1Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertSource1Register(toARM64Cursor(cursor));
cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg());
setBinaryLength(cursor - instructionStart);
Expand All @@ -818,8 +790,7 @@ int32_t TR::ARM64MemSrc1Instruction::estimateBinaryLength(int32_t currentEstimat
uint8_t *TR::ARM64MemSrc2Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg());
Expand All @@ -838,8 +809,7 @@ int32_t TR::ARM64MemSrc2Instruction::estimateBinaryLength(int32_t currentEstimat
uint8_t *TR::ARM64Trg1MemSrc1Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertTargetRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
cursor = getMemoryReference()->generateBinaryEncoding(this, cursor, cg());
Expand All @@ -858,8 +828,7 @@ int32_t TR::ARM64Trg1MemSrc1Instruction::estimateBinaryLength(int32_t currentEst
uint8_t *TR::ARM64Src1Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertSource1Register(toARM64Cursor(cursor));
cursor += ARM64_INSTRUCTION_LENGTH;
setBinaryLength(ARM64_INSTRUCTION_LENGTH);
Expand All @@ -870,8 +839,7 @@ uint8_t *TR::ARM64Src1Instruction::generateBinaryEncoding()
uint8_t *TR::ARM64Src2Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
cursor += ARM64_INSTRUCTION_LENGTH;
Expand All @@ -883,8 +851,7 @@ uint8_t *TR::ARM64Src2Instruction::generateBinaryEncoding()
uint8_t *TR::ARM64ZeroSrc2Instruction::generateBinaryEncoding()
{
uint8_t *instructionStart = cg()->getBinaryBufferCursor();
uint8_t *cursor = instructionStart;
cursor = getOpCode().copyBinaryToBuffer(instructionStart);
uint8_t *cursor = getOpCode().copyBinaryToBuffer(instructionStart);
insertZeroRegister(toARM64Cursor(cursor));
insertSource1Register(toARM64Cursor(cursor));
insertSource2Register(toARM64Cursor(cursor));
Expand Down

0 comments on commit d396e45

Please sign in to comment.