Mips instructions using llvm?

Hi All,


Is there any way to generate MIPS instructions from C code in llvm ?


|

"Generate MIPS instructions" is kind of vague, but something like
"clang myfile.c -S -target mips-unknown-linux" will make clang
generate MIPS assembly.

-Eli

Hi Eli,


What do you mean by “kind of vague” ? So does not guarantee to generate correct instructions ?


I just tried what you said but getting following error ? Any ideas ?
What I did is clang hello.c -S -target mips-unknown-linux


Error:
In file included from hello.c:1
In file included from /usr/include/stdio.h:28
/usr/include/features.h:323:10 fatak error ‘bits/predefs.h’ file not found.





===========================================

Phone : 82-42-860-1838
Fax : 82-42-860-6790
Cell Phone: 82-10-7599-1981
===========================================


— On Mon, 11/12/12, Eli Friedman eli.friedman@gmail.com wrote:


> From: Eli Friedman eli.friedman@gmail.com
> Subject: Re: [LLVMdev] Mips instructions using llvm?
> To: “janarbek” canarbekmatay@yahoo.com
> Cc: llvmdev@cs.uiuc.edu
> Date: Monday, November 12, 2012, 4:55 PM
>
> On Mon, Nov 12, 2012 at 4:41 PM, janarbek canarbekmatay@yahoo.com wrote:
> >
> > Hi All,
> >
> > Is there any way to generate MIPS instructions from C code in llvm ?
>
> “Generate MIPS instructions” is kind of vague, but something like
> “clang myfile.c -S -target mips-unknown-linux” will make clang
> generate MIPS assembly.
>
> -Eli


|

What do you mean by "kind of vague" ? So does not guarantee to generate correct instructions ?

Your question is vague. Generally, you get better answers if you ask better questions.

I just tried what you said but getting following error ? Any ideas ?
What I did is clang hello.c -S -target mips-unknown-linux

Error:
In file included from hello.c:1
In file included from /usr/include/stdio.h:28
/usr/include/features.h:323:10 fatak error 'bits/predefs.h' file not found.

This sounds like you are using headers that do not support MIPS.

David

What do you mean by “kind of vague” ? So does not guarantee to generate correct instructions ?

>Your question is vague. Generally, you get better answers if you ask better questions.

Sorry, I didn’t mean to be rude. My question is does that mean institution generated may not guarantee what the “instructions” mean to be ?

>This sounds like you are using headers that do not support MIPS.

So can I fix this? In my hello.c code I have only stdio.h header file.






===========================================

Phone : 82-42-860-1838
Fax : 82-42-860-6790
Cell Phone: 82-10-7599-1981
===========================================


— On Mon, 11/12/12, David Chisnall dc552@cam.ac.uk wrote:


> From: David Chisnall dc552@cam.ac.uk
> Subject: Re: [LLVMdev] Mips instructions using llvm?
> To: “janarbek” canarbekmatay@yahoo.com
> Cc: “Eli Friedman” eli.friedman@gmail.com, llvmdev@cs.uiuc.edu
> Date: Monday, November 12, 2012, 5:31 PM
>
> On 12 Nov 2012, at 17:22, janarbek wrote:
>
> > What do you mean by “kind of vague” ? So does not guarantee to generate correct instructions ?
>
> Your question is vague. Generally, you get better answers if you ask better questions.
>
> > I just tried what you said but getting following error ? Any ideas ?
> > What I did is clang hello.c -S -target mips-unknown-linux
> >
> > Error:
> > In file included from hello.c:1
> > In file included from /usr/include/stdio.h:28
> > /usr/include/features.h:323:10 fatak error ‘bits/predefs.h’ file not found.
>
> This sounds like you are using headers that do not support MIPS.
>
> David


|

The issue here is that you don’t just need some arbitrary stdio.h, you need one that corresponds to your target. Without knowing what that target is, it’s hard to say more.

What I meant by “kind of vague” is that MIPS is a CPU architecture, not a target. Consider if you said, for example, “I want to generate x86-64 code”: did you want code for Windows, or Ubuntu, or OS X, or something else? They’re all very different. (My example is x86 because I’m not familiar with common MIPS targets.)

-Eli


Thanks Eli.
That makes it clear.




>

|

See:

https://dmz-portal.mips.com/wiki/Clang_cross_compilation