Upgrade to Pro — share decks privately, control downloads, hide ads and more …

社内版SwiftコンパイラにContributeするまで

freddi(Yuki Aki)
October 09, 2020
59

 社内版SwiftコンパイラにContributeするまで

freddi(Yuki Aki)

October 09, 2020
Tweet

Transcript

  1. Agenda • Contributeͨ͠಺༰ ͷ͸ͳ͠ • Swift ͷίϯύΠϧϑϩʔ ͷ͸ͳ͠ • Swift

    Intermediate Language ͷ͸ͳ͠ • SILOptimizer ʹ͍ͭͯ • (͋ΒͨΊͯ) Contributeͨ͠಺༰ ͷ͸ͳ͠
  2. Agenda • Contributeͨ͠಺༰ ͷ͸ͳ͠ • Swift ͷίϯύΠϧϑϩʔ ͷ͸ͳ͠ • Swift

    Intermediate Language ͷ͸ͳ͠ • SILOptimizer ʹ͍ͭͯ • (͋ΒͨΊͯ) Contributeͨ͠಺༰ ͷ͸ͳ͠ ๻ͷೖ໳ϑϩʔ
  3. Contributeͨ͠಺༰ ͷ͸ͳ͠ • ̎ͭ Contribute ͨ͠ • https://github.com/apple/swift/pull/33851 • ࠷దԽϩδοΫͷϛε

    • https://github.com/apple/swift/pull/31847 • Docs ͷ BNF Ͱॻ͔Εͨ Grammer ͷϛε
  4. Swift ͷίϯύΠϧϑϩʔ ͷ͸ͳ͠ • LLVM IR => … • SIL

    Λ LLVM IR ʹ௚ͯ͠LLVM ʹ౤͛Δ • ͦͷ͋ͱϦϯΧʹ౤͛ΒΕͨΓ • όΠφϦ౳ʹͳΔ
  5. Swift Intermediate Language ͷ͸ͳ͠ • ࢼ͠ʹ hello world! Λ SIL

    Ͱ ੜ੒ͯ͠ΈΔ • ࠓճ͸͕࣌ؒͳ͍ͷͰ raw SIL ͚ͩ
  6. Swift Intermediate Language ͷ͸ͳ͠ • SIL ͷߏ଄Λେ͖͍ॱʹ • SILModule (ιʔείʔυશମ)

    • SILFunction (֤ؔ਺) • SILBasicBlock (͍ΘΏΔείʔϓ) • SILInstruction (SILίʔυҰจҰจ)
  7. Contributeͨ͠಺༰ ͷ͸ͳ͠ • ϝϞϦΞΫηε͕ى͜Γͦ͏ͳInstructionͷݕ஌ํ๏ • SILInstruction ͷଐੑΛݟΔ • LLVMͷInstruction ͷଐੑΛݟΔ

    • apply Instruction ͳΒݺͼग़͠ઌͷؔ਺ͷଐੑΛݟΔ • ͜͜Β΁Μͷॲཧ͸ͯͯ͝͝ͷXϚΫϩ͕ೖͬͨॲཧͳͷ ͰׂѪɻڵຯ͕͋ͬͨΒ࣭໰Ͱฉ͍͍ͯͩ͘͞
  8. Contributeͨ͠಺༰ ͷ͸ͳ͠ • ΋͏গ͠஌Γ͍ͨํ͸ Θ͍Θ͍swiftc #20 ͷ๻ͷࢿྉΛݟ͍ͯͩ͘͞ 
 
 


    
 
 
 
 • 
 
 
 https://speakerdeck.com/freddi/mayhavesideeffect
  9. Contributeͨ͠಺༰ ͷ͸ͳ͠ • PRग़ͨ͠ΒɺTest ॻ͍ͨΒϚʔδ͢ΔͱݴΘΕͨ • SILͷςετ΋ LLVMͷlitΛ࢖͍ͬͯΔΒ͍͠ • LLVM

    Integrated Tester ͷུ • ͦΜͳ͜ΜͳͰϚʔδ͞Εͨ • ΂ͭʹόάνέοτΛ੾Δඞཁ͸ͳ͍Β͍͠