From cee712105850ac3385cd0091a923438167433f9f Mon Sep 17 00:00:00 2001
From: TSR Berry <20988865+TSRBerry@users.noreply.github.com>
Date: Sat, 8 Apr 2023 01:22:00 +0200
Subject: Move solution and projects to src
---
src/ARMeilleure/CodeGen/CompiledFunction.cs | 68 +++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100644 src/ARMeilleure/CodeGen/CompiledFunction.cs
(limited to 'src/ARMeilleure/CodeGen/CompiledFunction.cs')
diff --git a/src/ARMeilleure/CodeGen/CompiledFunction.cs b/src/ARMeilleure/CodeGen/CompiledFunction.cs
new file mode 100644
index 00000000..0560bf2e
--- /dev/null
+++ b/src/ARMeilleure/CodeGen/CompiledFunction.cs
@@ -0,0 +1,68 @@
+using ARMeilleure.CodeGen.Linking;
+using ARMeilleure.CodeGen.Unwinding;
+using ARMeilleure.Translation.Cache;
+using System;
+using System.Runtime.InteropServices;
+
+namespace ARMeilleure.CodeGen
+{
+ ///
+ /// Represents a compiled function.
+ ///
+ readonly struct CompiledFunction
+ {
+ ///
+ /// Gets the machine code of the .
+ ///
+ public byte[] Code { get; }
+
+ ///
+ /// Gets the of the .
+ ///
+ public UnwindInfo UnwindInfo { get; }
+
+ ///
+ /// Gets the of the .
+ ///
+ public RelocInfo RelocInfo { get; }
+
+ ///
+ /// Initializes a new instance of the struct with the specified machine code,
+ /// unwind info and relocation info.
+ ///
+ /// Machine code
+ /// Unwind info
+ /// Relocation info
+ internal CompiledFunction(byte[] code, UnwindInfo unwindInfo, RelocInfo relocInfo)
+ {
+ Code = code;
+ UnwindInfo = unwindInfo;
+ RelocInfo = relocInfo;
+ }
+
+ ///
+ /// Maps the onto the and returns a delegate of type
+ /// pointing to the mapped function.
+ ///
+ /// Type of delegate
+ /// A delegate of type pointing to the mapped function
+ public T Map()
+ {
+ return MapWithPointer(out _);
+ }
+
+ ///
+ /// Maps the onto the and returns a delegate of type
+ /// pointing to the mapped function.
+ ///
+ /// Type of delegate
+ /// Pointer to the function code in memory
+ /// A delegate of type pointing to the mapped function
+ public T MapWithPointer(out IntPtr codePointer)
+ {
+ codePointer = JitCache.Map(this);
+
+ return Marshal.GetDelegateForFunctionPointer(codePointer);
+ }
+ }
+}
\ No newline at end of file
--
cgit v1.2.3