Skip to content

Commit a3df206

Browse files
committed
Introduce DynamicOperandModel (non-functional change)
1 parent 674d177 commit a3df206

File tree

7 files changed

+130
-102
lines changed

7 files changed

+130
-102
lines changed

truffle/src/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/bytecode/generator/BytecodeDSLNodeFactory.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,7 +3676,7 @@ private CodeExecutableElement createBegin(OperationModel operation) {
36763676
b.statement("tagNodes.add(node)");
36773677
}
36783678

3679-
if (operation.requiresRootOperation) {
3679+
if (operation.requiresRootOperation()) {
36803680
b.startStatement().startCall("validateRootOperationBegin").end(2);
36813681
}
36823682

@@ -4195,16 +4195,16 @@ private CodeExecutableElement createEnd(OperationModel operation) {
41954195
emitThrowIllegalStateException(b, "\"Operation " + operation.name + " expected at least " + childString(1) +
41964196
", but \" + operation.childCount + \" provided. This is probably a bug in the parser.\"");
41974197
b.end();
4198-
} else if (operation.isVariadic && operation.numChildren > 1) {
4198+
} else if (operation.isVariadic && operation.numChildren() > 1) {
41994199
// The variadic child is included in numChildren, so the operation requires
42004200
// numChildren - 1 children at minimum.
4201-
b.startIf().string("operation.childCount < " + (operation.numChildren - 1)).end().startBlock();
4202-
emitThrowIllegalStateException(b, "\"Operation " + operation.name + " expected at least " + childString(operation.numChildren - 1) +
4201+
b.startIf().string("operation.childCount < " + (operation.numChildren() - 1)).end().startBlock();
4202+
emitThrowIllegalStateException(b, "\"Operation " + operation.name + " expected at least " + childString(operation.numChildren() - 1) +
42034203
", but \" + operation.childCount + \" provided. This is probably a bug in the parser.\"");
42044204
b.end();
42054205
} else if (!operation.isVariadic) {
4206-
b.startIf().string("operation.childCount != " + operation.numChildren).end().startBlock();
4207-
emitThrowIllegalStateException(b, "\"Operation " + operation.name + " expected exactly " + childString(operation.numChildren) +
4206+
b.startIf().string("operation.childCount != " + operation.numChildren()).end().startBlock();
4207+
emitThrowIllegalStateException(b, "\"Operation " + operation.name + " expected exactly " + childString(operation.numChildren()) +
42084208
", but \" + operation.childCount + \" provided. This is probably a bug in the parser.\"");
42094209
b.end();
42104210
}
@@ -5038,7 +5038,7 @@ private CodeExecutableElement createEmit(OperationModel operation) {
50385038
}
50395039
}
50405040

5041-
if (operation.requiresRootOperation) {
5041+
if (operation.requiresRootOperation()) {
50425042
b.startStatement().startCall("validateRootOperationBegin").end(2);
50435043
}
50445044

@@ -5153,7 +5153,7 @@ private List<String> emitConstantOperands(CodeTreeBuilder b, OperationModel oper
51535153
return List.of();
51545154
}
51555155

5156-
boolean inEmit = operation.numChildren == 0;
5156+
boolean inEmit = !operation.hasChildren();
51575157
List<String> result = new ArrayList<>(numConstantOperands);
51585158
for (int i = 0; i < numConstantOperands; i++) {
51595159
if (i < constantOperandsBefore.size()) {
@@ -5195,11 +5195,11 @@ private String[] buildCustomInitializer(CodeTreeBuilder b, OperationModel operat
51955195
b.statement("doEmitVariadic(operation.childCount - " + (instruction.signature.dynamicOperandCount - 1) + ")");
51965196
}
51975197

5198-
if (customChildBci != null && operation.numChildren > 1) {
5198+
if (customChildBci != null && operation.numChildren() > 1) {
51995199
throw new AssertionError("customChildBci can only be used with a single child.");
52005200
}
52015201

5202-
boolean inEmit = operation.numChildren == 0;
5202+
boolean inEmit = !operation.hasChildren();
52035203

52045204
if (!inEmit) {
52055205
// make "operationData" available for endX methods.
@@ -5279,7 +5279,7 @@ private CodeExecutableElement createBeforeChild() {
52795279
b.startSwitch().string("operationStack[operationSp - 1].operation").end().startBlock();
52805280

52815281
Map<BeforeChildKind, List<OperationModel>> groupedOperations = model.getOperations().stream().filter(OperationModel::hasChildren).collect(Collectors.groupingBy(op -> {
5282-
if (op.isTransparent && (op.isVariadic || op.numChildren > 1)) {
5282+
if (op.isTransparent && (op.isVariadic || op.numChildren() > 1)) {
52835283
return BeforeChildKind.TRANSPARENT;
52845284
} else if (op.kind == OperationKind.CUSTOM_SHORT_CIRCUIT) {
52855285
return BeforeChildKind.SHORT_CIRCUIT;
@@ -5442,12 +5442,12 @@ private CodeExecutableElement createAfterChild() {
54425442
* Ensure the stack balances. If a value was expected, assert that the child
54435443
* produced a value. If a value was not expected but the child produced one, pop it.
54445444
*/
5445-
if (op.childrenMustBeValues != null) {
5445+
if (op.requiresStackBalancing()) {
54465446
List<Integer> valueChildren = new ArrayList<>();
54475447
List<Integer> nonValueChildren = new ArrayList<>();
54485448

5449-
for (int i = 0; i < op.childrenMustBeValues.length; i++) {
5450-
if (op.childrenMustBeValues[i]) {
5449+
for (int i = 0; i < op.dynamicOperands.length; i++) {
5450+
if (!op.dynamicOperands[i].voidAllowed()) {
54515451
valueChildren.add(i);
54525452
} else {
54535453
nonValueChildren.add(i);
@@ -5475,7 +5475,7 @@ private CodeExecutableElement createAfterChild() {
54755475
if (i != 0) {
54765476
b.string(" || ");
54775477
}
5478-
String operator = (op.isVariadic && valueChildren.get(i) == op.childrenMustBeValues.length - 1) ? ">=" : "==";
5478+
String operator = (op.isVariadic && valueChildren.get(i) == op.dynamicOperands.length - 1) ? ">=" : "==";
54795479
b.string("childIndex " + operator + " " + valueChildren.get(i));
54805480
}
54815481
b.string(") && !producedValue");
@@ -5492,7 +5492,7 @@ private CodeExecutableElement createAfterChild() {
54925492
if (i != 0) {
54935493
b.string(" || ");
54945494
}
5495-
String operator = (op.isVariadic && nonValueChildren.get(i) == op.childrenMustBeValues.length - 1) ? ">=" : "==";
5495+
String operator = (op.isVariadic && nonValueChildren.get(i) == op.dynamicOperands.length - 1) ? ">=" : "==";
54965496
b.string("childIndex " + operator + " " + nonValueChildren.get(i));
54975497
}
54985498
b.string(") && producedValue");

0 commit comments

Comments
 (0)