3 ** Copyright (C) 2005-2010 Mike Pall. See Copyright Notice in luajit.h
18 /* Hardcoded limits. Increase as needed. */
19 #define BUILD_MAX_RELOC 100 /* Max. number of relocations. */
20 #define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */
22 /* Prefix for scanned library definitions. */
23 #define LIBDEF_PREFIX "LJLIB_"
25 /* Prefix for scanned fold definitions. */
26 #define FOLDDEF_PREFIX "LJFOLD"
28 /* Prefixes for generated labels. */
29 #define LABEL_PREFIX "lj_"
30 #define LABEL_PREFIX_BC LABEL_PREFIX "BC_"
31 #define LABEL_PREFIX_FF LABEL_PREFIX "ff_"
32 #define LABEL_PREFIX_CF LABEL_PREFIX "cf_"
33 #define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_"
34 #define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_"
35 #define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_"
38 #define LABEL_ASM_BEGIN LABEL_PREFIX "vm_asm_begin"
39 #define LABEL_OP_OFS LABEL_PREFIX "vm_op_ofs"
41 /* Forward declaration. */
45 #if LJ_TARGET_X86ORX64
46 #define BUILDDEFX(_) _(peobj)
52 _(elfasm) _(coffasm) _(machasm) BUILDDEFX(_) _(raw) \
53 _(ffdef) _(libdef) _(recdef) _(vmdef) \
57 #define BUILDENUM(name) BUILD_##name,
63 /* Code relocation. */
64 typedef struct BuildReloc
{
70 /* Build context structure. */
71 typedef struct BuildCtx
{
72 /* DynASM state pointer. Should be first member. */
74 /* Parsed command line. */
79 /* Code and symbols generated by DynASM. */
82 int npc
, nglob
, nsym
, nreloc
;
86 /* Strings generated by DynASM. */
87 const char *const *extnames
;
88 const char *const *globnames
;
89 const char *dasm_ident
;
90 const char *dasm_arch
;
92 BuildReloc reloc
[BUILD_MAX_RELOC
];
95 extern void owrite(BuildCtx
*ctx
, const void *ptr
, size_t sz
);
96 extern void emit_asm(BuildCtx
*ctx
);
97 extern void emit_peobj(BuildCtx
*ctx
);
98 extern void emit_lib(BuildCtx
*ctx
);
99 extern void emit_fold(BuildCtx
*ctx
);
101 extern const char *const bc_names
[];
102 extern const char *const ir_names
[];
103 extern const char *const irfpm_names
[];
104 extern const char *const irfield_names
[];
105 extern const char *const ircall_names
[];