If I understand correctly, LLVM is a *typed* assembly language. Could I just look for a pointer type plus an integer type followed by a dereference? That would catch both a[n] and *(a+n). Gry On Tue, Apr 7, 2015 at 10:46 PM, Bruce Hoult <bruce at hoult.org> wrote:> Far too late. That would need to be in Clang. > > On Wed, Apr 8, 2015 at 5:36 PM, Gry Gunvor <gry.gunvor at gmail.com> wrote: >> >> Normally for int n unknown at static time, "a[n]" and "*(a+n)" results >> in an add and then a dereference. I want instead for it to compile to >> a system call that takes two arguments, a and n. Where should I >> intercept this in LLVM? >> >> Gry >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu llvm.cs.uiuc.edu >> lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
You might be able to match the GEP + load pair and replace with a call. But, it would depend entirely on how the llvm instructions were generated and what optimisations have been run. On Wed, Apr 8, 2015 at 3:54 PM, Gry Gunvor <gry.gunvor at gmail.com> wrote:> If I understand correctly, LLVM is a *typed* assembly language. Could > I just look for a pointer type plus an integer type followed by a > dereference? That would catch both a[n] and *(a+n). > Gry > > > On Tue, Apr 7, 2015 at 10:46 PM, Bruce Hoult <bruce at hoult.org> wrote: > > Far too late. That would need to be in Clang. > > > > On Wed, Apr 8, 2015 at 5:36 PM, Gry Gunvor <gry.gunvor at gmail.com> wrote: > >> > >> Normally for int n unknown at static time, "a[n]" and "*(a+n)" results > >> in an add and then a dereference. I want instead for it to compile to > >> a system call that takes two arguments, a and n. Where should I > >> intercept this in LLVM? > >> > >> Gry > >> _______________________________________________ > >> LLVM Developers mailing list > >> LLVMdev at cs.uiuc.edu llvm.cs.uiuc.edu > >> lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu llvm.cs.uiuc.edu > lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <lists.llvm.org/pipermail/llvm-dev/attachments/20150408/558f730b/attachment.html>
Ok, sounds like you are saying it would be a flaky solution. Gry On Tue, Apr 7, 2015 at 11:56 PM, Jeremy Lakeman <Jeremy.Lakeman at gmail.com> wrote:> You might be able to match the GEP + load pair and replace with a call. > But, it would depend entirely on how the llvm instructions were generated > and what optimisations have been run. > > On Wed, Apr 8, 2015 at 3:54 PM, Gry Gunvor <gry.gunvor at gmail.com> wrote: >> >> If I understand correctly, LLVM is a *typed* assembly language. Could >> I just look for a pointer type plus an integer type followed by a >> dereference? That would catch both a[n] and *(a+n). >> Gry >> >> >> On Tue, Apr 7, 2015 at 10:46 PM, Bruce Hoult <bruce at hoult.org> wrote: >> > Far too late. That would need to be in Clang. >> > >> > On Wed, Apr 8, 2015 at 5:36 PM, Gry Gunvor <gry.gunvor at gmail.com> wrote: >> >> >> >> Normally for int n unknown at static time, "a[n]" and "*(a+n)" results >> >> in an add and then a dereference. I want instead for it to compile to >> >> a system call that takes two arguments, a and n. Where should I >> >> intercept this in LLVM? >> >> >> >> Gry >> >> _______________________________________________ >> >> LLVM Developers mailing list >> >> LLVMdev at cs.uiuc.edu llvm.cs.uiuc.edu >> >> lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > >> > >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu llvm.cs.uiuc.edu >> lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >