all repos — mgba @ 3c18fe162c2c76eca80692d37083f6809bae4c8d

mGBA Game Boy Advance Emulator

src/arm/emitter-inlines.h (view raw)

  1/* Copyright (c) 2013-2014 Jeffrey Pfau
  2 *
  3 * This Source Code Form is subject to the terms of the Mozilla Public
  4 * License, v. 2.0. If a copy of the MPL was not distributed with this
  5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6#ifndef EMITTER_INLINES_H
  7#define EMITTER_INLINES_H
  8
  9#define DO_4(DIRECTIVE) \
 10	DIRECTIVE, \
 11	DIRECTIVE, \
 12	DIRECTIVE, \
 13	DIRECTIVE
 14
 15#define DO_8(DIRECTIVE) \
 16	DIRECTIVE, \
 17	DIRECTIVE, \
 18	DIRECTIVE, \
 19	DIRECTIVE, \
 20	DIRECTIVE, \
 21	DIRECTIVE, \
 22	DIRECTIVE, \
 23	DIRECTIVE
 24
 25#define DO_256(DIRECTIVE) \
 26	DO_4(DO_8(DO_8(DIRECTIVE)))
 27
 28#define DO_INTERLACE(LEFT, RIGHT) \
 29	LEFT, \
 30	RIGHT
 31
 32#define APPLY(F, ...) F(__VA_ARGS__)
 33
 34#define COUNT_CALL_1(EMITTER, PREFIX, ...) \
 35	EMITTER(PREFIX ## 0, 0, __VA_ARGS__) \
 36	EMITTER(PREFIX ## 1, 1, __VA_ARGS__)
 37
 38#define COUNT_CALL_2(EMITTER, PREFIX, ...) \
 39	COUNT_CALL_1(EMITTER, PREFIX, __VA_ARGS__) \
 40	EMITTER(PREFIX ## 2, 2, __VA_ARGS__) \
 41	EMITTER(PREFIX ## 3, 3, __VA_ARGS__)
 42
 43#define COUNT_CALL_3(EMITTER, PREFIX, ...) \
 44	COUNT_CALL_2(EMITTER, PREFIX, __VA_ARGS__) \
 45	EMITTER(PREFIX ## 4, 4, __VA_ARGS__) \
 46	EMITTER(PREFIX ## 5, 5, __VA_ARGS__) \
 47	EMITTER(PREFIX ## 6, 6, __VA_ARGS__) \
 48	EMITTER(PREFIX ## 7, 7, __VA_ARGS__)
 49
 50#define COUNT_CALL_4(EMITTER, PREFIX, ...) \
 51	COUNT_CALL_3(EMITTER, PREFIX, __VA_ARGS__) \
 52	EMITTER(PREFIX ## 8, 8, __VA_ARGS__) \
 53	EMITTER(PREFIX ## 9, 9, __VA_ARGS__) \
 54	EMITTER(PREFIX ## A, 10, __VA_ARGS__) \
 55	EMITTER(PREFIX ## B, 11, __VA_ARGS__) \
 56	EMITTER(PREFIX ## C, 12, __VA_ARGS__) \
 57	EMITTER(PREFIX ## D, 13, __VA_ARGS__) \
 58	EMITTER(PREFIX ## E, 14, __VA_ARGS__) \
 59	EMITTER(PREFIX ## F, 15, __VA_ARGS__)
 60
 61#define COUNT_CALL_5(EMITTER, PREFIX, ...) \
 62	COUNT_CALL_4(EMITTER, PREFIX ## 0, __VA_ARGS__) \
 63	EMITTER(PREFIX ## 10, 16, __VA_ARGS__) \
 64	EMITTER(PREFIX ## 11, 17, __VA_ARGS__) \
 65	EMITTER(PREFIX ## 12, 18, __VA_ARGS__) \
 66	EMITTER(PREFIX ## 13, 19, __VA_ARGS__) \
 67	EMITTER(PREFIX ## 14, 20, __VA_ARGS__) \
 68	EMITTER(PREFIX ## 15, 21, __VA_ARGS__) \
 69	EMITTER(PREFIX ## 16, 22, __VA_ARGS__) \
 70	EMITTER(PREFIX ## 17, 23, __VA_ARGS__) \
 71	EMITTER(PREFIX ## 18, 24, __VA_ARGS__) \
 72	EMITTER(PREFIX ## 19, 25, __VA_ARGS__) \
 73	EMITTER(PREFIX ## 1A, 26, __VA_ARGS__) \
 74	EMITTER(PREFIX ## 1B, 27, __VA_ARGS__) \
 75	EMITTER(PREFIX ## 1C, 28, __VA_ARGS__) \
 76	EMITTER(PREFIX ## 1D, 29, __VA_ARGS__) \
 77	EMITTER(PREFIX ## 1E, 30, __VA_ARGS__) \
 78	EMITTER(PREFIX ## 1F, 31, __VA_ARGS__) \
 79
 80#define COUNT_1(EMITTER, PREFIX) \
 81	EMITTER(PREFIX ## 0) \
 82	EMITTER(PREFIX ## 1)
 83
 84#define COUNT_2(EMITTER, PREFIX) \
 85	COUNT_1(EMITTER, PREFIX) \
 86	EMITTER(PREFIX ## 2) \
 87	EMITTER(PREFIX ## 3)
 88
 89#define COUNT_3(EMITTER, PREFIX) \
 90	COUNT_2(EMITTER, PREFIX) \
 91	EMITTER(PREFIX ## 4) \
 92	EMITTER(PREFIX ## 5) \
 93	EMITTER(PREFIX ## 6) \
 94	EMITTER(PREFIX ## 7)
 95
 96#define COUNT_4(EMITTER, PREFIX) \
 97	COUNT_3(EMITTER, PREFIX) \
 98	EMITTER(PREFIX ## 8) \
 99	EMITTER(PREFIX ## 9) \
100	EMITTER(PREFIX ## A) \
101	EMITTER(PREFIX ## B) \
102	EMITTER(PREFIX ## C) \
103	EMITTER(PREFIX ## D) \
104	EMITTER(PREFIX ## E) \
105	EMITTER(PREFIX ## F)
106
107#define COUNT_5(EMITTER, PREFIX) \
108	COUNT_4(EMITTER, PREFIX ## 0) \
109	EMITTER(PREFIX ## 10) \
110	EMITTER(PREFIX ## 11) \
111	EMITTER(PREFIX ## 12) \
112	EMITTER(PREFIX ## 13) \
113	EMITTER(PREFIX ## 14) \
114	EMITTER(PREFIX ## 15) \
115	EMITTER(PREFIX ## 16) \
116	EMITTER(PREFIX ## 17) \
117	EMITTER(PREFIX ## 18) \
118	EMITTER(PREFIX ## 19) \
119	EMITTER(PREFIX ## 1A) \
120	EMITTER(PREFIX ## 1B) \
121	EMITTER(PREFIX ## 1C) \
122	EMITTER(PREFIX ## 1D) \
123	EMITTER(PREFIX ## 1E) \
124	EMITTER(PREFIX ## 1F) \
125
126#define ECHO(...) __VA_ARGS__,
127#define ECHO_4(...) \
128	ECHO(__VA_ARGS__) \
129	ECHO(__VA_ARGS__) \
130	ECHO(__VA_ARGS__) \
131	ECHO(__VA_ARGS__)
132
133#endif