Ok, so I can use the structure-type to represent base or acid or salts. My next question is how union-typing works in LLVM. After reading a bit about, it's unclear to me if it is a "thing" anymore; my intuition -- and poking around in the sources is that it's a "no", it's been deprecated. Which then means that it doesn't much matter about typing LLVM. I can pass that up to a python script and handle typing up there. I just want to make sure this is accurate. On Mon, May 14, 2018 at 4:27 PM, Friedman, Eli <efriedma at codeaurora.org> wrote:> On 5/14/2018 4:18 PM, Jason Ott via llvm-dev wrote: > >> I was reading: https://llvm.org/docs/ExtendingLLVM.html >> >> And am heeding the warnings that come with new (derived) types. >> >> I'm trying to use LLVM to model chemicals. More specifically, there are >> several reactive groups that exist: salts, bases, acids, etc. that >> adequately represent their respective values. I, for obvious reasons, want >> to manifest those types in LLVM so I can type check a given input and use >> LLVM for all my compilation needs. >> >> I'm uncertain what I should do with respect to LLVM and the guidance the >> documentation provides for adding new types. >> > > You almost certainly don't want a new type in that sense. Try > https://llvm.org/docs/LangRef.html#structure-type instead. > > -Eli > > -- > Employee of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux > Foundation Collaborative Project > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180514/a0e5fd51/attachment.html>
On 5/14/2018 4:38 PM, Jason Ott wrote:> Ok, so I can use the structure-type to represent base or acid or > salts. My next question is how union-typing works in LLVM. After > reading a bit about, it's unclear to me if it is a "thing" anymore; my > intuition -- and poking around in the sources is that it's a "no", > it's been deprecated.No, LLVM doesn't have unions; you just bitcast pointers between different struct types. (In general, if you're having trouble understanding how to lower something to LLVM IR, it's often useful to use "clang -S -emit-llvm" to see what clang emits for a simple C testcase.)> Which then means that it doesn't much matter about typing LLVM. I can > pass that up to a python script and handle typing up there.Yes, you should only use LLVM types as far as they're actually helpful. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Silly question .. what do you expect to do driving LLVM directly that you couldn't do by generating C and compiling that? It's a lot easier. On Tue, May 15, 2018 at 11:38 AM, Jason Ott via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Ok, so I can use the structure-type to represent base or acid or salts. > My next question is how union-typing works in LLVM. After reading a bit > about, it's unclear to me if it is a "thing" anymore; my intuition -- and > poking around in the sources is that it's a "no", it's been deprecated. > > Which then means that it doesn't much matter about typing LLVM. I can > pass that up to a python script and handle typing up there. > > I just want to make sure this is accurate. > > On Mon, May 14, 2018 at 4:27 PM, Friedman, Eli <efriedma at codeaurora.org> > wrote: > >> On 5/14/2018 4:18 PM, Jason Ott via llvm-dev wrote: >> >>> I was reading: https://llvm.org/docs/ExtendingLLVM.html >>> >>> And am heeding the warnings that come with new (derived) types. >>> >>> I'm trying to use LLVM to model chemicals. More specifically, there are >>> several reactive groups that exist: salts, bases, acids, etc. that >>> adequately represent their respective values. I, for obvious reasons, want >>> to manifest those types in LLVM so I can type check a given input and use >>> LLVM for all my compilation needs. >>> >>> I'm uncertain what I should do with respect to LLVM and the guidance the >>> documentation provides for adding new types. >>> >> >> You almost certainly don't want a new type in that sense. Try >> https://llvm.org/docs/LangRef.html#structure-type instead. >> >> -Eli >> >> -- >> Employee of Qualcomm Innovation Center, Inc. >> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a >> Linux Foundation Collaborative Project >> >> > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180515/d570519c/attachment.html>
We have a natural-language DSL for a research project I'm on that we had our own custom compiler for; but quickly out grew. Instead of reinventing the wheel and implementing all the overhead for register allocation, stack frame generation, retargetability, etc., we wanted to use LLVM to do all the heavy lifting for us. I actually have no problem with handling typing in a layer above LLVM. It works out nicely as 2 other projects I'm on, that are closely related, require it and need the type checker anyways. And we rely on type inference in most cases, the typing is completely optional. So in LLVM I can type all materials (acids, bases, etc) as one of the base types in LLVM and then just pass up a json representation of variable interaction and run type inference on that. From what I've read z3 is *much* easier to use in python than C++ anyways. Overall, I think this approach is much easier, I was just curious. Thanks! On Mon, May 14, 2018 at 5:01 PM, Bruce Hoult <brucehoult at sifive.com> wrote:> Silly question .. what do you expect to do driving LLVM directly that you > couldn't do by generating C and compiling that? > > It's a lot easier. > > On Tue, May 15, 2018 at 11:38 AM, Jason Ott via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > >> Ok, so I can use the structure-type to represent base or acid or salts. >> My next question is how union-typing works in LLVM. After reading a bit >> about, it's unclear to me if it is a "thing" anymore; my intuition -- and >> poking around in the sources is that it's a "no", it's been deprecated. >> >> Which then means that it doesn't much matter about typing LLVM. I can >> pass that up to a python script and handle typing up there. >> >> I just want to make sure this is accurate. >> >> On Mon, May 14, 2018 at 4:27 PM, Friedman, Eli <efriedma at codeaurora.org> >> wrote: >> >>> On 5/14/2018 4:18 PM, Jason Ott via llvm-dev wrote: >>> >>>> I was reading: https://llvm.org/docs/ExtendingLLVM.html >>>> >>>> And am heeding the warnings that come with new (derived) types. >>>> >>>> I'm trying to use LLVM to model chemicals. More specifically, there >>>> are several reactive groups that exist: salts, bases, acids, etc. that >>>> adequately represent their respective values. I, for obvious reasons, want >>>> to manifest those types in LLVM so I can type check a given input and use >>>> LLVM for all my compilation needs. >>>> >>>> I'm uncertain what I should do with respect to LLVM and the guidance >>>> the documentation provides for adding new types. >>>> >>> >>> You almost certainly don't want a new type in that sense. Try >>> https://llvm.org/docs/LangRef.html#structure-type instead. >>> >>> -Eli >>> >>> -- >>> Employee of Qualcomm Innovation Center, Inc. >>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a >>> Linux Foundation Collaborative Project >>> >>> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180514/e0e6d2de/attachment-0001.html>