Commit aff3b97
authored
[mono-move] flesh out u64 arithmetic / bitwise / shift micro-ops (#19591)
Adds the missing reg-reg and reg-imm forms so the lowerer can stop
bail!ing on common Move arithmetic. New micro-ops:
reg-reg: SubU64, MulU64, DivU64, BitAndU64, BitOrU64, ShlU64, ShrU64
imm: MulU64Imm, DivU64Imm, ModU64Imm, ShlU64Imm
All checked: overflow / underflow / div-by-zero / shift>=64 abort.
Rename: XorU64 -> BitXorU64 for naming consistency with the new
BitAnd/BitOr (and to disambiguate from forthcoming logical Or/And/Not).
Wires the new ops through every layer: enum + Display, gas
HasCfgInfo / RemapTargets / cost, runtime verifier + interpreter, and
the specializer's BinaryOp / BinaryOpImm lowering. Reverse-immediate
forms for non-commutative ops other than Sub are deferred.
The verifier rejects DivU64Imm / ModU64Imm with imm == 0 and ShlU64Imm
/ ShrU64Imm with imm >= 64 -- always-abort patterns become hard errors.
Refactor: arithmetic arms in step() factored through five helpers
(binop_u64, checked_binop_u64, imm_op_u64, checked_imm_op_u64,
shift_u64) with #[inline(always)]. Inlining verified by inspecting
release-build x64 asm on 2026-04-30; per-block // SAFETY: comments and
INVARIANT docs in place; debug_assert!s defend the verifier-guaranteed
invariants on imm-form Div/Mod/Shl/Shr; error messages standardized to
the "OpName: short-message" form.
Snapshot baseline regenerated with extended coverage; runtime tests
exercise each new op including abort paths, plus verifier tests cover
the new static checks.
Boolean Or/And/Not, comparison-to-register, and Negate are still TODO.1 parent 38059a7 commit aff3b97
10 files changed
Lines changed: 1217 additions & 93 deletions
File tree
- third_party/move/mono-move
- core/src/instruction
- programs/src
- runtime
- src
- tests
- specializer/src/lower
- testsuite/tests/test_cases/snapshot/masm
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
47 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
48 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
49 | 60 | | |
50 | 61 | | |
51 | 62 | | |
| |||
131 | 142 | | |
132 | 143 | | |
133 | 144 | | |
| 145 | + | |
134 | 146 | | |
135 | 147 | | |
136 | | - | |
137 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
138 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
139 | 161 | | |
140 | 162 | | |
141 | 163 | | |
| |||
186 | 208 | | |
187 | 209 | | |
188 | 210 | | |
| 211 | + | |
189 | 212 | | |
190 | 213 | | |
191 | | - | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
192 | 220 | | |
193 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
194 | 226 | | |
195 | 227 | | |
196 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
272 | 277 | | |
273 | 278 | | |
274 | | - | |
| 279 | + | |
| 280 | + | |
275 | 281 | | |
276 | 282 | | |
277 | 283 | | |
| 284 | + | |
| 285 | + | |
278 | 286 | | |
279 | 287 | | |
280 | 288 | | |
| |||
289 | 297 | | |
290 | 298 | | |
291 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
292 | 308 | | |
293 | 309 | | |
294 | 310 | | |
| |||
303 | 319 | | |
304 | 320 | | |
305 | 321 | | |
306 | | - | |
307 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
308 | 325 | | |
309 | 326 | | |
310 | 327 | | |
311 | 328 | | |
312 | 329 | | |
313 | | - | |
314 | | - | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
315 | 347 | | |
316 | 348 | | |
317 | 349 | | |
318 | 350 | | |
319 | 351 | | |
320 | | - | |
| 352 | + | |
| 353 | + | |
321 | 354 | | |
322 | 355 | | |
323 | 356 | | |
324 | 357 | | |
325 | 358 | | |
326 | 359 | | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
327 | 425 | | |
328 | 426 | | |
329 | 427 | | |
| |||
705 | 803 | | |
706 | 804 | | |
707 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
708 | 809 | | |
709 | 810 | | |
710 | 811 | | |
711 | 812 | | |
712 | 813 | | |
713 | 814 | | |
714 | | - | |
715 | | - | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
716 | 826 | | |
717 | 827 | | |
718 | 828 | | |
719 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
720 | 854 | | |
721 | 855 | | |
722 | 856 | | |
| |||
895 | 1029 | | |
896 | 1030 | | |
897 | 1031 | | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | 1032 | | |
902 | 1033 | | |
903 | 1034 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| |||
0 commit comments