<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Jan 13, 2016, at 2:08 PM, Luke Howard via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class="">On 14 Jan 2016, at 4:31 AM, Joe Groff <<a href="mailto:jgroff@apple.com" class="">jgroff@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Georgia; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Jan 12, 2016, at 11:37 PM, Luke Howard via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">Also, what’s the best way of doing alignment when emitting C structs from IRGen?</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">For now I added this to ConstantBuilderBase: <div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> <span class="" style="color: rgb(187, 44, 162);">void</span><span class="Apple-converted-space"> </span>alignToWordBoundary() {</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> NextOffset = NextOffset.roundUpToAlignment(IGM.getPointerAlignment());</div><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"> }</div></div></div></div></blockquote><div style="font-family: Georgia; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Georgia; font-size: 18px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Why do you need to do this?</div></div></blockquote><br class=""></div><div class="">Emitting this:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> GenericParameterDescriptor {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> uint32_t Offset;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> uint32_t NumParams;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> uint32_t NumPrimaryParams;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""> <br class="webkit-block-placeholder"></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// A type parameter.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">struct</span> Parameter {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// The number of protocol witness tables required by this type parameter.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> size_t NumWitnessTables;</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// The protocols required by this type parameter. If NumWitnessTables is</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// zero, this is absent.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> ProtocolDescriptor *Protocols[<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>];</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> };</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// The parameter descriptors are in a tail-emplaced array of NumParams</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// elements. Because Parameters are variable length, use getParameterAt()</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>/// to access them.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> Parameter Parameters[<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>];</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div class=""><br class=""></div><div class="">needed to align the start of Parameters correctly (and also Protocols but I changed NumWitnessTables to a size_t for now to make that simpler). But perhaps there’s a way to get LLVM to do the layout for you, I feel I’m doing something wrong here.</div></div></div></blockquote><div><br class=""></div></div>You should use a relative reference here instead of an absolute pointer. We really, really don’t want relocations in reflective metadata. <div class=""><br class=""></div><div class="">John.</div></body></html>