Skip to content

Commit

Permalink
Fix: memcpy/memmov/memset intrinsics for AVR
Browse files Browse the repository at this point in the history
  • Loading branch information
ysbaddaden committed Apr 8, 2024
1 parent 3849df9 commit 07ab1c6
Showing 1 changed file with 43 additions and 31 deletions.
74 changes: 43 additions & 31 deletions src/intrinsics.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,57 @@ lib LibIntrinsics
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_debugtrap)] {% end %}
fun debugtrap = "llvm.debugtrap"

{% if flag?(:bits64) %}
{% if flag?(:avr) %}
{% if compare_versions(Crystal::LLVM_VERSION, "15.0.0") < 0 %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0i8.p0i8.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0i8.p0i8.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0i8.i64"(dest : Void*, val : UInt8, len : UInt64, is_volatile : Bool)
fun memcpy = "llvm.memcpy.p0i8.p0i8.i16"(dest : Void*, src : Void*, len : UInt16, is_volatile : Bool)
fun memmove = "llvm.memmove.p0i8.p0i8.i16"(dest : Void*, src : Void*, len : UInt16, is_volatile : Bool)
fun memset = "llvm.memset.p0i8.i16"(dest : Void*, val : UInt8, len : UInt16, is_volatile : Bool)
{% else %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0.p0.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0.p0.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0.i64"(dest : Void*, val : UInt8, len : UInt64, is_volatile : Bool)
fun memcpy = "llvm.memcpy.p0.p0.i16"(dest : Void*, src : Void*, len : UInt16, is_volatile : Bool)
fun memmove = "llvm.memmove.p0.p0.i16"(dest : Void*, src : Void*, len : UInt16, is_volatile : Bool)
fun memset = "llvm.memset.p0.i16"(dest : Void*, val : UInt8, len : UInt16, is_volatile : Bool)
{% end %}
{% else %}
{% if compare_versions(Crystal::LLVM_VERSION, "15.0.0") < 0 %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0i8.p0i8.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)
{% if flag?(:bits64) %}
{% if compare_versions(Crystal::LLVM_VERSION, "15.0.0") < 0 %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0i8.p0i8.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0i8.p0i8.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0i8.i64"(dest : Void*, val : UInt8, len : UInt64, is_volatile : Bool)
{% else %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0.p0.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0.p0.i64"(dest : Void*, src : Void*, len : UInt64, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0.i64"(dest : Void*, val : UInt8, len : UInt64, is_volatile : Bool)
{% end %}
{% else %}
{% if compare_versions(Crystal::LLVM_VERSION, "15.0.0") < 0 %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0i8.p0i8.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0i8.p0i8.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0i8.p0i8.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0i8.i32"(dest : Void*, val : UInt8, len : UInt32, is_volatile : Bool)
{% else %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0.p0.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0i8.i32"(dest : Void*, val : UInt8, len : UInt32, is_volatile : Bool)
{% else %}
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memcpy)] {% end %}
fun memcpy = "llvm.memcpy.p0.p0.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0.p0.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memmove)] {% end %}
fun memmove = "llvm.memmove.p0.p0.i32"(dest : Void*, src : Void*, len : UInt32, is_volatile : Bool)

{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0.i32"(dest : Void*, val : UInt8, len : UInt32, is_volatile : Bool)
{% if flag?(:interpreted) %} @[Primitive(:interpreter_intrinsics_memset)] {% end %}
fun memset = "llvm.memset.p0.i32"(dest : Void*, val : UInt8, len : UInt32, is_volatile : Bool)
{% end %}
{% end %}
{% end %}

Expand Down

0 comments on commit 07ab1c6

Please sign in to comment.