[Lldb-commits] [lldb] [lldb] Add APSInt literal support to formatter_bytecode.py (PR #223805)
Dave Lee via lldb-commits
lldb-commits at lists.llvm.org
Tue Sep 15 13:08:02 PDT 2026
https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/223805
None
>From a86a8d947f56ee77182dd5a7351547c2f93497b7 Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Tue, 15 Sep 2026 10:43:20 -0700
Subject: [PATCH] [lldb] Add APSInt literal support to formatter_bytecode.py
---
lldb/examples/python/formatter_bytecode.py | 13 +++++++++++--
.../FormatterBytecode/RigidArrayLLDBFormatterC.txt | 2 +-
.../RigidArrayLLDBFormatterSwift.txt | 2 +-
3 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/lldb/examples/python/formatter_bytecode.py b/lldb/examples/python/formatter_bytecode.py
index 2971bf5085cd1..71ed727c5acbd 100644
--- a/lldb/examples/python/formatter_bytecode.py
+++ b/lldb/examples/python/formatter_bytecode.py
@@ -61,6 +61,7 @@ def define_opcode(n, mnemonic, name):
define_opcode(0x21, None, "lit_int")
define_opcode(0x22, None, "lit_string")
define_opcode(0x23, None, "lit_selector")
+define_opcode(0x24, None, "lit_integer")
define_opcode(0x2A, "as_int", "as_int")
define_opcode(0x2B, "as_uint", "as_uint")
@@ -398,7 +399,9 @@ def emit(byte):
emit(op_lit_uint)
emit(int(tok[:-1])) # FIXME
else:
- emit(op_lit_int)
+ # With the introduction of op_lit_integer, op_lit_int is no
+ # longer emitted by the assembler.
+ emit(op_lit_integer)
emit(int(tok)) # FIXME
elif tok[0] == "@":
emit(op_lit_selector)
@@ -474,6 +477,9 @@ def next_byte():
elif b == op_lit_int:
b = next_byte()
asm += str(b)
+ elif b == op_lit_integer:
+ b = next_byte()
+ asm += str(b)
elif b == op_lit_selector:
b = next_byte()
asm += selector[b]
@@ -617,6 +623,9 @@ def next_byte():
elif b == op_lit_int:
b = next_byte() # FIXME uleb
data.append(int(b))
+ elif b == op_lit_integer:
+ b = next_byte() # FIXME sleb
+ data.append(int(b))
elif b == op_lit_selector:
b = next_byte()
data.append(b)
@@ -1251,7 +1260,7 @@ class TestAssembler(unittest.TestCase):
def test_assemble(self):
self.assertEqual(assemble("1u dup").hex(), "200101")
self.assertEqual(assemble('"1u dup"').hex(), "2206317520647570")
- self.assertEqual(assemble("16 < { dup } if").hex(), "21105210010111")
+ self.assertEqual(assemble("16 < { dup } if").hex(), "24105210010111")
self.assertEqual(assemble('{ { " } " } }').hex(), "100710052203207d20")
def roundtrip(asm):
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
index e8e9fc9015711..3d9bd38bd1df7 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterC.txt
@@ -22,7 +22,7 @@ unsigned char _RigidArray_formatter[] =
// program size
"\x2a"
// program
- "\x20\x00\x03\x22\x08\x5f\x73\x74\x6f\x72\x61\x67\x65\x23\x12\x60\x23\x18\x60\x20\x00\x03\x22\x06\x5f\x63\x6f\x75\x6e\x74\x23\x12\x60\x23\x18\x60\x23\x21\x60\x21\x01\x13"
+ "\x20\x00\x03\x22\x08\x5f\x73\x74\x6f\x72\x61\x67\x65\x23\x12\x60\x23\x18\x60\x20\x00\x03\x22\x06\x5f\x63\x6f\x75\x6e\x74\x23\x12\x60\x23\x18\x60\x23\x21\x60\x24\x01\x13"
// sig_get_num_children
"\x02"
// program size
diff --git a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
index c92abea2b479a..068558574acc3 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Inputs/FormatterBytecode/RigidArrayLLDBFormatterSwift.txt
@@ -21,7 +21,7 @@ let `RigidArray formatter`: (UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UInt8, UI
// program size
0x2a,
// program
- 0x20, 0x00, 0x03, 0x22, 0x08, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x23, 0x12, 0x60, 0x23, 0x18, 0x60, 0x20, 0x00, 0x03, 0x22, 0x06, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x23, 0x12, 0x60, 0x23, 0x18, 0x60, 0x23, 0x21, 0x60, 0x21, 0x01, 0x13,
+ 0x20, 0x00, 0x03, 0x22, 0x08, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x23, 0x12, 0x60, 0x23, 0x18, 0x60, 0x20, 0x00, 0x03, 0x22, 0x06, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x23, 0x12, 0x60, 0x23, 0x18, 0x60, 0x23, 0x21, 0x60, 0x24, 0x01, 0x13,
// sig_get_num_children
0x02,
// program size
More information about the lldb-commits
mailing list