From 19bad9d05b723980551eb203715456e700b06002 Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Mon, 26 Mar 2018 00:44:52 +0200
Subject: [PATCH 1/2] Fix codegen/asm specs to run x86 ASM only on x86_64 and
 i686

See https://github.com/crystal-lang/crystal/pull/5861#issuecomment-376006679

Upstream-Issue: https://github.com/crystal-lang/crystal/pull/5866
---
 spec/compiler/codegen/asm_spec.cr | 59 ++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 28 deletions(-)

diff --git a/spec/compiler/codegen/asm_spec.cr b/spec/compiler/codegen/asm_spec.cr
index 6fe8cbc26e..bc68d0f0cc 100644
--- a/spec/compiler/codegen/asm_spec.cr
+++ b/spec/compiler/codegen/asm_spec.cr
@@ -1,34 +1,37 @@
 require "../../spec_helper"
 
 describe "Code gen: asm" do
-  it "codegens without inputs" do
-    run(%(
-      dst = uninitialized Int32
-      asm("mov $$1234, $0" : "=r"(dst))
-      dst
-      )).to_i.should eq(1234)
-  end
+  # TODO: arm asm tests
+  {% if flag?(:i686) || flag?(:x86_64) %}
+    it "codegens without inputs" do
+      run(%(
+        dst = uninitialized Int32
+        asm("mov $$1234, $0" : "=r"(dst))
+        dst
+        )).to_i.should eq(1234)
+    end
 
-  it "codegens with one input" do
-    run(%(
-      src = 1234
-      dst = uninitialized Int32
-      asm("mov $1, $0" : "=r"(dst) : "r"(src))
-      dst
-      )).to_i.should eq(1234)
-  end
+    it "codegens with one input" do
+      run(%(
+        src = 1234
+        dst = uninitialized Int32
+        asm("mov $1, $0" : "=r"(dst) : "r"(src))
+        dst
+        )).to_i.should eq(1234)
+    end
 
-  it "codegens with two inputs" do
-    run(%(
-      c = uninitialized Int32
-      a = 20
-      b = 22
-      asm(
-        "add $2, $0"
-           : "=r"(c)
-           : "0"(a), "r"(b)
-        )
-      c
-      )).to_i.should eq(42)
-  end
+    it "codegens with two inputs" do
+      run(%(
+        c = uninitialized Int32
+        a = 20
+        b = 22
+        asm(
+          "add $2, $0"
+             : "=r"(c)
+             : "0"(a), "r"(b)
+          )
+        c
+        )).to_i.should eq(42)
+    end
+  {% end %}
 end

From bde57387cf7239dea152b870471500da8faaec6f Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Mon, 26 Mar 2018 00:48:14 +0200
Subject: [PATCH 2/2] Fix codegen/sizeof specs for aarch64 (and other 64bit
 arches)

See https://github.com/crystal-lang/crystal/pull/5861#issuecomment-376006679
---
 spec/compiler/codegen/sizeof_spec.cr | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/spec/compiler/codegen/sizeof_spec.cr b/spec/compiler/codegen/sizeof_spec.cr
index 2f703abd1c..bc4a2d5b9a 100644
--- a/spec/compiler/codegen/sizeof_spec.cr
+++ b/spec/compiler/codegen/sizeof_spec.cr
@@ -48,7 +48,7 @@ describe "Code gen: sizeof" do
     # be struct { 8 bytes, 8 bytes }.
     #
     # In 32 bits structs are aligned to 4 bytes, so it remains the same.
-    {% if flag?(:x86_64) %}
+    {% if flag?(:bits64) %}
       size.should eq(16)
     {% else %}
       size.should eq(12)
@@ -137,7 +137,7 @@ describe "Code gen: sizeof" do
       sizeof(typeof(foo))
       )).to_i
 
-    {% if flag?(:x86_64) %}
+    {% if flag?(:bits64) %}
       size.should eq(8)
     {% else %}
       size.should eq(4)
