Could LLVM help me?

Howdy:
    I'm a newbie of LLVM. I want to make sure that my way is correct.
Plz tell me…
we design a new processor with a new arch. we wanna get a compiler as
fast as possible. The target code of the new compiler is machine
code.
So, is it I just to create a whole new backend for our new processor,
right? And then???

Thx.

    I'm a newbie of LLVM. I want to make sure that my way is correct.
Plz tell me…
we design a new processor with a new arch. we wanna get a compiler as
fast as possible. The target code of the new compiler is machine
code.
So, is it I just to create a whole new backend for our new processor,
right? And then???

Yes. LLVM would be great for your project. Please check out the document
on how to write a backend.
http://llvm.cs.uiuc.edu/docs/WritingAnLLVMBackend.html

-Tanya

You are the only one who response my problem. The others maybe don't
understand my questions....:frowning:

I'm also replying to the list. People are very nice and helpful! Plus, I am on vacation! :slight_smile:

well....my questions are following.
1. I wrote a very simple backend, but I dont know how to tell the llvm
compiler to use it.
   I found something in "llc --help", it says that I can use
-march=BACKEND. But it only
   can use X86, sparcev9 and powerpc. The skeleton looks like for
custom use, but I dnot
   know how to use it??

You need to use -load or link it in statically to the llc executable. If you have done this you should see your backend option with -help.

2. I dont know how to generate the "machine code", which I mean is
the code looks like "01001110101010100010....". All I got was the
"assembly code", not machine code.

Usually you use a system assembler to do this. The other way to do it is to implement the JIT code emitter interface.

Above just a part of my questions, thx for your help!!!

You're welcome!

-Tanya

>1. I wrote a very simple backend, but I dont know how to tell the
>llvm compiler to use it. I found something in "llc --help", it says
>that I can use -march=BACKEND. But it only can use X86, sparcev9 and
>powerpc. The skeleton looks like for custom use, but I dnot know how
>to use it??

You need to use -load or link it in statically to the llc executable.
If you have done this you should see your backend option with -help.

In addition to what Tanya said, you need something like this, taken from
llvm/lib/Target/X86/X86TargetMachine.cpp:

// Register the target.
RegisterTarget<X86TargetMachine> X("x86", " IA-32 (Pentium and above)");

This will add an option "-march=x86" to llc.

>2. I dont know how to generate the "machine code", which I mean is
>the code looks like "01001110101010100010....". All I got was the
>"assembly code", not machine code.

Usually you use a system assembler to do this. The other way to do it
is to implement the JIT code emitter interface.

Just to clarify: a JIT compiler will write out code to MEMORY, which is
probably not what you want for your new test processor. The JIT
compiler does have support for relocations, so it is possible (though
not currently implemented) to have LLVM produce object files (machine
code) to DISK instead of memory. This will require some work, though.