c3c icon indicating copy to clipboard operation
c3c copied to clipboard

@cputarget attribute

Open lerno opened this issue 3 years ago • 7 comments

Set the attribute, e.g. @cputarget("sse3") to compile a particular function for a particular featureset.

lerno avatar Sep 24 '22 22:09 lerno

Possibilities:

fn void foo() @target("sse4.1") { ... }
fn void foo() @target(sse4_1) { ... }

If string:

fn void foo() @target("v1+sse4.1+ssse3-mmx") { ... }
fn void foo() @target("cpu=v1,+sse4.1,+ssse3,-mmx") { ... }
fn void foo() @target(.cpu = "v1",.features = "sse4.1,+ssse3,-mmx") { ... }
fn void foo() @target("v1", "sse4.1", "ssse3", !"mmx") { ... }

If not:

fn void foo() @target(v1, sse4_1, ssse3, !mmx) { ... }
fn void foo() @target(v1: +sse4_1, +ssse3, -mmx) { ... }
fn void foo() @target(v1) @features(sse4_1, ssse3, !mmx) { ... }
fn void foo() @target(v1: sse4_1, ssse3, !mmx) { ... }

lerno avatar May 26 '23 21:05 lerno

I think it will useful for asm-functions only.

data-man avatar May 28 '23 11:05 data-man

It's intended for being able to write for multiple targets in the same compilation. ASM will always ignore instruction limitations.

lerno avatar May 30 '23 13:05 lerno

It's intended for being able to write for multiple targets in the same compilation.

I don't understand what it's for. To generate multiple binaries? Or will an application detect CPU's features in runtime and use optimized functions?

data-man avatar May 30 '23 14:05 data-man

For the latter, like you can use CPUID to switch between calling function A or B depending on what CPU is detected at startup.

lerno avatar May 30 '23 19:05 lerno

Yes. As a former Delphi/FreePascal developer I know that their runtime can use CPU capability detection to override memory manager fastmove functions. :)

data-man avatar May 31 '23 00:05 data-man

Yeah, so this was the idea. I had some thoughts of doing "target_clone" from GCC, but I think I limit myself to just "target" as there are some challenges making it work seamlessly.

lerno avatar May 31 '23 09:05 lerno