This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RFC: ASM_OUTPUT_MI_THUNK for PPC/rs6000


Hi,

I did the appended version of ASM_OUTPUT_MI_THUNK and wanted to know if I'm on
the right track here. Especially I'm not sure about the jump handling, do I
have to go over CTR here or does the compiler/linker handle branches >24bit?

This is totally untested! And if you try to explain something to me about this,
keep in mind that I don't have a lot of background here, so please be verbose.

Franz.

#define ASM_OUTPUT_MI_THUNK(FILE, THUNK_FNDECL, FUNCTION, DELTA)	\
do {									\
	if (((unsigned HOST_WIDE_INT) DELTA) + 0x8000 < 0x10000)	\
		asm_fprintf(FILE, "\t{cal|addi} 3,3,%d\n", DELTA);	\
	else if (DELTA & 0xffff == 0)					\
		asm_fprintf(FILE, "\t{cau|addis} 3,3,%d\n",		\
			    ((unsigned HOST_WIDE_INT) DELTA) >> 16);	\
	else if (DELTA & 0x8000)					\
	{								\
		asm_fprintf(FILE, "\t{cau|addis} 3,3,%d\n",		\
			    (((unsigned HOST_WIDE_INT) DELTA) + 0x10000) >> 16); \
		asm_fprintf(FILE, "\t{cal|addi} 3,3,%d\n", DELTA & 0xffff); \
	}								\
	else								\
	{								\
		asm_fprintf(FILE, "\t{cau|addis} 3,3,%d\n",		\
			    ((unsigned HOST_WIDE_INT) DELTA) >> 16);	\
		asm_fprintf(FILE, "\t{cal|addi} 3,3,%d\n", DELTA & 0xffff); \
	}								\
									\
	if (flag_pic) {							\
		asm_fprintf (FILE, "\t{l|lwz} 0,");			\
		assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
		fprintf (FILE, "@got(11)\n");				\
	}								\
	else {								\
		asm_fprintf (FILE, "\t{liu|lis} 0,");			\
		assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
		fprintf (FILE, "@ha\n");				\
		asm_fprintf (FILE, "\t{lil|li} 0,");			\
		assemble_name (FILE, XSTR (XEXP (DECL_RTL (FUNCTION), 0), 0)); \
		fprintf (FILE, "@l\n");					\
	}								\
	fprintf (FILE, "\tmtctr 0\n");					\
	fprintf (FILE, "\tbctr\n");					\
} while (0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]