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

Implement missing f128-related compiler_rt functions #495

Closed
tiehuis opened this Issue Sep 24, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@tiehuis
Member

tiehuis commented Sep 24, 2017

See https://github.com/llvm-project/llvm-project-20170507/tree/master/compiler-rt/lib/builtins for a reference.

A tentative list is as follows:

  • floatunditf
  • floatunsitf
  • floatuntitf
  • floatuntidf
  • floatuntisf
  • trunctfdf2
  • trunctfsf2
  • floattitf
  • floattidf
  • floattisf

The following example program should compile with no linking errors when complete.

fn check_floatunditf(a: u64) -> f128 { f128(a) }
fn check_floatunsitf(a: u32) -> f128 { f128(a) }
fn check_floatuntitf(a: u128) -> f128 { f128(a) }
fn check_floatuntidf(a: u128) -> f64 { f64(a) }
fn check_floatuntisf(a: u128) -> f32 { f32(a) }
fn check_trunctfdf2(a: f128) -> f64 { f64(a) }
fn check_trunctfsf2(a: f128) -> f32 { f32(a) }
fn check_floattitf(a: i128) -> f128 { f128(a) }
fn check_floattidf(a: i128) -> f64 { f64(a) }
fn check_floattisf(a: i128) -> f32 { f32(a) }

pub fn main() -> %void {
    _ = check_floatunditf(123);
    _ = check_floatunsitf(123);
    _ = check_floatuntitf(1237);
    _ = check_floatuntidf(1237);
    _ = check_floatuntisf(1237);
    _ = check_trunctfdf2(0.4);
    _ = check_trunctfsf2(0.4);
    _ = check_floattitf(123);
    _ = check_floattidf(123);
    _ = check_floattisf(123);
}

@tiehuis tiehuis self-assigned this Sep 24, 2017

@tiehuis tiehuis added the enhancement label Sep 24, 2017

@tiehuis tiehuis added this to the 0.2.0 milestone Sep 24, 2017

@skyfex

This comment has been minimized.

skyfex commented Dec 13, 2017

Possible missing built-ins when compiling for ARM with soft-float:

ld.lld: error: undefined symbol: __aeabi_memcpy
>>> referenced by test.zig:70 (C:\SW\zig\zig-nrf-demo\test.zig:70)
>>>               .\zig-cache\test.o:(main)

ld.lld: error: undefined symbol: __aeabi_fmul
>>> referenced by builtin.zig:75
>>>               .\zig-cache\builtin.o:(generic_fmod)

ld.lld: error: undefined symbol: __aeabi_fdiv
>>> referenced by builtin.zig:75
>>>               .\zig-cache\builtin.o:(generic_fmod)

ld.lld: error: undefined symbol: __aeabi_fmul
>>> referenced by builtin.zig:79
>>>               .\zig-cache\builtin.o:(generic_fmod)

ld.lld: error: undefined symbol: __aeabi_fmul
>>> referenced by builtin.zig:106
>>>               .\zig-cache\builtin.o:(generic_fmod)

ld.lld: error: undefined symbol: __aeabi_fmul
>>> referenced by builtin.zig:114
>>>               .\zig-cache\builtin.o:(generic_fmod)

ld.lld: error: undefined symbol: __aeabi_dmul
>>> referenced by builtin.zig:75
>>>               .\zig-cache\builtin.o:(generic_fmod.1)

ld.lld: error: undefined symbol: __aeabi_ddiv
>>> referenced by builtin.zig:75
>>>               .\zig-cache\builtin.o:(generic_fmod.1)

ld.lld: error: undefined symbol: __aeabi_dmul
>>> referenced by builtin.zig:79
>>>               .\zig-cache\builtin.o:(generic_fmod.1)

ld.lld: error: undefined symbol: __aeabi_dmul
>>> referenced by builtin.zig:106
>>>               .\zig-cache\builtin.o:(generic_fmod.1)

ld.lld: error: undefined symbol: __aeabi_dmul
>>> referenced by builtin.zig:114
>>>               .\zig-cache\builtin.o:(generic_fmod.1)

