Shang-Yi,
Regard your questions in InstrInfo.td for the beginner. I remembered one reader asked me about td before. I told him I don’t know many things in td. The td purpose is do DAG translate from IR to machine instruction in compiler book knowledge as my book indicated as follows,
http://jonathan2251.github.io/lbd/backendstructure.html#dag-directed-acyclic-graph
There are many other knowledges include many llvm IR to machine instructions translate, branch/loop handle, function call, assembler/obj printing, disassembler, AsmParser, elf format, elf linker, llvm-objdump, … (I don’t know if you stay in td or keep going to other chapters)
To program based on a existed software structure, I try to got the overview structure first and skip the details. (Maybe you think what kind of specific td node is important and is the big picture because it exists in your InstrInfo.td)
Regards
Jonathan
Shang-Yi Yang ilway25@gmail.com 於 2013/12/6 (週五) 12:22 PM 寫道﹕
Hi Jonathan,
After reading/skimming through the official LLVM backend documents, I actually tried following your steps to write a new backend, but how to write td files still remains unclear. The details are not well explained, though I know most of them can be found in other documents or have already been documented somewhere in the LLVM source code or td files.
For a beginner with no experience like me, it is really hard to extract the fundamental structure from existing backends, e.g., what is necessary for an early stage and what is the refined result after years of development.
For example, everything went well with Cpu0RegisterInfo.td, with only a little struggle. But for Cpu0InstrInfo.td, questions start to come up: Why simm16 is inherited from Operand? What are PatLeaf and ComplexPattern? What is isReMaterializable? etc. Every line of description, every occurrence of new keyword or concept would confuse a beginner reader. They need to find enough information to follow this tutorial. This tutorial seems to tell that you have to write these 10 files, completely, without error, to continue to the next step. And this – how to start from starch, at least for me, is the most frustrating thing
If this is meant for beginners, I would say that a brief description or a link to these new concepts would be helpful.
Thanks,
Shang-Yi
2013/12/6 Mikael Lyngvig <mikael@lyngvig.org>