Xiaochu Liu via llvm-dev
2016-Mar-16 22:19 UTC
[llvm-dev] How to prevent clang/llvm from generating floating-point instructions?
Hi Tim, Thanks for your message! It turns out that the infrastructure (an outdated one) that I am working on is using gcc+dragonegg to generate llvm code: gcc -m32 -S -c -O0 -fplugin=$(DRAGONEGG_SO) -fplugin-arg-dragonegg-emit-ir $< -o $@.tmp It directly generates llvm code with fadd, etc. I'm not familiar with dragonegg plugin... Thanks, XIaochu On Wed, Mar 16, 2016 at 12:00 PM, Tim Northover <t.p.northover at gmail.com> wrote:> Hi Xiaochu, > > On 16 March 2016 at 11:49, Xiaochu Liu via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> I was trying to compile a code with only integer type variables and >> integer operations. Clang/llvm kept showing me llvm code with >> floating-point instructions (fmul, fadd, fptosi, etc.). Is there a way >> in Clang or llvm to stop the compiler from doing that? My experiment >> does not allow floating-point operations... > > I think Clang's "-mno-implicit-float" is probably the option you want. > > I'm very surprised you're getting real floating operations like fadd > if your source really contains no floats though (it's mostly only used > implicitly for things like memcpy). So if that doesn't work, you > should probably investigate where they're coming from more deeply. > Maybe it's some external header you've included? > > Cheers. > > Tim.
Xiaochu Liu via llvm-dev
2016-Mar-17 02:10 UTC
[llvm-dev] How to prevent clang/llvm from generating floating-point instructions?
I was wondering if there exists an LLVM pass that emulate floating point operations with integers? Or simply just convert fp ops to int ons in an approximate way... I found certain backend has software float-point emulation support but not on IR-level. On Wed, Mar 16, 2016 at 3:19 PM, Xiaochu Liu <xiaochu1122 at gmail.com> wrote:> Hi Tim, > > Thanks for your message! It turns out that the infrastructure (an > outdated one) that I am working on is using gcc+dragonegg to generate > llvm code: > > gcc -m32 -S -c -O0 -fplugin=$(DRAGONEGG_SO) > -fplugin-arg-dragonegg-emit-ir $< -o $@.tmp > > It directly generates llvm code with fadd, etc. I'm not familiar with > dragonegg plugin... > > Thanks, > XIaochu > > > > > On Wed, Mar 16, 2016 at 12:00 PM, Tim Northover <t.p.northover at gmail.com> wrote: >> Hi Xiaochu, >> >> On 16 March 2016 at 11:49, Xiaochu Liu via llvm-dev >> <llvm-dev at lists.llvm.org> wrote: >>> I was trying to compile a code with only integer type variables and >>> integer operations. Clang/llvm kept showing me llvm code with >>> floating-point instructions (fmul, fadd, fptosi, etc.). Is there a way >>> in Clang or llvm to stop the compiler from doing that? My experiment >>> does not allow floating-point operations... >> >> I think Clang's "-mno-implicit-float" is probably the option you want. >> >> I'm very surprised you're getting real floating operations like fadd >> if your source really contains no floats though (it's mostly only used >> implicitly for things like memcpy). So if that doesn't work, you >> should probably investigate where they're coming from more deeply. >> Maybe it's some external header you've included? >> >> Cheers. >> >> Tim.
Tim Northover via llvm-dev
2016-Mar-17 02:37 UTC
[llvm-dev] How to prevent clang/llvm from generating floating-point instructions?
On 16 March 2016 at 19:10, Xiaochu Liu <xiaochu1122 at gmail.com> wrote:> I was wondering if there exists an LLVM pass that emulate floating > point operations with integers? Or simply just convert fp ops to int > ons in an approximate way... I found certain backend has software > float-point emulation support but not on IR-level.I'm afraid not. If libcalls do need to be used, LLVM expects to expand them during the DAG phase. I don't *think* LLVM can do that for x86. DragonEgg is mostly pretty unsupported these days, but you could try giving it the "-msoft-float" option. If GCC's frontend inserts the calls early enough, you might get away with it. But I have no idea when that actually happens. Cheers. Tim.