From 88f7aecdecf5a4e2d4f4f243aa2517129a191b25 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 20 Jul 2023 23:34:29 +0100 Subject: Change local-copy to more general local-store --- .../org/shedlang/compiler/patio/PatioCodeGenContext.java | 4 ++-- .../org/shedlang/compiler/patio/ast/PatioSerializer.java | 8 ++++---- .../compiler/patio/ast/instructions/PatioInstruction.java | 2 +- .../compiler/patio/ast/instructions/PatioLocalCopy.java | 14 -------------- .../compiler/patio/ast/instructions/PatioLocalStore.java | 15 +++++++++++++++ 5 files changed, 22 insertions(+), 21 deletions(-) delete mode 100644 src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java create mode 100644 src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalStore.java (limited to 'src/main/java') diff --git a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java index f85d97a1..aca3f71c 100644 --- a/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java +++ b/src/main/java/org/shedlang/compiler/patio/PatioCodeGenContext.java @@ -7,7 +7,7 @@ import org.pcollections.PVector; import org.shedlang.compiler.backends.llvm.NameAllocator; import org.shedlang.compiler.patio.ast.*; import org.shedlang.compiler.patio.ast.instructions.PatioInstruction; -import org.shedlang.compiler.patio.ast.instructions.PatioLocalCopy; +import org.shedlang.compiler.patio.ast.instructions.PatioLocalStore; import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; import org.shedlang.compiler.patio.ast.types.PatioDataLayout; import org.shedlang.compiler.patio.ast.types.PatioType; @@ -244,7 +244,7 @@ public record PatioCodeGenContext( var result = this.functionContext.temporaryPop(); return new PatioCodeGenContext(this.compilationUnitContext, result.context) - .addInstruction(new PatioLocalCopy(target, result.value, source)); + .addInstruction(new PatioLocalStore(target, result.value, source)); } public PatioCodeGenContext temporaryPush(PatioLocalRef value) { diff --git a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java index 8edf1464..bfdbac89 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/PatioSerializer.java @@ -174,11 +174,11 @@ public class PatioSerializer { operandToTree(intToDataPtr.value()) ); - case PatioLocalCopy localCopy -> + case PatioLocalStore localStore -> treeList( - treeIdentifier("local-copy"), - operandToTree(localCopy.target()), - operandToTree(localCopy.value()) + treeIdentifier("local-store"), + operandToTree(localStore.target()), + operandToTree(localStore.value()) ); case PatioMemoryLoad memoryLoad -> diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java index 88b47962..c18afbd1 100644 --- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java +++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioInstruction.java @@ -2,6 +2,6 @@ package org.shedlang.compiler.patio.ast.instructions; import org.shedlang.compiler.sources.Source; -public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDataPtrGet, PatioDataPtrToInt, PatioFunctionPointerGet, PatioIf, PatioIntAdd, PatioIntGet, PatioIntToDataPtr, PatioLocalCopy, PatioMemoryLoad, PatioMemoryStore, PatioReturn { +public sealed interface PatioInstruction permits PatioAlloc, PatioCallPointer, PatioDataPtrGet, PatioDataPtrToInt, PatioFunctionPointerGet, PatioIf, PatioIntAdd, PatioIntGet, PatioIntToDataPtr, PatioLocalStore, PatioMemoryLoad, PatioMemoryStore, PatioReturn { Source source(); } diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java deleted file mode 100644 index 34d5bbaa..00000000 --- a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalCopy.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.shedlang.compiler.patio.ast.instructions; - -import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; -import org.shedlang.compiler.sources.Source; - -/** - * Copy the given value into the target local. - */ -public record PatioLocalCopy( - PatioLocalRef target, - PatioLocalRef value, - Source source -) implements PatioInstruction { -} diff --git a/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalStore.java b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalStore.java new file mode 100644 index 00000000..22939cd5 --- /dev/null +++ b/src/main/java/org/shedlang/compiler/patio/ast/instructions/PatioLocalStore.java @@ -0,0 +1,15 @@ +package org.shedlang.compiler.patio.ast.instructions; + +import org.shedlang.compiler.patio.ast.operands.PatioLocalRef; +import org.shedlang.compiler.patio.ast.operands.PatioOperand; +import org.shedlang.compiler.sources.Source; + +/** + * Store the given value in the target local. + */ +public record PatioLocalStore( + PatioLocalRef target, + PatioOperand value, + Source source +) implements PatioInstruction { +} -- cgit v1.2.3