<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I was looking at using multiple contexts in LLVM for codegen, but I’m running into some problems.<div class=""><br class=""></div><div class="">First a quick rundown of what my idea was:</div><div class=""><br class=""></div><div class="">1. Run lexing-parsing-sema in a single thread. Store each ast-module separately.</div><div class="">2. Build the LLVM IR using 1 context per ast-module.</div><div class="">3. Launch multiple threads doing code gen on each of the contexts in parallel.</div><div class=""><br class=""></div><div class="">A problem is that in order to do the correct semantic analysis I need to know a bit about alignment and sizes as macros will be able to do conditional compilation depending on sizes and offsets.</div><div class=""><br class=""></div><div class="">The ABI / preferred alignments can be found if I generate LLVM types, but I don’t generate a context until (2) and I need the alignments during (1). I see a few possibilities (note that i use the LLVM C API)</div><div class=""><br class=""></div><div class="">1. Keep a completely independent list of these settings inside of my frontend and calculate layout myself.</div><div class="">2. Parse the Data Layout string for the machine to use to get the information need otherwise do the calculation as in (1)</div><div class="">3. During (1) use the global context  to generate LLVM types from my current types and rely on LLVM for calculation. These types will then need to be recreated in (2) but for the ”right” context.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Are there other ways to do this?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Best Regards,</div><div class=""><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  "><div class="">Christoffer</div><div class=""><br class=""></div></span></div></div></body></html>