[llvm] [Xtensa] Implement Xtensa Floating Point Option. (PR #136086)
Andrei Safronov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 26 16:39:18 PDT 2025
================
@@ -815,6 +898,21 @@ SDValue XtensaTargetLowering::LowerImmediate(SDValue Op,
return Op;
}
+SDValue XtensaTargetLowering::LowerImmediateFP(SDValue Op,
+ SelectionDAG &DAG) const {
+ const ConstantFPSDNode *CN = cast<ConstantFPSDNode>(Op);
+ SDLoc DL(CN);
+ APFloat apval = CN->getValueAPF();
+ int64_t value = llvm::bit_cast<uint32_t>(CN->getValueAPF().convertToFloat());
+ if (Op.getValueType() == MVT::f32) {
+ Type *Ty = Type::getInt32Ty(*DAG.getContext());
+ Constant *CV = ConstantInt::get(Ty, value);
+ SDValue CP = DAG.getConstantPool(CV, MVT::i32);
+ return DAG.getNode(ISD::BITCAST, DL, MVT::f32, CP);
----------------
andreisfr wrote:
I think you are right, thanks for the comment. I have significantly reworked the code related to loading constants from the constant pool. So, in last version FP immediate is just expanded instead of custom lowering. Also added changes that fix a possible memory leak when creating XtensaConstantPoolValue objects.
https://github.com/llvm/llvm-project/pull/136086
More information about the llvm-commits
mailing list