Skip to content
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

compiler-rt: add aeabi_fcmp, comparesf2 #2299

Merged
merged 1 commit into from
Apr 21, 2019

Conversation

justinbalexander
Copy link
Contributor

No description provided.

std.math.inf(f32),
};

fn generateVector(comptime a: f32, comptime b: f32) TestVector {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make these function parameters comptime in order to use the function in the compile time initialization of the test_vectors array at line 91. The error said that the parameters needed to be comptime known, which they were because I was passing them in at compile time so I'm confused. I tried adding inline in front of the for loops and that didn't make a difference. Is this a bug?

In the documentation a function without comptime parameters is used at compile time but it is not contained within a block, which I suspect is the difference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For functions that return generics, the return type should be type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this function is supposed to return a generic? It's supposed to return a struct with the values filled out, not instantiate a struct type.

Am i understanding what you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the relevant documentation:

https://ziglang.org/documentation/master/#Compile-Time-Expressions

See the section:

const first_25_primes = firstNPrimes(25);
const sum_of_first_25_primes = sum(first_25_primes);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fast replies -- misread generateVector as genericVector!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug?

That does sound like a bug. Before I merge this let me play around with it a bit and see if it's something I can fix along with the merge.

@@ -636,10 +636,12 @@ set(ZIG_STD_FILES
"special/build_runner.zig"
"special/builtin.zig"
"special/compiler_rt.zig"
"special/compiler_rt/arm/aeabi_fcmp.zig"
Copy link
Contributor

@kristate kristate Apr 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a new directory for arm.
aeabi_fcmp doesn't seem to conflict with any other namespace.

Copy link
Contributor Author

@justinbalexander justinbalexander Apr 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following the directory structure of compiler-rt.

How close should the port of compiler-rt be?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opinion: up until now we don't have sub-directories, so I think it should be flat, unless re run into namespace conflicts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to like flat directory structures too. It's already pretty nested, but nesting it makes the intention to follow compiler-rt more explicit.

I would like to consider that we don't follow compiler-rt exactly. The hard floating point targets can just have the hard floating point instructions directly in the functions that provide them instead of branching all over the place to functions from other files. Compiler-rt has a complicated (seemingly to me) system for determining which version of a function gets linked. I think compiler-rt is a great starting point, but if we are already doing a port, I would like to be able to reorder/insert inline some stuff. That would make the port for hard float ABI progress at the same time as the soft float ABI. Of course that does make it harder to compare against future releases of compiler-rt.

//
// https://github.com/llvm/llvm-project/commit/d674d96bc56c0f377879d01c9d8dfdaaa7859cdb/compiler-rt/lib/builtins/arm/aeabi_fcmp.S

const compiler_rt_armhf_target = false; // TODO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be tied to builtin state and become a compile error if not possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would disable every hard floating point arm32 target because there is no support for hard floating point at all currently and release-fast/release-safe mode include even unused built-ins #2062. Such a change is beyond my area of responsibility. On a different compiler-rt pull request I did I just didn't add the assembly section at all. This time I marked it with a TODO, I'm not sure why I marked it this time.

Because the port of compiler-rt is so large, I think it might make more sense to incrementally add hard floating point support (my current plan), rather than just say it won't work at all. I am working my way through the soft floating point routines I need to work around #2062 first.

I know we have #1290, but maybe the hard floating point support on arm32 targets could be it's own issue so it doesn't get lost in the sauce. It also would document the plan to add it explicitly.

Can i request the opinion of @andrewrk?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even without TODOs in the code, its very easy to see what needs to be added from compiler-rt to support hard floating point. Just grep for COMPILER_RT_ARMHF_TARGET.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I think that should be a compiler error is that if the floatABI is set to hard and we don't deliver hard, then it seems like a fallacy. The @compileError should mention to set the floatABI to soft.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you re-enable the hard float abi once every function was complete? That is a lot of code to wait on.

It would also make testing the addition of each function more difficult as you would have to go through and comment out the compile errors in order to get a binary with the hard float routine you are working on in it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether or not hard float is desired is available via this logic:

const compiler_rt_armhf_target = switch (builtin.abi) { .gnueabihf, .eabihf, .musleabihf => true, else => false };

I get that compiler-rt is incomplete, especially for these targets, but aren't compile errors better than silently incorrect ABI?

@justinbalexander
Copy link
Contributor Author

justinbalexander commented Apr 18, 2019 via email

@justinbalexander
Copy link
Contributor Author

Haha, forget my last comment about v4t. My program had an illegal instruction for that architecture in it, hence the error. I had an inline asm block for testing that I forgot to remove. Also explains why I was unable to find any instruction mov r0, r0 anywhere in the compiler at all!

Everything else in my comment still stands.

@andrewrk andrewrk merged commit bb25f21 into ziglang:master Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants