SIL to IR lowering


(Rebecca Chen) #1

I was wondering where the SIL to IR lowering code is in the Swift source
code. I am specifically looking for the code that lowers the function
return types. For example, from Int to i64.

Any hints would be appreciated.


(Douglas Gregor) #2

I was wondering where the SIL to IR lowering code is in the Swift source code.

That’s the responsibility of IRGen:

  https://github.com/apple/swift/tree/master/lib/IRGen

I am specifically looking for the code that lowers the function return types. For example, from Int to i64.

Technically, Int is a struct type defined in the standard library that looks like this:

  struct Int {
    var _value: Builtin.Int64
  }

The lowering of a builtin integer type to an LLVM type is here:

  https://github.com/apple/swift/blob/master/lib/IRGen/GenType.cpp#L1256

  - Doug

···

On Sep 8, 2016, at 1:17 PM, Rebecca Chen via swift-dev <swift-dev@swift.org> wrote:


(Slava Pestov) #3

I was wondering where the SIL to IR lowering code is in the Swift source code.

That’s the responsibility of IRGen:

  https://github.com/apple/swift/tree/master/lib/IRGen

I am specifically looking for the code that lowers the function return types. For example, from Int to i64.

The one place that Int is lowered to i64 is when lowering C function signatures. This is done in IRGen/GenClangType.cpp. There’s a visitor that walks SIL types to produce corresponding Clang types when expanding the signature of a C function declaration or call.

Slava

···

On Sep 9, 2016, at 9:27 AM, Douglas Gregor via swift-dev <swift-dev@swift.org> wrote:

On Sep 8, 2016, at 1:17 PM, Rebecca Chen via swift-dev <swift-dev@swift.org> wrote:

Technically, Int is a struct type defined in the standard library that looks like this:

  struct Int {
    var _value: Builtin.Int64
  }

The lowering of a builtin integer type to an LLVM type is here:

  https://github.com/apple/swift/blob/master/lib/IRGen/GenType.cpp#L1256

  - Doug

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev