[LLVMdev] Representing -ffast-math at the IR level
    Duncan Sands 
    baldrick at free.fr
       
    Mon Apr 16 05:20:42 PDT 2012
    
    
  
Hi Renato,
> I like the changes to IRBuilder and how the operator can't change it.
> Looks a lot safer (mistake-wise) and more convenient.
thanks!
> This function won't to remove a previously set tag, which could be
> used by optimisations or inlining.
This is private to IRBuilder and is only applied to newly created instructions,
thus removing tags is not useful.  I guess it could be exposed for general use -
is that what you are suggesting?  If so, I think it would be better if MDBuilder
got methods for applying metadata such as:
   SetTBAAMetadata(Instruction *I, MDNode *MD);
   SetFPMathMetadata(Instruction *I, MDNode *MD);
along with getters.  I will add that.
>
> +  Instruction *AddFPMathTag(Instruction *I, MDNode *FPMathTag) const {
> +    if (!FPMathTag)
> +      FPMathTag = DefaultFPMathTag;
> +    if (FPMathTag)
> +      I->setMetadata(LLVMContext::MD_fpmath, FPMathTag);
> +    return I;
> +  }
>
> If you want to keep it as only Add, then make FPMathTag = 0 so that
> you can easily add the default by just calling AddFPMathTag(instr);
>
> But I'd add a ClearFPMathTag function for optimisations/inlining. Maybe later.
See above.
> Also, would be good to make sure the instruction is, in fact, a
> floating point operation. Either via restricting the type or asserting
> on it.
That would be appropriate for MDBuilder - I will do it.
CIao, Duncan.
    
    
More information about the llvm-dev
mailing list