Patch adds support for fadd, fsub, fdiv, fmul and fcmp to IR interpreter.
~~~
OS Laboratory. Huawei RRI. Saint-Petersburg
Differential D126359
[LLDB] Add basic floating point ops to IR interpreter kpdev42 on May 25 2022, 1:39 AM. Authored by
Details Patch adds support for fadd, fsub, fdiv, fmul and fcmp to IR interpreter. ~~~ OS Laboratory. Huawei RRI. Saint-Petersburg
Diff Detail
Event TimelineComment Actions I know very little about the interpreter so someone else can comment there. Certainly seems like a useful change. Added some generic comments.
Comment Actions Will the floating point emulation be perfect compared to actually JITing the code? If we are going to enable this feature I would like to see tests that actually JIT code do the same operations somehow to verify that things match up with the IR interpreted results produce. The main reason we didn't include floating point code in the IR interpreter before is it is harder to make things match up with exactly how things are going to be run if it were JIT'ed into the process. On x86_64 or x64 there are floating point settings that can be changed and affect how operations happen in the current thread. The main example I always think of is how older debuggers would create recursive descent parsers and evaluate floating point operations using native floating point types. I believe that our APFloat classes can do everything correctly, but I would like to see tests that verify that we get the same results as if we were running actual code in the process. For this you can add an extra function to the lldb/test/API/lang/c/fpeval/main.c source like: typedef enum FloatOperation { add, subtract, multiply, ... }; double eval(double a, double b, FloatOperation op) { switch (op) { case add: return a+b; case subtract: return a-b; ... } }
Comment Actions Update test case so it compares JIT’ed and interpreted FP division results and also check operations on float type. Patch doesn’t implement long double, because IR interpreter currently doesn’t support instruction argument size of more than 64 bit which includes both fp128 and int128. This deserves a separate patch, I think |
Update this comment