SlideShare a Scribd company logo
SIL for First Time
Learners
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Hi, I'm Yusuke
@kitasuke
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Why SIL? 
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Why SIL?
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Why SIL?
• Better idea of Swift type system
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Why SIL?
• Better idea of Swift type system
• Optimizations magic !✨
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Why SIL?
• Better idea of Swift type system
• Optimizations magic !✨
• Just for fun!
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
SIL  
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Swift
Intermediate
Language
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
SIL is a language
specific Intermediate
Representation
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Swift Compiler
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Swift Compiler
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Swift Compiler
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
What SIL looks like?
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
sample.swift
func number() -> Int {
let x: Int
x = 1
return x
}
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Emit SIL
$swiftc -emit-sil sample.swift -o sample.sil
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
sample.sil
sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int {
bb0:
%0 = alloc_stack $Int, let, name "x"
%1 = integer_literal $Builtin.Int64, 1
%2 = struct $Int (%1 : $Builtin.Int64)
store %2 to %0 : $*Int
dealloc_stack %0 : $*Int
return %2 : $Int
}
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Emit SIL with -O
$swiftc -emit-sil -O sample.swift -o sample.sil
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
sample.sil with -O
sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int {
bb0:
%0 = integer_literal $Builtin.Int64, 1
%1 = struct $Int (%0 : $Builtin.Int64)
return %1 : $Int
}
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
sample.swift
func number() -> Int {
let x: Int
x = 1
return x
}
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
sample.swift
func number() -> Int {
return 1
}
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Diff
sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int {
bb0:
%0 = alloc_stack $Int, let, name "x"
%1 = integer_literal $Builtin.Int64, 1
%2 = struct $Int (%1 : $Builtin.Int64)
store %2 to %0 : $*Int
dealloc_stack %0 : $*Int
return %2 : $Int
}
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
sample.sil with -O
sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int {
bb0:
%0 = integer_literal $Builtin.Int64, 1
%1 = struct $Int (%0 : $Builtin.Int64)
return %1 : $Int
}
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Optimizations !✨
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Optimization flag
• -Onone
• -O
• -Ounchecked
• -Osize New!
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Summary
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Summary
• Somehow understandable
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Summary
• Somehow understandable
• Better idea of how Swift Compiler works
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Summary
• Somehow understandable
• Better idea of how Swift Compiler works
• Definitely worth learning!
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
References
• swift/docs/SIL.rst
• Swift's High-Level IR: A Case Study of Complementing LLVM
IR with Language-Specific Optimization
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
Thank you!
SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018

More Related Content

More from Yusuke Kita

