Need help trying to generate mblaze code.

Hello,

this is a very dump question, I hope to do more valuable question soon, but for now I’m just trying to run a simple hello world in C for clang and llvm to the target mblaze, but is not working.

( I need to change the compiler in the next stage)

I past all the weekend tried to run this, and I was unable, I did the build of llVM/clang, but no bin was generate, only silly folder that I don’t know for what can be useful.

Can you please recommend me some tutorials or explain what I need to do run to generate a code to mblaze from a .c file using LLVM ? this is been a very frustrating experience because of the lack of experience and information. This appears to be so basic that there is no tutorial available.

tks in advance

best regards.

Hi Bruno,

$ clang -emit-llvm -S -c test.c -o - | opt -O3 | ./llc -march=mblaze -o -

The piped command above first emits LLVM IR using clang frontend, then
optimizes IR with -O3 level, and then codegens IR using mblaze
backend.

I used the following code:

$ cat test.c
#include <stdio.h>

int main(int argc, char* argv[])
{
  printf("Hello, world!\n");
  return 0;
}

$ clang -emit-llvm -S -c test.c -o - | opt -O3 | ./llc -march=mblaze -o -
  .file "<stdin>"
  .text
  .globl main
  .align 2
  .type main,@function
  .ent main # @main
main:
  .frame r1,4,r15
  .mask 0x8000
# BB#0: # %entry
  addik r1, r1, -4
  swi r15, r1, 0
  ori r5, r0, ($str)
  brlid r15, puts
  nop
  addk r3, r0, r0
  lwi r15, r1, 0
  rtsd r15, 8
  addik r1, r1, 4
  .end main
$tmp0:
  .size main, ($tmp0)-main

  .type $str,@object # @str
  .section .rodata.str1.1,"aMS",@progbits,1
$str:
  .asciz "Hello, world!"
  .size $str, 14

Is it what you want to get?
- D.

Hi Bruno,

MBlaze is enabled by default if you just build LLVM+Clang, and if you
don't see a bin directory under your build directory, you probably
haven't managed to compile it correctly.

The default page for building LLVM+Clang is:

http://llvm.org/docs/GettingStarted.html

Basically, checkout (svn or git) and "make" should do the trick. There
should be a bin dir where you built it.

You can "sudo make install" if you want those binaries to be your
default LLVM (if you don't have packages installed, that is).

Also, I'm assuming Linux here... if you have Windows or Mac, other
people can advise, as I have no idea... :wink: