[Mlir-commits] [mlir] [MLIR][LLVMIR] Add module flags support (PR #130679)

Tobias Gysi llvmlistbot at llvm.org
Tue Mar 11 01:06:46 PDT 2025


================
@@ -270,6 +270,19 @@ static void convertLinkerOptionsOp(ArrayAttr options,
   linkerMDNode->addOperand(listMDNode);
 }
 
+static void convertModuleFlagsOp(ArrayAttr flags, llvm::IRBuilderBase &builder,
+                                 LLVM::ModuleTranslation &moduleTranslation) {
+  llvm::Module *llvmModule = moduleTranslation.getLLVMModule();
+  for (Attribute attr : flags) {
+    auto flag = cast<ModuleFlagAttr>(attr);
+    auto intVal = dyn_cast<IntegerAttr>(flag.getValue());
+    assert(intVal && "expected integer attribute");
+    llvmModule->addModuleFlag(
+        (llvm::Module::ModFlagBehavior)flag.getBehavior().getValue(),
----------------
gysit wrote:

```suggestion
        static_cast<llvm::Module::ModFlagBehavior>(flag.getBehavior().getValue()),
```
nit: avoid c-style casts.

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


More information about the Mlir-commits mailing list