Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon



SIL, aka Swift Intermediate Language, is an ir created in 2012.

#479on PLDB 10Years Old 0Books

Example from the web:
// SIL is reliant on Swift's type system and declarations, so SIL syntax is an extension of Swift's. A .sil file is a Swift source file with added SIL definitions. The Swift source is parsed only for its declarations; Swift func bodies (except for nested declarations) and top-level code are ignored by the SIL parser. In a .sil file, there are no implicit imports; the swift and/or Builtin standard modules must be imported explicitly if used. sil_stage canonical import Swift // Define types used by the SIL function. struct Point { var x : Double var y : Double } class Button { func onClick() func onMouseDown() func onMouseUp() } // Declare a Swift function. The body is ignored by SIL. func taxicabNorm(_ a:Point) -> Double { return a.x + a.y } // Define a SIL function. // The name @_T5norms11taxicabNormfT1aV5norms5Point_Sd is the mangled name // of the taxicabNorm Swift function. sil @_T5norms11taxicabNormfT1aV5norms5Point_Sd : $(Point) -> Double { bb0(%0 : $Point): // func Swift.+(Double, Double) -> Double %1 = function_ref @_Tsoi1pfTSdSd_Sd %2 = struct_extract %0 : $Point, #Point.x %3 = struct_extract %0 : $Point, #Point.y %4 = apply %1(%2, %3) : $(Double, Double) -> Double return %4 : Double } // Define a SIL vtable. This matches dynamically-dispatched method // identifiers to their implementations for a known static class type. sil_vtable Button { #Button.onClick: @_TC5norms6Button7onClickfS0_FT_T_ #Button.onMouseDown: @_TC5norms6Button11onMouseDownfS0_FT_T_ #Button.onMouseUp: @_TC5norms6Button9onMouseUpfS0_FT_T_ }
Example from hello-world:
print Hello World

Language features

Feature Supported Example Token
Print() Debugging print
// A comment
Line Comments
// A comment
Semantic Indentation ϴ
hjson.html · swift-il.html · troff.html

View source

PLDB - Build the next great programming language · v2022 · Day 32 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub ·