Skip to content

Conversation

@wizardengineer
Copy link
Contributor

@wizardengineer wizardengineer commented Nov 20, 2025

No description provided.

appendModuleInlineAsm(D->getAsmString());
}

void CIRGenModule::finalizeModuleAttributes() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name might be too generic. Should I rename it to something more specific?

Comment on lines +90 to +99
// Handle module-level inline assembly
if (auto moduleAsmAttr =
mlir::dyn_cast<cir::ModuleAsmAttr>(attribute.getValue())) {
mlir::ArrayAttr asmStrings = moduleAsmAttr.getAsmStrings();
for (mlir::Attribute attr : asmStrings) {
if (auto strAttr = mlir::dyn_cast<mlir::StringAttr>(attr)) {
llvmModule->appendModuleInlineAsm(strAttr.getValue());
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to place the lowering here or is there another place you guys prefer?

@wizardengineer wizardengineer force-pushed the julius/filescopeasm-impl branch from 2ff14fa to 0b01e1c Compare November 20, 2025 03:18
@wizardengineer wizardengineer force-pushed the julius/filescopeasm-impl branch from 0b01e1c to e01ecbf Compare November 20, 2025 03:32
@wizardengineer wizardengineer marked this pull request as ready for review November 20, 2025 14:11
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving this, comments inline

}

//===----------------------------------------------------------------------===//
// FileScopeAsm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> CIR_ModuleAsmAttr?

break;
}
case Decl::FileScopeAsm:
buildFileScopeAsm(cast<FileScopeAsmDecl>(decl));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please follow OG skeleton:

  case Decl::FileScopeAsm:
    // File-scope asm is ignored during device-side CUDA compilation.
    if (langOpts.CUDA && langOpts.CUDAIsDevice)
      break;
    // File-scope asm is ignored during device-side OpenMP compilation.
    if (langOpts.OpenMPIsTargetDevice)
      break;
    // File-scope asm is ignored during device-side SYCL compilation.
    if (langOpts.SYCLIsDevice)
      break;
    buildFileScopeAsm(cast<FileScopeAsmDecl>(decl));
    break;
  }

break;
}
case Decl::FileScopeAsm:
buildFileScopeAsm(cast<FileScopeAsmDecl>(decl));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just call moduleAsm.push_back(Asm.str()); directly here, the two levels of indirection are not providing any benefits right now

}

// Finalize module attributes (including inline assembly)
finalizeModuleAttributes();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OG doesn't do this right here, why are we? There's already other model level attributes being handled, the content of this function should be there

// LLVM: module asm ".section .rodata"
// LLVM: module asm ".string {{\\22}}hello{{\\22}}"

// LLVM: define{{.*}} i32 @foo()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look for OGCG in other tests and add the similar here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants