Skip to content

Instantly share code, notes, and snippets.

@sueszli
Created January 4, 2026 16:00
Show Gist options
  • Select an option

  • Save sueszli/7a1931b2d6f4e113c31098703f2f332e to your computer and use it in GitHub Desktop.

Select an option

Save sueszli/7a1931b2d6f4e113c31098703f2f332e to your computer and use it in GitHub Desktop.
type conversions are correct. differences are purely cosmetic or related to generator defaults.
#!/bin/bash
set -e
set -o pipefail
# llvmlite
uv run python tests/backend/llvm/generate_types_ir.py --mlir > source.mlir
uv run python tests/backend/llvm/generate_types_ir.py --llvm > generated.ll
# mlir-translate
cat source.mlir | \
mlir-opt --convert-scf-to-cf --convert-func-to-llvm --convert-arith-to-llvm --convert-cf-to-llvm --reconcile-unrealized-casts | \
mlir-translate --mlir-to-llvmir > reference.ll
diff -u generated.ll reference.ll || true
--- generated.ll 2026-01-04 16:57:11
+++ reference.ll 2026-01-04 16:57:11
@@ -1,6 +1,8 @@
-; ModuleID = "LLVMDialectModule"
-target triple = "unknown-unknown-unknown"
-target datalayout = ""
+; ModuleID = 'LLVMDialectModule'
+source_filename = "LLVMDialectModule"
-declare void @"test_types"(i32 %".1", double %".2", float %".3", half %".4", <4 x i32> %".5", ptr %".6", [10 x i32] %".7", {i32, double} %".8")
+declare void @test_types(i32, double, float, half, <4 x i32>, ptr, [10 x i32], { i32, double })
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
; ModuleID = "LLVMDialectModule"
target triple = "unknown-unknown-unknown"
target datalayout = ""
declare void @"test_types"(i32 %".1", double %".2", float %".3", half %".4", <4 x i32> %".5", ptr %".6", [10 x i32] %".7", {i32, double} %".8")
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"
declare void @test_types(i32, double, float, half, <4 x i32>, ptr, [10 x i32], { i32, double })
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}
builtin.module {
func.func private @test_types(i32, f64, f32, f16, vector<4xi32>, !llvm.ptr, !llvm.array<10 x i32>, !llvm.struct<(i32, f64)>) -> ()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment