Skip to content
This repository has been archived by the owner on Jan 29, 2022. It is now read-only.

Commit

Permalink
Begin to create target definition system of our own.
Browse files Browse the repository at this point in the history
Inspiration taken heavily from Rust.
  • Loading branch information
keplersj committed May 21, 2016
1 parent e4e35d0 commit cc2c0f8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/compiler/crystal/codegen/target.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
abstract struct Crystal::Target
@triple: String?
@endian: String?
@pointer_width: String?
@os: String?
@env: String?
@vendor: String?
@arch: String?
@data_layout: String?
@option: Options?
end

abstract struct Crystal::Target::Options
@linker: String = ENV["CC"]? || "cc"
@ar: String = ENV["AR"]? || "ar"
@dynamic_linking: Bool = false
@executables: Bool = false
@executable_suffix: String = ""
end
23 changes: 23 additions & 0 deletions src/compiler/crystal/codegen/target/asmjs_unknown_emscripten.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require "../target"

module Crystal
struct Target::ASMJS::Emscripten < Target
@triple = "asmjs-unknown-target"
@endian = "little"
@pointer_width = "32"
@os = "emscripten"
@env = ""
@vendor = "unknown"
@data_layout = "e-p:32:32-i64:64-v128:32:128-n32-S128"
@arch = "asmjs"
@option = Options.new

struct Options < Target::Options
@linker = "emcc"
@ar = "emar"
@dynamic_linking = false
@executables = true
@executable_suffix = ".js"
end
end
end
15 changes: 15 additions & 0 deletions src/compiler/crystal/codegen/target/x86_64_apple_darwin.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "../target"


module Crystal
struct Target::X86_64::Apple::Darwin < Target
triple = "x86_64-apple-darwin"
endian = "little"
pointer_width = "64"
data_layout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
arch = "x86_64"
os = "macos"
env = ""
vendor = "apple"
end
end

0 comments on commit cc2c0f8

Please sign in to comment.