-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Float16T mismatch casts (LLVM-325) #91
Comments
Hi @kassane ! What llvm-project branch do you use? LLVM 17.x release branch? I suppose that floating point support has not been upstreamed yet. You can try using our repo instead (https://github.com/espressif/llvm-project/tree/xtensa_release_17.0.1). |
I'm using this branch exactly |
@kassane , thank you very much for report, we will investigate the problem. |
Do you know if xtensa enables conversion intrinsic fp16? Missing on:
search link: https://github.com/search?q=repo%3Aespressif%2Fllvm-project%20FP16Conversion&type=code |
Hi @gerekon, LLVM Emit Object... LLVM ERROR: Cannot select: 0x7d7a4f7d0770: f32 = fp16_to_fp 0x7d7a50359440, float_from_int.zig:46:9 @[ floatsihf.zig:11:24 ]
0x7d7a50359440: i32 = or 0x7d7a4f84cfc0, 0x7d7a503598a0, float_from_int.zig:46:9 @[ floatsihf.zig:11:24 ]
0x7d7a4f84cfc0: i32 = AssertZext 0x7d7a50359d70, ValueType:ch:i16, float_from_int.zig:46:9 @[ floatsihf.zig:11:24 ]
0x7d7a50359d70: i32,ch = CopyFromReg 0x7d7a4f9973e0, Register:i32 %1, float_from_int.zig:46:9 @[ floatsihf.zig:11:24 ]
0x7d7a4f0c40b0: i32 = Register %1
0x7d7a503598a0: i32 = XtensaISD::PCREL_WRAPPER TargetConstantPool:i32<i32 31744> 0
0x7d7a4f0ca650: i32 = TargetConstantPool<i32 31744> 0
In function: __floatsihf
`` |
ok. Sorry for confusion. Do you have a simple scenario to reproduce this? |
No worries! Make anywhere freestanding example for make executable. void _start(){} Command: # CPU = esp8266**|esp32s3|esp32|esp32s2*|cnl
# *: no issue
# **: no tested yet
# clang cli
zig cc start.c -target xtensa-freestanding-none -mcpu=CPU
# or zig cli
zig build-exe start.c -target xtensa-freestanding-none -mcpu=CPU
# if add -fno-compiler-rt no issue for build-exe or build-lib -dynamic
# replace build-exe to build-lib [staticlib, default] or build-obj, no get error (no compiler-rt by default) |
Ok. Thanks. static volatile __fp16 s_val;
int main()
{
int ival = 5;
s_val = ival;
return 0;
} and got
Looks like the same problem. |
@andreisfr @sstefan1 Do you have any idea? |
@maciej-czekaj Added floating support in #89. And have float intrinsics |
@kassane Ok. Looks like I made a step toward solution. Now
But that can be specific to my toolchain build only. But in any case implemented fix makes use of software conversion functions. In future we will need to lower this to HW instructions if possible. |
Last commit I attempted to turn false gnu_fp16 (similar to riscv32), but didn't get a different result.
Indeed. lld (builtin), zig doesn't allow
Ok. |
In our toolchain problem is solved using GNU ld by passing |
@gerekon , Before applying your current patch, the new error mentioned in the PR occurred when removing the # -mcpu=<esp32|esp32s3>-fp
error: <unknown>:0: Undefined temporary symbol .LBB385_2
# -mcpu=esp32-fp-s32c1i
lld errors: undefined references... Your patch applied: |
I was trying to understand the Xtensa floating point alignment, but I got an llvm-ir error about converting
floatFromInt
onesp32
|esp32s3
|cnl
targets, onlyesp32s2
had no problem.I could work around this problem (not solved) by removing the
fp
(Single FP) ands32c1i
or by removing the compiler-rt.I didn't see any reference to
f16
oru16
in the Xtensa target in the llvm-17.0.1 source.This issue only occurs when creating an executable. Unlike static objects and libraries.
Reference
floatFromInt
cast kassane/zig-espressif-bootstrap#2The text was updated successfully, but these errors were encountered: