2.2. 【TDA4 C71】TI CGT C7000 —— 编译指导

982 阅读4分钟

1. TI CGT C7000 是做什么的

TI CGT C7000 是 C71 芯片平台的编译器。由 PSDK 提供。

2. 编译器的说明文档有哪些?

《C7000 C/ c++优化编译器用户指南》

  • SPRUIV4A_C7000_Optimization_Guide.pdf: C7000优化指南
  • SPRUIG4C_C7000_EABI_Technical_Reference.pdf: C7000嵌入式应用二进制接口(EABI)参考指南
  • SPRUIG5C_C6000_to_C7000_Migration.pdf: c6000 - c7000迁移用户指南
  • Spruig3c_c7000_vcop_kernel_c_translate .pdf: VCOP Kernel-C to C7000 Migration Tool User’s Guide
  • SPRUIG6G_C7000_Host_Emulation_Users_Guide.pdf: C7000主机仿真用户指南

另外,一些文档需要从TI工程师手中获取

  • 《C71x DSP Corepac技术参考手册》
  • 《C7x使用指南 》
  • 《C71x DSP CPU、指令集和矩阵乘法加速器(spip0) 》

3. 如何运行一段C71程序

3.1. 如何搭建C71编译链

使用开发包中的程序

ti-processor-sdk-rtos-j721e-evm-08_00_00_12/ti-cgt-c7000_1.4.2.LTS/bin/cl7x

3.2. 如何书写一段C71程序

3.2.1. 编程语言支持

C71程序遵循C/C++语言标准。其中C语言支持C89全部标准和C99、C11部分新特性,不完全支持宽字节(如wchar_t)。其中C++支持到C++14,对除异常处理、宽字节、原子操作及相关操作、复杂的比较交换、bidirectional fences、内存模型C++11、threadlocal storage、动态初始化和并发销毁不支持。

3.2.2. 特性优化支持

使用 c7x_mma.h中的定义内容可使用MMA的计算runtime。

使用特殊的加载存储指令可使用C7x特有的内存、操作指令。如 Vector Load and Duplicate: __vload_dup(…)。

C7x编译期支持编译C6x源码。

3.2.3. C/C++堆支持

The C/C++ compiler uses a stack to:

  • Save function return addresses
  • Allocate local variables
  • Pass arguments to functions
  • Save temporary results

The linker sets the stack size, creates a global symbol, __TI_STACK_SIZE, and assigns it a value equal to the stack size in bytes. The default stack size is 0x2000 bytes. You can change the stack size at link time by using the --stack_size option with the linker command.

Dynamically allocated objects are not addressed directly (they are always accessed with pointers) and the memory pool is in a separate section (.sysmem); therefore, the dynamic memory pool can have a size limited only by the amount of available memory in your system. To conserve space in the .bss section, you can allocate large arrays from the heap instead of defining them as global or static. For example, instead of a definition such as:

struct big table[100];

Use a pointer and call the malloc function:

struct big *table table = (struct big *)malloc(100*sizeof(struct big));

3.3. 如何完成一个程序编译

To invoke the compiler, enter:

cl7x[options] [filenames] [--run_linker [link_options] object files]]
cl7xCommand that runs the compiler.
optionsOptions that affect the way the compiler processes input files. The options are listed in Table 3-6 through Table 3-27.
filenamesOne or more C/C++ source files.
--run_linker (-z)Option that invokes the linker. The --run_linker option's short form is -z. See Section 11 for more information.
link_optionsOptions that control the linking process.
object filesNames of the object files for the linking process.

The arguments to the compiler are of three types:

  • Compiler options
  • Link options
  • Filenames

The --run_linker option indicates linking is to be performed. If the --run_linker option is used, any compiler options must precede the --run_linker option, and all link options must follow the --run_linker option.

Source code filenames must be placed before the --run_linker option. Additional object file filenames can be placed after the --run_linker option.

For example, if you want to compile two files named symtab.c and file.c, and link to create an executable program called myprogram.out, you will enter:

cl7x -mv7100 --c99 --opt_level=1 --define=c7000 --include_path="C:/ti/ti-cgt-c7000/include" hello.c objects.cpp --run_linker --library=lnk.cmd --heap_size=0x800 --output_file=myprogram.out

3.4. 如何控制编译优化等级

Optimization Options

OptionAliasEffect
--opt_level=off
Disables all optimization (default if option not used and --vectypes=off) .
--opt_level=n-OnLevel 0 (-O0) optimizes register usage only (default if option not used and --vectypes=on) .
Level 1 (-O1) uses Level 0 optimizations and optimizes locally.
Level 2 (-O2) uses Level 1 optimizations and optimizes globally (default if option used with no setting) .
Level 3 (-O3) uses Level 2 optimizations and optimizes the file.
Level 4 (-O4) uses Level 3 optimizations and performs link-time optimization.
--opt_for_speed[=n]-mfControls the tradeoff between size and speed (0-5 range). If this option is not specified or is specified without n, the default value is 4.

3.5. 如何开启调试符号

Debug Options

OptionAliasEffect
--symdebug:dwarf-gDefault behavior. Enables symbolic debugging. The generation of debug information does not impact optimization. Therefore, generating debug information is enabled by default.
--symdebug:dwarf_version=3|4
Specifies the DWARF format version. The default version is 4.
--symdebug:none
Disables all symbolic debugging.

3.6. 编译期可用的优化

  • Run-Time Relocation,使用不同的内存加载位置
  • 使用ram_model或者rom_model

3.7. 如何使用A72调用C7x的程序

// TODO