Skip to content

Commit

Permalink
Rename AssignPop to AssignNoPush (#2058)
Browse files Browse the repository at this point in the history
Co-authored-by: ike709 <[email protected]>
  • Loading branch information
ike709 and ike709 authored Oct 24, 2024
1 parent 2d93944 commit b974c59
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion DMCompiler/Bytecode/DreamProcOpcode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public enum DreamProcOpcode : byte {
// Peephole optimization opcodes
//0x84
[OpcodeMetadata(-1, OpcodeArgType.Reference)]
AssignPop = 0x85,
AssignNoPush = 0x85,
[OpcodeMetadata(1, OpcodeArgType.Reference, OpcodeArgType.String)]
PushRefAndDereferenceField = 0x86,
[OpcodeMetadata(true, 0, OpcodeArgType.Int)]
Expand Down
10 changes: 5 additions & 5 deletions DMCompiler/Optimizer/PeepholeOptimizations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ namespace DMCompiler.Optimizer;

// Assign [ref]
// Pop
// -> AssignPop [ref]
internal sealed class AssignPop : IPeepholeOptimization {
// -> AssignNoPush [ref]
internal sealed class AssignNoPush : IPeepholeOptimization {
public ReadOnlySpan<DreamProcOpcode> GetOpcodes() {
return [
DreamProcOpcode.Assign,
Expand All @@ -22,18 +22,18 @@ public void Apply(List<IAnnotatedBytecode> input, int index) {
AnnotatedBytecodeReference assignTarget = firstInstruction.GetArg<AnnotatedBytecodeReference>(0);

input.RemoveRange(index, 2);
input.Insert(index, new AnnotatedBytecodeInstruction(DreamProcOpcode.AssignPop, [assignTarget]));
input.Insert(index, new AnnotatedBytecodeInstruction(DreamProcOpcode.AssignNoPush, [assignTarget]));
}
}

// PushNull
// AssignPop [ref]
// AssignNoPush [ref]
// -> AssignNull [ref]
internal sealed class AssignNull : IPeepholeOptimization {
public ReadOnlySpan<DreamProcOpcode> GetOpcodes() {
return [
DreamProcOpcode.PushNull,
DreamProcOpcode.AssignPop
DreamProcOpcode.AssignNoPush
];
}

Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Procs/DMOpcodeHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2877,7 +2877,7 @@ public static ProcStatus NullRef(DMProcState state) {
return ProcStatus.Continue;
}

public static ProcStatus AssignPop(DMProcState state) {
public static ProcStatus AssignNoPush(DMProcState state) {
DreamReference reference = state.ReadReference();
DreamValue value = state.Pop();

Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Procs/DMProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ public sealed class DMProcState : ProcState {
{DreamProcOpcode.Rgb, DMOpcodeHandlers.Rgb},
// Peephole optimizer opcode handlers
{DreamProcOpcode.NullRef, DMOpcodeHandlers.NullRef},
{DreamProcOpcode.AssignPop, DMOpcodeHandlers.AssignPop},
{DreamProcOpcode.AssignNoPush, DMOpcodeHandlers.AssignNoPush},
{DreamProcOpcode.PushRefAndDereferenceField, DMOpcodeHandlers.PushReferenceAndDereferenceField},
{DreamProcOpcode.PushNRefs, DMOpcodeHandlers.PushNRefs},
{DreamProcOpcode.PushNFloats, DMOpcodeHandlers.PushNFloats},
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Procs/ProcDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public ITuple DecodeInstruction() {
case DreamProcOpcode.OutputReference:
case DreamProcOpcode.PushReferenceValue:
case DreamProcOpcode.PopReference:
case DreamProcOpcode.AssignPop:
case DreamProcOpcode.AssignNoPush:
case DreamProcOpcode.ReturnReferenceValue:
return (opcode, ReadReference());

Expand Down

0 comments on commit b974c59

Please sign in to comment.