[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline
Yusuke Kita
 
Creating your own Bitrise step
Creating your own Bitrise stepCreating your own Bitrise step
Creating your own Bitrise step
Yusuke Kita
 
Introducing swift-format
Introducing swift-formatIntroducing swift-format
Introducing swift-format
Yusuke Kita
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUI
Yusuke Kita
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
Yusuke Kita
 
Writing an interpreter in swift
Writing an interpreter in swiftWriting an interpreter in swift
Writing an interpreter in swift
Yusuke Kita
 
var, let in SIL
var, let in SILvar, let in SIL
var, let in SIL
Yusuke Kita
 
How to try! Swift
How to try! SwiftHow to try! Swift
How to try! Swift
Yusuke Kita
 
SIL for the first time
SIL for the first timeSIL for the first time
SIL for the first time
Yusuke Kita
 
Introducing protobuf in Swift
Introducing protobuf in SwiftIntroducing protobuf in Swift
Introducing protobuf in Swift
Yusuke Kita
 
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfType-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
Yusuke Kita
 
Type-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSConType-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSCon
Yusuke Kita
 
Swift core
Swift coreSwift core
Swift core
Yusuke Kita
 
SwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたSwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみた
Yusuke Kita
 
Search APIs & Universal Links
Search APIs & Universal LinksSearch APIs & Universal Links
Search APIs & Universal Links
Yusuke Kita
 
Introducing Cardio
Introducing CardioIntroducing Cardio
Introducing Cardio
Yusuke Kita
 
Command Line Tool in swift
Command Line Tool in swiftCommand Line Tool in swift
Command Line Tool in swift
Yusuke Kita
 
WWDCのチケット外れてもSFに行った方が良い理由
WWDCのチケット外れてもSFに行った方が良い理由WWDCのチケット外れてもSFに行った方が良い理由
WWDCのチケット外れてもSFに行った方が良い理由
Yusuke Kita
 
Search APIs in Spotlight and Safari
Search APIs in Spotlight and SafariSearch APIs in Spotlight and Safari
Search APIs in Spotlight and Safari
Yusuke Kita
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in Swift
Yusuke Kita
 

More from Yusuke Kita (20)

[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline[Deprecated] Integrating libSyntax into the compiler pipeline
[Deprecated] Integrating libSyntax into the compiler pipeline
 
Creating your own Bitrise step
Creating your own Bitrise stepCreating your own Bitrise step
Creating your own Bitrise step
 
Introducing swift-format
Introducing swift-formatIntroducing swift-format
Introducing swift-format
 
Unidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUIUnidirectional Data Flow Through SwiftUI
Unidirectional Data Flow Through SwiftUI
 
Writing a compiler in go
Writing a compiler in goWriting a compiler in go
Writing a compiler in go
 
Writing an interpreter in swift
Writing an interpreter in swiftWriting an interpreter in swift
Writing an interpreter in swift
 
var, let in SIL
var, let in SILvar, let in SIL
var, let in SIL
 
How to try! Swift
How to try! SwiftHow to try! Swift
How to try! Swift
 
SIL for the first time
SIL for the first timeSIL for the first time
SIL for the first time
 
Introducing protobuf in Swift
Introducing protobuf in SwiftIntroducing protobuf in Swift
Introducing protobuf in Swift
 
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConfType-safe Web APIs with Protocol Buffers in Swift at AltConf
Type-safe Web APIs with Protocol Buffers in Swift at AltConf
 
Type-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSConType-safe Web APIs with Protocol Buffers in Swift at iOSCon
Type-safe Web APIs with Protocol Buffers in Swift at iOSCon
 
Swift core
Swift coreSwift core
Swift core
 
SwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみたSwiftCoreとFoundationを読んでみた
SwiftCoreとFoundationを読んでみた
 
Search APIs & Universal Links
Search APIs & Universal LinksSearch APIs & Universal Links
Search APIs & Universal Links
 
Introducing Cardio
Introducing CardioIntroducing Cardio
Introducing Cardio
 
Command Line Tool in swift
Command Line Tool in swiftCommand Line Tool in swift
Command Line Tool in swift
 
WWDCのチケット外れてもSFに行った方が良い理由
WWDCのチケット外れてもSFに行った方が良い理由WWDCのチケット外れてもSFに行った方が良い理由
WWDCのチケット外れてもSFに行った方が良い理由
 
Search APIs in Spotlight and Safari
Search APIs in Spotlight and SafariSearch APIs in Spotlight and Safari
Search APIs in Spotlight and Safari
 
Protocol in Swift
Protocol in SwiftProtocol in Swift
Protocol in Swift
 

Recently uploaded

Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
c5vrf27qcz
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
Mydbops
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
Fwdays
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
christinelarrosa
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
christinelarrosa
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
LizaNolte
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
Hiroshi SHIBATA
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
UiPathCommunity
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
Neo4j
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
Pablo Gómez Abajo
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
Fwdays
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 

Recently uploaded (20)

Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
Y-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PPY-Combinator seed pitch deck template PP
Y-Combinator seed pitch deck template PP
 
Must Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during MigrationMust Know Postgres Extension for DBA and Developer during Migration
Must Know Postgres Extension for DBA and Developer during Migration
 
"What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w..."What does it really mean for your system to be available, or how to define w...
"What does it really mean for your system to be available, or how to define w...
 
Christine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptxChristine's Product Research Presentation.pptx
Christine's Product Research Presentation.pptx
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptxPRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
PRODUCT LISTING OPTIMIZATION PRESENTATION.pptx
 
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham HillinQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
inQuba Webinar Mastering Customer Journey Management with Dr Graham Hill
 
Introduction of Cybersecurity with OSS at Code Europe 2024
Introduction of Cybersecurity with OSS  at Code Europe 2024Introduction of Cybersecurity with OSS  at Code Europe 2024
Introduction of Cybersecurity with OSS at Code Europe 2024
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
Session 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdfSession 1 - Intro to Robotic Process Automation.pdf
Session 1 - Intro to Robotic Process Automation.pdf
 
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
Northern Engraving | Modern Metal Trim, Nameplates and Appliance Panels
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving | Nameplate Manufacturing Process - 2024
Northern Engraving | Nameplate Manufacturing Process - 2024
 
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge GraphGraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
GraphRAG for LifeSciences Hands-On with the Clinical Knowledge Graph
 
Mutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented ChatbotsMutation Testing for Task-Oriented Chatbots
Mutation Testing for Task-Oriented Chatbots
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota"Choosing proper type of scaling", Olena Syrota
"Choosing proper type of scaling", Olena Syrota
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 

SIL for First Time Leaners LT

  • 1. SIL for First Time Learners SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 2. Hi, I'm Yusuke @kitasuke SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 3. Why SIL?  SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 4. Why SIL? SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 5. Why SIL? • Better idea of Swift type system SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 6. Why SIL? • Better idea of Swift type system • Optimizations magic !✨ SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 7. Why SIL? • Better idea of Swift type system • Optimizations magic !✨ • Just for fun! SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 8. SIL   SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 9. Swift Intermediate Language SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 10. SIL is a language specific Intermediate Representation SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 11. Swift Compiler SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 12. Swift Compiler SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 13. Swift Compiler SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 14. What SIL looks like? SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 15. sample.swift func number() -> Int { let x: Int x = 1 return x } SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 16. Emit SIL $swiftc -emit-sil sample.swift -o sample.sil SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 17. sample.sil sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int { bb0: %0 = alloc_stack $Int, let, name "x" %1 = integer_literal $Builtin.Int64, 1 %2 = struct $Int (%1 : $Builtin.Int64) store %2 to %0 : $*Int dealloc_stack %0 : $*Int return %2 : $Int } SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 18. Emit SIL with -O $swiftc -emit-sil -O sample.swift -o sample.sil SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 19. sample.sil with -O sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int { bb0: %0 = integer_literal $Builtin.Int64, 1 %1 = struct $Int (%0 : $Builtin.Int64) return %1 : $Int } SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 20. sample.swift func number() -> Int { let x: Int x = 1 return x } SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 21. sample.swift func number() -> Int { return 1 } SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 22. Diff sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int { bb0: %0 = alloc_stack $Int, let, name "x" %1 = integer_literal $Builtin.Int64, 1 %2 = struct $Int (%1 : $Builtin.Int64) store %2 to %0 : $*Int dealloc_stack %0 : $*Int return %2 : $Int } SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 23. sample.sil with -O sil hidden @_T06sample6numberSiyF : $@convention(thin) () -> Int { bb0: %0 = integer_literal $Builtin.Int64, 1 %1 = struct $Int (%0 : $Builtin.Int64) return %1 : $Int } SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 24. Optimizations !✨ SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 25. Optimization flag • -Onone • -O • -Ounchecked • -Osize New! SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 26. Summary SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 27. Summary • Somehow understandable SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 28. Summary • Somehow understandable • Better idea of how Swift Compiler works SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 29. Summary • Somehow understandable • Better idea of how Swift Compiler works • Definitely worth learning! SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 30. References • swift/docs/SIL.rst • Swift's High-Level IR: A Case Study of Complementing LLVM IR with Language-Specific Optimization SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018
  • 31. Thank you! SIL for First Time Learners, Yusuke Kita (@kitasuke), try! Swift Tokyo 2018