[Mlir-commits] [mlir] [MLIR] Add llvm (debug) attributes to CAPI (PR #83992)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Wed Mar 6 01:35:59 PST 2024
================
@@ -225,12 +226,157 @@ static int testStructTypeCreation(MlirContext ctx) {
return 0;
}
+// CHECK-LABEL: testLLVMAttributes
+static void testLLVMAttributes(MlirContext ctx) {
+ fprintf(stderr, "testLLVMAttributes\n");
+
+ // CHECK: #llvm.linkage<internal>
+ mlirAttributeDump(mlirLLVMLinkageAttrGet(ctx, 0x1));
+ // CHECK: #llvm.cconv<ccc>
+ mlirAttributeDump(mlirLLVMCConvAttrGet(ctx, 0x0));
+ // CHECK: #llvm<comdat any>
+ mlirAttributeDump(mlirLLVMComdatAttrGet(ctx, 0x0));
+}
+
+// CHECK-LABEL: testDebugInfoAttributes
+static void testDebugInfoAttributes(MlirContext ctx) {
+ fprintf(stderr, "testDebugInfoAttributes\n");
+
+ MlirAttribute foo =
+ mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("foo"));
+ MlirAttribute bar =
+ mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("bar"));
+ MlirAttribute id = mlirDisctinctAttrCreate(foo);
+
+ // CHECK: #llvm.di_null_type
+ mlirAttributeDump(mlirLLVMDINullTypeAttrGet(ctx));
+ // CHECK: #llvm.di_basic_type<tag = DW_TAG_null, name = "foo", sizeInBits =
+ // 64, encoding = DW_ATE_signed>
+ MlirAttribute di_type = mlirLLVMDIBasicTypeAttrGet(ctx, 0, foo, 64, 0x5);
+ mlirAttributeDump(di_type);
+
+ MlirAttribute file = mlirLLVMDIFileAttrGet(ctx, foo, bar);
+
+ // CHECK: #llvm.di_file<"foo" in "bar">
+ mlirAttributeDump(file);
+
+ MlirAttribute compile_unit =
+ mlirLLVMDICompileUnitAttrGet(ctx, id, 0x1C, file, foo, false, 0x1);
+
+ // CHECK: #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
+ // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
+ // false, emissionKind = Full>
+ mlirAttributeDump(compile_unit);
+
+ MlirAttribute di_module = mlirLLVMDIModuleAttrGet(
+ ctx, file, compile_unit, foo,
+ mlirStringAttrGet(ctx, mlirStringRefCreateFromCString("")), bar, foo, 1,
+ 0);
+ // CHECK: #llvm.di_module<file = <"foo" in "bar">, scope =
+ // #llvm.di_compile_unit<id = distinct[0]<"foo">, sourceLanguage =
+ // DW_LANG_Rust, file = <"foo" in "bar">, producer = "foo", isOptimized =
+ // false, emissionKind = Full>, name = "foo", configMacros = "", includePath =
+ // "bar", apinotes = "foo", line = 1>
----------------
ftynse wrote:
Please format this to be readable and actually check what needs to be checked. FileCheck has many useful directives: https://llvm.org/docs/CommandGuide/FileCheck.html
Specifically, comments lines _not_ starting with `CHECK` are not actually checked! There is also a way to capture previously matched strings and reuse them below.
https://github.com/llvm/llvm-project/pull/83992
More information about the Mlir-commits
mailing list