aarch64 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df38bc865f977ddb5498fa1616a56829303b3b6d34230b02cd9edf9af4a3c70e
4
- data.tar.gz: 6161450d59e1e419f3e5935a2f213029e7fe68866bfaf0911520ae43465d7e6d
3
+ metadata.gz: d4148547f29912a9cea29d06ba88ebafff8ffd701b187ab9aa3a0b4ee1d309b0
4
+ data.tar.gz: dc7b08ee7be2e57acfb2d5181d374a9baf6806be65dee0318cd95417349a2cfc
5
5
  SHA512:
6
- metadata.gz: 61bdd48efacc2d2425833351baf51c47f8170494857c8579e5cdd15d0763991fcbf2e277bef9819ae578e89c1535042411fc03304cb35f79c43741c066aa3144
7
- data.tar.gz: 59a47c392685565777aadc2d970bb3dbfed4e3b5c70394e4f2116b9dd1410192fdf4917d9495472dca9b4ed3c300aed832648e760b745fc0d25bf3f46843ca78
6
+ metadata.gz: f215a62f40c5ad36e81ec7d1d1110e21639ab0b19950283f4b5dbde46e5b26c17081a527d41dca600c4a8e8aa07eb0fc5f1f21a68d4425084c5eaf94de8baaef
7
+ data.tar.gz: 4d0027eeb4a45b5d77e409b2fc343d59ec19548b4874f1c2e61bfeabcecb991ee2527a0969133f1029aa13e2623361bef3e6637ed65f9617001f5709ab31b99a
@@ -1,3 +1,3 @@
1
1
  module AArch64
2
- VERSION = "2.0.1"
2
+ VERSION = "2.0.2"
3
3
  end
data/lib/aarch64.rb CHANGED
@@ -10,6 +10,7 @@ module AArch64
10
10
  alias sp? sp
11
11
  alias zr? zr
12
12
  def integer?; false; end
13
+ def register?; true; end
13
14
  end
14
15
 
15
16
  class XRegister < Register
@@ -22,6 +23,7 @@ module AArch64
22
23
  def opc; 0b10; end
23
24
  def opc2; 0b11; end
24
25
  def opc3; 0b10; end
26
+ def name; "X#{to_i}"; end
25
27
  end
26
28
 
27
29
  class WRegister < Register
@@ -34,6 +36,7 @@ module AArch64
34
36
  def opc; 0b11; end
35
37
  def opc2; 0b10; end
36
38
  def opc3; 0b00; end
39
+ def name; "W#{to_i}"; end
37
40
  end
38
41
 
39
42
  31.times { |i|
@@ -2715,14 +2718,26 @@ module AArch64
2715
2718
  if label.integer?
2716
2719
  label = wrap_offset_with_label label
2717
2720
  end
2718
- a TBNZ.new(rt, imm, label, rt.sf)
2721
+
2722
+ sf = 0
2723
+ if imm > 31
2724
+ sf = 1
2725
+ imm -= 32
2726
+ end
2727
+ a TBNZ.new(rt, imm, label, sf)
2719
2728
  end
2720
2729
 
2721
2730
  def tbz rt, imm, label
2722
2731
  if label.integer?
2723
2732
  label = wrap_offset_with_label label
2724
2733
  end
2725
- a TBZ.new(rt, imm, label, rt.sf)
2734
+
2735
+ sf = 0
2736
+ if imm > 31
2737
+ sf = 1
2738
+ imm -= 32
2739
+ end
2740
+ a TBZ.new(rt, imm, label, sf)
2726
2741
  end
2727
2742
 
2728
2743
  def tlbi tlbi_op, xt = XZR
@@ -2827,6 +2842,12 @@ module AArch64
2827
2842
  a YIELD.new
2828
2843
  end
2829
2844
 
2845
+ ##
2846
+ # Yields the offset in the instructions
2847
+ def patch_location
2848
+ yield @insns.length * 4
2849
+ end
2850
+
2830
2851
  def write_to io
2831
2852
  io.write to_binary
2832
2853
  end
@@ -2774,6 +2774,12 @@ class BaseInstructionsTest < AArch64::Test
2774
2774
  end
2775
2775
  end
2776
2776
 
2777
+ def test_ldb_x30
2778
+ assert_bytes [0xfe,0x7b,0xc1,0xa8] do |asm|
2779
+ asm.ldp x30, x30, [sp], 16
2780
+ end
2781
+ end
2782
+
2777
2783
  def test_LDP_gen
2778
2784
  # LDP <Wt1>, <Wt2>, [<Xn|SP>], #<imm>
2779
2785
  # LDP <Xt1>, <Xt2>, [<Xn|SP>], #<imm>
@@ -8866,6 +8872,18 @@ class BaseInstructionsTest < AArch64::Test
8866
8872
  asm.tbnz w3, 5, label
8867
8873
  asm.put_label label
8868
8874
  end
8875
+
8876
+ assert_one_insn "tbnz x0, #0x20, #4" do |asm|
8877
+ label = asm.make_label :foo
8878
+ asm.tbnz x0, 32, label
8879
+ asm.put_label label
8880
+ end
8881
+
8882
+ assert_one_insn "tbnz w0, #0, #4" do |asm|
8883
+ label = asm.make_label :foo
8884
+ asm.tbnz x0, 0, label
8885
+ asm.put_label label
8886
+ end
8869
8887
  end
8870
8888
 
8871
8889
  def test_TBZ
@@ -8878,6 +8896,12 @@ class BaseInstructionsTest < AArch64::Test
8878
8896
  asm.tbz w3, 5, label
8879
8897
  asm.put_label label
8880
8898
  end
8899
+
8900
+ assert_one_insn "tbz x0, #0x20, #4" do |asm|
8901
+ label = asm.make_label :foo
8902
+ asm.tbz x0, 32, label
8903
+ asm.put_label label
8904
+ end
8881
8905
  end
8882
8906
 
8883
8907
  def test_TLBI_SYS
data/test/dsl_test.rb CHANGED
@@ -1,6 +1,20 @@
1
1
  require "helper"
2
2
 
3
3
  class DSLTest < AArch64::Test
4
+ def test_patch_location
5
+ asm = AArch64::Assembler.new
6
+ found = nil
7
+ asm.pretty do
8
+ asm.mov x0, x1
9
+ asm.patch_location { |loc| found = loc }
10
+ asm.movz x2, 5
11
+ end
12
+
13
+ bytes = asm.to_binary
14
+ assert_equal 8, bytes.bytesize
15
+ assert_equal 4, found
16
+ end
17
+
4
18
  def test_dsl_has_methods
5
19
  assert_bytes [0x9f,0x08,0x25,0xab] do |asm|
6
20
  asm.pretty do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aarch64
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-19 00:00:00.000000000 Z
11
+ date: 2023-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hatstone