ld.lld: error: undefined symbol: __aeabi_fadd
>>> referenced by floor.zig:45 (C:\SW\zig\lib\zig\std\math\floor.zig:45)
>>>               .\zig-cache\builtin.o:(floor.0)

ld.lld: error: undefined symbol: __aeabi_fadd
>>> referenced by floor.zig:39 (C:\SW\zig\lib\zig\std\math\floor.zig:39)
>>>               .\zig-cache\builtin.o:(floor.0)

ld.lld: error: undefined symbol: __aeabi_fcmpeq
>>> referenced by floor.zig:26 (C:\SW\zig\lib\zig\std\math\floor.zig:26)
>>>               .\zig-cache\builtin.o:(floor.0)

ld.lld: error: undefined symbol: __aeabi_fadd
>>> referenced by ceil.zig:44 (C:\SW\zig\lib\zig\std\math\ceil.zig:44)
>>>               .\zig-cache\builtin.o:(ceil.0)

ld.lld: error: undefined symbol: __aeabi_fadd
>>> referenced by ceil.zig:37 (C:\SW\zig\lib\zig\std\math\ceil.zig:37)
>>>               .\zig-cache\builtin.o:(ceil.0)

ld.lld: error: undefined symbol: __aeabi_fcmpeq
>>> referenced by ceil.zig:26 (C:\SW\zig\lib\zig\std\math\ceil.zig:26)
>>>               .\zig-cache\builtin.o:(ceil.0)

ld.lld: error: undefined symbol: __aeabi_dcmpeq
>>> referenced by floor.zig:59 (C:\SW\zig\lib\zig\std\math\floor.zig:59)
>>>               .\zig-cache\builtin.o:(floor.0.2)

ld.lld: error: undefined symbol: __aeabi_dsub
>>> referenced by floor.zig:65 (C:\SW\zig\lib\zig\std\math\floor.zig:65)
>>>               .\zig-cache\builtin.o:(floor.0.2)

ld.lld: error: undefined symbol: __aeabi_dadd
>>> referenced by floor.zig:65 (C:\SW\zig\lib\zig\std\math\floor.zig:65)
>>>               .\zig-cache\builtin.o:(floor.0.2)
@tiehuis

This comment has been minimized.

Member

tiehuis commented Dec 13, 2017

Reference code can be found here: https://github.com/llvm-project/llvm-project-20170507/tree/master/compiler-rt/lib/builtins/arm

The arm builtins are all assembly and it would be nice if we could embed the llvm implementations directly with minimal changes. This brings up a question of what the idiomatic way of dealing with architecture specific specializations should be handled. It is likely that choosing the implementation is shifted from the build step (as in C) to a compile-time generative step in Zig. I think #462 would help here.

Also; progress report. I have the main trunc implementations here fairly complete bar some really close inaccuracies (which I suspect are failing due to bad f128 hex literal parsing). Will probably be low on the implementation till January, but expect a partial branch up shortly.

@skyfex

This comment has been minimized.

skyfex commented Dec 15, 2017

It seems that __umodsi3 is missing. That should perhaps be prioritized.

tiehuis added a commit that referenced this issue Dec 16, 2017

WIP
The main trunc implementation is fairly complete. The tests fail but are
fairly close which suggest to me a slight error instead on the hex
literal parsing side to compare.

See #495.

tiehuis added a commit that referenced this issue Dec 16, 2017

WIP
The main trunc implementation is fairly complete. The tests fail but are
fairly close which suggest to me a slight error instead on the hex
literal parsing side to compare.

See #495.
@andrewrk

This comment has been minimized.

Member

andrewrk commented Dec 19, 2017

I implemented #462. You can see examples of how to use it in bootstrap.zig and compiler_rt/index.zig.

@andrewrk andrewrk modified the milestones: 0.2.0, 0.3.0 Feb 28, 2018

tiehuis added a commit that referenced this issue Jun 28, 2018

tiehuis added a commit that referenced this issue Jun 30, 2018

@tiehuis tiehuis closed this in 9f48b2a Jun 30, 2018

@tiehuis tiehuis changed the title from Implement missing compiler_rt functions to Implement missing f128-related compiler_rt functions Jun 30, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment