Hi, I'm trying to emit FP_ROUND f64 -> f32 considering a mips target that only supports single float point operations. The problem is that f32 is considered legal on this target but f64 doesn't and the only way I can codegen this instruction is using setConvertAction(MVT::f64, MVT::f32, Expand), which issues a EmitStackConvert. What if I want a libcall instead? What should I do? The libcall FROUND_F64_F32 is there, but it seems that it cannot be reached without hacking. What should I do to support this? Am I missing something? Thanks, -- Bruno Cardoso Lopes http://www.brunocardoso.cc "When faced with untenable alternatives, you should consider your imperative."
Hi Bruno,> I'm trying to emit FP_ROUND f64 -> f32 considering a mips target that > only supports single > float point operations. The problem is that f32 is considered legal on this > target but f64 doesn't and the only way I can codegen this instruction is using > setConvertAction(MVT::f64, MVT::f32, Expand), which issues a EmitStackConvert. > What if I want a libcall instead? What should I do? The libcall FROUND_F64_F32 > is there, but it seems that it cannot be reached without hacking. What > should I do > to support this? Am I missing something?with the new LegalizeTypes infrastructure you could add a method to DAGTypeLegalizer::SoftenFloatOperand which would turn FP_ROUND into a libcall (this logic will only be called if FP_ROUND has a legal return value but an illegal operand [f64] that is converted to an integer of the same size [i64]). Ciao, Duncan.
On Mon, Jul 7, 2008 at 4:30 PM, Duncan Sands <baldrick at free.fr> wrote:> Hi Bruno, > >> I'm trying to emit FP_ROUND f64 -> f32 considering a mips target that >> only supports single >> float point operations. The problem is that f32 is considered legal on this >> target but f64 doesn't and the only way I can codegen this instruction is using >> setConvertAction(MVT::f64, MVT::f32, Expand), which issues a EmitStackConvert. >> What if I want a libcall instead? What should I do? The libcall FROUND_F64_F32 >> is there, but it seems that it cannot be reached without hacking. What >> should I do >> to support this? Am I missing something? > > with the new LegalizeTypes infrastructure you could add a method to > DAGTypeLegalizer::SoftenFloatOperand which would turn FP_ROUND into > a libcall (this logic will only be called if FP_ROUND has a legal > return value but an illegal operand [f64] that is converted to an > integer of the same size [i64]).Seems that it's exactly what I'm looking for! Thanks Duncan -- Bruno Cardoso Lopes http://www.brunocardoso.cc "When faced with untenable alternatives, you should consider your imperative."
On Jul 7, 2008, at 11:20 AM, Bruno Cardoso Lopes wrote:> Hi, > > I'm trying to emit FP_ROUND f64 -> f32 considering a mips target that > only supports single > float point operations. The problem is that f32 is considered legal > on this > target but f64 doesn't and the only way I can codegen this > instruction is using > setConvertAction(MVT::f64, MVT::f32, Expand), which issues a > EmitStackConvert. > What if I want a libcall instead? What should I do? The libcall > FROUND_F64_F32 > is there, but it seems that it cannot be reached without hacking. What > should I do > to support this? Am I missing something?There really isn't an easy way to achieve this without modifying legalizer. You should add the support in legalizer. By default it would call EmitStackConvert unless the corresponding libcall name is not null. So if the target want to expand it to a libcall, it can issue setLibcallName(RTLIB::FP_ROUND, "__foo"). Evan> > > Thanks, > > -- > Bruno Cardoso Lopes > http://www.brunocardoso.cc > "When faced with untenable alternatives, you > should consider your imperative." > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Mon, Jul 7, 2008 at 5:37 PM, Chris Lattner <sabre at nondot.org> wrote:> On Mon, 7 Jul 2008, Bruno Cardoso Lopes wrote: >> I'm trying to emit FP_ROUND f64 -> f32 considering a mips target that >> only supports single >> float point operations. The problem is that f32 is considered legal on this >> target but f64 doesn't and the only way I can codegen this instruction is using >> setConvertAction(MVT::f64, MVT::f32, Expand), which issues a EmitStackConvert. >> What if I want a libcall instead? What should I do? The libcall FROUND_F64_F32 >> is there, but it seems that it cannot be reached without hacking. What >> should I do >> to support this? Am I missing something? > > Is it possible to handle this with a custom expander?I think don't, If you don't call setConvertAction it considers the return type legal (f32, which is true) and asserts into LegalizeOp, whether the action is Custom or Expand. -- Bruno Cardoso Lopes http://www.brunocardoso.cc "When faced with untenable alternatives, you should consider your imperative."
On Mon, 7 Jul 2008, Bruno Cardoso Lopes wrote:> I'm trying to emit FP_ROUND f64 -> f32 considering a mips target that > only supports single > float point operations. The problem is that f32 is considered legal on this > target but f64 doesn't and the only way I can codegen this instruction is using > setConvertAction(MVT::f64, MVT::f32, Expand), which issues a EmitStackConvert. > What if I want a libcall instead? What should I do? The libcall FROUND_F64_F32 > is there, but it seems that it cannot be reached without hacking. What > should I do > to support this? Am I missing something?Is it possible to handle this with a custom expander? -Chris -- http://nondot.org/sabre/ http://llvm.org/