Skip to content

Commit 40f7d88

Browse files
committed
feat: simplify Args in layout, remove xchgArgs case
1 parent b7ee3f6 commit 40f7d88

File tree

4 files changed

+24
-12
lines changed

4 files changed

+24
-12
lines changed

gen/tvm-specification.json

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68260,11 +68260,25 @@
6826068260
"checkLen": 8,
6826168261
"skipLen": 16,
6826268262
"args": {
68263-
"$": "xchgArgs",
68264-
"range": {
68265-
"min": "1",
68266-
"max": "16"
68267-
}
68263+
"$": "simpleArgs",
68264+
"children": [
68265+
{
68266+
"$": "stack",
68267+
"len": 4,
68268+
"range": {
68269+
"min": "1",
68270+
"max": "15"
68271+
}
68272+
},
68273+
{
68274+
"$": "stack",
68275+
"len": 4,
68276+
"range": {
68277+
"min": "0",
68278+
"max": "15"
68279+
}
68280+
}
68281+
]
6826868282
},
6826968283
"exec": "exec_xchg",
6827068284
"kind": "fixed",

src/instructions/instructions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const hash: hash = {$: "hash"}
7676
export type setcpArg = {$: "setcpArg", range: range}
7777
export const setcpArg: setcpArg = {$: "setcpArg", range: range(-15n, 239n)}
7878

79-
export type args = simpleArgs | xchgArgs | dictpush
79+
export type args = simpleArgs | dictpush
8080

8181
export type simpleArgs = {$: "simpleArgs", children: arg[]}
8282
export const seq = (...args: arg[]): simpleArgs => ({$: "simpleArgs", children: args})
@@ -1477,7 +1477,7 @@ export const instructions: Record<string, Opcode> = {
14771477

14781478
XCHG_0I_LONG: cat("stack", mkfixedn(0x11, 8, 8, seq(stack2(8, 1n)), `exec_xchg0_l`)),
14791479
XCHG_0I: cat("stack", mkfixedrangen(0x02, 0x10, 8, 4, seq(stack2(4, 1n)), `exec_xchg0`)),
1480-
XCHG_IJ: cat("stack", mkfixedn(0x10, 8, 8, xchgArgs, `exec_xchg`)),
1480+
XCHG_IJ: cat("stack", mkfixedn(0x10, 8, 8, seq(stack2(4, 1n), stack(4)), `exec_xchg`)),
14811481
XCHG_1I: cat("stack", mkfixedrangen(0x12, 0x20, 8, 4, seq(s1, stack2(4, 2n)), `exec_xchg1`)),
14821482

14831483
// special case: opcode with holes

src/instructions/tlb.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ export function generateTlb(
173173
}
174174
}
175175

176-
if (instruction.args.$ === "simpleArgs") {
176+
if (name === "XCHG_IJ") {
177+
result += "i: (## 4) j: (## 4) { 1 <= i } { i + 1 <= j }"
178+
} else if (instruction.args.$ === "simpleArgs") {
177179
for (const arg of instruction.args.children) {
178180
generateArg(arg)
179181
}
180-
} else if (instruction.args.$ === "xchgArgs") {
181-
result += "i: (## 4) j: (## 4) { 1 <= i } { i + 1 <= j }"
182182
} else if (instruction.args.$ === "dictpush") {
183183
result += "d: ^Cell key_len: (## 10)"
184184
}

validity/input-instr-signature.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ const generateArgs = (opcode: Opcode): string[] => {
4040
return args.children.map(arg => generateArg(arg))
4141
case "dictpush":
4242
return ["19", "[0 => {} 2 => {}]"]
43-
case "xchgArgs":
44-
return ["s1", "s1"]
4543
}
4644
}
4745

0 commit comments

Comments
 (0)