Sandeep Kumar Singh via llvm-dev
2015-Sep-25 05:12 UTC
[llvm-dev] Upper 32bits from 64bit value
Hi, I need to fetch lower and higher 32bits from 64bit value. I found "CreateLShr" function to fetch lower 32bits, llvm::Value *intermediateValue = LLVMIRBuilder->CreateLShr(x64BitValue, 32); What function I need to use for fetching upper 32bits from 64bit value. Thanks in advance, Deep -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150925/f2975dc0/attachment.html>
On 24 September 2015 at 22:12, Sandeep Kumar Singh via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I need to fetch lower and higher 32bits from 64bit value. I found > "CreateLShr" function to fetch lower 32bits, > llvm::Value *intermediateValue = LLVMIRBuilder->CreateLShr(x64BitValue, 32);That would give you the upper bits, I think.> What function I need to use for fetching upper 32bits from 64bit value.There's multiple ways to get the other half: "x & 0xffffffff" is the canonical one (LLVM's optimisers will convert the others into that if they can). Cheers. Tim.
Sandeep Kumar Singh via llvm-dev
2015-Sep-28 03:34 UTC
[llvm-dev] Upper 32bits from 64bit value
Hi Tim, Thank you for reply.> llvm::Value *intermediateValue = LLVMIRBuilder->CreateLShr(x64BitValue,32); Now I am using below to calculate upper 32bits, I think this is OK, llvm::Value *intermediateValue = LLVMIRBuilder->CreateAnd(x64BitValue, 0xFFFFFFFF00000000); intermediateValue = LLVMIRBuilder->CreateLShr(intermediateValue, 32); //cast value to 32 bit intermediateValue = castValueByOpSize(intermediateValue, 32); Regards, Deep On Fri, Sep 25, 2015 at 7:12 PM, Tim Northover <t.p.northover at gmail.com> wrote:> On 24 September 2015 at 22:12, Sandeep Kumar Singh via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > I need to fetch lower and higher 32bits from 64bit value. I found > > "CreateLShr" function to fetch lower 32bits, > > llvm::Value *intermediateValue = LLVMIRBuilder->CreateLShr(x64BitValue, > 32); > > That would give you the upper bits, I think. > > > What function I need to use for fetching upper 32bits from 64bit value. > > There's multiple ways to get the other half: "x & 0xffffffff" is the > canonical one (LLVM's optimisers will convert the others into that if > they can). > > Cheers. > > Tim. >-- Thanks and Regards, Sandeep Kumar Singh -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150928/bdc44bec/attachment.html>