ytljit 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/ext/ytljit.h CHANGED
@@ -67,7 +67,7 @@ struct rb_iseq_struct {
67
67
  VALUE name; /* String: iseq name */
68
68
  VALUE filename; /* file information where this sequence from */
69
69
  VALUE filepath; /* real file path or nil */
70
- VALUE *iseq; /* iseq (insn number and openrads) */
70
+ VALUE *iseq; /* iseq (insn number and operands) */
71
71
  VALUE *iseq_encoded; /* encoded iseq */
72
72
  unsigned long iseq_size;
73
73
  VALUE mark_ary; /* Array: includes operands which should be GC marked */
@@ -91,7 +91,7 @@ struct rb_iseq_struct {
91
91
  * argument information
92
92
  *
93
93
  * def m(a1, a2, ..., aM, # mandatory
94
- * b1=(...), b2=(...), ..., bN=(...), # optinal
94
+ * b1=(...), b2=(...), ..., bN=(...), # optional
95
95
  * *c, # rest
96
96
  * d1, d2, ..., dO, # post
97
97
  * &e) # block
data/lib/ytljit/asmext.rb CHANGED
@@ -136,6 +136,26 @@ module YTLJit
136
136
  return [rcode, TypedData.new(rtype, dst)]
137
137
  end
138
138
 
139
+ when :push
140
+ case dst
141
+ when OpRegXMM
142
+ rcode = ""
143
+ rcode += sub(SPR, 8)
144
+ rcode += mov(INDIRECT_SPR, dst)
145
+
146
+ return rcode
147
+ end
148
+
149
+ when :pop
150
+ case dst
151
+ when OpRegXMM
152
+ rcode = ""
153
+ rcode += mov(dst, INDIRECT_SPR)
154
+ rcode += add(SPR, 8)
155
+
156
+ return rcode
157
+ end
158
+
139
159
  when :seta, :setae, :setb, :setbe, :setl, :setle, :setg, :setge,
140
160
  :setna, :setnae, :setnb, :setnbe, :setnc, :setnle,
141
161
  :setno, :seto, :setz, :setnz
@@ -14,6 +14,9 @@ module YTLJit
14
14
  when :c
15
15
  ARGPOS2REG
16
16
 
17
+ when :cfloat
18
+ ARGPOS2FREG
19
+
17
20
  when :ytl
18
21
  []
19
22
 
@@ -29,6 +32,9 @@ module YTLJit
29
32
  def argpos2reg
30
33
  case @abi_kind
31
34
  when :c
35
+ ARGPOS2REG
36
+
37
+ when :cfloat
32
38
  ARGPOS2FREG
33
39
 
34
40
  when :ytl
@@ -81,13 +87,15 @@ module YTLJit
81
87
 
82
88
  if @no < argpos2reg.size then
83
89
  argreg = argpos2reg[@no]
84
-
90
+
91
+ =begin
85
92
  # for nested function call. need save previous reg.
86
93
  if asm.retry_mode != :change_op and
87
94
  fainfo.used_arg_tab.last[@no] then
88
95
  asm.update_state(gen.push(argreg))
89
96
  fainfo.push argreg
90
97
  end
98
+ =end
91
99
  code += asm.update_state(gen.mov(argreg, src))
92
100
  else
93
101
  # spilled reg
@@ -165,7 +173,7 @@ module YTLJit
165
173
  code += @asm.update_state(mov(RAX, OpImmidiate32.new(argnum)))
166
174
  code += @asm.update_state(call(addr))
167
175
  callpos = @asm.current_address - @asm.output_stream.base_address
168
- if @asm.retry_mode != :change_op then
176
+ if @asm.retry_mode == :change_op then
169
177
  return [code, callpos]
170
178
  end
171
179
 
@@ -7,7 +7,7 @@ module YTLJit
7
7
  when :c
8
8
  AsmType::MACHINE_WORD.size
9
9
 
10
- when :ytl
10
+ when :ytl, :cfloat
11
11
  8
12
12
  end
13
13
  end
@@ -92,7 +92,10 @@ module YTLJit
92
92
  TMPR = OpEAX.instance
93
93
  TMPR2 = OpEDX.instance
94
94
  TMPR3 = OpECX.instance
95
+ DBLLOR = OpEAX.instance
96
+ DBLHIR = OpEDX.instance
95
97
  RETR = OpEAX.instance
98
+ RETFR = XMM0
96
99
  SPR = OpESP.instance
97
100
  BPR = OpEBP.instance
98
101
  when /x86_64/
@@ -101,7 +104,10 @@ module YTLJit
101
104
  # TMPR3 = OpRCX.instance
102
105
  TMPR2 = OpR10.instance
103
106
  TMPR3 = OpR11.instance
107
+ DBLLOR = OpRAX.instance
108
+ DBLHIR = OpRDX.instance
104
109
  RETR = OpRAX.instance
110
+ RETFR = XMM0
105
111
  SPR = OpRSP.instance
106
112
  BPR = OpRBP.instance
107
113
  end
@@ -114,7 +120,7 @@ module YTLJit
114
120
  hash[key] = FunctionArgumentInt.new(key, :c)
115
121
  }
116
122
  FUNC_FLOAT_ARG = Hash.new {|hash, key|
117
- hash[key] = FunctionArgumentFloat.new(key, :c)
123
+ hash[key] = FunctionArgumentFloat.new(key, :cfloat)
118
124
  }
119
125
  FUNC_ARG_YTL = Hash.new {|hash, key|
120
126
  hash[key] = FunctionArgumentInt.new(key, :ytl)
@@ -1193,20 +1193,20 @@ module YTLJit
1193
1193
  case dst
1194
1194
  when OpReg8, OpMem8
1195
1195
  if src == nil then
1196
- modseq, modfmt = modrm(:imul, 5, dst, dst, 5)
1196
+ modseq, modfmt = modrm(:imul, 5, dst, dst, src)
1197
1197
  return ([0xF6] + modseq).pack("C#{modfmt}")
1198
1198
  end
1199
1199
 
1200
1200
  when OpIndirect, OpMem32
1201
- if src != nil then
1202
- modseq, modfmt = modrm(:imul, 5, dst, dst, 5)
1203
- return (rexseq + [0xF7] + modseq).pack("#{rexfmt}C#(modfmt}")
1201
+ if src == nil then
1202
+ modseq, modfmt = modrm(:imul, 5, dst, dst, src)
1203
+ return (rexseq + [0xF7] + modseq).pack("#{rexfmt}C#{modfmt}")
1204
1204
  end
1205
1205
 
1206
1206
  when OpReg32, OpReg64
1207
1207
  case src
1208
1208
  when nil
1209
- modseq, modfmt = modrm(:imul, 5, dst, dst, 5)
1209
+ modseq, modfmt = modrm(:imul, 5, dst, dst, src)
1210
1210
  return (rexseq + [0xF7] + modseq).pack("#{rexfmt}C#(modfmt}")
1211
1211
 
1212
1212
  when OpReg32, OpMem32, OpIndirect, OpReg64
@@ -1250,6 +1250,48 @@ module YTLJit
1250
1250
  return nosupported_addressing_mode(:imul, dst, src, src2)
1251
1251
  end
1252
1252
 
1253
+ def idiv(src)
1254
+ rexseq, rexfmt = rex(src, nil)
1255
+ case src
1256
+ when OpReg8, OpMem8
1257
+ modseq, modfmt = modrm(:idiv, 7, src, src, nil)
1258
+ return ([0xF6] + modseq).pack("C#{modfmt}")
1259
+
1260
+ when OpIndirect, OpMem32
1261
+ modseq, modfmt = modrm(:idiv, 7, src, src, nil)
1262
+ return (rexseq + [0xF7] + modseq).pack("#{rexfmt}C#{modfmt}")
1263
+
1264
+ when OpReg32, OpReg64
1265
+ modseq, modfmt = modrm(:idiv, 7, src, src, nil)
1266
+ return (rexseq + [0xF7] + modseq).pack("#{rexfmt}C#{modfmt}")
1267
+ end
1268
+
1269
+ return nosupported_addressing_mode(:idiv, src, nil, nil)
1270
+ end
1271
+
1272
+ def neg(src)
1273
+ rexseq, rexfmt = rex(src, nil)
1274
+ case src
1275
+ when OpReg8, OpMem8
1276
+ modseq, modfmt = modrm(:neg, 3, src, src, nil)
1277
+ return ([0xF6] + modseq).pack("C#{modfmt}")
1278
+
1279
+ when OpIndirect, OpMem32
1280
+ modseq, modfmt = modrm(:neg, 3, src, src, nil)
1281
+ return (rexseq + [0xF7] + modseq).pack("#{rexfmt}C#{modfmt}")
1282
+
1283
+ when OpReg32, OpReg64
1284
+ modseq, modfmt = modrm(:neg, 3, src, src, nil)
1285
+ return (rexseq + [0xF7] + modseq).pack("#{rexfmt}C#{modfmt}")
1286
+ end
1287
+
1288
+ return nosupported_addressing_mode(:neg, src, nil, nil)
1289
+ end
1290
+
1291
+ def cdq
1292
+ [0x99].pack("C")
1293
+ end
1294
+
1253
1295
  def movss(dst, src)
1254
1296
  common_movssd(dst, src, 0xF3, :movss)
1255
1297
  end
data/lib/ytljit/util.rb CHANGED
@@ -61,3 +61,4 @@ class Float
61
61
  [self].pack('d').unpack('q')[0]
62
62
  end
63
63
  end
64
+