This is the mail archive of the gcc-help@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] |
| Other format: | [Raw text] | |
At Tue, 22 Aug 2006 14:44:44 +0100,
Andrew Haley wrote:
> Simon Kagstrom writes:
> > I'm trying to dyanmically generate different bitpatterns using inline
> > assembly depeding on a value is constant or not. I'm using it to issue
> > system calls (see http://spel.bth.se/index.php/Cibyl) and avoid
> > clobbering registers with constant values. What I'm trying to achieve
> > is this:
> >
> > move a0,v0 # Normal MIPS instruction
> > 0000fffd # Argument, is a constant
> > 00000020 # Constant 32
> > ffff0001 # System call number 1
> [...]
> Trying something simpler,
>
> #include <stdio.h>
> int main() {
> printf("%d\n", __builtin_constant_p("Hello!"));
> }
>
> returns 1.
Hmm... I tried this example and it seems that this might be a problem
with my version of GCC for MIPS. It works fine with Debian/testing GCC
3.3.6, 3.4.6 and 4.1.2 but the MIPS cross compiler (3.4.3) doesn't
work. The flags I use to compile are
-Wall -mips1 -fno-delayed-branch -Os -fno-pic -mno-abicalls
> Can you try expanding your example with gcc -E, and paste the result
> here so I can try it? Then we'll have a test case we can use.
I've attached it below.
The code is slightly changed but the result is the same. I now do
#define __emit_parameter(x) \
if (__builtin_constant_p(x)) { \
__asm__ volatile ( \
".long 0xfffd0000\n" \
".long %0\n" \
: \
: "i,!r"(x) \
); \
} \
else { \
__asm__ volatile ( \
".short 0xfffe\n" \
".short %0\n" \
: \
: "r"(x) \
); \
}
#define _syscall1(type,name,atype,a) \
type name(atype a) \
{ \
register unsigned long __v0 asm("$2"); \
\
__asm__ volatile (".set push\n.set noreorder\n"); \
__emit_parameter(a); \
...
but the result is the same. Thanks for looking into this.
// Simon
Attachment:
main.out
Description: Binary data
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |