From 97d095a0556e19cdc12eab6f5e5aa5920273e461 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 10 Jul 2024 16:09:35 -0400 Subject: [PATCH] xo-jit: ++ HOWTO --- HOWTO | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/HOWTO b/HOWTO index 6965105f..c3eed238 100644 --- a/HOWTO +++ b/HOWTO @@ -43,3 +43,30 @@ mp.machgen_current_module() fn=mp.lookup_fn('int (*)(int)', 'sq') fn(16) # -> 256 + +** to figure out what 'IR should look like' for something simple + + write some c++: + + #include + + struct env_type { + env_type * parent; + env_type * (*unwind)(env_type *, int); + }; + + double wrap_sqrt(env_type * env, double x) { + return ::sqrt(x); + } + + int main() { + wrap_sqrt(nullptr, 2.0); + } + + compile to emit IR + + $ clang -cc1 ex_cpp.cpp -emit-llvm + + inspect + + ex_cpp.ll