English 中文(简体)
• 如何写出您自己的代码生成器背书,以获得优惠?
原标题:How to write your own code generator backend for gcc?
  • 时间:2012-05-16 11:05:08
  •  标签:
  • c
  • gcc

我创建了我自己的(非常简单)密码语言,并建立了执行该语言的虚拟机器。 该公司进行罚款,但我现在要利用gcc(或任何其他可自由获得的汇编者)从正常的c方案中为这一机器编造密码。 因此,问题是,我如何修改或扩大优惠,以便它能够产生我自己的附庸法? 请注意,我真的NOT想要将我的附束代码编成机码,我想用“编织式”式编码(自称)代号。

I realize that this is a potentially large question, and it is possible that the best answer is "go look at the gcc source code". I just need some help with how to get started with this. I figure that there must be some articles or books on this subject that could describe the process to add a custom generator to gcc, but I haven t found anything by googling.

最佳回答

www.un.org/spanish/ecosoc 这是一项艰巨的工作。

例如,我还用我自己的特制设计了自己的“定型”,并想为海合会制定C/C++法典。 这是我如何做到:

  1. At first you should read everything about porting in the manual of GCC.
  2. Also not forget too read GCC Internals.
  3. Read many things about Compilers.
  4. Also look at this question and the answers here.
  5. Google for more information.
  6. Ask yourself if you are really ready.
  7. Be sure to have a very good cafe machine... you will need it.
  8. Start to add machine dependet files to gcc.
  9. Compile gcc in a cross host-target way.
  10. Check the code results in the Hex-Editor.
  11. Do more tests.
  12. Now have fun with your own architecture :D

当你完成学业时,你只能使用c或c++,而不必使用依赖的图书馆(目前,他们没有在你的建筑上担任顾问),现在(如果你需要的话),你应该把许多其他图书馆与你的交叉编辑汇编成册,以便有一个良好的框架。

PS:LVER(Clang)更容易港......或许你希望开始港?

问题回答

我忙于把电车运到我们早先设计的8个轨道处理器。 我对我们机器来说是一项艰巨的任务,因为它是8倍,我们只有一个蓄水器,但如果你拥有更多的资源,它就会变得容易。 这正是我们如何用4.9克谢来管理它,并利用cy子:

  1. Download gcc 4.9 source
  2. Add your architecture name to config.sub around line 250 look for # Decode aliases for certain CPU-COMPANY combinations. In that list add | my_processor
  3. In that same file look for # Recognize the basic CPU types with company name. add yourself to the list: | my_processor-*
  4. 查阅文件gcc/config.gcc,在档案中查询案件编号为-target} 大约为第880条,添加如下内容:

      ;;
    my_processor*-*-*)
      c_target_objs="my_processor-c.o"
      cxx_target_objs="my_processor-c.o"
      target_has_targetm_common=no
      tmake_file="${tmake_file} my_processor/t-my_processor"
      ;;
    
  5. Create a folder gcc-4.9.0gccconfigmy_processor
  6. Copy files from an existing project and just edit it, or create your own from scratch. In our project we had copied all the files from the msp430 project and edited it all
  7. You should have the following files (not all files are mandatory):
    • my_processor.c
    • my_processor.h
    • my_processor.md
    • my_processor.opt
    • my_processor-c.c
    • my_processor.def
    • my_processor-protos.h
    • constraints.md
    • predicates.md
    • README.txt
    • t-my_processor
  8. create a path gcc-4.9.0/build/object
  9. run ../../configure --target=my_processor --prefix=path for my compiler --enable-languages="c"
  10. make
  11. make install
  12. Do a lot of research and debugging.
  13. Have fun.

这并非是一切的。 如果您的目标机器与另一个目标机器相合理,则将其RTL(?)定义作为起点并加以修改,那么 则通过boot锁阶段汇编<>测试/代码;在操作之前进行洗衣和重复。 也许不需要写任何实际代码,只是机体定义模板。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...