gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > thumb compilation

#8010 - johnny_north - Mon Jun 30, 2003 6:35 pm

I?ve been having difficulties compiling my code thumb mode. I?ve developed a sizable project and it compiles and runs fine in arm using DevKit R4 and C++. When I began to compile in thumb, I was getting errors that I suspected were related to C++, but now I not so sure. After ripping up my make file and separating the rules to compile each C++ file separately, I began to notice several distinct errors.

First, code in .cpp files compiles fine except when a member function calls another member function of the same class. In these cases I can force the compiler to accept the code and compile in thumb only if I add ?inline? to the function definition. Of course, I don?t always want this to happen, and most of the time I would rather the code branch to, rather that inline the called function. Anyone have an idea about this?

Second, some inline assembly code calling the swi lz77 decompression is causing an error: ?invalid swi instruction?. The swi compiles fine in arm though.

Third, it appears that files that have mixed C/C++ (i.e. files with mixed class scoped and file scoped functions) also produce errors, although I haven?t thoroughly explored this problem yet.

I?m using the following cpp flags:
CFLAGS = -I $(INCDIR2) -I $(INCDIR) -I $(PRJDIR) -mthumb-interwork ?mthumb -mlong-calls -c -g -Wall -fverbose-asm

Any suggestions would be appreciated.

#8016 - tepples - Mon Jun 30, 2003 8:03 pm

johnny_north wrote:
First, code in .cpp files compiles fine except when a member function calls another member function of the same class. In these cases I can force the compiler to accept the code and compile in thumb only if I add ?inline? to the function definition. Of course, I don?t always want this to happen, and most of the time I would rather the code branch to, rather that inline the called function. Anyone have an idea about this?

I can't really help you unless you paste the full text of the error messages.

Quote:
Second, some inline assembly code calling the swi lz77 decompression is causing an error: ?invalid swi instruction?. The swi compiles fine in arm though.

ARM: swi 0xnn0000
Thumb: swi 0xnn
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#8039 - johnny_north - Tue Jul 01, 2003 4:21 am

The following error is fixed when I add "inline" to void InitBGs(). The same error happens when any function call another function from the same class.

background.cpp: In member function `void Background::StoryStart()':
background.cpp:420: Unrecognizable insn:
(call_insn 205 204 206 (parallel[
(call (mem:SI (symbol_ref:SI ("^_ZN10Background7InitBGsEh")) 0)
(const_int 0 [0x0]))
(use (const_int 1 [0x1]))
(clobber (reg:SI 14 lr))
] ) -1 (nil)
(expr_list:REG_DEAD (reg:SI 0 r0)
(expr_list:REG_DEAD (reg:SI 1 r1)
(expr_list:REG_UNUSED (reg:SI 14 lr)
(nil))))
(expr_list (use (reg:SI 1 r1))
(expr_list (use (reg:SI 0 r0))
(nil))))
background.cpp:420: Internal compiler error in extract_insn, at recog.c:2218

#8041 - johnny_north - Tue Jul 01, 2003 4:40 am

Compiling in thumb doesn't seem to work with the interupt table either:

void (*IntrTable[])() = {
vbl, // v-blank
0, // h-blank
0, // vcount
0, // timer0
0,// timer1
timer2, // timer2
0, // timer3
0, // serial
0, // dma0
MP, // dma1
0, // dma2
0, // dma3
0, // key
0 // cart
};

The (main.cpp:12: Unrecognizable insn:) part refers to the only global instance of a class declaration.

main.cpp: In function `void _GLOBAL__I_IntrTable()':
main.cpp:12: Unrecognizable insn:
(call_insn 20 19 26 (parallel[
(call (mem:SI (symbol_ref:SI ("^^_Z41__static_initialization_and_destruction_0ii")) 0)
(const_int 0 [0x0]))
(use (const_int 1 [0x1]))
(clobber (reg:SI 14 lr))
] ) -1 (nil)
(expr_list:REG_DEAD (reg:SI 0 r0)
(expr_list:REG_DEAD (reg:SI 1 r1)
(expr_list:REG_UNUSED (reg:SI 14 lr)
(nil))))
(expr_list (use (reg:SI 1 r1))
(expr_list (use (reg:SI 0 r0))
(nil))))
main.cpp:12: Internal compiler error in extract_insn, at recog.c:2218

#8104 - johnny_north - Wed Jul 02, 2003 3:59 am

Ok, it appears that the compiler option -mlong-calls was causing me to add the inline statement.