Advertisement
Zelatrix

Addition inside a function

Jun 30th, 2022
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. ; ModuleID = "/home/callum/fns2/funs_no_errors_v2/functions_no_errors/codegen.py"
  2. target triple = "x86_64-unknown-linux-gnu"
  3. target datalayout = ""
  4.  
  5. define void @"main"()
  6. {
  7. entry:
  8. %".2" = bitcast [6 x i8]* @"fstr" to i64*
  9. %".3" = call i64 @"myfun"()
  10. }
  11.  
  12. declare dso_local i32 @"printf"(i64* %".1", ...)
  13.  
  14. @"fstr" = internal constant [6 x i8] c"%lf \0a\00"
  15. define i64 @"myfun"()
  16. {
  17. function:
  18. %".2" = alloca double
  19. store double 0x4000000000000000, double* %".2"
  20. %".4" = alloca double
  21. store double 0x4008000000000000, double* %".4"
  22. %".6" = alloca double
  23. %".7" = load double, double* %".2"
  24. %".8" = load double, double* %".4"
  25. %".9" = fadd double %".7", %".8"
  26. store double %".9", double* %".6"
  27. %".11" = load double, double* %".6"
  28. %".12" = call i32 (i64*, ...) @"printf"(i64* %".2", double %".11")
  29. ret i64 0
  30. }
  31.  
  32. Traceback (most recent call last):
  33. File "main.py", line 105, in <module>
  34. codegen.create_ir()
  35. File "/home/callum/fns2/funs_no_errors_v2/functions_no_errors/codegen.py", line 668, in create_ir
  36. self._compile_ir()
  37. File "/home/callum/fns2/funs_no_errors_v2/functions_no_errors/codegen.py", line 658, in _compile_ir
  38. mod = self.binding.parse_assembly(llvm_ir)
  39. File "/home/callum/.local/lib/python3.8/site-packages/llvmlite/binding/module.py", line 25, in parse_assembly
  40. raise RuntimeError("LLVM IR parsing error\n{0}".format(errmsg))
  41. RuntimeError: LLVM IR parsing error
  42. <string>:29:48: error: '%.2' defined with type 'double*' but expected 'i64*'
  43. %".12" = call i32 (i64*, ...) @"printf"(i64* %".2", double %".11")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement