Skip to content

Instantly share code, notes, and snippets.

Created February 23, 2017 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/652ff876293730601cccd1091f1ed446 to your computer and use it in GitHub Desktop.
Save anonymous/652ff876293730601cccd1091f1ed446 to your computer and use it in GitHub Desktop.
#define TARGET(op) \
L##op: \
opcode = op; \
case op:
void use(int);
void foo(int *p) {
static void *targets[16] = {
&&L0,
&&L1,
&&L2,
&&L3,
&&L4,
&&L5,
&&L6,
&&L7,
&&L8,
&&L9,
&&L10,
&&L11,
&&L12,
&&L13,
&&L14,
&&L15
};
int opcode = 0;
switch(*p++) {
TARGET(0) { use (opcode); goto *targets[*p++]; }
TARGET(1) { use (opcode); goto *targets[*p++]; }
TARGET(2) { use (opcode); goto *targets[*p++]; }
TARGET(3) { use (opcode); goto *targets[*p++]; }
TARGET(4) { use (opcode); goto *targets[*p++]; }
TARGET(5) { use (opcode); goto *targets[*p++]; }
TARGET(6) { use (opcode); goto *targets[*p++]; }
TARGET(7) { use (opcode); goto *targets[*p++]; }
TARGET(8) { use (opcode); goto *targets[*p++]; }
TARGET(9) { use (opcode); goto *targets[*p++]; }
TARGET(10) { use (opcode); goto *targets[*p++]; }
TARGET(11) { use (opcode); goto *targets[*p++]; }
TARGET(12) { use (opcode); goto *targets[*p++]; }
TARGET(13) { use (opcode); goto *targets[*p++]; }
TARGET(14) { use (opcode); goto *targets[*p++]; }
TARGET(15) { use (opcode); goto *targets[*p++]; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment