(
uop: Part,
emitter: Emitter,
offset: int,
stack: Stack,
inst: Instruction,
braces: bool,
)
| 69 | |
| 70 | |
| 71 | def write_uop( |
| 72 | uop: Part, |
| 73 | emitter: Emitter, |
| 74 | offset: int, |
| 75 | stack: Stack, |
| 76 | inst: Instruction, |
| 77 | braces: bool, |
| 78 | ) -> tuple[bool, int, Stack]: |
| 79 | # out.emit(stack.as_comment() + "\n") |
| 80 | if isinstance(uop, Skip): |
| 81 | entries = "entries" if uop.size > 1 else "entry" |
| 82 | emitter.emit(f"/* Skip {uop.size} cache {entries} */\n") |
| 83 | return True, (offset + uop.size), stack |
| 84 | if isinstance(uop, Flush): |
| 85 | emitter.emit(f"// flush\n") |
| 86 | stack.flush(emitter.out) |
| 87 | return True, offset, stack |
| 88 | locals: dict[str, Local] = {} |
| 89 | emitter.out.start_line() |
| 90 | if braces: |
| 91 | emitter.out.emit(f"// {uop.name}\n") |
| 92 | emitter.emit("{\n") |
| 93 | stack._print(emitter.out) |
| 94 | storage = Storage.for_uop(stack, uop, emitter.out) |
| 95 | |
| 96 | for cache in uop.caches: |
| 97 | if cache.name != "unused": |
| 98 | if cache.size == 4: |
| 99 | type = "PyObject *" |
| 100 | reader = "read_obj" |
| 101 | else: |
| 102 | type = f"uint{cache.size*16}_t " |
| 103 | reader = f"read_u{cache.size*16}" |
| 104 | emitter.emit( |
| 105 | f"{type}{cache.name} = {reader}(&this_instr[{offset}].cache);\n" |
| 106 | ) |
| 107 | if inst.family is None: |
| 108 | emitter.emit(f"(void){cache.name};\n") |
| 109 | offset += cache.size |
| 110 | |
| 111 | reachable, storage = emitter.emit_tokens(uop, storage, inst, False) |
| 112 | if braces: |
| 113 | emitter.out.start_line() |
| 114 | emitter.emit("}\n") |
| 115 | # emitter.emit(stack.as_comment() + "\n") |
| 116 | return reachable, offset, storage.stack |
| 117 | |
| 118 | |
| 119 | def uses_this(inst: Instruction) -> bool: |
no test coverage detected
searching dependent graphs…