@@ -2212,6 +2212,33 @@ mlir::LogicalResult CIRToLLVMFuncOpLowering::matchAndRewrite(
2212
2212
Loc, op.getName (), llvmFnTy, linkage, isDsoLocal, cconv,
2213
2213
mlir::SymbolRefAttr (), attributes);
2214
2214
2215
+ // Lower CIR attributes for arguments.
2216
+ for (unsigned index = 0 ; index < fnType.getNumInputs (); index ++) {
2217
+ mlir::DictionaryAttr cirAttrs = op.getArgAttrDict (index );
2218
+ if (cirAttrs) {
2219
+ if (cirAttrs.get (cir::CIRDialect::getZExtAttrName ()))
2220
+ fn.setArgAttr (index , mlir::LLVM::LLVMDialect::getZExtAttrName (),
2221
+ rewriter.getUnitAttr ());
2222
+ if (cirAttrs.get (cir::CIRDialect::getSExtAttrName ()))
2223
+ fn.setArgAttr (index , mlir::LLVM::LLVMDialect::getSExtAttrName (),
2224
+ rewriter.getUnitAttr ());
2225
+ }
2226
+ }
2227
+
2228
+ // Lower CIR attributes for return value.
2229
+ // Each function has no more than one result in CIR, so no need for a loop.
2230
+ if (op.getNumResults () > 0 ) {
2231
+ mlir::DictionaryAttr resultAttrs = op.getResultAttrDict (0 );
2232
+ if (resultAttrs) {
2233
+ if (resultAttrs.get (cir::CIRDialect::getZExtAttrName ()))
2234
+ fn.setResultAttr (0 , mlir::LLVM::LLVMDialect::getZExtAttrName (),
2235
+ rewriter.getUnitAttr ());
2236
+ if (resultAttrs.get (cir::CIRDialect::getSExtAttrName ()))
2237
+ fn.setResultAttr (0 , mlir::LLVM::LLVMDialect::getSExtAttrName (),
2238
+ rewriter.getUnitAttr ());
2239
+ }
2240
+ }
2241
+
2215
2242
fn.setVisibility_Attr (mlir::LLVM::VisibilityAttr::get (
2216
2243
getContext (), lowerCIRVisibilityToLLVMVisibility (
2217
2244
op.getGlobalVisibilityAttr ().getValue ())));
0 commit comments