Hi Fellows, What's the best way to emit the following code in LLVM APIs: %Nx = call i32 @get_local_size(i32 0) %Ny = call i32 @get_local_size(i32 1) %Nz = call i32 @get_local_size(i32 2) %A = alloca [Nx x [ Ny x [Nz x i32]]], align64 It basically allocates a 3D dynamic array, where the 3D sizes are unknown at compile time. I am not sure if using alloca is the right direction? Any other alternatives? Best, Paul -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140401/478a47e5/attachment.html>
David Majnemer
2014-Apr-02 02:24 UTC
[LLVMdev] Dynamic allocation of a 3D array in LLVM APIs?
Something like the following should work: %Nx = call i32 @get_local_size(i32 0) %Ny = call i32 @get_local_size(i32 1) %Nz = call i32 @get_local_size(i32 2) %mul1 = mul nuw i32 %Ny, %Nx %mul2 = mul nuw i32 %Nz, %mul1 %A = alloca i32, i32 %mul2, align 4 On Tue Apr 01 2014 at 4:57:44 PM, Paul Vario <paul.paul.mit at gmail.com> wrote:> Hi Fellows, > > What's the best way to emit the following code in LLVM APIs: > > %Nx = call i32 @get_local_size(i32 0) > %Ny = call i32 @get_local_size(i32 1) > %Nz = call i32 @get_local_size(i32 2) > > %A = alloca [Nx x [ Ny x [Nz x i32]]], align64 > > It basically allocates a 3D dynamic array, where the 3D sizes are > unknown at compile time. I am not sure if using alloca is the right > direction? Any other alternatives? > > Best, > Paul > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140402/38113dde/attachment.html>
Malloc? On Tue, Apr 1, 2014 at 7:54 PM, Paul Vario <paul.paul.mit at gmail.com> wrote:> Hi Fellows, > > What's the best way to emit the following code in LLVM APIs: > > %Nx = call i32 @get_local_size(i32 0) > %Ny = call i32 @get_local_size(i32 1) > %Nz = call i32 @get_local_size(i32 2) > > %A = alloca [Nx x [ Ny x [Nz x i32]]], align64 > > It basically allocates a 3D dynamic array, where the 3D sizes are > unknown at compile time. I am not sure if using alloca is the right > direction? Any other alternatives? > > Best, > Paul > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140407/45fef63d/attachment.html>