vm-i-scheme.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. /* Copyright (C) 2001, 2009 Free Software Foundation, Inc.
  2. *
  3. * This library is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU Lesser General Public License
  5. * as published by the Free Software Foundation; either version 3 of
  6. * the License, or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * Lesser General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Lesser General Public
  14. * License along with this library; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  16. * 02110-1301 USA
  17. */
  18. /* This file is included in vm_engine.c */
  19. /*
  20. * Predicates
  21. */
  22. #define ARGS1(a1) SCM a1 = sp[0];
  23. #define ARGS2(a1,a2) SCM a1 = sp[-1], a2 = sp[0]; sp--; NULLSTACK (1);
  24. #define ARGS3(a1,a2,a3) SCM a1 = sp[-2], a2 = sp[-1], a3 = sp[0]; sp -= 2; NULLSTACK (2);
  25. #define RETURN(x) do { *sp = x; NEXT; } while (0)
  26. VM_DEFINE_FUNCTION (100, not, "not", 1)
  27. {
  28. ARGS1 (x);
  29. RETURN (SCM_BOOL (SCM_FALSEP (x)));
  30. }
  31. VM_DEFINE_FUNCTION (101, not_not, "not-not", 1)
  32. {
  33. ARGS1 (x);
  34. RETURN (SCM_BOOL (!SCM_FALSEP (x)));
  35. }
  36. VM_DEFINE_FUNCTION (102, eq, "eq?", 2)
  37. {
  38. ARGS2 (x, y);
  39. RETURN (SCM_BOOL (SCM_EQ_P (x, y)));
  40. }
  41. VM_DEFINE_FUNCTION (103, not_eq, "not-eq?", 2)
  42. {
  43. ARGS2 (x, y);
  44. RETURN (SCM_BOOL (!SCM_EQ_P (x, y)));
  45. }
  46. VM_DEFINE_FUNCTION (104, nullp, "null?", 1)
  47. {
  48. ARGS1 (x);
  49. RETURN (SCM_BOOL (SCM_NULLP (x)));
  50. }
  51. VM_DEFINE_FUNCTION (105, not_nullp, "not-null?", 1)
  52. {
  53. ARGS1 (x);
  54. RETURN (SCM_BOOL (!SCM_NULLP (x)));
  55. }
  56. VM_DEFINE_FUNCTION (106, eqv, "eqv?", 2)
  57. {
  58. ARGS2 (x, y);
  59. if (SCM_EQ_P (x, y))
  60. RETURN (SCM_BOOL_T);
  61. if (SCM_IMP (x) || SCM_IMP (y))
  62. RETURN (SCM_BOOL_F);
  63. SYNC_REGISTER ();
  64. RETURN (scm_eqv_p (x, y));
  65. }
  66. VM_DEFINE_FUNCTION (107, equal, "equal?", 2)
  67. {
  68. ARGS2 (x, y);
  69. if (SCM_EQ_P (x, y))
  70. RETURN (SCM_BOOL_T);
  71. if (SCM_IMP (x) || SCM_IMP (y))
  72. RETURN (SCM_BOOL_F);
  73. SYNC_REGISTER ();
  74. RETURN (scm_equal_p (x, y));
  75. }
  76. VM_DEFINE_FUNCTION (108, pairp, "pair?", 1)
  77. {
  78. ARGS1 (x);
  79. RETURN (SCM_BOOL (SCM_CONSP (x)));
  80. }
  81. VM_DEFINE_FUNCTION (109, listp, "list?", 1)
  82. {
  83. ARGS1 (x);
  84. RETURN (SCM_BOOL (scm_ilength (x) >= 0));
  85. }
  86. /*
  87. * Basic data
  88. */
  89. VM_DEFINE_FUNCTION (110, cons, "cons", 2)
  90. {
  91. ARGS2 (x, y);
  92. CONS (x, x, y);
  93. RETURN (x);
  94. }
  95. #define VM_VALIDATE_CONS(x) \
  96. if (SCM_UNLIKELY (!scm_is_pair (x))) \
  97. { finish_args = x; \
  98. goto vm_error_not_a_pair; \
  99. }
  100. VM_DEFINE_FUNCTION (111, car, "car", 1)
  101. {
  102. ARGS1 (x);
  103. VM_VALIDATE_CONS (x);
  104. RETURN (SCM_CAR (x));
  105. }
  106. VM_DEFINE_FUNCTION (112, cdr, "cdr", 1)
  107. {
  108. ARGS1 (x);
  109. VM_VALIDATE_CONS (x);
  110. RETURN (SCM_CDR (x));
  111. }
  112. VM_DEFINE_INSTRUCTION (113, set_car, "set-car!", 0, 2, 0)
  113. {
  114. SCM x, y;
  115. POP (y);
  116. POP (x);
  117. VM_VALIDATE_CONS (x);
  118. SCM_SETCAR (x, y);
  119. NEXT;
  120. }
  121. VM_DEFINE_INSTRUCTION (114, set_cdr, "set-cdr!", 0, 2, 0)
  122. {
  123. SCM x, y;
  124. POP (y);
  125. POP (x);
  126. VM_VALIDATE_CONS (x);
  127. SCM_SETCDR (x, y);
  128. NEXT;
  129. }
  130. /*
  131. * Numeric relational tests
  132. */
  133. #undef REL
  134. #define REL(crel,srel) \
  135. { \
  136. ARGS2 (x, y); \
  137. if (SCM_I_INUMP (x) && SCM_I_INUMP (y)) \
  138. RETURN (SCM_BOOL (SCM_I_INUM (x) crel SCM_I_INUM (y))); \
  139. SYNC_REGISTER (); \
  140. RETURN (srel (x, y)); \
  141. }
  142. VM_DEFINE_FUNCTION (115, ee, "ee?", 2)
  143. {
  144. REL (==, scm_num_eq_p);
  145. }
  146. VM_DEFINE_FUNCTION (116, lt, "lt?", 2)
  147. {
  148. REL (<, scm_less_p);
  149. }
  150. VM_DEFINE_FUNCTION (117, le, "le?", 2)
  151. {
  152. REL (<=, scm_leq_p);
  153. }
  154. VM_DEFINE_FUNCTION (118, gt, "gt?", 2)
  155. {
  156. REL (>, scm_gr_p);
  157. }
  158. VM_DEFINE_FUNCTION (119, ge, "ge?", 2)
  159. {
  160. REL (>=, scm_geq_p);
  161. }
  162. /*
  163. * Numeric functions
  164. */
  165. #undef FUNC2
  166. #define FUNC2(CFUNC,SFUNC) \
  167. { \
  168. ARGS2 (x, y); \
  169. if (SCM_I_INUMP (x) && SCM_I_INUMP (y)) \
  170. { \
  171. scm_t_int64 n = SCM_I_INUM (x) CFUNC SCM_I_INUM (y);\
  172. if (SCM_FIXABLE (n)) \
  173. RETURN (SCM_I_MAKINUM (n)); \
  174. } \
  175. SYNC_REGISTER (); \
  176. RETURN (SFUNC (x, y)); \
  177. }
  178. VM_DEFINE_FUNCTION (120, add, "add", 2)
  179. {
  180. FUNC2 (+, scm_sum);
  181. }
  182. VM_DEFINE_FUNCTION (167, add1, "add1", 1)
  183. {
  184. ARGS1 (x);
  185. if (SCM_I_INUMP (x))
  186. {
  187. scm_t_int64 n = SCM_I_INUM (x) + 1;
  188. if (SCM_FIXABLE (n))
  189. RETURN (SCM_I_MAKINUM (n));
  190. }
  191. SYNC_REGISTER ();
  192. RETURN (scm_sum (x, SCM_I_MAKINUM (1)));
  193. }
  194. VM_DEFINE_FUNCTION (121, sub, "sub", 2)
  195. {
  196. FUNC2 (-, scm_difference);
  197. }
  198. VM_DEFINE_FUNCTION (168, sub1, "sub1", 1)
  199. {
  200. ARGS1 (x);
  201. if (SCM_I_INUMP (x))
  202. {
  203. scm_t_int64 n = SCM_I_INUM (x) - 1;
  204. if (SCM_FIXABLE (n))
  205. RETURN (SCM_I_MAKINUM (n));
  206. }
  207. SYNC_REGISTER ();
  208. RETURN (scm_difference (x, SCM_I_MAKINUM (1)));
  209. }
  210. VM_DEFINE_FUNCTION (122, mul, "mul", 2)
  211. {
  212. ARGS2 (x, y);
  213. SYNC_REGISTER ();
  214. RETURN (scm_product (x, y));
  215. }
  216. VM_DEFINE_FUNCTION (123, div, "div", 2)
  217. {
  218. ARGS2 (x, y);
  219. SYNC_REGISTER ();
  220. RETURN (scm_divide (x, y));
  221. }
  222. VM_DEFINE_FUNCTION (124, quo, "quo", 2)
  223. {
  224. ARGS2 (x, y);
  225. SYNC_REGISTER ();
  226. RETURN (scm_quotient (x, y));
  227. }
  228. VM_DEFINE_FUNCTION (125, rem, "rem", 2)
  229. {
  230. ARGS2 (x, y);
  231. SYNC_REGISTER ();
  232. RETURN (scm_remainder (x, y));
  233. }
  234. VM_DEFINE_FUNCTION (126, mod, "mod", 2)
  235. {
  236. ARGS2 (x, y);
  237. SYNC_REGISTER ();
  238. RETURN (scm_modulo (x, y));
  239. }
  240. /*
  241. * GOOPS support
  242. */
  243. VM_DEFINE_FUNCTION (127, slot_ref, "slot-ref", 2)
  244. {
  245. size_t slot;
  246. ARGS2 (instance, idx);
  247. slot = SCM_I_INUM (idx);
  248. RETURN (SCM_PACK (SCM_STRUCT_DATA (instance) [slot]));
  249. }
  250. VM_DEFINE_INSTRUCTION (128, slot_set, "slot-set", 0, 3, 0)
  251. {
  252. SCM instance, idx, val;
  253. size_t slot;
  254. POP (val);
  255. POP (idx);
  256. POP (instance);
  257. slot = SCM_I_INUM (idx);
  258. SCM_STRUCT_DATA (instance) [slot] = SCM_UNPACK (val);
  259. NEXT;
  260. }
  261. VM_DEFINE_FUNCTION (129, vector_ref, "vector-ref", 2)
  262. {
  263. long i = 0;
  264. ARGS2 (vect, idx);
  265. if (SCM_LIKELY (SCM_I_IS_VECTOR (vect)
  266. && SCM_I_INUMP (idx)
  267. && ((i = SCM_I_INUM (idx)) >= 0)
  268. && i < SCM_I_VECTOR_LENGTH (vect)))
  269. RETURN (SCM_I_VECTOR_ELTS (vect)[i]);
  270. else
  271. {
  272. SYNC_REGISTER ();
  273. RETURN (scm_vector_ref (vect, idx));
  274. }
  275. }
  276. VM_DEFINE_INSTRUCTION (130, vector_set, "vector-set", 0, 3, 0)
  277. {
  278. long i = 0;
  279. SCM vect, idx, val;
  280. POP (val); POP (idx); POP (vect);
  281. if (SCM_LIKELY (SCM_I_IS_VECTOR (vect)
  282. && SCM_I_INUMP (idx)
  283. && ((i = SCM_I_INUM (idx)) >= 0)
  284. && i < SCM_I_VECTOR_LENGTH (vect)))
  285. SCM_I_VECTOR_WELTS (vect)[i] = val;
  286. else
  287. {
  288. SYNC_REGISTER ();
  289. scm_vector_set_x (vect, idx, val);
  290. }
  291. NEXT;
  292. }
  293. #define VM_VALIDATE_BYTEVECTOR(x) \
  294. if (SCM_UNLIKELY (!SCM_BYTEVECTOR_P (x))) \
  295. { finish_args = x; \
  296. goto vm_error_not_a_bytevector; \
  297. }
  298. #define BV_REF_WITH_ENDIANNESS(stem, fn_stem) \
  299. { \
  300. SCM endianness; \
  301. POP (endianness); \
  302. if (scm_is_eq (endianness, scm_i_native_endianness)) \
  303. goto VM_LABEL (bv_##stem##_native_ref); \
  304. { \
  305. ARGS2 (bv, idx); \
  306. RETURN (scm_bytevector_##fn_stem##_ref (bv, idx, endianness)); \
  307. } \
  308. }
  309. VM_DEFINE_FUNCTION (131, bv_u16_ref, "bv-u16-ref", 3)
  310. BV_REF_WITH_ENDIANNESS (u16, u16)
  311. VM_DEFINE_FUNCTION (132, bv_s16_ref, "bv-s16-ref", 3)
  312. BV_REF_WITH_ENDIANNESS (s16, s16)
  313. VM_DEFINE_FUNCTION (133, bv_u32_ref, "bv-u32-ref", 3)
  314. BV_REF_WITH_ENDIANNESS (u32, u32)
  315. VM_DEFINE_FUNCTION (134, bv_s32_ref, "bv-s32-ref", 3)
  316. BV_REF_WITH_ENDIANNESS (s32, s32)
  317. VM_DEFINE_FUNCTION (135, bv_u64_ref, "bv-u64-ref", 3)
  318. BV_REF_WITH_ENDIANNESS (u64, u64)
  319. VM_DEFINE_FUNCTION (136, bv_s64_ref, "bv-s64-ref", 3)
  320. BV_REF_WITH_ENDIANNESS (s64, s64)
  321. VM_DEFINE_FUNCTION (137, bv_f32_ref, "bv-f32-ref", 3)
  322. BV_REF_WITH_ENDIANNESS (f32, ieee_single)
  323. VM_DEFINE_FUNCTION (138, bv_f64_ref, "bv-f64-ref", 3)
  324. BV_REF_WITH_ENDIANNESS (f64, ieee_double)
  325. #undef BV_REF_WITH_ENDIANNESS
  326. #define BV_FIXABLE_INT_REF(stem, fn_stem, type, size) \
  327. { \
  328. long i = 0; \
  329. ARGS2 (bv, idx); \
  330. VM_VALIDATE_BYTEVECTOR (bv); \
  331. if (SCM_LIKELY (SCM_I_INUMP (idx) \
  332. && ((i = SCM_I_INUM (idx)) >= 0) \
  333. && (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
  334. && (i % size == 0))) \
  335. RETURN (SCM_I_MAKINUM (*(scm_t_##type*) \
  336. (SCM_BYTEVECTOR_CONTENTS (bv) + i))); \
  337. else \
  338. RETURN (scm_bytevector_##fn_stem##_ref (bv, idx)); \
  339. }
  340. #define BV_INT_REF(stem, type, size) \
  341. { \
  342. long i = 0; \
  343. ARGS2 (bv, idx); \
  344. VM_VALIDATE_BYTEVECTOR (bv); \
  345. if (SCM_LIKELY (SCM_I_INUMP (idx) \
  346. && ((i = SCM_I_INUM (idx)) >= 0) \
  347. && (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
  348. && (i % size == 0))) \
  349. { scm_t_##type x = (*(scm_t_##type*)(SCM_BYTEVECTOR_CONTENTS (bv) + i)); \
  350. if (SCM_FIXABLE (x)) \
  351. RETURN (SCM_I_MAKINUM (x)); \
  352. else \
  353. RETURN (scm_from_##type (x)); \
  354. } \
  355. else \
  356. RETURN (scm_bytevector_##stem##_native_ref (bv, idx)); \
  357. }
  358. #define BV_FLOAT_REF(stem, fn_stem, type, size) \
  359. { \
  360. long i = 0; \
  361. ARGS2 (bv, idx); \
  362. VM_VALIDATE_BYTEVECTOR (bv); \
  363. if (SCM_LIKELY (SCM_I_INUMP (idx) \
  364. && ((i = SCM_I_INUM (idx)) >= 0) \
  365. && (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
  366. && (i % size == 0))) \
  367. RETURN (scm_from_double ((*(type*)(SCM_BYTEVECTOR_CONTENTS (bv) + i)))); \
  368. else \
  369. RETURN (scm_bytevector_##fn_stem##_native_ref (bv, idx)); \
  370. }
  371. VM_DEFINE_FUNCTION (139, bv_u8_ref, "bv-u8-ref", 2)
  372. BV_FIXABLE_INT_REF (u8, u8, uint8, 1)
  373. VM_DEFINE_FUNCTION (140, bv_s8_ref, "bv-s8-ref", 2)
  374. BV_FIXABLE_INT_REF (s8, s8, int8, 1)
  375. VM_DEFINE_FUNCTION (141, bv_u16_native_ref, "bv-u16-native-ref", 2)
  376. BV_FIXABLE_INT_REF (u16, u16_native, uint16, 2)
  377. VM_DEFINE_FUNCTION (142, bv_s16_native_ref, "bv-s16-native-ref", 2)
  378. BV_FIXABLE_INT_REF (s16, s16_native, int16, 2)
  379. VM_DEFINE_FUNCTION (143, bv_u32_native_ref, "bv-u32-native-ref", 2)
  380. /* FIXME: u32 is always a fixnum on 64-bit builds */
  381. BV_INT_REF (u32, uint32, 4)
  382. VM_DEFINE_FUNCTION (144, bv_s32_native_ref, "bv-s32-native-ref", 2)
  383. BV_INT_REF (s32, int32, 4)
  384. VM_DEFINE_FUNCTION (145, bv_u64_native_ref, "bv-u64-native-ref", 2)
  385. BV_INT_REF (u64, uint64, 8)
  386. VM_DEFINE_FUNCTION (146, bv_s64_native_ref, "bv-s64-native-ref", 2)
  387. BV_INT_REF (s64, int64, 8)
  388. VM_DEFINE_FUNCTION (147, bv_f32_native_ref, "bv-f32-native-ref", 2)
  389. BV_FLOAT_REF (f32, ieee_single, float, 4)
  390. VM_DEFINE_FUNCTION (148, bv_f64_native_ref, "bv-f64-native-ref", 2)
  391. BV_FLOAT_REF (f64, ieee_double, double, 8)
  392. #undef BV_FIXABLE_INT_REF
  393. #undef BV_INT_REF
  394. #undef BV_FLOAT_REF
  395. #define BV_SET_WITH_ENDIANNESS(stem, fn_stem) \
  396. { \
  397. SCM endianness; \
  398. POP (endianness); \
  399. if (scm_is_eq (endianness, scm_i_native_endianness)) \
  400. goto VM_LABEL (bv_##stem##_native_set); \
  401. { \
  402. SCM bv, idx, val; POP (val); POP (idx); POP (bv); \
  403. scm_bytevector_##fn_stem##_set_x (bv, idx, val, endianness); \
  404. NEXT; \
  405. } \
  406. }
  407. VM_DEFINE_INSTRUCTION (149, bv_u16_set, "bv-u16-set", 0, 4, 0)
  408. BV_SET_WITH_ENDIANNESS (u16, u16)
  409. VM_DEFINE_INSTRUCTION (150, bv_s16_set, "bv-s16-set", 0, 4, 0)
  410. BV_SET_WITH_ENDIANNESS (s16, s16)
  411. VM_DEFINE_INSTRUCTION (151, bv_u32_set, "bv-u32-set", 0, 4, 0)
  412. BV_SET_WITH_ENDIANNESS (u32, u32)
  413. VM_DEFINE_INSTRUCTION (152, bv_s32_set, "bv-s32-set", 0, 4, 0)
  414. BV_SET_WITH_ENDIANNESS (s32, s32)
  415. VM_DEFINE_INSTRUCTION (153, bv_u64_set, "bv-u64-set", 0, 4, 0)
  416. BV_SET_WITH_ENDIANNESS (u64, u64)
  417. VM_DEFINE_INSTRUCTION (154, bv_s64_set, "bv-s64-set", 0, 4, 0)
  418. BV_SET_WITH_ENDIANNESS (s64, s64)
  419. VM_DEFINE_INSTRUCTION (155, bv_f32_set, "bv-f32-set", 0, 4, 0)
  420. BV_SET_WITH_ENDIANNESS (f32, ieee_single)
  421. VM_DEFINE_INSTRUCTION (156, bv_f64_set, "bv-f64-set", 0, 4, 0)
  422. BV_SET_WITH_ENDIANNESS (f64, ieee_double)
  423. #undef BV_SET_WITH_ENDIANNESS
  424. #define BV_FIXABLE_INT_SET(stem, fn_stem, type, min, max, size) \
  425. { \
  426. long i = 0, j = 0; \
  427. SCM bv, idx, val; POP (val); POP (idx); POP (bv); \
  428. VM_VALIDATE_BYTEVECTOR (bv); \
  429. if (SCM_LIKELY (SCM_I_INUMP (idx) \
  430. && ((i = SCM_I_INUM (idx)) >= 0) \
  431. && (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
  432. && (i % size == 0) \
  433. && (SCM_I_INUMP (val)) \
  434. && ((j = SCM_I_INUM (val)) >= min) \
  435. && (j <= max))) \
  436. *(scm_t_##type*) (SCM_BYTEVECTOR_CONTENTS (bv) + i) = (scm_t_##type)j; \
  437. else \
  438. scm_bytevector_##fn_stem##_set_x (bv, idx, val); \
  439. NEXT; \
  440. }
  441. #define BV_INT_SET(stem, type, size) \
  442. { \
  443. long i = 0; \
  444. SCM bv, idx, val; POP (val); POP (idx); POP (bv); \
  445. VM_VALIDATE_BYTEVECTOR (bv); \
  446. if (SCM_LIKELY (SCM_I_INUMP (idx) \
  447. && ((i = SCM_I_INUM (idx)) >= 0) \
  448. && (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
  449. && (i % size == 0))) \
  450. *(scm_t_##type*) (SCM_BYTEVECTOR_CONTENTS (bv) + i) = scm_to_##type (val); \
  451. else \
  452. scm_bytevector_##stem##_native_set_x (bv, idx, val); \
  453. NEXT; \
  454. }
  455. #define BV_FLOAT_SET(stem, fn_stem, type, size) \
  456. { \
  457. long i = 0; \
  458. SCM bv, idx, val; POP (val); POP (idx); POP (bv); \
  459. VM_VALIDATE_BYTEVECTOR (bv); \
  460. if (SCM_LIKELY (SCM_I_INUMP (idx) \
  461. && ((i = SCM_I_INUM (idx)) >= 0) \
  462. && (i + size <= SCM_BYTEVECTOR_LENGTH (bv)) \
  463. && (i % size == 0))) \
  464. *(type*) (SCM_BYTEVECTOR_CONTENTS (bv) + i) = scm_to_double (val); \
  465. else \
  466. scm_bytevector_##fn_stem##_native_set_x (bv, idx, val); \
  467. NEXT; \
  468. }
  469. VM_DEFINE_INSTRUCTION (157, bv_u8_set, "bv-u8-set", 0, 3, 0)
  470. BV_FIXABLE_INT_SET (u8, u8, uint8, 0, SCM_T_UINT8_MAX, 1)
  471. VM_DEFINE_INSTRUCTION (158, bv_s8_set, "bv-s8-set", 0, 3, 0)
  472. BV_FIXABLE_INT_SET (s8, s8, int8, SCM_T_INT8_MIN, SCM_T_INT8_MAX, 1)
  473. VM_DEFINE_INSTRUCTION (159, bv_u16_native_set, "bv-u16-native-set", 0, 3, 0)
  474. BV_FIXABLE_INT_SET (u16, u16_native, uint16, 0, SCM_T_UINT16_MAX, 2)
  475. VM_DEFINE_INSTRUCTION (160, bv_s16_native_set, "bv-s16-native-set", 0, 3, 0)
  476. BV_FIXABLE_INT_SET (s16, s16_native, int16, SCM_T_INT16_MIN, SCM_T_INT16_MAX, 2)
  477. VM_DEFINE_INSTRUCTION (161, bv_u32_native_set, "bv-u32-native-set", 0, 3, 0)
  478. /* FIXME: u32 is always a fixnum on 64-bit builds */
  479. BV_INT_SET (u32, uint32, 4)
  480. VM_DEFINE_INSTRUCTION (162, bv_s32_native_set, "bv-s32-native-set", 0, 3, 0)
  481. BV_INT_SET (s32, int32, 4)
  482. VM_DEFINE_INSTRUCTION (163, bv_u64_native_set, "bv-u64-native-set", 0, 3, 0)
  483. BV_INT_SET (u64, uint64, 8)
  484. VM_DEFINE_INSTRUCTION (164, bv_s64_native_set, "bv-s64-native-set", 0, 3, 0)
  485. BV_INT_SET (s64, int64, 8)
  486. VM_DEFINE_INSTRUCTION (165, bv_f32_native_set, "bv-f32-native-set", 0, 3, 0)
  487. BV_FLOAT_SET (f32, ieee_single, float, 4)
  488. VM_DEFINE_INSTRUCTION (166, bv_f64_native_set, "bv-f64-native-set", 0, 3, 0)
  489. BV_FLOAT_SET (f64, ieee_double, double, 8)
  490. #undef BV_FIXABLE_INT_SET
  491. #undef BV_INT_SET
  492. #undef BV_FLOAT_SET
  493. /*
  494. (defun renumber-ops ()
  495. "start from top of buffer and renumber 'VM_DEFINE_FOO (\n' sequences"
  496. (interactive "")
  497. (save-excursion
  498. (let ((counter 99)) (goto-char (point-min))
  499. (while (re-search-forward "^VM_DEFINE_[^ ]+ (\\([^,]+\\)," (point-max) t)
  500. (replace-match
  501. (number-to-string (setq counter (1+ counter)))
  502. t t nil 1)))))
  503. */
  504. /*
  505. Local Variables:
  506. c-file-style: "gnu"
  507. End:
  508. */