Skip to content

Commit 82949f2

Browse files
committed
support addsd/subsd/divsd
1 parent 3040175 commit 82949f2

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

rxbyak/rxbyak.cpp

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,30 @@ class RXbyakGenerator : public Xbyak::CodeGenerator {
141141
movq(addr, reg);
142142
}
143143

144+
void _addsd(const VALUE& xmm_dest, const VALUE& xmm_src) {
145+
const Xbyak::Xmm& dest = id2xmmx(xmm_dest);
146+
const Xbyak::Xmm& src = id2xmmx(xmm_src);
147+
addsd(dest, src);
148+
}
149+
150+
void _subsd(const VALUE& xmm_dest, const VALUE& xmm_src) {
151+
const Xbyak::Xmm& dest = id2xmmx(xmm_dest);
152+
const Xbyak::Xmm& src = id2xmmx(xmm_src);
153+
subsd(dest, src);
154+
}
155+
144156
void _mulsd(const VALUE& xmm_dest, const VALUE& xmm_src) {
145157
const Xbyak::Xmm& dest = id2xmmx(xmm_dest);
146158
const Xbyak::Xmm& src = id2xmmx(xmm_src);
147159
mulsd(dest, src);
148160
}
149161

162+
void _divsd(const VALUE& xmm_dest, const VALUE& xmm_src) {
163+
const Xbyak::Xmm& dest = id2xmmx(xmm_dest);
164+
const Xbyak::Xmm& src = id2xmmx(xmm_src);
165+
divsd(dest, src);
166+
}
167+
150168
void _ret(int imm = 0) { ret(imm); }
151169
void _aaa() { aaa(); }
152170
void _aad() { aad(); }
@@ -283,14 +301,32 @@ VALUE RXbyak_movq(VALUE self, const VALUE a1, const VALUE a2) {
283301
return Qnil;
284302
}
285303

286-
extern "C"
287-
VALUE RXbyak_mulsd(VALUE self, VALUE a1, VALUE a2) {
288-
RXbyakGenerator* rx;
289-
Data_Get_Struct(self, RXbyakGenerator, rx);
304+
305+
extern "C" VALUE RXbyak_addsd(VALUE self, VALUE a1, VALUE a2) {
306+
RXBYAK_GENERATOR(self, rx);
307+
rx->_addsd(a1, a2);
308+
return Qnil;
309+
}
310+
311+
extern "C" VALUE RXbyak_subsd(VALUE self, VALUE a1, VALUE a2) {
312+
RXBYAK_GENERATOR(self, rx);
313+
rx->_subsd(a1, a2);
314+
return Qnil;
315+
}
316+
317+
extern "C" VALUE RXbyak_mulsd(VALUE self, VALUE a1, VALUE a2) {
318+
RXBYAK_GENERATOR(self, rx);
290319
rx->_mulsd(a1, a2);
291320
return Qnil;
292321
}
293322

323+
extern "C" VALUE RXbyak_divsd(VALUE self, VALUE a1, VALUE a2) {
324+
RXBYAK_GENERATOR(self, rx);
325+
rx->_divsd(a1, a2);
326+
return Qnil;
327+
}
328+
329+
294330
extern "C" VALUE RXbyak_ret(VALUE self) {
295331
RXBYAK_GENERATOR(self, rx);
296332
rx->_ret();
@@ -567,7 +603,10 @@ void Init_RXbyak(void) {
567603

568604
rb_define_method(rb_cRXbyak, "mov", RB_FUNC(RXbyak_mov), 2);
569605
rb_define_method(rb_cRXbyak, "movq", RB_FUNC(RXbyak_movq), 2);
606+
rb_define_method(rb_cRXbyak, "addsd", RB_FUNC(RXbyak_addsd), 2);
607+
rb_define_method(rb_cRXbyak, "subsd", RB_FUNC(RXbyak_subsd), 2);
570608
rb_define_method(rb_cRXbyak, "mulsd", RB_FUNC(RXbyak_mulsd), 2);
609+
rb_define_method(rb_cRXbyak, "divsd", RB_FUNC(RXbyak_divsd), 2);
571610
rb_define_method(rb_cRXbyak, "ret", RB_FUNC(RXbyak_ret), 0);
572611

573612
rb_define_method(rb_cRXbyak, "aaa", RB_FUNC(RXbyak_aaa), 0);

rxbyak/test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
rx.movq :xmm0, [:eax]
55
rx.mov :eax, [:esp, 12]
66
rx.movq :xmm1, [:eax]
7-
rx.mulsd :xmm0, :xmm1
7+
rx.divsd :xmm0, :xmm1
88
rx.mov :eax, [:esp, 4]
99
rx.movq [:eax], :xmm0
1010
rx.ret

0 commit comments

Comments
 (0)