The input language is at assembly level, and the location akin to a %temp ( a virtual register if you will) and contains moves from one virtual to another. Though these are not like memory but I could represent them as local variables and do loads and stores; so I dont know how to represent it in C except as local variables. On Thu, May 28, 2009 at 4:06 PM, Mike Stump <mrs at apple.com> wrote:> On May 28, 2009, at 3:46 PM, Vinod Grover wrote: > > We are working on a new front-end for LLVM IR for a low level > > language; The input has mov from one scalar to another and we would > > like to represent these in LLVM IR. being new to LLVM I am not sure > > if there is a way to represent this since I couldnt find a mov instr. > > Do you know how to do the action you seek in C? If yes, just compile > with clang or llvm-gcc at -O4 and then read the output directly for > the operations to use. > _______________________________________________ > 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/20090528/29259a12/attachment.html>
Hi, A way to handle moves is to have an array mapping virtual regs to the llvm instructions which compute them. Then a dr <- sr move can be handled by doing reg_to_inst [dr] = reg_to_inst [sr]. And whenever sr is used as an input to an operation, use reg_to_inst [sr] instead. Zoltan On Fri, May 29, 2009 at 1:23 AM, Vinod Grover <vgrover528 at gmail.com> wrote:> The input language is at assembly level, and the location akin to a %temp ( > a virtual register if you will) and contains moves from one virtual to > another. Though these are not like memory but I could represent them as > local variables and do loads and stores; so I dont know how to represent it > in C except as local variables. > > On Thu, May 28, 2009 at 4:06 PM, Mike Stump <mrs at apple.com> wrote: > >> On May 28, 2009, at 3:46 PM, Vinod Grover wrote: >> > We are working on a new front-end for LLVM IR for a low level >> > language; The input has mov from one scalar to another and we would >> > like to represent these in LLVM IR. being new to LLVM I am not sure >> > if there is a way to represent this since I couldnt find a mov instr. >> >> Do you know how to do the action you seek in C? If yes, just compile >> with clang or llvm-gcc at -O4 and then read the output directly for >> the operations to use. >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> > > > _______________________________________________ > 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/20090529/86f2603a/attachment.html>
On May 28, 2009, at 4:23 PM, Vinod Grover wrote:> The input language is at assembly level,And C makes for an excellent assembler: $ cat s.c main() { volatile register int i, j; i = j; } $ clang -O4 s.c -o - -S ; ModuleID = 's.c' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32- i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64- f80:128:128" target triple = "x86_64-apple-darwin10.0" define i32 @main() nounwind readnone { entry: %i = alloca i32, align 4 ; <i32*> [#uses=1] %j = alloca i32, align 4 ; <i32*> [#uses=1] %tmp = volatile load i32* %j ; <i32> [#uses=1] volatile store i32 %tmp, i32* %i ret i32 undef } ? Since you didn't give enough information on how the above is different from what you want to do, I can't do better.> and the location akin to a %temp ( a virtual register if you will) > and contains moves from one virtual to another. Though these are not > like memory but I could represent them as local variables and do > loads and stores; so I dont know how to represent it in C except as > local variables.
you can use an add with zero, if you dont think you are adding redundancy. On Thu, May 28, 2009 at 7:35 PM, Zoltan Varga <vargaz at gmail.com> wrote:> Hi, > > A way to handle moves is to have an array mapping virtual regs to the > llvm instructions > which compute them. Then a > dr <- sr > move can be handled by doing > reg_to_inst [dr] = reg_to_inst [sr]. > > And whenever sr is used as an input to an operation, use reg_to_inst [sr] > instead. > > Zoltan > > > On Fri, May 29, 2009 at 1:23 AM, Vinod Grover <vgrover528 at gmail.com>wrote: > >> The input language is at assembly level, and the location akin to a %temp >> ( a virtual register if you will) and contains moves from one virtual to >> another. Though these are not like memory but I could represent them as >> local variables and do loads and stores; so I dont know how to represent it >> in C except as local variables. >> >> On Thu, May 28, 2009 at 4:06 PM, Mike Stump <mrs at apple.com> wrote: >> >>> On May 28, 2009, at 3:46 PM, Vinod Grover wrote: >>> > We are working on a new front-end for LLVM IR for a low level >>> > language; The input has mov from one scalar to another and we would >>> > like to represent these in LLVM IR. being new to LLVM I am not sure >>> > if there is a way to represent this since I couldnt find a mov instr. >>> >>> Do you know how to do the action you seek in C? If yes, just compile >>> with clang or llvm-gcc at -O4 and then read the output directly for >>> the operations to use. >>> _______________________________________________ >>> LLVM Developers mailing list >>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >>> >> >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > > _______________________________________________ > 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/20090528/534219c6/attachment.html>
On 2009-05-28, at 19:23, Vinod Grover wrote:> The input language is at assembly level, and the location akin to a > %temp ( a virtual register if you will) and contains moves from one > virtual to another. Though these are not like memory but I could > represent them as local variables and do loads and stores; so I dont > know how to represent it in C except as local variables.Loading from and storing to an alloca is the correct way to model this in LLVM IR. In SSA form, variable are immutable—as if all were declared 'const' in C. Only memory locations are mutable. Mid-level optimizations will eliminate the loads and stores to the stack slot where possible (i.e., the address of the alloca does not escape the function). — Gordon
On Thu, May 28, 2009 at 4:23 PM, Vinod Grover <vgrover528 at gmail.com> wrote:> The input language is at assembly level, and the location akin to a %temp ( > a virtual register if you will) and contains moves from one virtual to > another. Though these are not like memory but I could represent them as > local variables and do loads and stores; so I dont know how to represent it > in C except as local variables. >If you want to move from one vreg to another, you can always perform a "bitcast" on the RHS and assign to the LHS (bitcasting to the same type, of course). Though first you should ask yourself why you want to do that and not simply just use the RHS. -bw
Indeed that is the closest to what I want to do, without the volatile. I was hoping I could represent it directly without using local variables, but that might be the simplest way and since the address of these is never taken, LLVM can clean them up as one might hope. Thanks Vinod On Thu, May 28, 2009 at 4:48 PM, Mike Stump <mrs at apple.com> wrote:> On May 28, 2009, at 4:23 PM, Vinod Grover wrote: > > The input language is at assembly level, > > And C makes for an excellent assembler: > > $ cat s.c > main() { > volatile register int i, j; > i = j; > } > $ clang -O4 s.c -o - -S > ; ModuleID = 's.c' > target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32- > i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64- > f80:128:128" > target triple = "x86_64-apple-darwin10.0" > > define i32 @main() nounwind readnone { > entry: > %i = alloca i32, align 4 ; <i32*> [#uses=1] > %j = alloca i32, align 4 ; <i32*> [#uses=1] > %tmp = volatile load i32* %j ; <i32> [#uses=1] > volatile store i32 %tmp, i32* %i > ret i32 undef > } > > ? Since you didn't give enough information on how the above is > different from what you want to do, I can't do better. > > > and the location akin to a %temp ( a virtual register if you will) > > and contains moves from one virtual to another. Though these are not > > like memory but I could represent them as local variables and do > > loads and stores; so I dont know how to represent it in C except as > > local variables. > _______________________________________________ > 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/20090528/31108266/attachment.html>