1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
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)
|