0
$\begingroup$

I'm currently developing my degree thesis, and the lab's idea is to design a new micro architecture, and then, be able to compile stuff for this architecture. So the question is, how do you instruct a compiler to generate your new assembler??? The general idea is to be able to compile with gcc and run netbsd or similar kernel with this new architecture. Well, thanks a lot!

$\endgroup$
4
  • $\begingroup$ Ok, I thing the best place to start is GCC internals manual... Machine description chapter Thanks! $\endgroup$ – Luciano César Natale Mar 19 '15 at 18:59
  • 1
    $\begingroup$ By the way, good luck with this. It's a huge job! Depending on the ultimate goal of this project, you might have more luck with porting PCC, which can compile the OpenBSD kernel. But PCC isn't up to the same standard as GCC or Clang/LLVM yet, and nobody is actively working on it. $\endgroup$ – Pseudonym Mar 19 '15 at 20:44
  • 1
    $\begingroup$ 1. This question is too broad. There are entire books written on the subject of compiler design. If someone can write entire books on the subject of your question, it is too broad. I encourage you to take a look at our help center to learn more about expectations on this site. 2. We also expect you to do a significant amount of research on your own before asking, and to show us what you've tried in the question. You might start by looking at Wikipedia, the tags mentioned in your question, and standard textbooks on the subject. $\endgroup$ – D.W. Mar 19 '15 at 21:48
  • $\begingroup$ If you must really invent a new ISA, then the first place to start would be to take the gcc machine description for a similar ISA rename it, and then tweak it incrementally. But if your research is in microarchitecture then you should not also invent a new ISA. You should take an existing ISA and implement it, and then the existing gcc machine description should be mostly fine. The only part of the gcc machine description you might want to tweak (and then only after you are mostly done implementing your microarchitecture) is the instruction latencies. $\endgroup$ – Wandering Logic Mar 20 '15 at 13:16
1
$\begingroup$

Many compilers, gcc included, are divided into two major parts: a front-end and a back-end. The front end is in charge of compiling the input language into some sort of intermediate form, and perform some of the optimization. The back-end takes this intermediate form and generates actual machine code. You only need to construct a new back-end (or even less than that). Luciano in his answer gave you a good pointer regarding that.

$\endgroup$
1
  • $\begingroup$ I would recommend an writing an LLVM backend -- the code base is much cleaner. $\endgroup$ – Demi Sep 7 '15 at 23:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.