aritmetics

This commit is contained in:
2026-03-24 13:42:34 +00:00
parent 5575c491a1
commit 2bc99cc901
10 changed files with 684 additions and 14 deletions
@@ -232,6 +232,20 @@ public record IRBackendExecutableFunction(
throw new IllegalArgumentException("PUSH_I32 must not carry call metadata");
}
}
case PUSH_BOOL -> {
if (label.isBlank()) {
throw new IllegalArgumentException("PUSH_BOOL requires immediate label payload");
}
if (!targetLabel.isBlank()
|| !calleeCallableName.isBlank()
|| calleeCallableId != null
|| hostCall != null
|| intrinsicCall != null
|| expectedArgSlots != null
|| expectedRetSlots != null) {
throw new IllegalArgumentException("PUSH_BOOL must not carry call metadata");
}
}
case PUSH_CONST -> {
if (!targetLabel.isBlank()
|| !calleeCallableName.isBlank()
@@ -257,6 +271,20 @@ public record IRBackendExecutableFunction(
throw new IllegalArgumentException("GET_LOCAL must not carry call metadata");
}
}
case SET_LOCAL -> {
if (expectedArgSlots == null) {
throw new IllegalArgumentException("SET_LOCAL requires local slot in expectedArgSlots");
}
if (!label.isBlank()
|| !targetLabel.isBlank()
|| !calleeCallableName.isBlank()
|| calleeCallableId != null
|| hostCall != null
|| intrinsicCall != null
|| expectedRetSlots != null) {
throw new IllegalArgumentException("SET_LOCAL must not carry call metadata");
}
}
case CALL_FUNC -> {
if (calleeCallableId == null) {
throw new IllegalArgumentException("CALL_FUNC requires calleeCallableId");
@@ -287,10 +315,13 @@ public record IRBackendExecutableFunction(
throw new IllegalArgumentException("CALL_INTRINSIC must not carry host metadata");
}
}
case HALT, RET -> {
case HALT, RET, POP, ADD, SUB, MUL, DIV, MOD, EQ, NEQ, LT, LTE, GT, GTE, AND, OR, NOT, NEG -> {
if (!calleeCallableName.isBlank() || calleeCallableId != null || hostCall != null || intrinsicCall != null) {
throw new IllegalArgumentException(kind + " must not carry callsite metadata");
}
if (!label.isBlank() || !targetLabel.isBlank()) {
throw new IllegalArgumentException(kind + " must not carry label metadata");
}
if (expectedArgSlots != null || expectedRetSlots != null) {
throw new IllegalArgumentException(kind + " must not carry expected slot metadata");
}
@@ -329,8 +360,26 @@ public record IRBackendExecutableFunction(
public enum InstructionKind {
PUSH_I32,
PUSH_BOOL,
PUSH_CONST,
GET_LOCAL,
SET_LOCAL,
POP,
ADD,
SUB,
MUL,
DIV,
MOD,
EQ,
NEQ,
LT,
LTE,
GT,
GTE,
AND,
OR,
NOT,
NEG,
HALT,
RET,
CALL_FUNC,