[llvm] [Xtensa] Implement lowering Mul/Div/Shift operations. (PR #99981)

Andrei Safronov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 26 07:02:45 PDT 2024


================
@@ -665,12 +693,30 @@ SDValue XtensaTargetLowering::getAddrPCRel(SDValue Op,
 SDValue XtensaTargetLowering::LowerConstantPool(ConstantPoolSDNode *CP,
                                                 SelectionDAG &DAG) const {
   EVT PtrVT = getPointerTy(DAG.getDataLayout());
+  auto C = const_cast<Constant *>(CP->getConstVal());
+  auto T = const_cast<Type *>(CP->getType());
   SDValue Result;
-  if (!CP->isMachineConstantPoolEntry()) {
-    Result = DAG.getTargetConstantPool(CP->getConstVal(), PtrVT, CP->getAlign(),
-                                       CP->getOffset());
+
+  // Do not use constant pool for aggregate or vector constant types,
+  // in such cases create global variable, for example to store tabel
+  // when we lower CTTZ operation.
+  if (T->isAggregateType() || T->isVectorTy()) {
+    auto AFI = DAG.getMachineFunction().getInfo<XtensaFunctionInfo>();
+    auto M = const_cast<Module *>(
+        DAG.getMachineFunction().getFunction().getParent());
+    auto GV = new GlobalVariable(
+        *M, T, /*isConstant=*/true, GlobalVariable::InternalLinkage, C,
+        Twine(DAG.getDataLayout().getPrivateGlobalPrefix()) + "CP" +
+            Twine(DAG.getMachineFunction().getFunctionNumber()) + "_" +
+            Twine(AFI->createLabelUId()));
+    Result = DAG.getTargetConstantPool(GV, PtrVT, Align(4));
   } else {
-    report_fatal_error("This constantpool type is not supported yet");
+    if (!CP->isMachineConstantPoolEntry()) {
+      Result = DAG.getTargetConstantPool(CP->getConstVal(), PtrVT,
+                                         CP->getAlign(), CP->getOffset());
+    } else {
+      report_fatal_error("This constantpool type is not supported yet");
+    }
----------------
andreisfr wrote:

Thank you for comments, I added test. Also I removed "Vector" case handling, probably it is early, I will implement it in future.

https://github.com/llvm/llvm-project/pull/99981


More information about the llvm-commits mailing list