خلفيّة سياديّة: ربط المحرّك بجداول SoT (table-driven) — توليد ترميز x86-64 من YAML - #321
Merged
Merged
Conversation
…86-64 من YAML تحقيقُ مبدأ «table-driven» في RFC الخلفيّة السياديّة (rfcs #57): مواصفاتُ الترميز (EncSpec) لم تعُد مضمَّنةً في المحرّك، بل تُولَّد من language-truth/backend/x86_64/ instructions.yaml (مصدر الحقيقة) إلى هيدر C++ يقرؤه المحرّك بـlookupEncSpec. فيصير x86_variable_encoder.h منطقًا صرفًا، والاختلافُ بين التعليمات بياناتٌ لا كود. المُضاف: • scripts/codegen/gen_backend_encoding.py: مولّدٌ يقرأ instructions.yaml (+تحقّق مخطّط) ويُخرج جدول EncSpec عبر lambda IIFE (C++17، لا designated inits) + lookupEncSpec. • compiler/include/backend/native/generated/x86_64_encoding_generated.h: الهيدر المولَّد (٦ صيغ)؛ مُلتزَمٌ في git (نمط go generate). • x.py: نطاق codegen backend_encoding_x86_64 ⇒ `gen --check` حارسُ انجرافٍ يفشل إن انحرف المولَّد عن الـYAML (بوّابة CI «فحص توليد الكود»). • language-truth/backend/x86_64/instructions.yaml: أُضيفت صيغة mov r32,imm32 (خروج ٤٢). • x86_variable_encoder.h: أُزيلت الدوالّ المصنّعة المضمَّنة (بقي المنطق encodeVariable). • test_native_backend_m1.cpp: يستعمل lookupEncSpec بمنمنمة عربيّة + صيغة (يُثبت قراءة البيانات من SoT). التحقّق: ١٠/١٠ PASS (مقودةً بالجدول المولَّد) + البرهان الحيّ (خروج ٤٢ على WSL2) قائم + gen --check أخضر (لا انجراف) + المخطّط يمرّ (16/16). أميليا CLEAR (توليد مطابق صفًّا بصفّ، بايتات م١ محفوظة، قطعيّ، آمن ضدّ nullptr، + تحصين modrm بلا reg/rm). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
📚 تذكير مزامنة دليل المطوّرين هذا الـPR يلمس مصادر موثَّقة في دليل المطوّرين. راجع الفصول الآتية وحدّثها إن تغيّر سلوكها، ثم ثبّت البصمات هناك (
بندٌ في معيار الإنجاز. تذكيرٌ آليّ — لا يحجب الدمج. |
test_domain_table_covers_exactly_the_expected_files يقارن مجموعةَ ملفّات النطاقات المُغطّاة بالمتوقَّعة حرفيًّا. أُضيف نطاق backend_encoding_x86_64 إلى x.py دون إضافة مخرَجه إلى EXPECTED_OUTPUTS، فاختلّت المجموعتان. أُضيف الهيدر المولَّد x86_64_encoding_generated.h إلى القائمة المتوقَّعة. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
الغرض
تحقيقُ مبدأ «table-driven» (جوهر RFC rfcs #57، بعد م١ #320): مواصفاتُ الترميز (
EncSpec) لم تعُد مضمَّنةً في المحرّك، بل تُولَّد منlanguage-truth/backend/x86_64/instructions.yaml(مصدر الحقيقة) إلى هيدر C++ يقرؤه المحرّك بـlookupEncSpec. فيصيرx86_variable_encoder.hمنطقًا صرفًا، والاختلافُ بين التعليمات بياناتٌ لا كود.المُضاف
scripts/codegen/gen_backend_encoding.pyinstructions.yaml(+تحقّق مخطّط) ويُخرج جدولEncSpec(lambda IIFE، C++17) +lookupEncSpec.../native/generated/x86_64_encoding_generated.hx.pybackend_encoding_x86_64⇒gen --checkحارسُ انجرافٍ (بوّابة «فحص توليد الكود»)instructions.yamlmov r32, imm32(مسار خروج ٤٢)x86_variable_encoder.hencodeVariable)test_native_backend_m1.cpplookupEncSpecبمنمنمة عربيّة + صيغةالتحقّق
lookupEncSpec→encodeVariable).python x.py gen --check— الهيدر المُلتزَم يطابق ما يولّده الـYAML بايتًا ببايت.TestBackendTables16/16 (بعد إضافةmov r32,imm32).ASSERT_TRUE)، + تحصينُmodrmبلاreg/rm.الأثر
المحرّكُ صار مقودًا بمصدر الحقيقة فعليًّا: إضافةُ تعليمةٍ = صفٌّ في YAML، لا كودُ C++. هذا يمهّد لتوليد جداول ARM64/RISC-V بنفس المولّد، وللكتابة بلغة ص لاحقًا.
🤖 Generated with Claude Code