[swift-dev] SIL to IR lowering

Slava Pestov spestov at apple.com
Tue Sep 13 03:15:03 CDT 2016


> On Sep 9, 2016, at 9:27 AM, Douglas Gregor via swift-dev <swift-dev at swift.org> wrote:
> 
> 
>> On Sep 8, 2016, at 1:17 PM, Rebecca Chen via swift-dev <swift-dev at swift.org> wrote:
>> 
>> 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

> 
> 
> 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 at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev



More information about the swift-dev mailing list