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

Add LLVM.init_native_target and LLVM.init_all_targets #15466

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/llvm.cr
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,30 @@ module LLVM
{% end %}
end

def self.init_native_target : Nil
{% if flag?(:i386) || flag?(:x86_64) %}
init_x86
{% elsif flag?(:aarch64) %}
init_aarch64
{% elsif flag?(:arm) %}
init_arm
{% elsif flag?(:wasm32) %}
init_webassembly
{% elsif flag?(:avr) %}
init_avr
{% else %}
{% raise "Unsupported platform" %}
{% end %}
HertzDevil marked this conversation as resolved.
Show resolved Hide resolved
end

def self.init_all_targets : Nil
{% for target in %i(x86 aarch64 arm avr webassembly) %}
{% if LibLLVM::BUILT_TARGETS.includes?(target) %}
init_{{ target.id }}
{% end %}
{% end %}
end

@[Deprecated("This method has no effect")]
def self.start_multithreaded : Bool
if multithreaded?
Expand Down
2 changes: 1 addition & 1 deletion src/llvm/target.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct LLVM::Target
end

def self.first : self
first? || raise "No LLVM targets available (did you forget to invoke LLVM.init_x86?)"
first? || raise "No LLVM targets available (did you forget to invoke LLVM.init_native_target?)"
end

def self.first? : self?
Expand Down